Stage 2 VSX Support
v3 cover Stage 2 VSX Support
NOTE: this is a resubmission of this patch series. Alex discovered some corruption in the patches from my previous submission.
This patch series continues adding support for the PowerPC Vector Scalar Extension (VSX). Patches are relative to the Stage 1 delivery (see
http://lists.nongnu.org/archive/html/qemu-ppc/2013-09/msg00231.html).
This series adds the following:
a) all remaining load and store instructions defined by the V2.06 Power ISA
(aka Power7).
b) The vector and scalar move instructions.
c) The logical instructions defined by V2.06.
d) Assorted permute and select instructions.
V2: reworked patches 4, 10, 11 and 12 per comments from Richard Henderson (thanks, Richard!)
V3: reworked patches 7 & 8 per comments from Paolo Bonzini (thanks, Paulo)
Tom Musta (13):
Abandon GEN_VSX_* macros
Add lxsdx
Add lxvdsx
Add lxvw4x
Add stxsdx
Add stxvw4x
Add VSX Scalar Move Instructions
Add VSX Vector Move Instructions
Add Power7 VSX Logical Instructions
Add xxmrgh/xxmrgl
Add xxsel
Add xxspltw
Add xxsldwi
target-ppc/translate.c | 491 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 483 insertions(+), 8 deletions(-)
PATCH v3 1/13 Abandon GEN_VSX_* macros
This patch eliminates the GEN_VSX_LXVNX/GEN_VSX_STXVNX macros which did not provide significant value above the general GEN_HANDLER_E macro.
--- target-ppc/translate.c | 12 ++---------- 1 files changed, 2 insertions(+), 10 deletions(-)
target-ppc/translate.c +2 -10
@@ -9514,17 +9514,9 @@ GEN_VAFORM_PAIRED(vmsumshm, vmsumshs, 20),GEN_VAFORM_PAIRED (vsel, vperm,21 ),GEN_VAFORM_PAIRED (vmaddfp, vnmsubfp,23 ), -#undef GEN_VSX_LXVNX -#define GEN_VSX_LXVNX (name, opc2, opc3) \ - GEN_HANDLER_E(lxv##name, 0x1F, opc2, opc3, 0x00000000, PPC_NONE, PPC2_VSX) +GEN_HANDLER_E (lxvd2x,0x1F ,0x0C ,0x1A ,0 ,PPC_NONE ,PPC2_VSX ), -GEN_VSX_LXVNX(d2x, 0x0C, 0x1A), - -#undef GEN_VSX_STXVNX -#define GEN_VSX_STXVNX (name, opc2, opc3) \ - GEN_HANDLER_E(stxv##name, 0x1F, opc2, opc3, 0x00000000, PPC_NONE, PPC2_VSX) - -GEN_VSX_STXVNX(d2x, 0x0C, 0x1E), +GEN_HANDLER_E (stxvd2x,0x1F ,0xC ,0x1E ,0 ,PPC_NONE ,PPC2_VSX ), #undef GEN_XX3FORM_DM #define GEN_XX3FORM_DM(name, opc2, opc3) \
Signature · 1 line
1.7.1
PATCH v3 2/13 Add lxsdx
In reply to Tom MustaThis patch adds the Load VSX Scalar Doubleowrd Indexed (lxsdx) instruction.
The lower 8 bytes of the target register are undefined; this implementation leaves those bytes unaltered.
--- target-ppc/translate.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
target-ppc/translate.c +16 -0
@@ -7003,6 +7003,21 @@ static inline TCGv_i64 cpu_vsrl(int n) } } +static void gen_lxsdx (DisasContext *ctx) +{ +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 ); +gen_qemu_ld64 (ctx,cpu_vsrh (xT (ctx->opcode)),EA ); +/* NOTE: cpu_vsrl is undefined */ +tcg_temp_free (EA ); +} +static void gen_lxvd2x (DisasContext *ctx) {TCGv EA ;
@@ -9514,6 +9529,7 @@ GEN_VAFORM_PAIRED(vmsumshm, vmsumshs, 20),GEN_VAFORM_PAIRED (vsel, vperm,21 ),GEN_VAFORM_PAIRED (vmaddfp, vnmsubfp,23 ), +GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ),GEN_HANDLER_E (lxvd2x,0x1F ,0x0C ,0x1A ,0 ,PPC_NONE ,PPC2_VSX ), GEN_HANDLER_E(stxvd2x, 0x1F, 0xC, 0x1E, 0, PPC_NONE, PPC2_VSX),
Signature · 1 line
1.7.1
PATCH v3 3/13 Add lxvdsx
In reply to Tom MustaThis patch adds the Load VSX Vector Doubleword & Splat Indexed (lxvdsx) instruction.
--- target-ppc/translate.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
target-ppc/translate.c +16 -0
@@ -7034,6 +7034,21 @@ static void gen_lxvd2x(DisasContext *ctx)tcg_temp_free (EA ); } +static void gen_lxvdsx (DisasContext *ctx) +{ +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 ); +gen_qemu_ld64 (ctx,cpu_vsrh (xT (ctx->opcode)),EA ); +tcg_gen_mov_tl (cpu_vsrl (xT (ctx->opcode)),cpu_vsrh (xT (ctx->opcode))); +tcg_temp_free (EA ); +} +static void gen_stxvd2x (DisasContext *ctx) {TCGv EA ;
@@ -9531,6 +9546,7 @@ GEN_VAFORM_PAIRED(vmaddfp, vnmsubfp, 23),GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ),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(stxvd2x, 0x1F, 0xC, 0x1E, 0, PPC_NONE, PPC2_VSX),
Signature · 1 line
1.7.1
PATCH v3 4/13 Add lxvw4x
In reply to Tom MustaThis patch adds the Load VSX Vector Word*4 Indexed (lxvw4x) instruction.
V2: changed to use deposit_i64 per Richard Henderson's review.
--- target-ppc/translate.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)
target-ppc/translate.c +29 -0
@@ -7049,6 +7049,34 @@ static void gen_lxvdsx(DisasContext *ctx)tcg_temp_free (EA ); } +static void gen_lxvw4x (DisasContext *ctx) +{ +TCGv EA , tmp; +TCGv_i64 xth =cpu_vsrh (xT (ctx->opcode)); +TCGv_i64 xtl =cpu_vsrl (xT (ctx->opcode)); +if (unlikely (!ctx->vsx_enabled)) { +gen_exception (ctx,POWERPC_EXCP_VSXU ); +return ; + } +gen_set_access_type (ctx,ACCESS_INT ); +EA =tcg_temp_new (); + tmp =tcg_temp_new (); +gen_addr_reg_index (ctx,EA ); +gen_qemu_ld32u (ctx, tmp,EA ); +tcg_gen_addi_tl (EA ,EA ,4 ); +gen_qemu_ld32u (ctx, xth,EA ); +tcg_gen_deposit_i64 (xth, xth, tmp,32 ,32 ); + +tcg_gen_addi_tl (EA ,EA ,4 ); +gen_qemu_ld32u (ctx, tmp,EA ); +tcg_gen_addi_tl (EA ,EA ,4 ); +gen_qemu_ld32u (ctx, xtl,EA ); +tcg_gen_deposit_i64 (xtl, xtl, tmp,32 ,32 ); + +tcg_temp_free (EA ); +tcg_temp_free (tmp); +} +static void gen_stxvd2x (DisasContext *ctx) {TCGv EA ;
@@ -9547,6 +9575,7 @@ GEN_VAFORM_PAIRED(vmaddfp, vnmsubfp, 23),GEN_HANDLER_E (lxsdx,0x1F ,0x0C ,0x12 ,0 ,PPC_NONE ,PPC2_VSX ),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(stxvd2x, 0x1F, 0xC, 0x1E, 0, PPC_NONE, PPC2_VSX),
Signature · 1 line
1.7.1
PATCH v3 5/13 Add stxsdx
In reply to Tom MustaThis patch adds the Store VSX Scalar Doubleword Indexed (stxsdx) instruction.
--- target-ppc/translate.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)
target-ppc/translate.c +15 -0
@@ -7077,6 +7077,20 @@ static void gen_lxvw4x(DisasContext *ctx)tcg_temp_free (tmp); } +static void gen_stxsdx (DisasContext *ctx) +{ +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 ); +gen_qemu_st64 (ctx,cpu_vsrh (xS (ctx->opcode)),EA ); +tcg_temp_free (EA ); +} +static void gen_stxvd2x (DisasContext *ctx) {TCGv EA ;
@@ -9577,6 +9591,7 @@ 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 (stxsdx,0x1F ,0xC ,0x16 ,0 ,PPC_NONE ,PPC2_VSX ),GEN_HANDLER_E (stxvd2x,0x1F ,0xC ,0x1E ,0 ,PPC_NONE ,PPC2_VSX ), #undef GEN_XX3FORM_DM
Signature · 1 line
1.7.1
PATCH v3 6/13 Add stxvw4x
In reply to Tom MustaThis patch adds the Store VSX Vector Word*4 Indexed (stxvw4x) instruction.
--- target-ppc/translate.c | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-)
target-ppc/translate.c +28 -0
@@ -7107,6 +7107,33 @@ static void gen_stxvd2x(DisasContext *ctx)tcg_temp_free (EA ); } +static void gen_stxvw4x (DisasContext *ctx) +{ +TCGv EA , tmp; +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 ); + tmp =tcg_temp_new (); + +tcg_gen_shri_i64 (tmp,cpu_vsrh (xS (ctx->opcode)),32 ); +gen_qemu_st32 (ctx, tmp,EA ); +tcg_gen_addi_tl (EA ,EA ,4 ); +gen_qemu_st32 (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 (ctx, tmp,EA ); +tcg_gen_addi_tl (EA ,EA ,4 ); +gen_qemu_st32 (ctx,cpu_vsrl (xS (ctx->opcode)),EA ); + +tcg_temp_free (EA ); +tcg_temp_free (tmp); +} +static void gen_xxpermdi (DisasContext *ctx) {TCGv_i64 xh, xl;
@@ -9593,6 +9620,7 @@ 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 (stxvd2x,0x1F ,0xC ,0x1E ,0 ,PPC_NONE ,PPC2_VSX ), +GEN_HANDLER_E (stxvw4x,0x1F ,0xC ,0x1C ,0 ,PPC_NONE ,PPC2_VSX ), #undef GEN_XX3FORM_DM #define GEN_XX3FORM_DM(name, opc2, opc3) \
Signature · 1 line
1.7.1
PATCH v3 7/13 Add VSX Scalar Move Instructions
In reply to Tom MustaThis 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).
V3: Per feedback from Paolo Bonzini, moved the sign mask into a temporary and used andc.
--- target-ppc/translate.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 69 insertions(+), 0 deletions(-)
target-ppc/translate.c +69 -0
@@ -7163,6 +7163,58 @@ static void gen_xxpermdi(DisasContext *ctx)tcg_temp_free (xh);tcg_temp_free (xl); } +#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, sgm; \ + if (unlikely(!ctx->vsx_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VSXU); \ + return; \ + } \ + xb = tcg_temp_new(); \ + sgm = tcg_temp_new(); \ + tcg_gen_mov_i64(xb, cpu_vsrh(xB(ctx->opcode))); \ + tcg_gen_movi_i64(sgm, sgn_mask); \ + switch (op) { \ + case OP_ABS: { \ + tcg_gen_andc_i64(xb, xb, sgm); \ + break; \ + } \ + case OP_NABS: { \ + tcg_gen_or_i64(xb, xb, sgm); \ + break; \ + } \ + case OP_NEG: { \ + tcg_gen_xor_i64(xb, xb, sgm); \ + break; \ + } \ + case OP_CPSGN: { \ + TCGv_i64 xa = tcg_temp_new(); \ + tcg_gen_mov_i64(xa, cpu_vsrh(xA(ctx->opcode))); \ + tcg_gen_and_i64(xa, xa, sgm); \ + tcg_gen_andc_i64(xb, xb, sgm); \ + 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); \ + tcg_temp_free(sgm); \ + } + +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 */
@@ -9622,6 +9674,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),\
@@ -9641,6 +9705,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
Signature · 1 line
1.7.1
PATCH v3 8/13 Add VSX Vector Move Instructions
In reply to Tom MustaThis patch adds the vector move instructions:
- xvabsdp - Vector Absolute Value Double-Precision
- xvnabsdp - Vector Negative Absolute Value Double-Precision
- xvnegdp - Vector Negate Double-Precision
- xvcpsgndp - Vector Copy Sign Double-Precision
- xvabssp - Vector Absolute Value Single-Precision
- xvnabssp - Vector Negative Absolute Value Single-Precision
- xvnegsp - Vector Negate Single-Precision
- xvcpsgnsp - Vector Copy Sign Single-Precision
V3: Per Paolo Bonzini's suggestion, used a temporary for the sign mask and andc.
--- target-ppc/translate.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-)
target-ppc/translate.c +71 -0
@@ -7215,6 +7215,69 @@ 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) +#define VSX_VECTOR_MOVE (name, op, sgn_mask) \ +static void glue(gen_, name)(DisasContext * ctx) \ + { \ + TCGv_i64 xbh, xbl, sgm; \ + if (unlikely(!ctx->vsx_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VSXU); \ + return; \ + } \ + xbh = tcg_temp_new(); \ + xbl = tcg_temp_new(); \ + sgm = tcg_temp_new(); \ + tcg_gen_mov_i64(xbh, cpu_vsrh(xB(ctx->opcode))); \ + tcg_gen_mov_i64(xbl, cpu_vsrl(xB(ctx->opcode))); \ + tcg_gen_movi_i64(sgm, sgn_mask); \ + switch (op) { \ + case OP_ABS: { \ + tcg_gen_andc_i64(xbh, xbh, sgm); \ + tcg_gen_andc_i64(xbl, xbl, sgm); \ + break; \ + } \ + case OP_NABS: { \ + tcg_gen_or_i64(xbh, xbh, sgm); \ + tcg_gen_or_i64(xbl, xbl, sgm); \ + break; \ + } \ + case OP_NEG: { \ + tcg_gen_xor_i64(xbh, xbh, sgm); \ + tcg_gen_xor_i64(xbl, xbl, sgm); \ + break; \ + } \ + case OP_CPSGN: { \ + TCGv_i64 xah = tcg_temp_new(); \ + TCGv_i64 xal = tcg_temp_new(); \ + tcg_gen_mov_i64(xah, cpu_vsrh(xA(ctx->opcode))); \ + tcg_gen_mov_i64(xal, cpu_vsrl(xA(ctx->opcode))); \ + tcg_gen_and_i64(xah, xah, sgm); \ + tcg_gen_and_i64(xal, xal, sgm); \ + tcg_gen_andc_i64(xbh, xbh, sgm); \ + tcg_gen_andc_i64(xbl, xbl, sgm); \ + tcg_gen_or_i64(xbh, xbh, xah); \ + tcg_gen_or_i64(xbl, xbl, xal); \ + tcg_temp_free(xah); \ + tcg_temp_free(xal); \ + break; \ + } \ + } \ + tcg_gen_mov_i64(cpu_vsrh(xT(ctx->opcode)), xbh); \ + tcg_gen_mov_i64(cpu_vsrl(xT(ctx->opcode)), xbl); \ + tcg_temp_free(xbh); \ + tcg_temp_free(xbl); \ + tcg_temp_free(sgm); \ + } + +VSX_VECTOR_MOVE(xvabsdp, OP_ABS, SGN_MASK_DP) +VSX_VECTOR_MOVE(xvnabsdp, OP_NABS, SGN_MASK_DP) +VSX_VECTOR_MOVE(xvnegdp, OP_NEG, SGN_MASK_DP) +VSX_VECTOR_MOVE(xvcpsgndp, OP_CPSGN, SGN_MASK_DP) +VSX_VECTOR_MOVE(xvabssp, OP_ABS, SGN_MASK_SP) +VSX_VECTOR_MOVE(xvnabssp, OP_NABS, SGN_MASK_SP) +VSX_VECTOR_MOVE(xvnegsp, OP_NEG, SGN_MASK_SP) +VSX_VECTOR_MOVE (xvcpsgnsp,OP_CPSGN ,SGN_MASK_SP ) + +/*** SPE extension ***/ /* Register moves */
@@ -9710,6 +9773,14 @@ GEN_XX2FORM(xsnabsdp, 0x12, 0x16, PPC2_VSX),GEN_XX2FORM (xsnegdp,0x12 ,0x17 ,PPC2_VSX ),GEN_XX3FORM (xscpsgndp,0x00 ,0x16 ,PPC2_VSX ), +GEN_XX2FORM (xvabsdp,0x12 ,0x1D ,PPC2_VSX ), +GEN_XX2FORM (xvnabsdp,0x12 ,0x1E ,PPC2_VSX ), +GEN_XX2FORM (xvnegdp,0x12 ,0x1F ,PPC2_VSX ), +GEN_XX3FORM (xvcpsgndp,0x00 ,0x1E ,PPC2_VSX ), +GEN_XX2FORM (xvabssp,0x12 ,0x19 ,PPC2_VSX ), +GEN_XX2FORM (xvnabssp,0x12 ,0x1A ,PPC2_VSX ), +GEN_XX2FORM (xvnegsp,0x12 ,0x1B ,PPC2_VSX ), +GEN_XX3FORM (xvcpsgnsp,0x00 ,0x1A ,PPC2_VSX ),GEN_XX3FORM_DM (xxpermdi,0x08 ,0x01 ), #undef GEN_SPE
Signature · 1 line
1.7.1
PATCH v3 9/13 Add Power7 VSX Logical Instructions
In reply to Tom MustaThis patch adds the VSX logical instructions that are defined by the Version 2.06 Power ISA (aka Power7):
- xxland
- xxlandc
- xxlor
- xxlxor
- xxlnor
--- target-ppc/translate.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)
target-ppc/translate.c +29 -0
@@ -7278,6 +7278,24 @@ VSX_VECTOR_MOVE(xvnegsp, OP_NEG, SGN_MASK_SP) VSX_VECTOR_MOVE(xvcpsgnsp, OP_CPSGN, SGN_MASK_SP) +#define VSX_LOGICAL (name, tcg_op) \ +static void glue(gen_, name)(DisasContext * ctx) \ + { \ + if (unlikely(!ctx->vsx_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VSXU); \ + return; \ + } \ + tcg_op(cpu_vsrh(xT(ctx->opcode)), cpu_vsrh(xA(ctx->opcode)), \ + cpu_vsrh(xB(ctx->opcode))); \ + tcg_op(cpu_vsrl(xT(ctx->opcode)), cpu_vsrl(xA(ctx->opcode)), \ + cpu_vsrl(xB(ctx->opcode))); \ + } + +VSX_LOGICAL(xxland, tcg_gen_and_tl) +VSX_LOGICAL(xxlandc, tcg_gen_andc_tl) +VSX_LOGICAL(xxlor, tcg_gen_or_tl) +VSX_LOGICAL(xxlxor, tcg_gen_xor_tl) +VSX_LOGICAL (xxlnor, tcg_gen_nor_tl)/*** SPE extension ***/ /* Register moves */
@@ -9781,6 +9799,17 @@ GEN_XX2FORM(xvabssp, 0x12, 0x19, PPC2_VSX),GEN_XX2FORM (xvnabssp,0x12 ,0x1A ,PPC2_VSX ),GEN_XX2FORM (xvnegsp,0x12 ,0x1B ,PPC2_VSX ),GEN_XX3FORM (xvcpsgnsp,0x00 ,0x1A ,PPC2_VSX ), + +#undef VSX_LOGICAL +#define VSX_LOGICAL(name, opc2, opc3, fl2) \ +GEN_XX3FORM(name, opc2, opc3, fl2) + +VSX_LOGICAL (xxland,0x8 ,0x10 ,PPC2_VSX ), +VSX_LOGICAL (xxlandc,0x8 ,0x11 ,PPC2_VSX ), +VSX_LOGICAL (xxlor,0x8 ,0x12 ,PPC2_VSX ), +VSX_LOGICAL (xxlxor,0x8 ,0x13 ,PPC2_VSX ), +VSX_LOGICAL (xxlnor,0x8 ,0x14 ,PPC2_VSX ), +GEN_XX3FORM_DM (xxpermdi,0x08 ,0x01 ), #undef GEN_SPE
Signature · 1 line
1.7.1
PATCH v3 10/13 Add xxmrgh/xxmrgl
In reply to Tom MustaThis patch adds the VSX Merge High Word and VSX Merge Low Word instructions.
V2: Now implemented using deposit (per Richard Henderson's comment)
--- target-ppc/translate.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-)
target-ppc/translate.c +41 -0
@@ -7297,6 +7297,45 @@ VSX_LOGICAL(xxlor, tcg_gen_or_tl) VSX_LOGICAL(xxlxor, tcg_gen_xor_tl) VSX_LOGICAL(xxlnor, tcg_gen_nor_tl) +#define VSX_XXMRG (name, high) \ +static void glue(gen_, name)(DisasContext * ctx) \ + { \ + TCGv_i64 a0, a1, b0, b1; \ + if (unlikely(!ctx->vsx_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VSXU); \ + return; \ + } \ + a0 = tcg_temp_new(); \ + a1 = tcg_temp_new(); \ + b0 = tcg_temp_new(); \ + b1 = tcg_temp_new(); \ + if (high) { \ + tcg_gen_mov_i64(a0, cpu_vsrh(xA(ctx->opcode))); \ + tcg_gen_mov_i64(a1, cpu_vsrh(xA(ctx->opcode))); \ + tcg_gen_mov_i64(b0, cpu_vsrh(xB(ctx->opcode))); \ + tcg_gen_mov_i64(b1, cpu_vsrh(xB(ctx->opcode))); \ + } else { \ + tcg_gen_mov_i64(a0, cpu_vsrl(xA(ctx->opcode))); \ + tcg_gen_mov_i64(a1, cpu_vsrl(xA(ctx->opcode))); \ + tcg_gen_mov_i64(b0, cpu_vsrl(xB(ctx->opcode))); \ + tcg_gen_mov_i64(b1, cpu_vsrl(xB(ctx->opcode))); \ + } \ + tcg_gen_shri_i64(a0, a0, 32); \ + tcg_gen_shri_i64(b0, b0, 32); \ + tcg_gen_deposit_i64(cpu_vsrh(xT(ctx->opcode)), \ + b0, a0, 32, 32); \ + tcg_gen_deposit_i64(cpu_vsrl(xT(ctx->opcode)), \ + b1, a1, 32, 32); \ + tcg_temp_free(a0); \ + tcg_temp_free(a1); \ + tcg_temp_free(b0); \ + tcg_temp_free(b1); \ + } + +VSX_XXMRG(xxmrghw, 1) +VSX_XXMRG (xxmrglw,0 ) + +/*** SPE extension ***/ /* Register moves */
@@ -9809,6 +9848,8 @@ VSX_LOGICAL(xxlandc, 0x8, 0x11, PPC2_VSX),VSX_LOGICAL (xxlor,0x8 ,0x12 ,PPC2_VSX ),VSX_LOGICAL (xxlxor,0x8 ,0x13 ,PPC2_VSX ),VSX_LOGICAL (xxlnor,0x8 ,0x14 ,PPC2_VSX ), +GEN_XX3FORM (xxmrghw,0x08 ,0x02 ,PPC2_VSX ), +GEN_XX3FORM (xxmrglw,0x08 ,0x06 ,PPC2_VSX ), GEN_XX3FORM_DM(xxpermdi, 0x08, 0x01),
Signature · 1 line
1.7.1
PATCH v3 11/13 Add xxsel
In reply to Tom MustaThis patch adds the VSX Select (xxsel) instruction.
The xxsel instruction has four VSR operands. Thus the xC instruction decoder is added.
The xxsel instruction is massively overloaded in the opcode table since only bits 26 and 27 are opcode bits. This overloading is done in matrix fashion with two macros (GEN_XXSEL_ROW and GEN_XX_SEL).
V2: (1) eliminated unecessary XXSEL macro (2) tighter implementation using tcg_gen_andc_i64.
--- target-ppc/translate.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 76 insertions(+), 0 deletions(-)
target-ppc/translate.c +76 -0
@@ -497,6 +497,7 @@ EXTRACT_HELPER_SPLIT(xT, 0, 1, 21, 5);EXTRACT_HELPER_SPLIT (xS,0 ,1 ,21 ,5 );EXTRACT_HELPER_SPLIT (xA,2 ,1 ,16 ,5 );EXTRACT_HELPER_SPLIT (xB,1 ,1 ,11 ,5 ); +EXTRACT_HELPER_SPLIT (xC,3 ,1 ,6 ,5 );EXTRACT_HELPER (DM ,8 ,2 );/*****************************************************************************/ /* PowerPC instructions table */
@@ -7335,6 +7336,38 @@ static void glue(gen_, name)(DisasContext * ctx) \ VSX_XXMRG(xxmrghw, 1) VSX_XXMRG(xxmrglw, 0) +static void gen_xxsel (DisasContext * ctx) +{ +TCGv_i64 a, b, c; +if (unlikely (!ctx->vsx_enabled)) { +gen_exception (ctx,POWERPC_EXCP_VSXU ); +return ; + } + a =tcg_temp_new (); + b =tcg_temp_new (); + c =tcg_temp_new (); + +tcg_gen_mov_i64 (a,cpu_vsrh (xA (ctx->opcode))); +tcg_gen_mov_i64 (b,cpu_vsrh (xB (ctx->opcode))); +tcg_gen_mov_i64 (c,cpu_vsrh (xC (ctx->opcode))); + +tcg_gen_and_i64 (b, b, c); +tcg_gen_andc_i64 (a, a, c); +tcg_gen_or_i64 (cpu_vsrh (xT (ctx->opcode)), a, b); + +tcg_gen_mov_i64 (a,cpu_vsrl (xA (ctx->opcode))); +tcg_gen_mov_i64 (b,cpu_vsrl (xB (ctx->opcode))); +tcg_gen_mov_i64 (c,cpu_vsrl (xC (ctx->opcode))); + +tcg_gen_and_i64 (b, b, c); +tcg_gen_andc_i64 (a, a, c); +tcg_gen_or_i64 (cpu_vsrl (xT (ctx->opcode)), a, b); + +tcg_temp_free (a); +tcg_temp_free (b); +tcg_temp_free (c); +} +/*** SPE extension ***/ /* Register moves */
@@ -9851,6 +9884,49 @@ VSX_LOGICAL(xxlnor, 0x8, 0x14, PPC2_VSX),GEN_XX3FORM (xxmrghw,0x08 ,0x02 ,PPC2_VSX ),GEN_XX3FORM (xxmrglw,0x08 ,0x06 ,PPC2_VSX ), +#define GEN_XXSEL_ROW(opc3) \ +GEN_HANDLER2_E (xxsel,"xxsel" ,0x3C ,0x18 , opc3,0 ,PPC_NONE ,PPC2_VSX ), \ +GEN_HANDLER2_E (xxsel,"xxsel" ,0x3C ,0x19 , opc3,0 ,PPC_NONE ,PPC2_VSX ), \ +GEN_HANDLER2_E (xxsel,"xxsel" ,0x3C ,0x1A , opc3,0 ,PPC_NONE ,PPC2_VSX ), \ +GEN_HANDLER2_E (xxsel,"xxsel" ,0x3C ,0x1B , opc3,0 ,PPC_NONE ,PPC2_VSX ), \ +GEN_HANDLER2_E (xxsel,"xxsel" ,0x3C ,0x1C , opc3,0 ,PPC_NONE ,PPC2_VSX ), \ +GEN_HANDLER2_E (xxsel,"xxsel" ,0x3C ,0x1D , opc3,0 ,PPC_NONE ,PPC2_VSX ), \ +GEN_HANDLER2_E (xxsel,"xxsel" ,0x3C ,0x1E , opc3,0 ,PPC_NONE ,PPC2_VSX ), \ +GEN_HANDLER2_E (xxsel,"xxsel" ,0x3C ,0x1F , opc3,0 ,PPC_NONE ,PPC2_VSX ), \ + +GEN_XXSEL_ROW(0x00) +GEN_XXSEL_ROW(0x01) +GEN_XXSEL_ROW(0x02) +GEN_XXSEL_ROW(0x03) +GEN_XXSEL_ROW(0x04) +GEN_XXSEL_ROW(0x05) +GEN_XXSEL_ROW(0x06) +GEN_XXSEL_ROW(0x07) +GEN_XXSEL_ROW(0x08) +GEN_XXSEL_ROW(0x09) +GEN_XXSEL_ROW(0x0A) +GEN_XXSEL_ROW(0x0B) +GEN_XXSEL_ROW(0x0C) +GEN_XXSEL_ROW(0x0D) +GEN_XXSEL_ROW(0x0E) +GEN_XXSEL_ROW(0x0F) +GEN_XXSEL_ROW(0x10) +GEN_XXSEL_ROW(0x11) +GEN_XXSEL_ROW(0x12) +GEN_XXSEL_ROW(0x13) +GEN_XXSEL_ROW(0x14) +GEN_XXSEL_ROW(0x15) +GEN_XXSEL_ROW(0x16) +GEN_XXSEL_ROW(0x17) +GEN_XXSEL_ROW(0x18) +GEN_XXSEL_ROW(0x19) +GEN_XXSEL_ROW(0x1A) +GEN_XXSEL_ROW(0x1B) +GEN_XXSEL_ROW(0x1C) +GEN_XXSEL_ROW(0x1D) +GEN_XXSEL_ROW(0x1E) +GEN_XXSEL_ROW(0x1F) +GEN_XX3FORM_DM (xxpermdi,0x08 ,0x01 ), #undef GEN_SPE
Signature · 1 line
1.7.1
PATCH v3 12/13 Add xxspltw
In reply to Tom MustaThis patch adds the VSX Splat Word (xxsplatw) instruction.
This is the first instruction to use the UIM immediate field and consequently a decoder is also added.
V2: reworked implementation per Richard Henderson's comments.
--- target-ppc/translate.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-)
target-ppc/translate.c +31 -0
@@ -499,6 +499,7 @@ EXTRACT_HELPER_SPLIT(xA, 2, 1, 16, 5);EXTRACT_HELPER_SPLIT (xB,1 ,1 ,11 ,5 );EXTRACT_HELPER_SPLIT (xC,3 ,1 ,6 ,5 );EXTRACT_HELPER (DM ,8 ,2 ); +EXTRACT_HELPER (UIM ,16 ,2 );/*****************************************************************************/ /* PowerPC instructions table */
@@ -7368,6 +7369,35 @@ static void gen_xxsel(DisasContext * ctx)tcg_temp_free (c); } +static void gen_xxspltw (DisasContext *ctx) +{ +TCGv_i64 b, b2; +TCGv_i64 vsr = (UIM (ctx->opcode) &2 ) ? +cpu_vsrl (xB (ctx->opcode)) : +cpu_vsrh (xB (ctx->opcode)); + +if (unlikely (!ctx->vsx_enabled)) { +gen_exception (ctx,POWERPC_EXCP_VSXU ); +return ; + } + + b =tcg_temp_new (); + b2 =tcg_temp_new (); + +if (UIM (ctx->opcode) &1 ) { +tcg_gen_ext32u_i64 (b, vsr); + }else { +tcg_gen_shri_i64 (b, vsr,32 ); + } + +tcg_gen_shli_i64 (b2, b,32 ); +tcg_gen_or_i64 (cpu_vsrh (xT (ctx->opcode)), b, b2); +tcg_gen_mov_i64 (cpu_vsrl (xT (ctx->opcode)),cpu_vsrh (xT (ctx->opcode))); + +tcg_temp_free (b); +tcg_temp_free (b2); +} +/*** SPE extension ***/ /* Register moves */
@@ -9883,6 +9913,7 @@ VSX_LOGICAL(xxlxor, 0x8, 0x13, PPC2_VSX),VSX_LOGICAL (xxlnor,0x8 ,0x14 ,PPC2_VSX ),GEN_XX3FORM (xxmrghw,0x08 ,0x02 ,PPC2_VSX ),GEN_XX3FORM (xxmrglw,0x08 ,0x06 ,PPC2_VSX ), +GEN_XX2FORM (xxspltw,0x08 ,0x0A ,PPC2_VSX ), #define GEN_XXSEL_ROW(opc3) \ GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x18, opc3, 0, PPC_NONE, PPC2_VSX), \
Signature · 1 line
1.7.1
PATCH v3 13/13 Add xxsldwi
In reply to Tom MustaThis patch adds the VSX Shift Left Double by Word Immediate (xxsldwi) instruction.
--- target-ppc/translate.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-)
target-ppc/translate.c +62 -0
@@ -500,6 +500,7 @@ EXTRACT_HELPER_SPLIT(xB, 1, 1, 11, 5);EXTRACT_HELPER_SPLIT (xC,3 ,1 ,6 ,5 );EXTRACT_HELPER (DM ,8 ,2 );EXTRACT_HELPER (UIM ,16 ,2 ); +EXTRACT_HELPER (SHW ,8 ,2 );/*****************************************************************************/ /* PowerPC instructions table */
@@ -7398,6 +7399,66 @@ static void gen_xxspltw(DisasContext *ctx)tcg_temp_free (b2); } +static void gen_xxsldwi (DisasContext *ctx) +{ +TCGv_i64 xth, xtl; +if (unlikely (!ctx->vsx_enabled)) { +gen_exception (ctx,POWERPC_EXCP_VSXU ); +return ; + } + xth =tcg_temp_new (); + xtl =tcg_temp_new (); + +switch (SHW (ctx->opcode)) { +case 0 : { +tcg_gen_mov_i64 (xth,cpu_vsrh (xA (ctx->opcode))); +tcg_gen_mov_i64 (xtl,cpu_vsrl (xA (ctx->opcode))); +break ; + } +case 1 : { +TCGv_i64 t0 =tcg_temp_new (); +tcg_gen_mov_i64 (xth,cpu_vsrh (xA (ctx->opcode))); +tcg_gen_shli_i64 (xth, xth,32 ); +tcg_gen_mov_i64 (t0,cpu_vsrl (xA (ctx->opcode))); +tcg_gen_shri_i64 (t0, t0,32 ); +tcg_gen_or_i64 (xth, xth, t0); +tcg_gen_mov_i64 (xtl,cpu_vsrl (xA (ctx->opcode))); +tcg_gen_shli_i64 (xtl, xtl,32 ); +tcg_gen_mov_i64 (t0,cpu_vsrh (xB (ctx->opcode))); +tcg_gen_shri_i64 (t0, t0,32 ); +tcg_gen_or_i64 (xtl, xtl, t0); +tcg_temp_free (t0); +break ; + } +case 2 : { +tcg_gen_mov_i64 (xth,cpu_vsrl (xA (ctx->opcode))); +tcg_gen_mov_i64 (xtl,cpu_vsrh (xB (ctx->opcode))); +break ; + } +case 3 : { +TCGv_i64 t0 =tcg_temp_new (); +tcg_gen_mov_i64 (xth,cpu_vsrl (xA (ctx->opcode))); +tcg_gen_shli_i64 (xth, xth,32 ); +tcg_gen_mov_i64 (t0,cpu_vsrh (xB (ctx->opcode))); +tcg_gen_shri_i64 (t0, t0,32 ); +tcg_gen_or_i64 (xth, xth, t0); +tcg_gen_mov_i64 (xtl,cpu_vsrh (xB (ctx->opcode))); +tcg_gen_shli_i64 (xtl, xtl,32 ); +tcg_gen_mov_i64 (t0,cpu_vsrl (xB (ctx->opcode))); +tcg_gen_shri_i64 (t0, t0,32 ); +tcg_gen_or_i64 (xtl, xtl, t0); +tcg_temp_free (t0); +break ; + } + } + +tcg_gen_mov_i64 (cpu_vsrh (xT (ctx->opcode)), xth); +tcg_gen_mov_i64 (cpu_vsrl (xT (ctx->opcode)), xtl); + +tcg_temp_free (xth); +tcg_temp_free (xtl); +} +/*** SPE extension ***/ /* Register moves */
@@ -9914,6 +9975,7 @@ VSX_LOGICAL(xxlnor, 0x8, 0x14, PPC2_VSX),GEN_XX3FORM (xxmrghw,0x08 ,0x02 ,PPC2_VSX ),GEN_XX3FORM (xxmrglw,0x08 ,0x06 ,PPC2_VSX ),GEN_XX2FORM (xxspltw,0x08 ,0x0A ,PPC2_VSX ), +GEN_XX3FORM_DM (xxsldwi,0x08 ,0x00 ), #define GEN_XXSEL_ROW(opc3) \ GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x18, opc3, 0, PPC_NONE, PPC2_VSX), \
Signature · 1 line
1.7.1
Quoted 35 lines · Tom Musta
NOTE: this is a resubmission of this patch series. Alex discovered some corruption in the patches from my previous submission.
This patch series continues adding support for the PowerPC Vector Scalar Extension (VSX). Patches are relative to the Stage 1 delivery (see
http://lists.nongnu.org/archive/html/qemu-ppc/2013-09/msg00231.html).This series adds the following:
a) all remaining load and store instructions defined by the V2.06 Power ISA
(aka Power7).b) The vector and scalar move instructions.
c) The logical instructions defined by V2.06.
d) Assorted permute and select instructions.V2: reworked patches 4, 10, 11 and 12 per comments from Richard Henderson (thanks, Richard!)
V3: reworked patches 7 & 8 per comments from Paolo Bonzini (thanks, Paulo)
Tom Musta (13):
Abandon GEN_VSX_* macros
Add lxsdx
Add lxvdsx
Add lxvw4x
Add stxsdx
Add stxvw4x
Add VSX Scalar Move Instructions
Add VSX Vector Move Instructions
Add Power7 VSX Logical Instructions
Add xxmrgh/xxmrgl
Add xxsel
Add xxspltw
Add xxsldwi
Quoted 3 lines
target-ppc/translate.c | 491 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 483 insertions(+), 8 deletions(-)
Ping.
Alexander Graf
AppliedQuoted 36 lines · Tom Musta
Quoted 35 lines · Tom Musta
NOTE: this is a resubmission of this patch series. Alex discovered some corruption in the patches from my previous submission.
This patch series continues adding support for the PowerPC Vector Scalar Extension (VSX). Patches are relative to the Stage 1 delivery (see
http://lists.nongnu.org/archive/html/qemu-ppc/2013-09/msg00231.html).This series adds the following:
a) all remaining load and store instructions defined by the V2.06 Power ISA
(aka Power7).b) The vector and scalar move instructions.
c) The logical instructions defined by V2.06.
d) Assorted permute and select instructions.V2: reworked patches 4, 10, 11 and 12 per comments from Richard Henderson (thanks, Richard!)
V3: reworked patches 7 & 8 per comments from Paolo Bonzini (thanks, Paulo)
Tom Musta (13):
Abandon GEN_VSX_* macros
Add lxsdx
Add lxvdsx
Add lxvw4x
Add stxsdx
Add stxvw4x
Add VSX Scalar Move Instructions
Add VSX Vector Move Instructions
Add Power7 VSX Logical Instructions
Add xxmrgh/xxmrgl
Add xxsel
Add xxspltw
Add xxsldwi
Quoted 5 lines
Quoted 3 lines
target-ppc/translate.c| 491 +++++++++++++++++++++++++++++++++++++++++++++++-1 files changed, 483 insertions(+), 8 deletions(-)Ping.
Thanks, applied to ppc-next.
Alex