qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com
Subject: [Qemu-devel] [PATCH 13/21] target-sparc: Implement PDIST.
Date: Tue, 18 Oct 2011 11:50:35 -0700	[thread overview]
Message-ID: <1318963843-25100-14-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1318963843-25100-1-git-send-email-rth@twiddle.net>

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target-sparc/helper.h     |    1 +
 target-sparc/translate.c  |   21 +++++++++++++++++++--
 target-sparc/vis_helper.c |   21 +++++++++++++++++++++
 3 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/target-sparc/helper.h b/target-sparc/helper.h
index 6e66574..1a8e586 100644
--- a/target-sparc/helper.h
+++ b/target-sparc/helper.h
@@ -137,6 +137,7 @@ DEF_HELPER_FLAGS_2(fmul8ulx16, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64, i64)
 DEF_HELPER_FLAGS_2(fmuld8sux16, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64, i64)
 DEF_HELPER_FLAGS_2(fmuld8ulx16, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64, i64)
 DEF_HELPER_FLAGS_2(fexpand, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64, i64)
+DEF_HELPER_FLAGS_3(pdist, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64, i64, i64)
 #define VIS_HELPER(name)                                                 \
     DEF_HELPER_FLAGS_2(f ## name ## 16, TCG_CALL_CONST | TCG_CALL_PURE,  \
                        i64, i64, i64)                                    \
diff --git a/target-sparc/translate.c b/target-sparc/translate.c
index d3f7648..0acb477 100644
--- a/target-sparc/translate.c
+++ b/target-sparc/translate.c
@@ -1743,6 +1743,21 @@ static void gen_ne_fop_DDD(DisasContext *dc, int rd, int rs1, int rs2,
 
     gen_store_fpr_D(dc, rd, dst);
 }
+
+static void gen_ne_fop_DDDD(DisasContext *dc, int rd, int rs1, int rs2,
+                            void (*gen)(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_i64))
+{
+    TCGv_i64 dst, src0, src1, src2;
+
+    src1 = gen_load_fpr_D(dc, rs1);
+    src2 = gen_load_fpr_D(dc, rs2);
+    src0 = gen_load_fpr_D(dc, rd);
+    dst = gen_dest_fpr_D();
+
+    gen(dst, src0, src1, src2);
+
+    gen_store_fpr_D(dc, rd, dst);
+}
 #endif
 
 static void gen_fop_QQ(DisasContext *dc, int rd, int rs,
@@ -4064,9 +4079,11 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
                 case 0x03a: /* VIS I fpack32 */
                 case 0x03b: /* VIS I fpack16 */
                 case 0x03d: /* VIS I fpackfix */
-                case 0x03e: /* VIS I pdist */
-                    // XXX
                     goto illegal_insn;
+                case 0x03e: /* VIS I pdist */
+                    CHECK_FPU_FEATURE(dc, VIS1);
+                    gen_ne_fop_DDDD(dc, rd, rs1, rs2, gen_helper_pdist);
+                    break;
                 case 0x048: /* VIS I faligndata */
                     CHECK_FPU_FEATURE(dc, VIS1);
                     cpu_src1_64 = gen_load_fpr_D(dc, rs1);
diff --git a/target-sparc/vis_helper.c b/target-sparc/vis_helper.c
index 39c8d9a..cd5d4a7 100644
--- a/target-sparc/vis_helper.c
+++ b/target-sparc/vis_helper.c
@@ -396,3 +396,24 @@ VIS_CMPHELPER(helper_fcmpgt, FCMPGT)
 VIS_CMPHELPER(helper_fcmpeq, FCMPEQ)
 VIS_CMPHELPER(helper_fcmple, FCMPLE)
 VIS_CMPHELPER(helper_fcmpne, FCMPNE)
+
+uint64_t helper_pdist(uint64_t sum, uint64_t src1, uint64_t src2)
+{
+    int i;
+    for (i = 0; i < 8; i++) {
+        int s1, s2;
+
+        s1 = (src1 >> (56 - (i * 8))) & 0xff;
+        s2 = (src2 >> (56 - (i * 8))) & 0xff;
+
+        /* Absolute value of difference. */
+        s1 -= s2;
+        if (s1 < 0) {
+            s1 = -s1;
+        }
+
+        sum += s1;
+    }
+
+    return sum;
+}
-- 
1.7.6.4

  parent reply	other threads:[~2011-10-18 18:52 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-18 18:50 [Qemu-devel] [PATCH 00/21] Sparc FPU/VIS improvements Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 01/21] target-sparc: Add accessors for single-precision fpr access Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 02/21] target-sparc: Mark fprs dirty in store accessor Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 03/21] target-sparc: Add accessors for double-precision fpr access Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 04/21] target-sparc: Pass float64 parameters instead of dt0/1 temporaries Richard Henderson
2011-10-18 20:04   ` Blue Swirl
2011-10-18 20:07     ` Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 05/21] target-sparc: Make VIS helpers const when possible Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 06/21] target-sparc: Extract common code for floating-point operations Richard Henderson
2011-10-18 20:24   ` Blue Swirl
2011-10-18 22:21     ` Richard Henderson
2011-10-23 11:34       ` Blue Swirl
2011-10-18 18:50 ` [Qemu-devel] [PATCH 07/21] target-sparc: Extract float128 move to a function Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 08/21] target-sparc: Undo cpu_fpr rename Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 09/21] target-sparc: Change fpr representation to doubles Richard Henderson
2011-10-18 20:28   ` Blue Swirl
2011-10-18 22:25     ` Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 10/21] tcg: Optimize some forms of deposit Richard Henderson
2011-10-18 20:30   ` Blue Swirl
2011-10-18 22:27     ` Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 11/21] target-sparc: Do exceptions management fully inside the helpers Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 12/21] sparc-linux-user: Handle SIGILL Richard Henderson
2011-10-18 20:32   ` Blue Swirl
2011-10-18 22:27     ` Richard Henderson
2011-10-18 18:50 ` Richard Henderson [this message]
2011-10-18 18:50 ` [Qemu-devel] [PATCH 14/21] target-sparc: Implement fpack{16, 32, fix} Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 15/21] target-sparc: Implement EDGE* instructions Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 16/21] target-sparc: Implement ALIGNADDR* inline Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 17/21] target-sparc: Implement BMASK/BSHUFFLE Richard Henderson
2011-10-18 20:36   ` Blue Swirl
2011-10-18 18:50 ` [Qemu-devel] [PATCH 18/21] target-sparc: Tidy fpack32 Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 19/21] target-sparc: Implement FALIGNDATA inline Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 20/21] sparc-linux-user: Add some missing syscall numbers Richard Henderson
2011-10-18 18:50 ` [Qemu-devel] [PATCH 21/21] sparc-linux-user: Enable NPTL Richard Henderson
2011-10-18 19:50 ` [Qemu-devel] [PATCH 00/21] Sparc FPU/VIS improvements Blue Swirl
2011-10-18 20:03   ` Richard Henderson
2011-10-18 20:19     ` Blue Swirl

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=1318963843-25100-14-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=blauwirbel@gmail.com \
    --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).