All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Musta <tommusta@gmail.com>
To: qemu-ppc@nongnu.org
Cc: Tom Musta <tommusta@gmail.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 07/13] Add VSX Scalar Move Instructions
Date: Fri, 04 Oct 2013 08:20:00 -0500	[thread overview]
Message-ID: <524EC080.90902@gmail.com> (raw)
In-Reply-To: <524EBE04.8050207@gmail.com>

This patch adds the VSX scalar move instructions:

   - xsabsdp (Scalar Absolute Value Double-Precision)
   - xsnabspd (Scalar Negative Absolute Value Double-Precision)
   - xsnegdp (Scalar Negate Double-Precision)
   - xscpsgndp (Scalar Copy Sign Double-Precision)

A common generator macro (VSX_SCALAR_MOVE) is added since these
instructions vary only slightly from each other.

Macros to support VSX XX2 and XX3 form opcodes are also added.
These macros handle the overloading of "opcode 2" space (instruction
bits 26:30) caused by AX and BX bits (29 and 30, respectively).

Signed-off-by: Tom Musta <tommusta@gmail.com>
---
  target-ppc/translate.c |   66 
++++++++++++++++++++++++++++++++++++++++++++++++
  1 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 7d71fb9..db54e4f 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -7158,6 +7158,55 @@ static void gen_xxpermdi(DisasContext *ctx)
          tcg_gen_mov_i64(cpu_vsrl(xT(ctx->opcode)), 
cpu_vsrl(xB(ctx->opcode)));
      }
  }
+#define OP_ABS 1
+#define OP_NABS 2
+#define OP_NEG 3
+#define OP_CPSGN 4
+#define SGN_MASK_DP  0x8000000000000000ul
+#define SGN_MASK_SP 0x8000000080000000ul
+
+#define VSX_SCALAR_MOVE(name, op, sgn_mask)                       \
+static void glue(gen_, name)(DisasContext * ctx)                  \
+    {                                                             \
+        TCGv_i64 xb;                                              \
+        if (unlikely(!ctx->vsx_enabled)) {                        \
+            gen_exception(ctx, POWERPC_EXCP_VSXU);                \
+            return;                                               \
+        }                                                         \
+        xb = tcg_temp_new();                                      \
+        tcg_gen_mov_i64(xb, cpu_vsrh(xB(ctx->opcode)));           \
+        switch (op) {                                             \
+            case OP_ABS: {                                        \
+                tcg_gen_andi_i64(xb, xb, ~(sgn_mask));            \
+                break;                                            \
+            }                                                     \
+            case OP_NABS: {                                       \
+                tcg_gen_ori_i64(xb, xb, (sgn_mask));              \
+                break;                                            \
+            }                                                     \
+            case OP_NEG: {                                        \
+                tcg_gen_xori_i64(xb, xb, (sgn_mask));             \
+                break;                                            \
+            }                                                     \
+            case OP_CPSGN: {                                      \
+                TCGv_i64 xa = tcg_temp_new();                     \
+                tcg_gen_mov_i64(xa, cpu_vsrh(xA(ctx->opcode)));   \
+                tcg_gen_andi_i64(xa, xa, (sgn_mask));             \
+                tcg_gen_andi_i64(xb, xb, ~(sgn_mask));            \
+                tcg_gen_or_i64(xb, xb, xa);                       \
+                tcg_temp_free(xa);                                \
+                break;                                            \
+            }                                                     \
+        }                                                         \
+        tcg_gen_mov_i64(cpu_vsrh(xT(ctx->opcode)), xb);           \
+        tcg_temp_free(xb);                                        \
+    }
+
+VSX_SCALAR_MOVE(xsabsdp, OP_ABS, SGN_MASK_DP)
+VSX_SCALAR_MOVE(xsnabsdp, OP_NABS, SGN_MASK_DP)
+VSX_SCALAR_MOVE(xsnegdp, OP_NEG, SGN_MASK_DP)
+VSX_SCALAR_MOVE(xscpsgndp, OP_CPSGN, SGN_MASK_DP)
+

  /***                           SPE 
extension                               ***/
  /* Register moves */
@@ -9617,6 +9666,18 @@ GEN_HANDLER_E(stxsdx, 0x1F, 0xC, 0x16, 0, 
PPC_NONE, PPC2_VSX),
  GEN_HANDLER_E(stxvd2x, 0x1F, 0xC, 0x1E, 0, PPC_NONE, PPC2_VSX),
  GEN_HANDLER_E(stxvw4x, 0x1F, 0xC, 0x1C, 0, PPC_NONE, PPC2_VSX),

+#undef GEN_XX2FORM
+#define GEN_XX2FORM(name, opc2, opc3, fl2)                           \
+GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0, opc3, 0, PPC_NONE, fl2), \
+GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0, PPC_NONE, fl2)
+
+#undef GEN_XX3FORM
+#define GEN_XX3FORM(name, opc2, opc3, fl2)                           \
+GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0, opc3, 0, PPC_NONE, fl2), \
+GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0, PPC_NONE, fl2), \
+GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 2, opc3, 0, PPC_NONE, fl2), \
+GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 3, opc3, 0, PPC_NONE, fl2)
+
  #undef GEN_XX3FORM_DM
  #define GEN_XX3FORM_DM(name, opc2, opc3) \
  GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x00, opc3|0x00, 0, PPC_NONE, 
PPC2_VSX),\
@@ -9636,6 +9697,11 @@ GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x01, 
opc3|0x0C, 0, PPC_NONE, PPC2_VSX),\
  GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x02, opc3|0x0C, 0, PPC_NONE, 
PPC2_VSX),\
  GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x03, opc3|0x0C, 0, PPC_NONE, 
PPC2_VSX)

+GEN_XX2FORM(xsabsdp, 0x12, 0x15, PPC2_VSX),
+GEN_XX2FORM(xsnabsdp, 0x12, 0x16, PPC2_VSX),
+GEN_XX2FORM(xsnegdp, 0x12, 0x17, PPC2_VSX),
+GEN_XX3FORM(xscpsgndp, 0x00, 0x16, PPC2_VSX),
+
  GEN_XX3FORM_DM(xxpermdi, 0x08, 0x01),

  #undef GEN_SPE
-- 
1.7.1

  parent reply	other threads:[~2013-10-04 13:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-04 13:09 [Qemu-devel] [PATCH 00/13] Stage 2 VSX Support Tom Musta
2013-10-04 13:11 ` [Qemu-devel] [PATCH 01/13] Abandon GEN_VSX_* macros Tom Musta
2013-10-04 13:13 ` [Qemu-devel] [PATCH 02/13] Add lxsdx Tom Musta
2013-10-04 13:15 ` [Qemu-devel] [PATCH 03/13] Add lxvdsx Tom Musta
2013-10-04 13:16 ` [Qemu-devel] [PATCH 04/13] Add lxvw4x Tom Musta
2013-10-09 19:54   ` Richard Henderson
2013-10-04 13:17 ` [Qemu-devel] [PATCH 05/13] Add stxsdx Tom Musta
2013-10-04 13:18 ` [Qemu-devel] [PATCH 06/13] Add stxvw4x Tom Musta
2013-10-04 13:20 ` Tom Musta [this message]
2013-10-04 13:21 ` [Qemu-devel] [PATCH 08/13] Add VSX Vector Move Instructions Tom Musta
2013-10-04 13:22 ` [Qemu-devel] [PATCH 09/13] Add Power7 VSX Logical Instructions Tom Musta
2013-10-04 13:23 ` [Qemu-devel] [PATCH 10/13] Add xxmrgh/xxmrgl Tom Musta
2013-10-09 20:09   ` Richard Henderson
2013-10-10 12:16     ` Tom Musta
2013-10-04 13:24 ` [Qemu-devel] [PATCH 11/13] Add xxsel Tom Musta
2013-10-09 20:13   ` Richard Henderson
2013-10-10 12:27     ` Tom Musta
2013-10-10 13:45       ` Richard Henderson
2013-10-04 13:26 ` [Qemu-devel] [PATCH 12/13] Add xxspltw Tom Musta
2013-10-09 20:19   ` Richard Henderson
2013-10-04 13:27 ` [Qemu-devel] [PATCH 13/13] Add xxsldwi Tom Musta

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=524EC080.90902@gmail.com \
    --to=tommusta@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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.