All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mateja Marjanovic <mateja.marjanovic@rt-rk.com>
To: qemu-devel@nongnu.org
Cc: aurelien@aurel32.net, amarkovic@wavecomp.com, arikalo@wavecomp.com
Subject: [Qemu-devel] [PATCH v3 13/13] target/mips: Add emulation of MMI instruction PEXTUW
Date: Mon,  4 Mar 2019 16:13:25 +0100	[thread overview]
Message-ID: <1551712405-2530-14-git-send-email-mateja.marjanovic@rt-rk.com> (raw)
In-Reply-To: <1551712405-2530-1-git-send-email-mateja.marjanovic@rt-rk.com>

From: Mateja Marjanovic <Mateja.Marjanovic@rt-rk.com>

Add emulation of MMI instruction PEXTUW. The emulation is implemented
using TCG front end operations directly to achieve better performance.

Signed-off-by: Mateja Marjanovic <mateja.marjanovic@rt-rk.com>
---
 target/mips/translate.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index da3fcad..5848f7a 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -25151,6 +25151,60 @@ static void gen_mmi_pextuh(DisasContext *ctx)
     }
 }
 
+/*
+ *  PEXTUW rd, rs, rt
+ *
+ *  Parallel Extend Upper from Word
+ *
+ *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ *  +-----------+---------+---------+---------+---------+-----------+
+ *  |    MMI    |    rs   |   rt    |   rd    | PEXTUW  |    MMI1   |
+ *  +-----------+---------+---------+---------+---------+-----------+
+ */
+
+static void gen_mmi_pextuw(DisasContext *ctx)
+{
+    uint32_t rs, rt, rd;
+    uint32_t opcode;
+
+    opcode = ctx->opcode;
+
+    rs = extract32(opcode, 21, 5);
+    rt = extract32(opcode, 16, 5);
+    rd = extract32(opcode, 11, 5);
+
+    if (rd == 0) {
+        /* nop */
+    } else {
+        TCGv_i64 t0 = tcg_temp_new();
+        TCGv_i64 t1 = tcg_temp_new();
+        uint64_t mask = (1ULL << 32) - 1;
+
+        tcg_gen_movi_i64(t1, 0);
+
+        tcg_gen_andi_i64(t0, cpu_gpr[rt], mask);
+        tcg_gen_or_i64(t1, t0, t1);
+        tcg_gen_andi_i64(t0, cpu_gpr[rs], mask);
+        tcg_gen_shli_i64(t0, t0, 32);
+        tcg_gen_or_i64(t1, t0, t1);
+        mask <<= 32;
+
+        tcg_gen_mov_i64(cpu_mmr[rd], t1);
+        tcg_gen_movi_i64(t1, 0);
+
+        tcg_gen_andi_i64(t0, cpu_gpr[rt], mask);
+        tcg_gen_or_i64(t1, t0, t1);
+        tcg_gen_andi_i64(t0, cpu_gpr[rs], mask);
+        tcg_gen_shli_i64(t0, t0, 32);
+        tcg_gen_or_i64(t1, t0, t1);
+
+        tcg_gen_mov_i64(cpu_gpr[rd], t1);
+
+        tcg_temp_free(t0);
+        tcg_temp_free(t1);
+    }
+}
+
 #endif
 
 
@@ -28140,7 +28194,6 @@ static void decode_mmi1(CPUMIPSState *env, DisasContext *ctx)
     case MMI_OPC_1_PCEQB:     /* TODO: MMI_OPC_1_PCEQB */
     case MMI_OPC_1_PADDUW:    /* TODO: MMI_OPC_1_PADDUW */
     case MMI_OPC_1_PSUBUW:    /* TODO: MMI_OPC_1_PSUBUW */
-    case MMI_OPC_1_PEXTUW:    /* TODO: MMI_OPC_1_PEXTUW */
     case MMI_OPC_1_PADDUH:    /* TODO: MMI_OPC_1_PADDUH */
     case MMI_OPC_1_PSUBUH:    /* TODO: MMI_OPC_1_PSUBUH */
     case MMI_OPC_1_PADDUB:    /* TODO: MMI_OPC_1_PADDUB */
@@ -28154,6 +28207,9 @@ static void decode_mmi1(CPUMIPSState *env, DisasContext *ctx)
     case MMI_OPC_1_PEXTUH:
         gen_mmi_pextuh(ctx);
         break;
+    case MMI_OPC_1_PEXTUW:
+        gen_mmi_pextuw(ctx);
+        break;
     default:
         MIPS_INVAL("TX79 MMI class MMI1");
         generate_exception_end(ctx, EXCP_RI);
-- 
2.7.4

      parent reply	other threads:[~2019-03-04 15:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04 15:13 [Qemu-devel] [PATCH v3 00/13] target/mips: Add emulation of data communication MMI instructions Mateja Marjanovic
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 01/13] target/mips: Add emulation of MMI instruction PCPYH Mateja Marjanovic
2019-03-04 20:36   ` Richard Henderson
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 02/13] target/mips: Add emulation of MMI instruction PCPYLD Mateja Marjanovic
2019-03-04 20:37   ` Richard Henderson
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 03/13] target/mips: Add emulation of MMI instruction PCPYUD Mateja Marjanovic
2019-03-04 20:38   ` Richard Henderson
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 04/13] target/mips: Add emulation of MMI instruction PEXCH Mateja Marjanovic
2019-03-04 17:36   ` Aleksandar Markovic
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 05/13] target/mips: Add emulation of MMI instruction PEXCW Mateja Marjanovic
2019-03-04 17:56   ` Aleksandar Markovic
2019-03-04 20:43   ` Richard Henderson
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 06/13] target/mips: Add emulation of MMI instruction PEXEH Mateja Marjanovic
2019-03-04 18:27   ` Aleksandar Markovic
2019-03-05 12:25     ` Richard Henderson
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 07/13] target/mips: Add emulation of MMI instruction PEXEW Mateja Marjanovic
2019-03-05 12:32   ` Richard Henderson
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 08/13] target/mips: Add emulation of MMI instruction PEXTLB Mateja Marjanovic
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 09/13] target/mips: Add emulation of MMI instruction PEXTLH Mateja Marjanovic
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 10/13] target/mips: Add emulation of MMI instruction PEXTLW Mateja Marjanovic
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 11/13] target/mips: Add emulation of MMI instruction PEXTUB Mateja Marjanovic
2019-03-04 15:13 ` [Qemu-devel] [PATCH v3 12/13] target/mips: Add emulation of MMI instruction PEXTUH Mateja Marjanovic
2019-03-04 15:13 ` Mateja Marjanovic [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1551712405-2530-14-git-send-email-mateja.marjanovic@rt-rk.com \
    --to=mateja.marjanovic@rt-rk.com \
    --cc=amarkovic@wavecomp.com \
    --cc=arikalo@wavecomp.com \
    --cc=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.