target/mips: Replace cpu_ld/st_mmuidx_ra() calls in LD/ST Multiple
v5 cover target/mips: Replace cpu_ld/st_mmuidx_ra() calls in LD/ST Multiple
Missing review: 2, 4
Since v4:
- s/size_t/unsigned/ (rth)
- Use DisasContext::default_tcg_memop_mask
Address Richard review comments on v3 single patch [*] as its own series.
Do not convert the helper to translation to KISS, since my goal is simply to kill the cpu_ld/st_mmuidx_ra() API and these are the last uses \o/
[*] https://lore.kernel.org/qemu-devel/[email protected]/
Philippe Mathieu-Daudé (4):
target/mips: Pass MemOpIdx argument to Load/Store Multiple helpers target/mips: Remove unnecessary target_ulong uses in LD/ST Multiple target/mips: Inline cpu_ld/st_mmuidx_ra() calls in LD/ST Multiple target/mips: Check alignment for microMIPS pre-R6 LD/ST multiple
target/mips/tcg/ldst_helper.c | 74 +++++++++++------------ target/mips/tcg/micromips_translate.c.inc | 18 ++++-- 2 files changed, 48 insertions(+), 44 deletions(-)
Signature · 1 line
2.53.0
PATCH v5 1/4 target/mips: Pass MemOpIdx argument to Load/Store Multiple helpers
In preparation of using the MemOp content in the next commit, pass it as MemOpIdx. Include the access size.
--- target/mips/tcg/ldst_helper.c | 16 ++++++++++++---- target/mips/tcg/micromips_translate.c.inc | 16 ++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-)
target/mips/tcg/ldst_helper.c +12 -4
@@ -224,8 +224,10 @@ void helper_sdr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,static const int multiple_regs[] = {16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,30 };void helper_lwm (CPUMIPSState *env,target_ulong addr,target_ulong reglist, -uint32_t mem_idx) +uint32_t memop_idx) { +MemOpIdx oi = memop_idx; +unsigned mem_idx =get_mmuidx (oi);target_ulong base_reglist = reglist &0xf ;target_ulong do_r31 = reglist &0x10 ;
@@ -246,8 +248,10 @@ void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, }void helper_swm (CPUMIPSState *env,target_ulong addr,target_ulong reglist, -uint32_t mem_idx) +uint32_t memop_idx) { +MemOpIdx oi = memop_idx; +unsigned mem_idx =get_mmuidx (oi);target_ulong base_reglist = reglist &0xf ;target_ulong do_r31 = reglist &0x10 ;
@@ -268,8 +272,10 @@ void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,#if defined(TARGET_MIPS64 )void helper_ldm (CPUMIPSState *env,target_ulong addr,target_ulong reglist, -uint32_t mem_idx) +uint32_t memop_idx) { +MemOpIdx oi = memop_idx; +unsigned mem_idx =get_mmuidx (oi);target_ulong base_reglist = reglist &0xf ;target_ulong do_r31 = reglist &0x10 ;
@@ -290,8 +296,10 @@ void helper_ldm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, }void helper_sdm (CPUMIPSState *env,target_ulong addr,target_ulong reglist, -uint32_t mem_idx) +uint32_t memop_idx) { +MemOpIdx oi = memop_idx; +unsigned mem_idx =get_mmuidx (oi);target_ulong base_reglist = reglist &0xf ;target_ulong do_r31 = reglist &0x10 ;
target/mips/tcg/micromips_translate.c.inc +10 -6
@@ -693,7 +693,8 @@ static void gen_ldst_multiple(DisasContext *ctx, uint32_t opc, int reglist, int base, int16_t offset) { TCGv t0, t1; - TCGv_i32 t2; + MemOp mop = MO_UNALN; + MemOpIdx oi; if (ctx->hflags & MIPS_HFLAG_BMASK) { gen_reserved_instruction(ctx);
@@ -705,22 +706,25 @@ static void gen_ldst_multiple(DisasContext *ctx, uint32_t opc, int reglist, gen_base_offset_addr(ctx, t0, base, offset); t1 = tcg_constant_tl(reglist); - t2 = tcg_constant_i32(ctx->mem_idx); save_cpu_state(ctx, 1); switch (opc) { case LWM32: - gen_helper_lwm(tcg_env, t0, t1, t2); + oi = make_memop_idx(mop | MO_UL, ctx->mem_idx); + gen_helper_lwm(tcg_env, t0, t1, tcg_constant_i32(oi)); break; case SWM32: - gen_helper_swm(tcg_env, t0, t1, t2); + oi = make_memop_idx(mop | MO_UL, ctx->mem_idx); + gen_helper_swm(tcg_env, t0, t1, tcg_constant_i32(oi)); break; #ifdef TARGET_MIPS64 case LDM: - gen_helper_ldm(tcg_env, t0, t1, t2); + oi = make_memop_idx(mop | MO_UQ, ctx->mem_idx); + gen_helper_ldm(tcg_env, t0, t1, tcg_constant_i32(oi)); break; case SDM: - gen_helper_sdm(tcg_env, t0, t1, t2); + oi = make_memop_idx(mop | MO_UQ, ctx->mem_idx); + gen_helper_sdm(tcg_env, t0, t1, tcg_constant_i32(oi)); break; #endif }
Signature · 1 line
2.53.0
PATCH v5 2/4 target/mips: Remove unnecessary target_ulong uses in LD/ST Multiple
In reply to Philippe Mathieu-Daudé@do_r31 is a boolean, @base_reglist an unsigned size and @i an unsigned index.
--- target/mips/tcg/ldst_helper.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-)
target/mips/tcg/ldst_helper.c +12 -20
@@ -228,13 +228,11 @@ void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, {MemOpIdx oi = memop_idx;unsigned mem_idx =get_mmuidx (oi); -target_ulong base_reglist = reglist &0xf ; -target_ulong do_r31 = reglist &0x10 ; +unsigned base_reglist = reglist &0xf ; +bool do_r31 = reglist &0x10 ;if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) { -target_ulong i; - -for (i =0 ; i < base_reglist; i++) { +for (unsigned i =0 ; i < base_reglist; i++) { env->active_tc.gpr[multiple_regs[i]] = (target_long )cpu_ldl_mmuidx_ra (env, addr, mem_idx,GETPC ()); addr +=4 ;
@@ -252,13 +250,11 @@ void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, {MemOpIdx oi = memop_idx;unsigned mem_idx =get_mmuidx (oi); -target_ulong base_reglist = reglist &0xf ; -target_ulong do_r31 = reglist &0x10 ; +unsigned base_reglist = reglist &0xf ; +bool do_r31 = reglist &0x10 ;if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) { -target_ulong i; - -for (i =0 ; i < base_reglist; i++) { +for (unsigned i =0 ; i < base_reglist; i++) {cpu_stl_mmuidx_ra (env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx,GETPC ()); addr +=4 ;
@@ -276,13 +272,11 @@ void helper_ldm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, {MemOpIdx oi = memop_idx;unsigned mem_idx =get_mmuidx (oi); -target_ulong base_reglist = reglist &0xf ; -target_ulong do_r31 = reglist &0x10 ; +unsigned base_reglist = reglist &0xf ; +bool do_r31 = reglist &0x10 ;if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) { -target_ulong i; - -for (i =0 ; i < base_reglist; i++) { +for (unsigned i =0 ; i < base_reglist; i++) { env->active_tc.gpr[multiple_regs[i]] =cpu_ldq_mmuidx_ra (env, addr, mem_idx,GETPC ()); addr +=8 ;
@@ -300,13 +294,11 @@ void helper_sdm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, {MemOpIdx oi = memop_idx;unsigned mem_idx =get_mmuidx (oi); -target_ulong base_reglist = reglist &0xf ; -target_ulong do_r31 = reglist &0x10 ; +unsigned base_reglist = reglist &0xf ; +bool do_r31 = reglist &0x10 ;if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) { -target_ulong i; - -for (i =0 ; i < base_reglist; i++) { +for (unsigned i =0 ; i < base_reglist; i++) {cpu_stq_mmuidx_ra (env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx,GETPC ()); addr +=8 ;
Signature · 1 line
2.53.0
Re: [PATCH v5 2/4] target/mips: Remove unnecessary target_ulong uses in LD/ST Multiple
Quoted 7 lines · Philippe Mathieu-Daudé
@do_r31 is a boolean, @base_reglist an unsigned size and @i an unsigned index.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/mips/tcg/ldst_helper.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-)
r~
PATCH v5 3/4 target/mips: Inline cpu_ld/st_mmuidx_ra() calls in LD/ST Multiple
In reply to Philippe Mathieu-DaudéIn preparation of removing the cpu_ld*_mmuidx_ra() and cpu_st*_mmuidx_ra() calls, inline them. Expand MO_TE to mo_endian_env(env) in gen_ldst_multiple().
--- target/mips/tcg/ldst_helper.c | 34 +++++++++++------------ target/mips/tcg/micromips_translate.c.inc | 2 ++ 2 files changed, 18 insertions(+), 18 deletions(-)
target/mips/tcg/ldst_helper.c +16 -18
@@ -227,21 +227,20 @@ void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, uint32_t memop_idx) {MemOpIdx oi = memop_idx; -unsigned mem_idx =get_mmuidx (oi);unsigned base_reglist = reglist &0xf ;bool do_r31 = reglist &0x10 ; +target_ulong *gpr = env->active_tc.gpr; +uintptr_t ra =GETPC ();if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) {for (unsigned i =0 ; i < base_reglist; i++) { - env->active_tc.gpr[multiple_regs[i]] = - (target_long )cpu_ldl_mmuidx_ra (env, addr, mem_idx,GETPC ()); + gpr[multiple_regs[i]] = (target_long )cpu_ldl_mmu (env, addr, oi, ra); addr +=4 ; } }if (do_r31) { - env->active_tc.gpr[31 ] = - (target_long )cpu_ldl_mmuidx_ra (env, addr, mem_idx,GETPC ()); + gpr[31 ] = (target_long )cpu_ldl_mmu (env, addr, oi, ra); } }
@@ -249,20 +248,20 @@ void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, uint32_t memop_idx) {MemOpIdx oi = memop_idx; -unsigned mem_idx =get_mmuidx (oi);unsigned base_reglist = reglist &0xf ;bool do_r31 = reglist &0x10 ; +target_ulong *gpr = env->active_tc.gpr; +uintptr_t ra =GETPC ();if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) {for (unsigned i =0 ; i < base_reglist; i++) { -cpu_stl_mmuidx_ra (env, addr, env->active_tc.gpr[multiple_regs[i]], - mem_idx,GETPC ()); +cpu_stl_mmu (env, addr, gpr[multiple_regs[i]], oi, ra); addr +=4 ; } }if (do_r31) { -cpu_stl_mmuidx_ra (env, addr, env->active_tc.gpr[31 ], mem_idx,GETPC ()); +cpu_stl_mmu (env, addr, gpr[31 ], oi, ra); } }
@@ -271,21 +270,20 @@ void helper_ldm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, uint32_t memop_idx) {MemOpIdx oi = memop_idx; -unsigned mem_idx =get_mmuidx (oi);unsigned base_reglist = reglist &0xf ;bool do_r31 = reglist &0x10 ; +target_ulong *gpr = env->active_tc.gpr; +uintptr_t ra =GETPC ();if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) {for (unsigned i =0 ; i < base_reglist; i++) { - env->active_tc.gpr[multiple_regs[i]] = -cpu_ldq_mmuidx_ra (env, addr, mem_idx,GETPC ()); + gpr[multiple_regs[i]] =cpu_ldq_mmu (env, addr, oi, ra); addr +=8 ; } }if (do_r31) { - env->active_tc.gpr[31 ] = -cpu_ldq_mmuidx_ra (env, addr, mem_idx,GETPC ()); + gpr[31 ] =cpu_ldq_mmu (env, addr, oi, ra); } }
@@ -293,20 +291,20 @@ void helper_sdm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, uint32_t memop_idx) {MemOpIdx oi = memop_idx; -unsigned mem_idx =get_mmuidx (oi);unsigned base_reglist = reglist &0xf ;bool do_r31 = reglist &0x10 ; +target_ulong *gpr = env->active_tc.gpr; +uintptr_t ra =GETPC ();if (base_reglist >0 && base_reglist <=ARRAY_SIZE (multiple_regs)) {for (unsigned i =0 ; i < base_reglist; i++) { -cpu_stq_mmuidx_ra (env, addr, env->active_tc.gpr[multiple_regs[i]], - mem_idx,GETPC ()); +cpu_stq_mmu (env, addr, gpr[multiple_regs[i]], oi, ra); addr +=8 ; } }if (do_r31) { -cpu_stq_mmuidx_ra (env, addr, env->active_tc.gpr[31 ], mem_idx,GETPC ()); +cpu_stq_mmu (env, addr, gpr[31 ], oi, ra); } }
target/mips/tcg/micromips_translate.c.inc +2 -0
@@ -701,6 +701,8 @@ static void gen_ldst_multiple(DisasContext *ctx, uint32_t opc, int reglist, return; } + mop |= mo_endian(ctx); + t0 = tcg_temp_new(); gen_base_offset_addr(ctx, t0, base, offset);
Signature · 1 line
2.53.0
PATCH v5 4/4 target/mips: Check alignment for microMIPS pre-R6 LD/ST multiple
In reply to Philippe Mathieu-DaudéPre-REL6 microMIPS requires alignment while REL6 microMIPS does not. Use @default_tcg_memop_mask in gen_ldst_multiple(), it is set to MO_UNALN for REL6 but MO_ALIGN for pre-REL6.
---
Good enough until making it explicit in a decodetree conversion.
--- target/mips/tcg/micromips_translate.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/micromips_translate.c.inc +1 -1
@@ -693,7 +693,7 @@ static void gen_ldst_multiple(DisasContext *ctx, uint32_t opc, int reglist, int base, int16_t offset) { TCGv t0, t1; - MemOp mop = MO_UNALN; + MemOp mop = ctx->default_tcg_memop_mask; MemOpIdx oi; if (ctx->hflags & MIPS_HFLAG_BMASK) {
Signature · 1 line
2.53.0
Re: [PATCH v5 4/4] target/mips: Check alignment for microMIPS pre-R6 LD/ST multiple
Quoted 4 lines · Philippe Mathieu-Daudé
Pre-REL6 microMIPS requires alignment while REL6 microMIPS does not. Use @default_tcg_memop_mask in
gen_ldst_multiple(), it is set toMO_UNALNfor REL6 butMO_ALIGNfor pre-REL6.
Quoted 8 lines
Fixes 3c824109da0 ("target-mips: microMIPS ASE support")Reported-by Richard Henderson<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>---
Good enough until making it explicit in a decodetree conversion.--- target/mips/tcg/micromips_translate.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
Quoted 5 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (4):
target/mips: Pass MemOpIdx argument to Load/Store Multiple helpers target/mips: Remove unnecessarytarget_ulonguses in LD/ST Multiple target/mips: Inline cpu_ld/st_mmuidx_ra() calls in LD/ST Multiple target/mips: Check alignment for microMIPS pre-R6 LD/ST multiple
Series queued, thanks.