qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, gang.chen.5i5j@gmail.com
Subject: [Qemu-devel] [PULL 18/35] target-tilegx: Handle most bit manipulation instructions
Date: Tue, 15 Sep 2015 08:03:56 -0700	[thread overview]
Message-ID: <1442329453-16260-19-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1442329453-16260-1-git-send-email-rth@twiddle.net>

The crc instructions are omitted from this set.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target-tilegx/helper.c    | 10 +++++++
 target-tilegx/helper.h    |  2 ++
 target-tilegx/translate.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/target-tilegx/helper.c b/target-tilegx/helper.c
index 5b37a8c..a01bb8d 100644
--- a/target-tilegx/helper.c
+++ b/target-tilegx/helper.c
@@ -40,6 +40,16 @@ uint64_t helper_cnttz(uint64_t arg)
     return ctz64(arg);
 }
 
+uint64_t helper_pcnt(uint64_t arg)
+{
+    return ctpop64(arg);
+}
+
+uint64_t helper_revbits(uint64_t arg)
+{
+    return revbit64(arg);
+}
+
 /*
  * Functional Description
  *     uint64_t a = rf[SrcA];
diff --git a/target-tilegx/helper.h b/target-tilegx/helper.h
index fd5517e..644d313 100644
--- a/target-tilegx/helper.h
+++ b/target-tilegx/helper.h
@@ -1,4 +1,6 @@
 DEF_HELPER_2(exception, noreturn, env, i32)
 DEF_HELPER_FLAGS_1(cntlz, TCG_CALL_NO_RWG_SE, i64, i64)
 DEF_HELPER_FLAGS_1(cnttz, TCG_CALL_NO_RWG_SE, i64, i64)
+DEF_HELPER_FLAGS_1(pcnt, TCG_CALL_NO_RWG_SE, i64, i64)
+DEF_HELPER_FLAGS_1(revbits, TCG_CALL_NO_RWG_SE, i64, i64)
 DEF_HELPER_FLAGS_3(shufflebytes, TCG_CALL_NO_RWG_SE, i64, i64, i64, i64)
diff --git a/target-tilegx/translate.c b/target-tilegx/translate.c
index 6b5de55..e581fc5 100644
--- a/target-tilegx/translate.c
+++ b/target-tilegx/translate.c
@@ -177,6 +177,43 @@ static void gen_saturate_op(TCGv tdest, TCGv tsrca, TCGv tsrcb,
     tcg_temp_free(t0);
 }
 
+/* Shift the 128-bit value TSRCA:TSRCD right by the number of bytes
+   specified by the bottom 3 bits of TSRCB, and set TDEST to the
+   low 64 bits of the resulting value.  */
+static void gen_dblalign(TCGv tdest, TCGv tsrcd, TCGv tsrca, TCGv tsrcb)
+{
+    TCGv t0 = tcg_temp_new();
+
+    tcg_gen_andi_tl(t0, tsrcb, 7);
+    tcg_gen_shli_tl(t0, t0, 3);
+    tcg_gen_shr_tl(tdest, tsrcd, t0);
+
+    /* We want to do "t0 = tsrca << (64 - t0)".  Two's complement
+       arithmetic on a 6-bit field tells us that 64 - t0 is equal
+       to (t0 ^ 63) + 1.  So we can do the shift in two parts,
+       neither of which will be an invalid shift by 64.  */
+    tcg_gen_xori_tl(t0, t0, 63);
+    tcg_gen_shl_tl(t0, tsrca, t0);
+    tcg_gen_shli_tl(t0, t0, 1);
+    tcg_gen_or_tl(tdest, tdest, t0);
+
+    tcg_temp_free(t0);
+}
+
+/* Similarly, except that the 128-bit value is TSRCA:TSRCB, and the
+   right shift is an immediate.  */
+static void gen_dblaligni(TCGv tdest, TCGv tsrca, TCGv tsrcb, int shr)
+{
+    TCGv t0 = tcg_temp_new();
+
+    tcg_gen_shri_tl(t0, tsrcb, shr);
+    tcg_gen_shli_tl(tdest, tsrca, 64 - shr);
+    tcg_gen_or_tl(tdest, tdest, t0);
+
+    tcg_temp_free(t0);
+}
+
+
 static TileExcp gen_rr_opcode(DisasContext *dc, unsigned opext,
                               unsigned dest, unsigned srca)
 {
@@ -210,8 +247,14 @@ static TileExcp gen_rr_opcode(DisasContext *dc, unsigned opext,
     switch (opext) {
     case OE_RR_X0(CNTLZ):
     case OE_RR_Y0(CNTLZ):
+        gen_helper_cntlz(tdest, tsrca);
+        mnemonic = "cntlz";
+        break;
     case OE_RR_X0(CNTTZ):
     case OE_RR_Y0(CNTTZ):
+        gen_helper_cnttz(tdest, tsrca);
+        mnemonic = "cnttz";
+        break;
     case OE_RR_X1(DRAIN):
     case OE_RR_X1(DTLBPR):
     case OE_RR_X1(FINV):
@@ -251,11 +294,17 @@ static TileExcp gen_rr_opcode(DisasContext *dc, unsigned opext,
     case OE_RR_Y1(LNK):
     case OE_RR_X1(MF):
     case OE_RR_X1(NAP):
+        return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
     case OE_RR_X0(PCNT):
     case OE_RR_Y0(PCNT):
+        gen_helper_pcnt(tdest, tsrca);
+        mnemonic = "pcnt";
+        break;
     case OE_RR_X0(REVBITS):
     case OE_RR_Y0(REVBITS):
-        return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
+        gen_helper_revbits(tdest, tsrca);
+        mnemonic = "revbits";
+        break;
     case OE_RR_X0(REVBYTES):
     case OE_RR_Y0(REVBYTES):
         tcg_gen_bswap64_tl(tdest, tsrca);
@@ -358,13 +407,26 @@ static TileExcp gen_rrr_opcode(DisasContext *dc, unsigned opext,
     case OE_RRR(CMUL, 0, X0):
     case OE_RRR(CRC32_32, 0, X0):
     case OE_RRR(CRC32_8, 0, X0):
+        return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
     case OE_RRR(DBLALIGN2, 0, X0):
     case OE_RRR(DBLALIGN2, 0, X1):
+        gen_dblaligni(tdest, tsrca, tsrcb, 16);
+        mnemonic = "dblalign2";
+        break;
     case OE_RRR(DBLALIGN4, 0, X0):
     case OE_RRR(DBLALIGN4, 0, X1):
+        gen_dblaligni(tdest, tsrca, tsrcb, 32);
+        mnemonic = "dblalign4";
+        break;
     case OE_RRR(DBLALIGN6, 0, X0):
     case OE_RRR(DBLALIGN6, 0, X1):
+        gen_dblaligni(tdest, tsrca, tsrcb, 48);
+        mnemonic = "dblalign6";
+        break;
     case OE_RRR(DBLALIGN, 0, X0):
+        gen_dblalign(tdest, load_gr(dc, dest), tsrca, tsrcb);
+        mnemonic = "dblalign";
+        break;
     case OE_RRR(EXCH4, 0, X1):
     case OE_RRR(EXCH, 0, X1):
     case OE_RRR(FDOUBLE_ADDSUB, 0, X0):
@@ -516,7 +578,11 @@ static TileExcp gen_rrr_opcode(DisasContext *dc, unsigned opext,
     case OE_RRR(SHRU, 0, X1):
     case OE_RRR(SHRU, 6, Y0):
     case OE_RRR(SHRU, 6, Y1):
+        return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
     case OE_RRR(SHUFFLEBYTES, 0, X0):
+        gen_helper_shufflebytes(tdest, load_gr(dc, dest), tsrca, tsrca);
+        mnemonic = "shufflebytes";
+        break;
     case OE_RRR(ST1, 0, X1):
     case OE_RRR(ST2, 0, X1):
     case OE_RRR(ST4, 0, X1):
-- 
2.4.3

  parent reply	other threads:[~2015-09-15 15:04 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-15 15:03 [Qemu-devel] [PULL 00/35] TileGX basic instructions Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 01/35] linux-user: tilegx: Add architecture related features Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 02/35] linux-user: Support tilegx architecture in linux-user Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 03/35] linux-user: Conditionalize syscalls which are not defined in tilegx Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 04/35] target-tilegx: Add opcode basic implementation from Tilera Corporation Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 05/35] target-tilegx: Modify opcode_tilegx.h to fit QEMU usage Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 06/35] target-tilegx: Modify _SPECIAL_ opcodes Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 07/35] target-tilegx: Fix LDNA_ADD_IMM8_OPCODE_X1 Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 08/35] target-tilegx: Add special register information from Tilera Corporation Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 09/35] target-tilegx: Add cpu basic features for linux-user Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 10/35] target-tilegx: Add several helpers for instructions translation Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 11/35] target-tilegx: Framework for decoding bundles Richard Henderson
2015-09-16 15:36   ` Chen Gang
2015-09-15 15:03 ` [Qemu-devel] [PULL 12/35] target-tilegx: Generate SEGV properly Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 13/35] target-tilegx: Add TILE-Gx building files Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 14/35] target-tilegx: Handle simple logical operations Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 15/35] target-tilegx: Handle arithmetic instructions Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 16/35] host-utils: Add revbit functions Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 17/35] target-arm: Use new " Richard Henderson
2015-09-15 15:03 ` Richard Henderson [this message]
2015-09-15 15:03 ` [Qemu-devel] [PULL 19/35] target-tilegx: Handle basic load and store instructions Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 20/35] target-tilegx: Handle post-increment " Richard Henderson
2015-09-15 15:03 ` [Qemu-devel] [PULL 21/35] target-tilegx: Handle unconditional jump instructions Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 22/35] target-tilegx: Handle conditional branch instructions Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 23/35] target-tilegx: Handle comparison instructions Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 24/35] target-tilegx: Implement system and memory management instructions Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 25/35] target-tilegx: Handle bitfield instructions Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 26/35] target-tilegx: Handle shift instructions Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 27/35] target-tilegx: Handle conditional move instructions Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 28/35] target-tilegx: Handle scalar multiply instructions Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 29/35] target-tilegx: Handle mask instructions Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 30/35] target-tilegx: Handle v1cmpeq, v1cmpne Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 31/35] target-tilegx: Handle mtspr, mfspr Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 32/35] target-tilegx: Handle atomic instructions Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 33/35] target-tilegx: Handle v4int_l/h Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 34/35] target-tilegx: Handle v1shli, v1shrui Richard Henderson
2015-09-15 15:04 ` [Qemu-devel] [PULL 35/35] target-tilegx: Handle v1shl, v1shru, v1shrs Richard Henderson
2015-09-16 15:28   ` Chen Gang
2015-09-16 14:50 ` [Qemu-devel] [PULL 00/35] TileGX basic instructions Peter Maydell
2015-09-16 15:20 ` Chen Gang
2015-09-16 22:36   ` Chen Gang
2015-09-27 11:48     ` Chen Gang
2015-09-28 13:58       ` Chen Gang

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=1442329453-16260-19-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=peter.maydell@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).