target/ppc: Move fixed-point insns to
v2 cover target/ppc: Move fixed-point insns to
Moving all fixed-point instructions of the following type to decodetree specification : arithmetic, compare, trap, select and logical.
Change log :
v2 : Implemented code clean-ups as per comments by Richard in
patches 1/8, 5/8 and 7/8 of v1.
v1 : https://lore.kernel.org/qemu-devel/[email protected]/
Chinmay Rath (8):
target/ppc: Move mul{li, lw, lwo, hw, hwu} instructions to decodetree. target/ppc: Make divw[u] handler method decodetree compatible. target/ppc: Move divw[u, e, eu] instructions to decodetree. target/ppc: Move neg, darn, mod{sw, uw} to decodetree. target/ppc: Move multiply fixed-point insns (64-bit operands) to
decodetree.
target/ppc: Move div/mod fixed-point insns (64 bits operands) to
decodetree.
target/ppc: Move cmp{rb, eqb}, tw[i], td[i], isel instructions to
decodetree.
target/ppc: Move logical fixed-point instructions to decodetree.
target/ppc/helper.h | 26 +- target/ppc/insn32.decode | 93 +++ target/ppc/excp_helper.c | 4 +- target/ppc/int_helper.c | 24 +- target/ppc/translate.c | 841 +-------------------- target/ppc/translate/fixedpoint-impl.c.inc | 631 ++++++++++++++++ 6 files changed, 762 insertions(+), 857 deletions(-)
Signature · 1 line
2.39.3
PATCH v2 1/8 target/ppc: Move mul{li, lw, lwo, hw, hwu} instructions to decodetree.
Moving the following instructions to decodetree specification :
mulli : D-form
mul{lw, lwo, hw, hwu}[.] : XO-formThe changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag. Also cleaned up code for mullw[o][.] as per review comments while keeping the logic of the tcg ops generated semantically same.
--- target/ppc/insn32.decode | 9 +++ target/ppc/translate.c | 89 ---------------------- target/ppc/translate/fixedpoint-impl.c.inc | 66 ++++++++++++++++ 3 files changed, 75 insertions(+), 89 deletions(-)
target/ppc/insn32.decode +9 -0
@@ -193,6 +193,9 @@ &XO_ta rt ra oe:bool rc:bool @XO_ta ...... rt:5 ra:5 ..... oe:1 ......... rc:1 &XO_ta +&XO_tab_rc rt ra rb rc:bool +@XO_tab_rc ...... rt:5 ra:5 rb:5 . ......... rc:1 &XO_tab_rc + %xx_xt 0:1 21:5 %xx_xb 1:1 11:5 %xx_xa 2:1 16:5
@@ -353,6 +356,12 @@ SUBFE 011111 ..... ..... ..... . 010001000 . @XO SUBFME 011111 ..... ..... ----- . 011101000 . @XO_ta SUBFZE 011111 ..... ..... ----- . 011001000 . @XO_ta +MULLI 000111 ..... ..... ................ @D +MULLW 011111 ..... ..... ..... 0 011101011 . @XO_tab_rc +MULLWO 011111 ..... ..... ..... 1 011101011 . @XO_tab_rc +MULHW 011111 ..... ..... ..... - 001001011 . @XO_tab_rc +MULHWU 011111 ..... ..... ..... - 000001011 . @XO_tab_rc + ## Fixed-Point Logical Instructions CFUGED 011111 ..... ..... ..... 0011011100 - @X
target/ppc/translate.c +0 -89
101 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +66 -0
72 lines not on this page · raw message
Signature · 1 line
2.39.3
PATCH v2 2/8 target/ppc: Make divw[u] handler method decodetree compatible.
In reply to Chinmay RathThe handler methods for divw[u] instructions internally use Rc(ctx->opcode), for extraction of Rc field of instructions, which poses a problem if we move the above said instructions to decodetree, as the ctx->opcode field is not popluated in decodetree. Hence, making it decodetree compatible, so that the mentioned insns can be safely move to decodetree specs.
--- target/ppc/translate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
target/ppc/translate.c +5 -4
@@ -1738,8 +1738,9 @@ static inline void gen_op_arith_add(DisasContext *ctx, TCGv ret, TCGv arg1, } } -static inline void gen_op_arith_divw (DisasContext *ctx,TCGv ret,TCGv arg1, -TCGv arg2,int sign,int compute_ov) +static inline void gen_op_arith_divw (DisasContext *ctx,TCGv ret, +TCGv arg1,TCGv arg2,bool sign, +bool compute_ov,bool compute_rc0) {TCGv_i32 t0 =tcg_temp_new_i32 ();TCGv_i32 t1 =tcg_temp_new_i32 ();
@@ -1773,7 +1774,7 @@ static inline void gen_op_arith_divw(DisasContext *ctx, TCGv ret, TCGv arg1,tcg_gen_or_tl (cpu_so, cpu_so, cpu_ov); } -if (unlikely (Rc (ctx->opcode) !=0 )) { +if (unlikely (compute_rc0)) {gen_set_Rc0 (ctx, ret); } }
@@ -1783,7 +1784,7 @@ static void glue(gen_, name)(DisasContext *ctx) \ { \gen_op_arith_divw (ctx, cpu_gpr[rD (ctx->opcode)], \ cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)], \ - sign, compute_ov); \ + sign, compute_ov,Rc (ctx->opcode)); \ }/* divwu divwu. divwuo divwuo. */ GEN_INT_ARITH_DIVW (divwu,0x0E ,0 ,0 );
Signature · 1 line
2.39.3
PATCH v2 3/8 target/ppc: Move divw[u, e, eu] instructions to decodetree.
In reply to Chinmay RathMoving the following instructions to decodetree specification :
divw[u, e, eu][o][.] : XO-form
The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.
--- target/ppc/helper.h | 4 +-- target/ppc/insn32.decode | 5 ++++ target/ppc/int_helper.c | 4 +-- target/ppc/translate.c | 31 ---------------------- target/ppc/translate/fixedpoint-impl.c.inc | 24 +++++++++++++++++ 5 files changed, 33 insertions(+), 35 deletions(-)
target/ppc/helper.h +2 -2
@@ -55,8 +55,8 @@ DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32) DEF_HELPER_4(divdeu, i64, env, i64, i64, i32) DEF_HELPER_4(divde, i64, env, i64, i64, i32)#endif -DEF_HELPER_4(divweu, tl, env, tl, tl, i32) -DEF_HELPER_4(divwe, tl, env, tl, tl, i32) +DEF_HELPER_4(DIVWEU, tl, env, tl, tl, i32) +DEF_HELPER_4(DIVWE, tl, env, tl, tl, i32) DEF_HELPER_FLAGS_1(popcntb, TCG_CALL_NO_RWG_SE, tl, tl)DEF_HELPER_FLAGS_2 (cmpb,TCG_CALL_NO_RWG_SE , tl, tl, tl)
target/ppc/insn32.decode +5 -0
@@ -362,6 +362,11 @@ MULLWO 011111 ..... ..... ..... 1 011101011 . @XO_tab_rc MULHW 011111 ..... ..... ..... - 001001011 . @XO_tab_rc MULHWU 011111 ..... ..... ..... - 000001011 . @XO_tab_rc +DIVW 011111 ..... ..... ..... . 111101011 . @XO +DIVWU 011111 ..... ..... ..... . 111001011 . @XO +DIVWE 011111 ..... ..... ..... . 110101011 . @XO +DIVWEU 011111 ..... ..... ..... . 110001011 . @XO + ## Fixed-Point Logical Instructions CFUGED 011111 ..... ..... ..... 0011011100 - @X
target/ppc/int_helper.c +2 -2
@@ -44,7 +44,7 @@ static inline void helper_update_ov_legacy(CPUPPCState *env, int ov) } } -target_ulong helper_divweu (CPUPPCState *env,target_ulong ra,target_ulong rb, +target_ulong helper_DIVWEU (CPUPPCState *env,target_ulong ra,target_ulong rb,uint32_t oe) {uint64_t rt =0 ;
@@ -71,7 +71,7 @@ target_ulong helper_divweu(CPUPPCState *env, target_ulong ra, target_ulong rb,return (target_ulong )rt; } -target_ulong helper_divwe (CPUPPCState *env,target_ulong ra,target_ulong rb, +target_ulong helper_DIVWE (CPUPPCState *env,target_ulong ra,target_ulong rb,uint32_t oe) {int64_t rt =0 ;
target/ppc/translate.c +0 -31
@@ -1778,21 +1778,6 @@ static inline void gen_op_arith_divw(DisasContext *ctx, TCGv ret,gen_set_Rc0 (ctx, ret); } } -/* Div functions */ -#define GEN_INT_ARITH_DIVW (name, opc3, sign, compute_ov) \ -static void glue(gen_, name)(DisasContext *ctx) \ -{ \ - gen_op_arith_divw(ctx, cpu_gpr[rD(ctx->opcode)], \ - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \ - sign, compute_ov, Rc(ctx->opcode)); \ -} -/* divwu divwu. divwuo divwuo. */ -GEN_INT_ARITH_DIVW (divwu,0x0E ,0 ,0 ); -GEN_INT_ARITH_DIVW (divwuo,0x1E ,0 ,1 ); -/* divw divw. divwo divwo. */ -GEN_INT_ARITH_DIVW (divw,0x0F ,1 ,0 ); -GEN_INT_ARITH_DIVW (divwo,0x1F ,1 ,1 ); -/* div[wd]eu[o][.] */ #define GEN_DIVE (name, hlpr, compute_ov) \ static void gen_##name(DisasContext *ctx) \
@@ -1805,11 +1790,6 @@ static void gen_##name(DisasContext *ctx) \ } \ } -GEN_DIVE (divweu, divweu,0 ); -GEN_DIVE (divweuo, divweu,1 ); -GEN_DIVE (divwe, divwe,0 ); -GEN_DIVE (divweo, divwe,1 ); -#if defined(TARGET_PPC64 )static inline void gen_op_arith_divd (DisasContext *ctx,TCGv ret,TCGv arg1,TCGv arg2,int sign,int compute_ov)
@@ -6562,17 +6542,6 @@ GEN_HANDLER_E(maddhd_maddhdu, 0x04, 0x18, 0xFF, 0x00000000, PPC_NONE,GEN_HANDLER_E (maddld,0x04 ,0x19 ,0xFF ,0x00000000 ,PPC_NONE ,PPC2_ISA300 ), #endif -#undef GEN_INT_ARITH_DIVW -#define GEN_INT_ARITH_DIVW (name, opc3, sign, compute_ov) \ -GEN_HANDLER(name, 0x1F, 0x0B, opc3, 0x00000000, PPC_INTEGER) -GEN_INT_ARITH_DIVW (divwu,0x0E ,0 ,0 ), -GEN_INT_ARITH_DIVW (divwuo,0x1E ,0 ,1 ), -GEN_INT_ARITH_DIVW (divw,0x0F ,1 ,0 ), -GEN_INT_ARITH_DIVW (divwo,0x1F ,1 ,1 ), -GEN_HANDLER_E (divwe,0x1F ,0x0B ,0x0D ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), -GEN_HANDLER_E (divweo,0x1F ,0x0B ,0x1D ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), -GEN_HANDLER_E (divweu,0x1F ,0x0B ,0x0C ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), -GEN_HANDLER_E (divweuo,0x1F ,0x0B ,0x1C ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ),GEN_HANDLER_E (modsw,0x1F ,0x0B ,0x18 ,0x00000001 ,PPC_NONE ,PPC2_ISA300 ), GEN_HANDLER_E(moduw, 0x1F, 0x0B, 0x08, 0x00000001, PPC_NONE, PPC2_ISA300),
target/ppc/translate/fixedpoint-impl.c.inc +24 -0
@@ -461,6 +461,30 @@ static bool do_mulhw(DisasContext *ctx, arg_XO_tab_rc *a, TRANS(MULHW, do_mulhw, tcg_gen_muls2_i32) TRANS(MULHWU, do_mulhw, tcg_gen_mulu2_i32) +static bool do_divw(DisasContext *ctx, arg_XO *a, int sign) +{ + gen_op_arith_divw(ctx, cpu_gpr[a->rt], cpu_gpr[a->ra], cpu_gpr[a->rb], + sign, a->oe, a->rc); + return true; +} + +static bool do_divwe(DisasContext *ctx, arg_XO *a, + void (*helper)(TCGv, TCGv_ptr, TCGv, TCGv, TCGv_i32)) +{ + REQUIRE_INSNS_FLAGS2(ctx, DIVE_ISA206); + helper(cpu_gpr[a->rt], tcg_env, cpu_gpr[a->ra], cpu_gpr[a->rb], + tcg_constant_i32(a->oe)); + if (unlikely(a->rc)) { + gen_set_Rc0(ctx, cpu_gpr[a->rt]); + } + return true; +} + +TRANS(DIVW, do_divw, 1); +TRANS(DIVWU, do_divw, 0); +TRANS(DIVWE, do_divwe, gen_helper_DIVWE); +TRANS(DIVWEU, do_divwe, gen_helper_DIVWEU); + static bool trans_INVALID(DisasContext *ctx, arg_INVALID *a) { gen_invalid(ctx);
Signature · 1 line
2.39.3
PATCH v2 4/8 target/ppc: Move neg, darn, mod{sw, uw} to decodetree.
In reply to Chinmay RathMoving the below instructions to decodetree specification :
neg[o][.] : XO-form
mod{sw, uw}, darn : X-formThe changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.
--- target/ppc/helper.h | 4 +- target/ppc/insn32.decode | 8 ++++ target/ppc/int_helper.c | 4 +- target/ppc/translate.c | 56 ---------------------- target/ppc/translate/fixedpoint-impl.c.inc | 44 +++++++++++++++++ 5 files changed, 56 insertions(+), 60 deletions(-)
target/ppc/helper.h +2 -2
@@ -71,8 +71,8 @@ DEF_HELPER_FLAGS_2(cmpeqb, TCG_CALL_NO_RWG_SE, i32, tl, tl) DEF_HELPER_FLAGS_1(popcntw, 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_FLAGS_0(darn32, TCG_CALL_NO_RWG, tl) -DEF_HELPER_FLAGS_0(darn64, TCG_CALL_NO_RWG, tl) +DEF_HELPER_FLAGS_0(DARN32, TCG_CALL_NO_RWG, tl) +DEF_HELPER_FLAGS_0(DARN64, TCG_CALL_NO_RWG, tl)#endif DEF_HELPER_FLAGS_1 (cntlsw32,TCG_CALL_NO_RWG_SE , i32, i32)
target/ppc/insn32.decode +8 -0
@@ -187,6 +187,9 @@ &X_a ra @X_a ...... ra:3 .. ..... ..... .......... . &X_a +&X_tl rt l +@X_tl ...... rt:5 ... l:2 ..... .......... . &X_tl + &XO rt ra rb oe:bool rc:bool @XO ...... rt:5 ra:5 rb:5 oe:1 ......... rc:1 &XO
@@ -367,6 +370,11 @@ DIVWU 011111 ..... ..... ..... . 111001011 . @XO DIVWE 011111 ..... ..... ..... . 110101011 . @XO DIVWEU 011111 ..... ..... ..... . 110001011 . @XO +MODSW 011111 ..... ..... ..... 1100001011 - @X +MODUW 011111 ..... ..... ..... 0100001011 - @X +DARN 011111 ..... --- .. ----- 1011110011 - @X_tl +NEG 011111 ..... ..... ----- . 001101000 . @XO_ta + ## Fixed-Point Logical Instructions CFUGED 011111 ..... ..... ..... 0011011100 - @X
target/ppc/int_helper.c +2 -2
@@ -171,7 +171,7 @@ uint32_t helper_cmpeqb(target_ulong ra, target_ulong rb)/* * Return a random number. */ -uint64_t helper_darn32 (void ) +uint64_t helper_DARN32 (void ) {Error *err =NULL ;uint32_t ret;
@@ -186,7 +186,7 @@ uint64_t helper_darn32(void)return ret; } -uint64_t helper_darn64 (void ) +uint64_t helper_DARN64 (void ) {Error *err =NULL ;uint64_t ret;
target/ppc/translate.c +0 -56
92 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +44 -0
50 lines not on this page · raw message
Signature · 1 line
2.39.3
PATCH v2 5/8 target/ppc: Move multiply fixed-point insns (64-bit operands) to decodetree.
In reply to Chinmay RathMoving the following instructions to decodetree :
mul{ld, ldo, hd, hdu}[.] : XO-form
madd{hd, hdu, ld} : VA-formThe changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.
--- target/ppc/insn32.decode | 9 ++ target/ppc/translate.c | 101 --------------------- target/ppc/translate/fixedpoint-impl.c.inc | 85 +++++++++++++++++ 3 files changed, 94 insertions(+), 101 deletions(-)
target/ppc/insn32.decode +9 -0
@@ -375,6 +375,15 @@ MODUW 011111 ..... ..... ..... 0100001011 - @X DARN 011111 ..... --- .. ----- 1011110011 - @X_tl NEG 011111 ..... ..... ----- . 001101000 . @XO_ta +MULLD 011111 ..... ..... ..... 0 011101001 . @XO_tab_rc +MULLDO 011111 ..... ..... ..... 1 011101001 . @XO_tab_rc +MULHD 011111 ..... ..... ..... - 001001001 . @XO_tab_rc +MULHDU 011111 ..... ..... ..... - 000001001 . @XO_tab_rc + +MADDLD 000100 ..... ..... ..... ..... 110011 @VA +MADDHD 000100 ..... ..... ..... ..... 110000 @VA +MADDHDU 000100 ..... ..... ..... ..... 110001 @VA + ## Fixed-Point Logical Instructions CFUGED 011111 ..... ..... ..... 0011011100 - @X
target/ppc/translate.c +0 -101
131 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +85 -0
91 lines not on this page · raw message
Signature · 1 line
2.39.3
PATCH v2 6/8 target/ppc: Move div/mod fixed-point insns (64 bits operands) to decodetree.
In reply to Chinmay RathMoving the below instructions to decodetree specification :
divd[u, e, eu][o][.] : XO-form
mod{sd, ud} : X-formWith this patch, all the fixed-point arithmetic instructions have been moved to decodetree.
The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured using the '-d in_asm,op' flag. Also, remaned do_divwe method in fixedpoint-impl.c.inc to do_dive because it is now used to divide doubleword operands as well, and not just words.
--- target/ppc/helper.h | 4 +- target/ppc/insn32.decode | 8 +++ target/ppc/int_helper.c | 4 +- target/ppc/translate.c | 65 ++-------------------- target/ppc/translate/fixedpoint-impl.c.inc | 29 +++++++++- 5 files changed, 42 insertions(+), 68 deletions(-)
target/ppc/helper.h +2 -2
@@ -52,8 +52,8 @@ DEF_HELPER_FLAGS_2(icbiep, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32)#if defined(TARGET_PPC64 ) -DEF_HELPER_4(divdeu, i64, env, i64, i64, i32) -DEF_HELPER_4(divde, i64, env, i64, i64, i32) +DEF_HELPER_4(DIVDEU, i64, env, i64, i64, i32) +DEF_HELPER_4(DIVDE, i64, env, i64, i64, i32)#endif DEF_HELPER_4(DIVWEU, tl, env, tl, tl, i32)DEF_HELPER_4 (DIVWE , tl, env, tl, tl, i32)
target/ppc/insn32.decode +8 -0
@@ -384,6 +384,14 @@ MADDLD 000100 ..... ..... ..... ..... 110011 @VA MADDHD 000100 ..... ..... ..... ..... 110000 @VA MADDHDU 000100 ..... ..... ..... ..... 110001 @VA +DIVD 011111 ..... ..... ..... . 111101001 . @XO +DIVDU 011111 ..... ..... ..... . 111001001 . @XO +DIVDE 011111 ..... ..... ..... . 110101001 . @XO +DIVDEU 011111 ..... ..... ..... . 110001001 . @XO + +MODSD 011111 ..... ..... ..... 1100001001 - @X +MODUD 011111 ..... ..... ..... 0100001001 - @X + ## Fixed-Point Logical Instructions CFUGED 011111 ..... ..... ..... 0011011100 - @X
target/ppc/int_helper.c +2 -2
@@ -101,7 +101,7 @@ target_ulong helper_DIVWE(CPUPPCState *env, target_ulong ra, target_ulong rb,#if defined(TARGET_PPC64 ) -uint64_t helper_divdeu (CPUPPCState *env,uint64_t ra,uint64_t rb,uint32_t oe) +uint64_t helper_DIVDEU (CPUPPCState *env,uint64_t ra,uint64_t rb,uint32_t oe) {uint64_t rt =0 ;int overflow =0 ;
@@ -120,7 +120,7 @@ uint64_t helper_divdeu(CPUPPCState *env, uint64_t ra, uint64_t rb, uint32_t oe)return rt; } -uint64_t helper_divde (CPUPPCState *env,uint64_t rau,uint64_t rbu,uint32_t oe) +uint64_t helper_DIVDE (CPUPPCState *env,uint64_t rau,uint64_t rbu,uint32_t oe) {uint64_t rt =0 ;int64_t ra = (int64_t )rau;
target/ppc/translate.c +4 -61
94 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +26 -3
@@ -468,7 +468,7 @@ static bool do_divw(DisasContext *ctx, arg_XO *a, int sign) return true; } -static bool do_divwe(DisasContext *ctx, arg_XO *a, +static bool do_dive(DisasContext *ctx, arg_XO *a, void (*helper)(TCGv, TCGv_ptr, TCGv, TCGv, TCGv_i32)) { REQUIRE_INSNS_FLAGS2(ctx, DIVE_ISA206);
@@ -482,8 +482,8 @@ static bool do_divwe(DisasContext *ctx, arg_XO *a, TRANS(DIVW, do_divw, 1); TRANS(DIVWU, do_divw, 0); -TRANS(DIVWE, do_divwe, gen_helper_DIVWE); -TRANS(DIVWEU, do_divwe, gen_helper_DIVWEU); +TRANS(DIVWE, do_dive, gen_helper_DIVWE); +TRANS(DIVWEU, do_dive, gen_helper_DIVWEU); static bool do_modw(DisasContext *ctx, arg_X *a, bool sign) {
@@ -614,6 +614,29 @@ static bool trans_MADDHDU(DisasContext *ctx, arg_MADDHDU *a) return true; } +static bool do_divd(DisasContext *ctx, arg_XO *a, bool sign) +{ + gen_op_arith_divd(ctx, cpu_gpr[a->rt], cpu_gpr[a->ra], cpu_gpr[a->rb], + sign, a->oe, a->rc); + return true; +} + +static bool do_modd(DisasContext *ctx, arg_X *a, bool sign) +{ + REQUIRE_INSNS_FLAGS2(ctx, ISA300); + gen_op_arith_modd(ctx, cpu_gpr[a->rt], cpu_gpr[a->ra], cpu_gpr[a->rb], + sign); + return true; +} + +TRANS64(DIVD, do_divd, true); +TRANS64(DIVDU, do_divd, false); +TRANS64(DIVDE, do_dive, gen_helper_DIVDE); +TRANS64(DIVDEU, do_dive, gen_helper_DIVDEU); + +TRANS64(MODSD, do_modd, true); +TRANS64(MODUD, do_modd, false); + static bool trans_INVALID(DisasContext *ctx, arg_INVALID *a) { gen_invalid(ctx);
Signature · 1 line
2.39.3
Re: [PATCH v2 6/8] target/ppc: Move div/mod fixed-point insns (64 bits operands) to decodetree.
Quoted 14 lines · Chinmay Rath
Moving the below instructions to decodetree specification :
divd[u, e, eu][o][.] : XO-form mod{sd, ud} : X-formWith this patch, all the fixed-point arithmetic instructions have been moved to decodetree.
The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured using the '-d in_asm,op' flag. Also, remaneddo_divwemethod in fixedpoint-impl.c.inc todo_divebecause it is now used to divide doubleword operands as well, and not just words.Signed-off-by Chinmay Rath <[email protected]>Reviewed-by Richard Henderson <[email protected]>
[...]
Quoted 12 lines
target/ppc/translate/fixedpoint-impl.c.inc +12
-0+static bool do_divd(DisasContext *ctx, arg_XO *a, bool sign) +{ + gen_op_arith_divd(ctx, cpu_gpr[a->rt], cpu_gpr[a->ra], cpu_gpr[a->rb], + sign, a->oe, a->rc); + return true; +} + +static bool do_modd(DisasContext *ctx, arg_X *a, bool sign) +{ + REQUIRE_INSNS_FLAGS2(ctx, ISA300); + gen_op_arith_modd(ctx, cpu_gpr[a->rt], cpu_gpr[a->ra], cpu_gpr[a->rb], + sign);
target/ppc/translate/fixedpoint-impl.c.inc static bool trans_MADDHDU(DisasContext *ctx, arg_MADDHDU *a) · line 638
Quoted 10 lines
target/ppc/translate/fixedpoint-impl.c.inc +10
-0+ return true; +} + +TRANS64(DIVD, do_divd, true); +TRANS64(DIVDU, do_divd, false); +TRANS64(DIVDE, do_dive, gen_helper_DIVDE); +TRANS64(DIVDEU, do_dive, gen_helper_DIVDEU); + +TRANS64(MODSD, do_modd, true); +TRANS64(MODUD, do_modd, false);
Sigh. I'm having to fix a bunch of these for 32-bit builds. Just doing the #ifdef TARGET_PPC64 ... #else qemu_build_not_reached(); thing.
Which is quite ugly and actually prevents using some of these macros and requires open coding (e.g., because DIVDE helper is not declared for 32-bit in this case).
Maybe we should move 64-bit only instructions into their own .decode file and not build them for 32-bit, so we don't have to add all these dummy translate functions for them.
For now I'll try to squash in the fixes.
Thanks,
Nick
Re: [PATCH v2 6/8] target/ppc: Move div/mod fixed-point insns (64 bits operands) to decodetree.
Quoted 45 lines · Nicholas Piggin
Quoted 14 lines · Chinmay Rath
Moving the below instructions to decodetree specification :
divd[u, e, eu][o][.] : XO-form mod{sd, ud} : X-formWith this patch, all the fixed-point arithmetic instructions have been moved to decodetree.
The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured using the '-d in_asm,op' flag. Also, remaneddo_divwemethod in fixedpoint-impl.c.inc todo_divebecause it is now used to divide doubleword operands as well, and not just words.Signed-off-by Chinmay Rath <[email protected]>Reviewed-by Richard Henderson <[email protected]>[...]
Quoted 12 lines
target/ppc/translate/fixedpoint-impl.c.inc +12
-0+static bool do_divd(DisasContext *ctx, arg_XO *a, bool sign) +{ + gen_op_arith_divd(ctx, cpu_gpr[a->rt], cpu_gpr[a->ra], cpu_gpr[a->rb], + sign, a->oe, a->rc); + return true; +} + +static bool do_modd(DisasContext *ctx, arg_X *a, bool sign) +{ + REQUIRE_INSNS_FLAGS2(ctx, ISA300); + gen_op_arith_modd(ctx, cpu_gpr[a->rt], cpu_gpr[a->ra], cpu_gpr[a->rb], + sign);target/ppc/translate/fixedpoint-impl.c.inc static bool trans_MADDHDU(DisasContext *ctx, arg_MADDHDU *a) · line 638
Quoted 10 lines
target/ppc/translate/fixedpoint-impl.c.inc +10
-0+ return true; +} + +TRANS64(DIVD, do_divd, true); +TRANS64(DIVDU, do_divd, false); +TRANS64(DIVDE, do_dive, gen_helper_DIVDE); +TRANS64(DIVDEU, do_dive, gen_helper_DIVDEU); + +TRANS64(MODSD, do_modd, true); +TRANS64(MODUD, do_modd, false);Sigh. I'm having to fix a bunch of these for 32-bit builds. Just doing the #ifdef
TARGET_PPC64... #elseqemu_build_not_reached(); thing.
Quoted 3 lines
Which is quite ugly and actually prevents using some of these macros and requires open coding (e.g., because DIVDE helper is not declared for 32-bit in this case).
Compare sparc:
# define gen_helper_pdist ({ qemu_build_not_reached(); NULL; })etc.
Quoted 3 lines
Maybe we should move 64-bit only instructions into their own .decode file and not build them for 32-bit, so we don't have to add all these dummy translate functions for them.
That's another option, yes. The decodetree script will take multiple input files to produce one output, so you could separate the insns by base vs 64-bit.
r~
Re: [PATCH v2 6/8] target/ppc: Move div/mod fixed-point insns (64 bits operands) to decodetree.
Quoted 50 lines · Richard Henderson
Quoted 45 lines · Nicholas Piggin
Quoted 14 lines · Chinmay Rath
Moving the below instructions to decodetree specification :
divd[u, e, eu][o][.] : XO-form mod{sd, ud} : X-formWith this patch, all the fixed-point arithmetic instructions have been moved to decodetree.
The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured using the '-d in_asm,op' flag. Also, remaneddo_divwemethod in fixedpoint-impl.c.inc todo_divebecause it is now used to divide doubleword operands as well, and not just words.Signed-off-by Chinmay Rath <[email protected]>Reviewed-by Richard Henderson <[email protected]>[...]
Quoted 12 lines
target/ppc/translate/fixedpoint-impl.c.inc +12
-0+static bool do_divd(DisasContext *ctx, arg_XO *a, bool sign) +{ + gen_op_arith_divd(ctx, cpu_gpr[a->rt], cpu_gpr[a->ra], cpu_gpr[a->rb], + sign, a->oe, a->rc); + return true; +} + +static bool do_modd(DisasContext *ctx, arg_X *a, bool sign) +{ + REQUIRE_INSNS_FLAGS2(ctx, ISA300); + gen_op_arith_modd(ctx, cpu_gpr[a->rt], cpu_gpr[a->ra], cpu_gpr[a->rb], + sign);target/ppc/translate/fixedpoint-impl.c.inc static bool trans_MADDHDU(DisasContext *ctx, arg_MADDHDU *a) · line 638
Quoted 10 lines
target/ppc/translate/fixedpoint-impl.c.inc +10
-0+ return true; +} + +TRANS64(DIVD, do_divd, true); +TRANS64(DIVDU, do_divd, false); +TRANS64(DIVDE, do_dive, gen_helper_DIVDE); +TRANS64(DIVDEU, do_dive, gen_helper_DIVDEU); + +TRANS64(MODSD, do_modd, true); +TRANS64(MODUD, do_modd, false);Sigh. I'm having to fix a bunch of these for 32-bit builds. Just doing the #ifdef
TARGET_PPC64... #elseqemu_build_not_reached(); thing.Quoted 3 lines
Which is quite ugly and actually prevents using some of these macros and requires open coding (e.g., because DIVDE helper is not declared for 32-bit in this case).
Quoted 5 lines
Compare sparc:
# define gen_helper_pdist ({ qemu_build_not_reached(); NULL; })etc.
That would help indeed.
Quoted 7 lines
Quoted 4 lines
Maybe we should move 64-bit only instructions into their own .decode file and not build them for 32-bit, so we don't have to add all these dummy translate functions for them.
That's another option, yes. The decodetree script will take multiple input files to produce one output, so you could separate the insns by base vs 64-bit.
Thinking about it a bit more, I guess the downside is that you would usually like to group instruction variants that operate on 64-bit data together with the others in the .decode file.
Thanks,
Nick
Re: [PATCH v2 6/8] target/ppc: Move div/mod fixed-point insns (64 bits operands) to decodetree.
Quoted 8 lines · On Mon, 20 May 2024, 09:18 Nicholas Piggin, <[email protected]> wrote:
Quoted 1 line
That's another option, yes. The decodetree script will take multiple
input files to
Quoted 1 line
produce one output, so you could separate the insns by base vs 64-bit.
Thinking about it a bit more, I guess the downside is that you would usually like to group instruction variants that operate on 64-bit data together with the others in the .decode file.
A third option is not too care as much about minimising the ppc32 build and include all of the helpers all of the time.
r~
Quoted 1 line
PATCH v2 7/8 target/ppc: Move cmp{rb, eqb}, tw[i], td[i], isel instructions to decodetree.
In reply to Chinmay RathMoving the following instructions to decodetree specification :
cmp{rb, eqb}, t{w, d} : X-form
t{w, d}i : D-form
isel : A-formThe changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured using the '-d in_asm,op' flag. Also for CMPRB, following review comments :
Replaced repetition of arithmetic right shifting (tcg_gen_shri_i32) followed by extraction of last 8 bits (tcg_gen_ext8u_i32) with extraction of the required bits using offsets (tcg_gen_extract_i32).
--- target/ppc/helper.h | 6 +- target/ppc/insn32.decode | 16 +++ target/ppc/excp_helper.c | 4 +- target/ppc/int_helper.c | 2 +- target/ppc/translate.c | 133 +-------------------- target/ppc/translate/fixedpoint-impl.c.inc | 120 +++++++++++++++++++ 6 files changed, 145 insertions(+), 136 deletions(-)
target/ppc/helper.h +3 -3
@@ -1,8 +1,8 @@ DEF_HELPER_FLAGS_3(raise_exception_err, TCG_CALL_NO_WG, noreturn, env, i32, i32) DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, i32) -DEF_HELPER_FLAGS_4(tw, TCG_CALL_NO_WG, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(TW, TCG_CALL_NO_WG, void, env, tl, tl, i32)#if defined(TARGET_PPC64 ) -DEF_HELPER_FLAGS_4(td, TCG_CALL_NO_WG, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(TD, TCG_CALL_NO_WG, void, env, tl, tl, i32)#endif DEF_HELPER_4(HASHST, void, env, tl, tl, tl)DEF_HELPER_4 (HASHCHK , void, env, tl, tl, tl)
@@ -67,7 +67,7 @@ DEF_HELPER_FLAGS_2(PEXTD, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_1(CDTBCD, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_1(CBCDTD, TCG_CALL_NO_RWG_SE, tl, tl)#if defined(TARGET_PPC64 ) -DEF_HELPER_FLAGS_2(cmpeqb, TCG_CALL_NO_RWG_SE, i32, tl, tl) +DEF_HELPER_FLAGS_2(CMPEQB, TCG_CALL_NO_RWG_SE, i32, tl, tl) DEF_HELPER_FLAGS_1(popcntw, 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)
target/ppc/insn32.decode +16 -0
@@ -23,6 +23,9 @@ &A_tb frt frb rc:bool @A_tb ...... frt:5 ..... frb:5 ..... ..... rc:1 &A_tb +&A_tab_bc rt ra rb bc +@A_tab_bc ...... rt:5 ra:5 rb:5 bc:5 ..... . &A_tab_bc + &D rt ra si:int64_t @D ...... rt:5 ra:5 si:s16 &D
@@ -331,6 +334,19 @@ CMP 011111 ... - . ..... ..... 0000000000 - @X_bfl CMPL 011111 ... - . ..... ..... 0000100000 - @X_bfl CMPI 001011 ... - . ..... ................ @D_bfs CMPLI 001010 ... - . ..... ................ @D_bfu +CMPRB 011111 ... - . ..... ..... 0011000000 - @X_bfl +CMPEQB 011111 ... -- ..... ..... 0011100000 - @X_bf + +### Fixed-Point Trap Instructions + +TW 011111 ..... ..... ..... 0000000100 - @X +TD 011111 ..... ..... ..... 0001000100 - @X +TWI 000011 ..... ..... ................ @D +TDI 000010 ..... ..... ................ @D + +### Fixed-Point Select Instruction + +ISEL 011111 ..... ..... ..... ..... 01111 - @A_tab_bc ### Fixed-Point Arithmetic Instructions
target/ppc/excp_helper.c +2 -2
@@ -2750,7 +2750,7 @@ void helper_rfmci(CPUPPCState *env) }#endif /* !CONFIG_USER_ONLY */ -void helper_tw(CPUPPCState *env, target_ulong arg1, target_ulong arg2, +void helper_TW(CPUPPCState *env, target_ulong arg1, target_ulong arg2, uint32_t flags) { if (!likely(!(((int32_t)arg1 < (int32_t)arg2 && (flags & 0x10)) ||
@@ -2764,7 +2764,7 @@ void helper_tw(CPUPPCState *env, target_ulong arg1, target_ulong arg2, } #ifdef TARGET_PPC64 -void helper_td(CPUPPCState *env, target_ulong arg1, target_ulong arg2, +void helper_TD(CPUPPCState *env, target_ulong arg1, target_ulong arg2, uint32_t flags) { if (!likely(!(((int64_t)arg1 < (int64_t)arg2 && (flags & 0x10)) ||
target/ppc/int_helper.c +1 -1
@@ -159,7 +159,7 @@ uint64_t helper_DIVDE(CPUPPCState *env, uint64_t rau, uint64_t rbu, uint32_t oe)/* When you XOR the pattern and there is a match, that byte will be zero */ #define hasvalue (x, n) (haszero((x) ^ pattern(n))) -uint32_t helper_cmpeqb (target_ulong ra,target_ulong rb) +uint32_t helper_CMPEQB (target_ulong ra,target_ulong rb) {return hasvalue (rb, ra) ?CRF_GT :0 ; }
target/ppc/translate.c +3 -130
169 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +120 -0
132 lines not on this page · raw message
Signature · 1 line
2.39.3
PATCH v2 8/8 target/ppc: Move logical fixed-point instructions to decodetree.
In reply to Chinmay RathMoving the below instructions to decodetree specification :
andi[s]., {ori, xori}[s] : D-form
{and, andc, nand, or, orc, nor, xor, eqv}[.],
exts{b, h, w}[.], cnt{l, t}z{w, d}[.],
popcnt{b, w, d}, prty{w, d}, cmp, bpermd : X-formWith this patch, all the fixed-point logical instructions have been moved to decodetree.
The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.
--- target/ppc/helper.h | 8 +- target/ppc/insn32.decode | 38 +++ target/ppc/int_helper.c | 10 +- target/ppc/translate.c | 359 --------------------- target/ppc/translate/fixedpoint-impl.c.inc | 269 +++++++++++++++ 5 files changed, 316 insertions(+), 368 deletions(-)
target/ppc/helper.h +4 -4
@@ -58,8 +58,8 @@ DEF_HELPER_4(DIVDE, i64, env, i64, i64, i32) DEF_HELPER_4(DIVWEU, tl, env, tl, tl, i32) DEF_HELPER_4(DIVWE, tl, env, tl, tl, i32) -DEF_HELPER_FLAGS_1(popcntb, TCG_CALL_NO_RWG_SE, tl, tl) -DEF_HELPER_FLAGS_2(cmpb, TCG_CALL_NO_RWG_SE, tl, tl, tl) +DEF_HELPER_FLAGS_1(POPCNTB, TCG_CALL_NO_RWG_SE, tl, tl) +DEF_HELPER_FLAGS_2(CMPB, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_3(sraw, tl, env, tl, tl) DEF_HELPER_FLAGS_2(CFUGED, TCG_CALL_NO_RWG_SE, i64, i64, i64)DEF_HELPER_FLAGS_2 (PDEPD ,TCG_CALL_NO_RWG_SE , i64, i64, i64)
@@ -68,8 +68,8 @@ DEF_HELPER_FLAGS_1(CDTBCD, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_1(CBCDTD, TCG_CALL_NO_RWG_SE, tl, tl)#if defined(TARGET_PPC64 ) DEF_HELPER_FLAGS_2(CMPEQB, TCG_CALL_NO_RWG_SE, i32, tl, tl) -DEF_HELPER_FLAGS_1(popcntw, TCG_CALL_NO_RWG_SE, tl, tl) -DEF_HELPER_FLAGS_2(bpermd, TCG_CALL_NO_RWG_SE, i64, i64, i64) +DEF_HELPER_FLAGS_1(POPCNTW, 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_FLAGS_0(DARN32, TCG_CALL_NO_RWG, tl)DEF_HELPER_FLAGS_0 (DARN64 ,TCG_CALL_NO_RWG , tl)
target/ppc/insn32.decode +38 -0
@@ -29,6 +29,9 @@ &D rt ra si:int64_t @D ...... rt:5 ra:5 si:s16 &D +&D_ui rt ra ui:uint64_t +@D_ui ...... rt:5 ra:5 ui:16 &D_ui + &D_bf bf l:bool ra imm @D_bfs ...... bf:3 . l:1 ra:5 imm:s16 &D_bf @D_bfu ...... bf:3 . l:1 ra:5 imm:16 &D_bf
@@ -96,6 +99,9 @@ &X_sa rs ra @X_sa ...... rs:5 ra:5 ..... .......... . &X_sa +&X_sa_rc rs ra rc +@X_sa_rc ...... rs:5 ra:5 ..... .......... rc:1 &X_sa_rc + %x_frtp 22:4 !function=times_2 %x_frap 17:4 !function=times_2 %x_frbp 12:4 !function=times_2
@@ -410,6 +416,38 @@ MODUD 011111 ..... ..... ..... 0100001001 - @X ## Fixed-Point Logical Instructions +ANDI_ 011100 ..... ..... ................ @D_ui +ANDIS_ 011101 ..... ..... ................ @D_ui +ORI 011000 ..... ..... ................ @D_ui +ORIS 011001 ..... ..... ................ @D_ui +XORI 011010 ..... ..... ................ @D_ui +XORIS 011011 ..... ..... ................ @D_ui + +AND 011111 ..... ..... ..... 0000011100 . @X_rc +ANDC 011111 ..... ..... ..... 0000111100 . @X_rc +NAND 011111 ..... ..... ..... 0111011100 . @X_rc +OR 011111 ..... ..... ..... 0110111100 . @X_rc +ORC 011111 ..... ..... ..... 0110011100 . @X_rc +NOR 011111 ..... ..... ..... 0001111100 . @X_rc +XOR 011111 ..... ..... ..... 0100111100 . @X_rc +EQV 011111 ..... ..... ..... 0100011100 . @X_rc +CMPB 011111 ..... ..... ..... 0111111100 . @X_rc + +EXTSB 011111 ..... ..... ----- 1110111010 . @X_sa_rc +EXTSH 011111 ..... ..... ----- 1110011010 . @X_sa_rc +EXTSW 011111 ..... ..... ----- 1111011010 . @X_sa_rc +CNTLZW 011111 ..... ..... ----- 0000011010 . @X_sa_rc +CNTTZW 011111 ..... ..... ----- 1000011010 . @X_sa_rc +CNTLZD 011111 ..... ..... ----- 0000111010 . @X_sa_rc +CNTTZD 011111 ..... ..... ----- 1000111010 . @X_sa_rc +POPCNTB 011111 ..... ..... ----- 0001111010 . @X_sa_rc + +POPCNTW 011111 ..... ..... ----- 0101111010 - @X_sa +POPCNTD 011111 ..... ..... ----- 0111111010 - @X_sa +PRTYW 011111 ..... ..... ----- 0010011010 - @X_sa +PRTYD 011111 ..... ..... ----- 0010111010 - @X_sa + +BPERMD 011111 ..... ..... ..... 0011111100 - @X CFUGED 011111 ..... ..... ..... 0011011100 - @X CNTLZDM 011111 ..... ..... ..... 0000111011 - @X CNTTZDM 011111 ..... ..... ..... 1000111011 - @X
target/ppc/int_helper.c +5 -5
@@ -201,7 +201,7 @@ uint64_t helper_DARN64(void)return ret; } -uint64_t helper_bpermd (uint64_t rs,uint64_t rb) +uint64_t helper_BPERMD (uint64_t rs,uint64_t rb) {int i;uint64_t ra =0 ;
@@ -219,7 +219,7 @@ uint64_t helper_bpermd(uint64_t rs, uint64_t rb)#endif -target_ulong helper_cmpb (target_ulong rs,target_ulong rb) +target_ulong helper_CMPB (target_ulong rs,target_ulong rb) {target_ulong mask =0xff ;target_ulong ra =0 ;
@@ -288,7 +288,7 @@ target_ulong helper_srad(CPUPPCState *env, target_ulong value,#endif #if defined(TARGET_PPC64 ) -target_ulong helper_popcntb (target_ulong val) +target_ulong helper_POPCNTB (target_ulong val) {/* Note that we don't fold past bytes */ val = (val & 0x5555555555555555ULL) + ((val >> 1) &
@@ -300,7 +300,7 @@ target_ulong helper_popcntb(target_ulong val)return val; } -target_ulong helper_popcntw (target_ulong val) +target_ulong helper_POPCNTW (target_ulong val) {/* Note that we don't fold past words. */ val = (val & 0x5555555555555555ULL) + ((val >> 1) &
@@ -316,7 +316,7 @@ target_ulong helper_popcntw(target_ulong val) return val; }#else -target_ulong helper_popcntb (target_ulong val) +target_ulong helper_POPCNTB (target_ulong val) {/* Note that we don't fold past bytes */ val = (val &0x55555555 ) + ((val >>1 ) &0x55555555 );
target/ppc/translate.c +0 -359
392 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +269 -0
281 lines not on this page · raw message
Signature · 1 line
2.39.3