Skip to contentSkip to conversation

POWER9 TCG enablements - part4

PATCH Superseded Nikunj A Dadhania 2 participants 17 messages Aug 10, 2016 – Aug 12, 2016

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/10 target-ppc: add xxspltib instruction

In reply to Nikunj A Dadhania

xxspltib: VSX Vector Splat Immediate Byte

Copy the immediate byte in each byte of target VSR

---
 target-ppc/translate.c              |  2 ++
 target-ppc/translate/vsx-impl.inc.c | 22 ++++++++++++++++++++++
 target-ppc/translate/vsx-ops.inc.c  |  7 +++++++
 3 files changed, 31 insertions(+)
target-ppc/translate.c +2 -0
index 0a5a3e2..2a87d1a 100644
@@ -589,6 +589,8 @@ EXTRACT_HELPER(DM, 8, 2);
 EXTRACT_HELPER(UIM, 16, 2);
 EXTRACT_HELPER(SHW, 8, 2);
 EXTRACT_HELPER(SP, 19, 2);
+EXTRACT_HELPER(IMM8, 11, 8);
+
 /*****************************************************************************/
 /* PowerPC instructions table                                                */
 
target-ppc/translate/vsx-impl.inc.c +22 -0
index 9f77b06..43d073e 100644
@@ -647,6 +647,28 @@ static void gen_xxspltw(DisasContext *ctx)
     tcg_temp_free_i64(b2);
 }
 
+#if defined(TARGET_PPC64)
+#define pattern(x) (((x) & 0xff) * (~(target_ulong)0 / 0xff))
+
+static void gen_xxspltib(DisasContext *ctx)
+{
+    unsigned char uim8 = IMM8(ctx->opcode);
+    if (xS(ctx->opcode) < 32) {
+        if (unlikely(!ctx->altivec_enabled)) {
+            gen_exception(ctx, POWERPC_EXCP_VPU);
+            return;
+        }
+    } else {
+        if (unlikely(!ctx->vsx_enabled)) {
+            gen_exception(ctx, POWERPC_EXCP_VSXU);
+            return;
+        }
+    }
+    tcg_gen_movi_i64(cpu_vsrh(xT(ctx->opcode)), pattern(uim8));
+    tcg_gen_movi_i64(cpu_vsrl(xT(ctx->opcode)), pattern(uim8));
+}
+#endif
+
 static void gen_xxsldwi(DisasContext *ctx)
 {
     TCGv_i64 xth, xtl;
target-ppc/translate/vsx-ops.inc.c +7 -0
index 8b9da65..9c98795 100644
@@ -20,6 +20,10 @@ GEN_HANDLER_E(mfvsrd, 0x1F, 0x13, 0x01, 0x0000F800, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(mtvsrd, 0x1F, 0x13, 0x05, 0x0000F800, PPC_NONE, PPC2_VSX207),
 #endif
 
+#define GEN_XX1FORM(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)
+
 #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)
@@ -222,6 +226,9 @@ VSX_LOGICAL(xxlorc, 0x8, 0x15, PPC2_VSX207),
 GEN_XX3FORM(xxmrghw, 0x08, 0x02, PPC2_VSX),
 GEN_XX3FORM(xxmrglw, 0x08, 0x06, PPC2_VSX),
 GEN_XX2FORM(xxspltw, 0x08, 0x0A, PPC2_VSX),
+#if defined(TARGET_PPC64)
+GEN_XX1FORM(xxspltib, 0x08, 0x0B, PPC2_ISA300),
+#endif
 GEN_XX3FORM_DM(xxsldwi, 0x08, 0x00),
 
 #define GEN_XXSEL_ROW(opc3) \
Signature · 1 line
2.7.4
#0 lore raw

cover POWER9 TCG enablements - part4

This series contains 10 new instructions for POWER9 ISA3.0. Use newer qemu load/store tcg helpers and optimize stxvw4x and lxvw4x.

Patches:

    01:  xxspltib: VSX Vector Splat Immediate Byte
    02:  Use tcg_gen_qemu_ld and write consolidated macro
    03:  Use tcg_gen_qemu_st and write consolidated macro
    04:  darn: Deliver A Random Number
    05:  lxsibzx - Load VSX Scalar as Integer Byte & Zero Indexed

lxsihzx - Load VSX Scalar as Integer Halfword & Zero Indexed
06: stxsibx - Store VSX Scalar as Integer Byte Indexed
stxsihx - Store VSX Scalar as Integer Halfword Indexed
07: lxvw4x - improve implementation
08: lxvb16x: Load VSX Vector Byte*16
lxvh8x: Load VSX Vector Halfword*8
09: stxv4x - improve implementation
10: stxvb16x: Store VSX Vector Byte*16
stxvh8x: Store VSX Vector Halfword*8

Changelog:
v0:
* darn - read /dev/random to get the random number
* xxspltib - make is PPC64 only
* Consolidate load/store operations and use macros to generate qemu_st/ld
* Simplify load/store vsx endian manipulation

Nikunj A Dadhania (9):
target-ppc: add xxspltib instruction
target-ppc: consolidate load operations
target-ppc: consolidate store operations
target-ppc: add lxsi[bw]zx instruction
target-ppc: add stxsi[bh]x instruction
target-ppc: improve lxvw4x implementation
target-ppc: add lxvb16x and lxvh8x
target-ppc: improve stxvw4x implementation
target-ppc: add stxvb16x and stxvh8x

Ravi Bangoria (1):
target-ppc: Implement darn instruction

 target-ppc/helper.h                 |   4 +
 target-ppc/int_helper.c             |  51 ++++++++++
 target-ppc/mem_helper.c             |  11 ++
 target-ppc/translate.c              | 131 ++++++++++++------------
 target-ppc/translate/vsx-impl.inc.c | 195 +++++++++++++++++++++++++++++++-----
 target-ppc/translate/vsx-ops.inc.c  |  15 +++
 6 files changed, 318 insertions(+), 89 deletions(-)
Signature · 1 line
2.7.4
#4 lore raw

PATCH 2/10 target-ppc: consolidate load operations

Implement macro to consolidate store operations using newer tcg_gen_qemu_ld functions.

---
 target-ppc/translate.c | 70 +++++++++++++++++++-------------------------------
 1 file changed, 26 insertions(+), 44 deletions(-)
target-ppc/translate.c +26 -44
index 2a87d1a..b00da0a 100644
@@ -2462,50 +2462,32 @@ static inline void gen_align_no_le(DisasContext *ctx)
 }
 
 /***                             Integer load                              ***/
-static inline void gen_qemu_ld8u(DisasContext *ctx, TCGv arg1, TCGv arg2)
-{
-    tcg_gen_qemu_ld8u(arg1, arg2, ctx->mem_idx);
-}
-
-static inline void gen_qemu_ld16u(DisasContext *ctx, TCGv arg1, TCGv arg2)
-{
-    TCGMemOp op = MO_UW | ctx->default_tcg_memop_mask;
-    tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
-}
-
-static inline void gen_qemu_ld16s(DisasContext *ctx, TCGv arg1, TCGv arg2)
-{
-    TCGMemOp op = MO_SW | ctx->default_tcg_memop_mask;
-    tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
-}
-
-static inline void gen_qemu_ld32u(DisasContext *ctx, TCGv arg1, TCGv arg2)
-{
-    TCGMemOp op = MO_UL | ctx->default_tcg_memop_mask;
-    tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
-}
-
-static void gen_qemu_ld32u_i64(DisasContext *ctx, TCGv_i64 val, TCGv addr)
-{
-    TCGv tmp = tcg_temp_new();
-    gen_qemu_ld32u(ctx, tmp, addr);
-    tcg_gen_extu_tl_i64(val, tmp);
-    tcg_temp_free(tmp);
-}
-
-static inline void gen_qemu_ld32s(DisasContext *ctx, TCGv arg1, TCGv arg2)
-{
-    TCGMemOp op = MO_SL | ctx->default_tcg_memop_mask;
-    tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
-}
-
-static void gen_qemu_ld32s_i64(DisasContext *ctx, TCGv_i64 val, TCGv addr)
-{
-    TCGv tmp = tcg_temp_new();
-    gen_qemu_ld32s(ctx, tmp, addr);
-    tcg_gen_ext_tl_i64(val, tmp);
-    tcg_temp_free(tmp);
-}
+#define GEN_QEMU_LOAD_TL(ldop, op)                                      \
+static void glue(gen_qemu_, ldop)(DisasContext *ctx,                    \
+                                  TCGv val,                             \
+                                  TCGv addr)                            \
+{                                                                       \
+    tcg_gen_qemu_ld_tl(val, addr, ctx->mem_idx,                         \
+                       op | ctx->default_tcg_memop_mask);               \
+}
+
+GEN_QEMU_LOAD_TL(ld8u,  MO_UB)
+GEN_QEMU_LOAD_TL(ld16u, MO_UW)
+GEN_QEMU_LOAD_TL(ld16s, MO_SW)
+GEN_QEMU_LOAD_TL(ld32u, MO_UL)
+GEN_QEMU_LOAD_TL(ld32s, MO_SL)
+
+#define GEN_QEMU_LOAD_64(ldop, op)                                  \
+static void glue(gen_qemu_, glue(ldop, _i64))(DisasContext *ctx,    \
+                                             TCGv_i64 val,          \
+                                             TCGv addr)             \
+{                                                                   \
+    tcg_gen_qemu_ld_i64(val, addr, ctx->mem_idx,                    \
+                        op | ctx->default_tcg_memop_mask);          \
+}
+
+GEN_QEMU_LOAD_64(ld32u, MO_UL)
+GEN_QEMU_LOAD_64(ld32s, MO_SL)
 
 static inline void gen_qemu_ld64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
 {
Signature · 1 line
2.7.4
#9 lore raw

PATCH 3/10 target-ppc: consolidate store operations

In reply to Nikunj A Dadhania

Implement macro to consolidate store operations using newer tcg_gen_qemu_st functions.

---
 target-ppc/translate.c | 37 ++++++++++++++++++-------------------
 1 file changed, 18 insertions(+), 19 deletions(-)
target-ppc/translate.c +18 -19
index b00da0a..c7bbe28 100644
@@ -2495,30 +2495,29 @@ static inline void gen_qemu_ld64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
     tcg_gen_qemu_ld_i64(arg1, arg2, ctx->mem_idx, op);
 }
 
-static inline void gen_qemu_st8(DisasContext *ctx, TCGv arg1, TCGv arg2)
-{
-    tcg_gen_qemu_st8(arg1, arg2, ctx->mem_idx);
+#define GEN_QEMU_STORE_TL(stop, op)                                     \
+static void glue(gen_qemu_, stop)(DisasContext *ctx,                    \
+                                  TCGv val,                             \
+                                  TCGv addr)                            \
+{                                                                       \
+    tcg_gen_qemu_st_tl(val, addr, ctx->mem_idx,                         \
+                       op | ctx->default_tcg_memop_mask);               \
 }
 
-static inline void gen_qemu_st16(DisasContext *ctx, TCGv arg1, TCGv arg2)
-{
-    TCGMemOp op = MO_UW | ctx->default_tcg_memop_mask;
-    tcg_gen_qemu_st_tl(arg1, arg2, ctx->mem_idx, op);
-}
+GEN_QEMU_STORE_TL(st8,  MO_UB)
+GEN_QEMU_STORE_TL(st16, MO_UW)
+GEN_QEMU_STORE_TL(st32, MO_UL)
 
-static inline void gen_qemu_st32(DisasContext *ctx, TCGv arg1, TCGv arg2)
-{
-    TCGMemOp op = MO_UL | ctx->default_tcg_memop_mask;
-    tcg_gen_qemu_st_tl(arg1, arg2, ctx->mem_idx, op);
+#define GEN_QEMU_STORE_64(stop, op)                               \
+static void glue(gen_qemu_, glue(stop, _i64))(DisasContext *ctx,  \
+                                              TCGv_i64 val,       \
+                                              TCGv addr)          \
+{                                                                 \
+    tcg_gen_qemu_st_i64(val, addr, ctx->mem_idx,                  \
+                        op | ctx->default_tcg_memop_mask);        \
 }
 
-static void gen_qemu_st32_i64(DisasContext *ctx, TCGv_i64 val, TCGv addr)
-{
-    TCGv tmp = tcg_temp_new();
-    tcg_gen_trunc_i64_tl(tmp, val);
-    gen_qemu_st32(ctx, tmp, addr);
-    tcg_temp_free(tmp);
-}
+GEN_QEMU_STORE_64(st32, MO_UL)
 
 static inline void gen_qemu_st64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
 {
Signature · 1 line
2.7.4
#10 lore raw

PATCH 4/10 target-ppc: Implement darn instruction

In reply to Nikunj A Dadhania

From: Ravi Bangoria <[email protected]>

darn: Deliver A Random Number

For both CRN and RRN, returning 64-bit random number.

[ use /dev/random to get the number ]
---
 target-ppc/helper.h     |  2 ++
 target-ppc/int_helper.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
 target-ppc/translate.c  | 18 +++++++++++++++++
 3 files changed, 71 insertions(+)
target-ppc/helper.h +2 -0
index 8eada2f..0e55d48 100644
@@ -50,6 +50,8 @@ DEF_HELPER_FLAGS_1(cnttzd, TCG_CALL_NO_RWG_SE, tl, tl)
 DEF_HELPER_FLAGS_1(popcntd, TCG_CALL_NO_RWG_SE, tl, tl)
 DEF_HELPER_FLAGS_2(bpermd, TCG_CALL_NO_RWG_SE, i64, i64, i64)
 DEF_HELPER_3(srad, tl, env, tl, tl)
+DEF_HELPER_0(darn32, tl)
+DEF_HELPER_0(darn64, tl)
 #endif
 
 DEF_HELPER_FLAGS_1(cntlsw32, TCG_CALL_NO_RWG_SE, i32, i32)
target-ppc/int_helper.c +51 -0

57 lines not on this page · raw message

target-ppc/translate.c +18 -0
index c7bbe28..67eac9f 100644
@@ -526,6 +526,8 @@ EXTRACT_HELPER(FPW, 16, 1);
 
 /* addpcis */
 EXTRACT_HELPER_DXFORM(DX, 10, 6, 6, 5, 16, 1, 1, 0, 0)
+/* darn */
+EXTRACT_HELPER(L, 16, 2);
 
 /***                            Jump target decoding                       ***/
 /* Immediate address */
@@ -1893,6 +1895,21 @@ static void gen_cnttzd(DisasContext *ctx)
         gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
     }
 }
+
+/* darn */
+static void gen_darn(DisasContext *ctx)
+{
+    int l = L(ctx->opcode);
+
+    if (l == 0) {
+        gen_helper_darn32(cpu_gpr[rD(ctx->opcode)]);
+    } else if (l <= 2) {
+        /* Return 64-bit random for both CRN and RRN */
+        gen_helper_darn64(cpu_gpr[rD(ctx->opcode)]);
+    } else {
+        tcg_gen_movi_i64(cpu_gpr[rD(ctx->opcode)], -1);
+    }
+}
 #endif
 
 /***                             Integer rotate                            ***/
@@ -6219,6 +6236,7 @@ GEN_HANDLER_E(prtyw, 0x1F, 0x1A, 0x04, 0x0000F801, PPC_NONE, PPC2_ISA205),
 GEN_HANDLER(popcntd, 0x1F, 0x1A, 0x0F, 0x0000F801, PPC_POPCNTWD),
 GEN_HANDLER(cntlzd, 0x1F, 0x1A, 0x01, 0x00000000, PPC_64B),
 GEN_HANDLER_E(cnttzd, 0x1F, 0x1A, 0x11, 0x00000000, PPC_NONE, PPC2_ISA300),
+GEN_HANDLER_E(darn, 0x1F, 0x13, 0x17, 0x001CF801, PPC_NONE, PPC2_ISA300),
 GEN_HANDLER_E(prtyd, 0x1F, 0x1A, 0x05, 0x0000F801, PPC_NONE, PPC2_ISA205),
 GEN_HANDLER_E(bpermd, 0x1F, 0x1C, 0x07, 0x00000001, PPC_NONE, PPC2_PERM_ISA206),
 #endif
Signature · 1 line
2.7.4
#11 lore raw

PATCH 5/10 target-ppc: add lxsi[bw]zx instruction

In reply to Nikunj A Dadhania

lxsibzx - Load VSX Scalar as Integer Byte & Zero Indexed lxsihzx - Load VSX Scalar as Integer Halfword & Zero Indexed

---
 target-ppc/translate.c              | 2 ++
 target-ppc/translate/vsx-impl.inc.c | 2 ++
 target-ppc/translate/vsx-ops.inc.c  | 2 ++
 3 files changed, 6 insertions(+)
target-ppc/translate.c +2 -0
index 67eac9f..1fc78d9 100644
@@ -2503,6 +2503,8 @@ static void glue(gen_qemu_, glue(ldop, _i64))(DisasContext *ctx,    \
                         op | ctx->default_tcg_memop_mask);          \
 }
 
+GEN_QEMU_LOAD_64(ld8u,  MO_UB)
+GEN_QEMU_LOAD_64(ld16u, MO_UW)
 GEN_QEMU_LOAD_64(ld32u, MO_UL)
 GEN_QEMU_LOAD_64(ld32s, MO_SL)
 
target-ppc/translate/vsx-impl.inc.c +2 -0
index 43d073e..9cb48e1 100644
@@ -36,6 +36,8 @@ static void gen_##name(DisasContext *ctx)                     \
 
 VSX_LOAD_SCALAR(lxsdx, ld64)
 VSX_LOAD_SCALAR(lxsiwax, ld32s_i64)
+VSX_LOAD_SCALAR(lxsibzx, ld8u_i64)
+VSX_LOAD_SCALAR(lxsihzx, ld16u_i64)
 VSX_LOAD_SCALAR(lxsiwzx, ld32u_i64)
 VSX_LOAD_SCALAR(lxsspx, ld32fs)
 
target-ppc/translate/vsx-ops.inc.c +2 -0
index 9c98795..4f32837 100644
@@ -1,6 +1,8 @@
 GEN_HANDLER_E(lxsdx, 0x1F, 0x0C, 0x12, 0, PPC_NONE, PPC2_VSX),
 GEN_HANDLER_E(lxsiwax, 0x1F, 0x0C, 0x02, 0, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(lxsiwzx, 0x1F, 0x0C, 0x00, 0, PPC_NONE, PPC2_VSX207),
+GEN_HANDLER_E(lxsibzx, 0x1F, 0x0D, 0x18, 0, PPC_NONE, PPC2_ISA300),
+GEN_HANDLER_E(lxsihzx, 0x1F, 0x0D, 0x19, 0, PPC_NONE, PPC2_ISA300),
 GEN_HANDLER_E(lxsspx, 0x1F, 0x0C, 0x10, 0, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(lxvd2x, 0x1F, 0x0C, 0x1A, 0, PPC_NONE, PPC2_VSX),
 GEN_HANDLER_E(lxvdsx, 0x1F, 0x0C, 0x0A, 0, PPC_NONE, PPC2_VSX),
Signature · 1 line
2.7.4
#12 lore raw

PATCH 6/10 target-ppc: add stxsi[bh]x instruction

In reply to Nikunj A Dadhania

stxsibx - Store VSX Scalar as Integer Byte Indexed stxsihx - Store VSX Scalar as Integer Halfword Indexed

---
 target-ppc/translate.c              | 2 ++
 target-ppc/translate/vsx-impl.inc.c | 2 ++
 target-ppc/translate/vsx-ops.inc.c  | 2 ++
 3 files changed, 6 insertions(+)
target-ppc/translate.c +2 -0
index 1fc78d9..efa5fd1 100644
@@ -2536,6 +2536,8 @@ static void glue(gen_qemu_, glue(stop, _i64))(DisasContext *ctx,  \
                         op | ctx->default_tcg_memop_mask);        \
 }
 
+GEN_QEMU_STORE_64(st8,  MO_UB)
+GEN_QEMU_STORE_64(st16, MO_UW)
 GEN_QEMU_STORE_64(st32, MO_UL)
 
 static inline void gen_qemu_st64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
target-ppc/translate/vsx-impl.inc.c +2 -0
index 9cb48e1..70812cb 100644
@@ -118,6 +118,8 @@ static void gen_##name(DisasContext *ctx)                     \
 }
 
 VSX_STORE_SCALAR(stxsdx, st64)
+VSX_STORE_SCALAR(stxsibx, st8_i64)
+VSX_STORE_SCALAR(stxsihx, st16_i64)
 VSX_STORE_SCALAR(stxsiwx, st32_i64)
 VSX_STORE_SCALAR(stxsspx, st32fs)
 
target-ppc/translate/vsx-ops.inc.c +2 -0
index 4f32837..d7be8ee 100644
@@ -9,6 +9,8 @@ GEN_HANDLER_E(lxvdsx, 0x1F, 0x0C, 0x0A, 0, PPC_NONE, PPC2_VSX),
 GEN_HANDLER_E(lxvw4x, 0x1F, 0x0C, 0x18, 0, PPC_NONE, PPC2_VSX),
 
 GEN_HANDLER_E(stxsdx, 0x1F, 0xC, 0x16, 0, PPC_NONE, PPC2_VSX),
+GEN_HANDLER_E(stxsibx, 0x1F, 0xD, 0x1C, 0, PPC_NONE, PPC2_ISA300),
+GEN_HANDLER_E(stxsihx, 0x1F, 0xD, 0x1D, 0, PPC_NONE, PPC2_ISA300),
 GEN_HANDLER_E(stxsiwx, 0x1F, 0xC, 0x04, 0, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(stxsspx, 0x1F, 0xC, 0x14, 0, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(stxvd2x, 0x1F, 0xC, 0x1E, 0, PPC_NONE, PPC2_VSX),
Signature · 1 line
2.7.4
#14 lore raw

PATCH 8/10 target-ppc: add lxvb16x and lxvh8x

In reply to Nikunj A Dadhania
lxvb16x: Load VSX Vector Byte*16
lxvh8x:  Load VSX Vector Halfword*8
---
 target-ppc/helper.h                 |  1 +
 target-ppc/mem_helper.c             |  6 ++++
 target-ppc/translate/vsx-impl.inc.c | 57 +++++++++++++++++++++++++++++++++++++
 target-ppc/translate/vsx-ops.inc.c  |  2 ++
 4 files changed, 66 insertions(+)
target-ppc/helper.h +1 -0
index 4f08ce4..0179957 100644
@@ -289,6 +289,7 @@ DEF_HELPER_3(lvebx, void, env, avr, tl)
 DEF_HELPER_3(lvehx, void, env, avr, tl)
 DEF_HELPER_3(lvewx, void, env, avr, tl)
 DEF_HELPER_1(bswap32x2, i64, i64)
+DEF_HELPER_1(bswap16x4, i64, i64)
 DEF_HELPER_3(stvebx, void, env, avr, tl)
 DEF_HELPER_3(stvehx, void, env, avr, tl)
 DEF_HELPER_3(stvewx, void, env, avr, tl)
target-ppc/mem_helper.c +6 -0
index 070dff6..09d552f 100644
@@ -359,6 +359,12 @@ uint64_t helper_bswap32x2(uint64_t x)
     return deposit64((x >> 32), 32, 32, (x));
 }
 
+uint64_t helper_bswap16x4(uint64_t x)
+{
+    uint64_t m = 0x00ff00ff00ff00ffull;
+    return ((x & m) << 8) | ((x >> 8) & m);
+}
+
 #undef HI_IDX
 #undef LO_IDX
 
target-ppc/translate/vsx-impl.inc.c +57 -0

63 lines not on this page · raw message

target-ppc/translate/vsx-ops.inc.c +2 -0
index d7be8ee..fc0aef3 100644
@@ -7,6 +7,8 @@ GEN_HANDLER_E(lxsspx, 0x1F, 0x0C, 0x10, 0, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(lxvd2x, 0x1F, 0x0C, 0x1A, 0, PPC_NONE, PPC2_VSX),
 GEN_HANDLER_E(lxvdsx, 0x1F, 0x0C, 0x0A, 0, PPC_NONE, PPC2_VSX),
 GEN_HANDLER_E(lxvw4x, 0x1F, 0x0C, 0x18, 0, PPC_NONE, PPC2_VSX),
+GEN_HANDLER_E(lxvh8x, 0x1F, 0x0C, 0x19, 0, PPC_NONE,  PPC2_ISA300),
+GEN_HANDLER_E(lxvb16x, 0x1F, 0x0C, 0x1B, 0, PPC_NONE, PPC2_ISA300),
 
 GEN_HANDLER_E(stxsdx, 0x1F, 0xC, 0x16, 0, PPC_NONE, PPC2_VSX),
 GEN_HANDLER_E(stxsibx, 0x1F, 0xD, 0x1C, 0, PPC_NONE, PPC2_ISA300),
Signature · 1 line
2.7.4
#13 lore raw

PATCH 7/10 target-ppc: improve lxvw4x implementation

In reply to Nikunj A Dadhania

Load 8byte at a time and manipulate.

---
 target-ppc/helper.h                 |  1 +
 target-ppc/mem_helper.c             |  5 +++++
 target-ppc/translate/vsx-impl.inc.c | 34 ++++++++++++++++++++--------------
 3 files changed, 26 insertions(+), 14 deletions(-)
target-ppc/helper.h +1 -0
index 0e55d48..4f08ce4 100644
@@ -288,6 +288,7 @@ DEF_HELPER_2(mtvscr, void, env, avr)
 DEF_HELPER_3(lvebx, void, env, avr, tl)
 DEF_HELPER_3(lvehx, void, env, avr, tl)
 DEF_HELPER_3(lvewx, void, env, avr, tl)
+DEF_HELPER_1(bswap32x2, i64, i64)
 DEF_HELPER_3(stvebx, void, env, avr, tl)
 DEF_HELPER_3(stvehx, void, env, avr, tl)
 DEF_HELPER_3(stvewx, void, env, avr, tl)
target-ppc/mem_helper.c +5 -0
index bf6c44a..070dff6 100644
@@ -354,6 +354,11 @@ STVE(stvewx, cpu_stl_data_ra, bswap32, u32)
 #undef I
 #undef LVE
 
+uint64_t helper_bswap32x2(uint64_t x)
+{
+    return deposit64((x >> 32), 32, 32, (x));
+}
+
 #undef HI_IDX
 #undef LO_IDX
 
target-ppc/translate/vsx-impl.inc.c +20 -14
index 70812cb..4dbb180 100644
@@ -75,7 +75,7 @@ static void gen_lxvdsx(DisasContext *ctx)
 static void gen_lxvw4x(DisasContext *ctx)
 {
     TCGv EA;
-    TCGv_i64 tmp;
+    TCGv_i64 t0, t1;
     TCGv_i64 xth = cpu_vsrh(xT(ctx->opcode));
     TCGv_i64 xtl = cpu_vsrl(xT(ctx->opcode));
     if (unlikely(!ctx->vsx_enabled)) {
@@ -84,22 +84,28 @@ static void gen_lxvw4x(DisasContext *ctx)
     }
     gen_set_access_type(ctx, ACCESS_INT);
     EA = tcg_temp_new();
-    tmp = tcg_temp_new_i64();
 
     gen_addr_reg_index(ctx, EA);
-    gen_qemu_ld32u_i64(ctx, tmp, EA);
-    tcg_gen_addi_tl(EA, EA, 4);
-    gen_qemu_ld32u_i64(ctx, xth, EA);
-    tcg_gen_deposit_i64(xth, xth, tmp, 32, 32);
-
-    tcg_gen_addi_tl(EA, EA, 4);
-    gen_qemu_ld32u_i64(ctx, tmp, EA);
-    tcg_gen_addi_tl(EA, EA, 4);
-    gen_qemu_ld32u_i64(ctx, xtl, EA);
-    tcg_gen_deposit_i64(xtl, xtl, tmp, 32, 32);
-
+    if (ctx->le_mode) {
+        t0 = tcg_temp_new_i64();
+        t1 = tcg_temp_new_i64();
+        tcg_gen_qemu_ld_i64(t0, EA, ctx->mem_idx, MO_LEQ);
+        tcg_gen_shri_i64(t1, t0, 32);
+        tcg_gen_deposit_i64(xth, t1, t0, 32, 32);
+        tcg_gen_addi_tl(EA, EA, 8);
+        tcg_gen_qemu_ld_i64(t0, EA, ctx->mem_idx, MO_LEQ);
+        tcg_gen_shri_i64(t1, t0, 32);
+        tcg_gen_deposit_i64(xtl, t1, t0, 32, 32);
+        tcg_temp_free_i64(t0);
+        tcg_temp_free_i64(t1);
+    } else {
+        tcg_gen_qemu_ld_i64(xth, EA, ctx->mem_idx, MO_LEQ);
+        gen_helper_bswap32x2(xth, xth);
+        tcg_gen_addi_tl(EA, EA, 8);
+        tcg_gen_qemu_ld_i64(xtl, EA, ctx->mem_idx, MO_LEQ);
+        gen_helper_bswap32x2(xtl, xtl);
+    }
     tcg_temp_free(EA);
-    tcg_temp_free_i64(tmp);
 }
 
 #define VSX_STORE_SCALAR(name, operation)                     \
Signature · 1 line
2.7.4
#16 lore raw

PATCH 10/10 target-ppc: add stxvb16x and stxvh8x

In reply to Nikunj A Dadhania
stxvb16x: Store VSX Vector Byte*16
stxvh8x:  Store VSX Vector Halfword*8
---
 target-ppc/translate/vsx-impl.inc.c | 55 +++++++++++++++++++++++++++++++++++++
 target-ppc/translate/vsx-ops.inc.c  |  2 ++
 2 files changed, 57 insertions(+)
target-ppc/translate/vsx-impl.inc.c +55 -0
index 498b6ea..16fef80 100644
@@ -165,6 +165,61 @@ static void gen_lxvh8x(DisasContext *ctx)
     tcg_temp_free(EA);
 }
 
+static void gen_stxvb16x(DisasContext *ctx)
+{
+    TCGv_i64 xsh = cpu_vsrh(xS(ctx->opcode));
+    TCGv_i64 xsl = cpu_vsrl(xS(ctx->opcode));
+    TCGv EA;
+
+    if (unlikely(!ctx->vsx_enabled)) {
+        gen_exception(ctx, POWERPC_EXCP_VSXU);
+        return;
+    }
+    gen_set_access_type(ctx, ACCESS_INT);
+    EA = tcg_temp_new();
+    gen_addr_reg_index(ctx, EA);
+
+    if (ctx->le_mode) {
+        tcg_gen_qemu_st_i64(xsh, EA, ctx->mem_idx, MO_BEQ);
+        tcg_gen_addi_tl(EA, EA, 8);
+        tcg_gen_qemu_st_i64(xsl, EA, ctx->mem_idx, MO_BEQ);
+    } else {
+        gen_helper_bswap32x2(xsh, xsh);
+        tcg_gen_qemu_st_i64(xsh, EA, ctx->mem_idx, MO_LEQ);
+        tcg_gen_addi_tl(EA, EA, 8);
+        gen_helper_bswap32x2(xsl, xsl);
+        tcg_gen_qemu_st_i64(xsl, EA, ctx->mem_idx, MO_LEQ);
+    }
+    tcg_temp_free(EA);
+}
+
+static void gen_stxvh8x(DisasContext *ctx)
+{
+    TCGv_i64 xsh = cpu_vsrh(xS(ctx->opcode));
+    TCGv_i64 xsl = cpu_vsrl(xS(ctx->opcode));
+    TCGv EA;
+
+    if (unlikely(!ctx->vsx_enabled)) {
+        gen_exception(ctx, POWERPC_EXCP_VSXU);
+        return;
+    }
+    gen_set_access_type(ctx, ACCESS_INT);
+    EA = tcg_temp_new();
+    gen_addr_reg_index(ctx, EA);
+    if (ctx->le_mode) {
+        tcg_gen_qemu_st_i64(xsh, EA, ctx->mem_idx, MO_BEQ);
+        tcg_gen_addi_tl(EA, EA, 8);
+        tcg_gen_qemu_st_i64(xsl, EA, ctx->mem_idx, MO_BEQ);
+    } else {
+        gen_helper_bswap32x2(xsh, xsh);
+        tcg_gen_qemu_st_i64(xsh, EA, ctx->mem_idx, MO_LEQ);
+        tcg_gen_addi_tl(EA, EA, 8);
+        gen_helper_bswap32x2(xsl, xsl);
+        tcg_gen_qemu_st_i64(xsl, EA, ctx->mem_idx, MO_LEQ);
+    }
+    tcg_temp_free(EA);
+}
+
 #define VSX_STORE_SCALAR(name, operation)                     \
 static void gen_##name(DisasContext *ctx)                     \
 {                                                             \
target-ppc/translate/vsx-ops.inc.c +2 -0
index fc0aef3..a1cf125 100644
@@ -17,6 +17,8 @@ GEN_HANDLER_E(stxsiwx, 0x1F, 0xC, 0x04, 0, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(stxsspx, 0x1F, 0xC, 0x14, 0, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(stxvd2x, 0x1F, 0xC, 0x1E, 0, PPC_NONE, PPC2_VSX),
 GEN_HANDLER_E(stxvw4x, 0x1F, 0xC, 0x1C, 0, PPC_NONE, PPC2_VSX),
+GEN_HANDLER_E(stxvh8x, 0x1F, 0x0C, 0x1D, 0, PPC_NONE,  PPC2_ISA300),
+GEN_HANDLER_E(stxvb16x, 0x1F, 0x0C, 0x1F, 0, PPC_NONE, PPC2_ISA300),
 
 GEN_HANDLER_E(mfvsrwz, 0x1F, 0x13, 0x03, 0x0000F800, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(mtvsrwa, 0x1F, 0x13, 0x06, 0x0000F800, PPC_NONE, PPC2_VSX207),
Signature · 1 line
2.7.4
#15 lore raw

PATCH 9/10 target-ppc: improve stxvw4x implementation

In reply to Nikunj A Dadhania

Manipulate data and store 8bytes instead of 4bytes.

---
 target-ppc/translate/vsx-impl.inc.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)
target-ppc/translate/vsx-impl.inc.c +13 -14
index 8912fe9..498b6ea 100644
@@ -204,7 +204,8 @@ static void gen_stxvd2x(DisasContext *ctx)
 
 static void gen_stxvw4x(DisasContext *ctx)
 {
-    TCGv_i64 tmp;
+    TCGv_i64 xsh = cpu_vsrh(xS(ctx->opcode));
+    TCGv_i64 xsl = cpu_vsrl(xS(ctx->opcode));
     TCGv EA;
     if (unlikely(!ctx->vsx_enabled)) {
         gen_exception(ctx, POWERPC_EXCP_VSXU);
@@ -213,21 +214,19 @@ static void gen_stxvw4x(DisasContext *ctx)
     gen_set_access_type(ctx, ACCESS_INT);
     EA = tcg_temp_new();
     gen_addr_reg_index(ctx, EA);
-    tmp = tcg_temp_new_i64();
-
-    tcg_gen_shri_i64(tmp, cpu_vsrh(xS(ctx->opcode)), 32);
-    gen_qemu_st32_i64(ctx, tmp, EA);
-    tcg_gen_addi_tl(EA, EA, 4);
-    gen_qemu_st32_i64(ctx, cpu_vsrh(xS(ctx->opcode)), EA);
-
-    tcg_gen_shri_i64(tmp, cpu_vsrl(xS(ctx->opcode)), 32);
-    tcg_gen_addi_tl(EA, EA, 4);
-    gen_qemu_st32_i64(ctx, tmp, EA);
-    tcg_gen_addi_tl(EA, EA, 4);
-    gen_qemu_st32_i64(ctx, cpu_vsrl(xS(ctx->opcode)), EA);
 
+    if (ctx->le_mode) {
+        tcg_gen_qemu_st_i64(xsh, EA, ctx->mem_idx, MO_BEQ);
+        tcg_gen_addi_tl(EA, EA, 8);
+        tcg_gen_qemu_st_i64(xsl, EA, ctx->mem_idx, MO_BEQ);
+    } else {
+        gen_helper_bswap32x2(xsh, xsh);
+        tcg_gen_qemu_st_i64(xsh, EA, ctx->mem_idx, MO_LEQ);
+        tcg_gen_addi_tl(EA, EA, 8);
+        gen_helper_bswap32x2(xsl, xsl);
+        tcg_gen_qemu_st_i64(xsl, EA, ctx->mem_idx, MO_LEQ);
+    }
     tcg_temp_free(EA);
-    tcg_temp_free_i64(tmp);
 }
 
 #define MV_VSRW(name, tcgop1, tcgop2, target, source)           \
Signature · 1 line
2.7.4
#2 lore raw

Re: [Qemu-devel] [PATCH v1 01/10] target-ppc: add xxspltib instruction

In reply to Nikunj A Dadhania
Quoted 4 lines · Nikunj A Dadhania
target-ppc/translate/vsx-impl.inc.c +4 -0
+#if defined(TARGET_PPC64)
+#define pattern(x) (((x) & 0xff) * (~(target_ulong)0 / 0xff))
+
+static void gen_xxspltib(DisasContext *ctx)

...

Quoted 1 line

+ tcg_gen_movi_i64(cpu_vsrh(xT(ctx->opcode)), pattern(uim8));

Is this function really not available in 32-bit mode?

I'd been pointing out that you should change target_ulong in PATTERN, above, to uint64_t, so that you match tcg_gen_movi_i64.

r~

#5 lore raw

Re: [Qemu-devel] [PATCH v1 02/10] target-ppc: consolidate load operations

In reply to Nikunj A Dadhania
Quoted 4 lines · Nikunj A Dadhania
target-ppc/translate.c +4 -0
+#define GEN_QEMU_LOAD_64(ldop, op)                                  \
+static void glue(gen_qemu_, glue(ldop, _i64))(DisasContext *ctx,    \
+                                             TCGv_i64 val,          \
+                                             TCGv addr)             \

target-ppc/translate.c static inline void gen_align_no_le(DisasContext *ctx) · line 2493

Quoted 10 lines
target-ppc/translate.c +7 -0
+{                                                                   \
+    tcg_gen_qemu_ld_i64(val, addr, ctx->mem_idx,                    \
+                        op | ctx->default_tcg_memop_mask);          \
+}
+
+GEN_QEMU_LOAD_64(ld32u, MO_UL)
+GEN_QEMU_LOAD_64(ld32s, MO_SL)
 
 static inline void gen_qemu_ld64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
 {

You can of course include this last function in the cleanup as well.

r~

#6 lore raw

Re: [Qemu-devel] [PATCH v1 02/10] target-ppc: consolidate load operations

Quoted 13 lines · Richard Henderson
Quoted 12 lines · Nikunj A Dadhania
target-ppc/translate.c +11 -0
+#define GEN_QEMU_LOAD_64(ldop, op)                                  \
+static void glue(gen_qemu_, glue(ldop, _i64))(DisasContext *ctx,    \
+                                             TCGv_i64 val,          \
+                                             TCGv addr)             \
+{                                                                   \
+    tcg_gen_qemu_ld_i64(val, addr, ctx->mem_idx,                    \
+                        op | ctx->default_tcg_memop_mask);          \
+}
+
+GEN_QEMU_LOAD_64(ld32u, MO_UL)
+GEN_QEMU_LOAD_64(ld32s, MO_SL)
Quoted 4 lines
Quoted 2 lines

static inline void gen_qemu_ld64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2) {

You can of course include this last function in the cleanup as well.

Let me do this as separate patch, as it will need patching at lot of places. This will be function name change: gen_qemu_ld64 => gen_qemu_ld64_i64

I have one more patch converting load/store with reservation to qemu_st/ld.

Regards,
Nikunj

#3 lore raw

Re: [Qemu-devel] [PATCH v1 01/10] target-ppc: add xxspltib instruction

In reply to Richard Henderson
Quoted 9 lines · Richard Henderson
Quoted 4 lines · Nikunj A Dadhania
target-ppc/translate/vsx-impl.inc.c +4 -0
+#if defined(TARGET_PPC64)
+#define pattern(x) (((x) & 0xff) * (~(target_ulong)0 / 0xff))
+
+static void gen_xxspltib(DisasContext *ctx)

...

Quoted 1 line

+ tcg_gen_movi_i64(cpu_vsrh(xT(ctx->opcode)), pattern(uim8));

Is this function really not available in 32-bit mode?

I need to on this.

Quoted 2 lines

I'd been pointing out that you should change target_ulong in PATTERN, above, to uint64_t, so that you match tcg_gen_movi_i64.

Ah.. in fact, I had changed it this way first, then thought that this may not be available in 32-bit and then put it under TARGET_PPC64

Regards
Nikunj

#7 lore raw

Re: [Qemu-devel] [PATCH v1 02/10] target-ppc: consolidate load operations

In reply to Nikunj A Dadhania
Quoted 15 lines · Nikunj A Dadhania
Quoted 13 lines · Richard Henderson
Quoted 12 lines · Nikunj A Dadhania
target-ppc/translate.c +11 -0
+#define GEN_QEMU_LOAD_64(ldop, op)                                  \
+static void glue(gen_qemu_, glue(ldop, _i64))(DisasContext *ctx,    \
+                                             TCGv_i64 val,          \
+                                             TCGv addr)             \
+{                                                                   \
+    tcg_gen_qemu_ld_i64(val, addr, ctx->mem_idx,                    \
+                        op | ctx->default_tcg_memop_mask);          \
+}
+
+GEN_QEMU_LOAD_64(ld32u, MO_UL)
+GEN_QEMU_LOAD_64(ld32s, MO_SL)
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

static inline void gen_qemu_ld64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2) {

You can of course include this last function in the cleanup as well.

Let me do this as separate patch, as it will need patching at lot of places. This will be function name change: gen_qemu_ld64 => gen_qemu_ld64_i64

Oh, right, of course.

r~

#8 lore raw

Re: [Qemu-devel] [PATCH v1 02/10] target-ppc: consolidate load operations

Quoted 21 lines · Richard Henderson
Quoted 20 lines · Nikunj A Dadhania
Quoted 17 lines · Richard Henderson
Quoted 4 lines · Nikunj A Dadhania
target-ppc/translate.c +4 -0
+#define GEN_QEMU_LOAD_64(ldop, op)                                  \
+static void glue(gen_qemu_, glue(ldop, _i64))(DisasContext *ctx,    \
+                                             TCGv_i64 val,          \
+                                             TCGv addr)             \

target-ppc/translate.c static inline void gen_align_no_le(DisasContext *ctx) · line 2493

Quoted 10 lines
target-ppc/translate.c +7 -0
+{                                                                   \
+    tcg_gen_qemu_ld_i64(val, addr, ctx->mem_idx,                    \
+                        op | ctx->default_tcg_memop_mask);          \
+}
+
+GEN_QEMU_LOAD_64(ld32u, MO_UL)
+GEN_QEMU_LOAD_64(ld32s, MO_SL)
 
 static inline void gen_qemu_ld64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
 {

You can of course include this last function in the cleanup as well.

Quoted 5 lines
Quoted 3 lines

Let me do this as separate patch, as it will need patching at lot of places. This will be function name change: gen_qemu_ld64 => gen_qemu_ld64_i64

Oh, right, of course.

I have done all these changes, will send to the list after testing.

Regards
Nikunj