Skip to contentSkip to conversation

target/mips: Replace cpu_ld/st_mmuidx_ra() calls in LD/ST Multiple

PATCH Superseded Philippe Mathieu-Daudé 2 participants 12 messages Apr 16 – Apr 17

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover target/mips: Replace cpu_ld/st_mmuidx_ra() calls in LD/ST Multiple

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 | 32 ++++++----
 2 files changed, 56 insertions(+), 50 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v4 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
index 4ebf72d610e..7be2cad89d6 100644
@@ -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
index 8fda7c8a214..4dca11b84b4 100644
@@ -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
#3 lore raw

PATCH v4 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 a size (size_t) 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
index 7be2cad89d6..fdc192e9c14 100644
@@ -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;
+    size_t 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;
+    size_t 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;
+    size_t 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;
+    size_t 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
#7 lore raw

PATCH v4 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. Pass the MemOp alignment as argument to gen_ldst_multiple(). Keep using MO_UNALN for REL6 decoder but use MO_ALIGN for the pre-REL6 part.

Fixes 3c824109da0 ("target-mips: microMIPS ASE support")
---
 target/mips/tcg/micromips_translate.c.inc | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
target/mips/tcg/micromips_translate.c.inc +9 -7
index fb107eb91fe..efd9781c53b 100644
@@ -690,10 +690,9 @@ static void gen_andi16(DisasContext *ctx)
 }
 
 static void gen_ldst_multiple(DisasContext *ctx, uint32_t opc, int reglist,
-                              int base, int16_t offset)
+                              int base, int16_t offset, MemOp mop)
 {
     TCGv t0, t1;
-    MemOp mop = MO_UNALN;
     MemOpIdx oi;
 
     if (ctx->hflags & MIPS_HFLAG_BMASK) {
@@ -772,7 +771,7 @@ static void gen_pool16c_insn(DisasContext *ctx)
             int offset = ZIMM(ctx->opcode, 0, 4);
 
             gen_ldst_multiple(ctx, LWM32, lwm_convert[(ctx->opcode >> 4) & 0x3],
-                              29, offset << 2);
+                              29, offset << 2, MO_ALIGN);
         }
         break;
     case SWM16 + 0:
@@ -784,7 +783,7 @@ static void gen_pool16c_insn(DisasContext *ctx)
             int offset = ZIMM(ctx->opcode, 0, 4);
 
             gen_ldst_multiple(ctx, SWM32, swm_convert[(ctx->opcode >> 4) & 0x3],
-                              29, offset << 2);
+                              29, offset << 2, MO_ALIGN);
         }
         break;
     case JR16 + 0:
@@ -887,7 +886,8 @@ static void gen_pool16c_r6_insn(DisasContext *ctx)
         {
             int lwm_converted = 0x11 + extract32(ctx->opcode, 8, 2);
             int offset = extract32(ctx->opcode, 4, 4);
-            gen_ldst_multiple(ctx, LWM32, lwm_converted, 29, offset << 2);
+            gen_ldst_multiple(ctx, LWM32, lwm_converted, 29, offset << 2,
+                              MO_UNALN);
         }
         break;
     case R6_JRC16: /* JRCADDIUSP */
@@ -927,7 +927,8 @@ static void gen_pool16c_r6_insn(DisasContext *ctx)
         {
             int swm_converted = 0x11 + extract32(ctx->opcode, 8, 2);
             int offset = extract32(ctx->opcode, 4, 4);
-            gen_ldst_multiple(ctx, SWM32, swm_converted, 29, offset << 2);
+            gen_ldst_multiple(ctx, SWM32, swm_converted, 29, offset << 2,
+                              MO_UNALN);
         }
         break;
     case JALRC16: /* BREAK16, SDBBP16 */
@@ -1861,7 +1862,8 @@ static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx)
             /* fall through */
         case LWM32:
         case SWM32:
-            gen_ldst_multiple(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12));
+            gen_ldst_multiple(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12),
+                              MO_ALIGN);
             break;
         default:
             MIPS_INVAL("pool32b");
Signature · 1 line
2.53.0
#5 lore raw

PATCH v4 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             | 40 +++++++++++------------
 target/mips/tcg/micromips_translate.c.inc |  2 ++
 2 files changed, 21 insertions(+), 21 deletions(-)
target/mips/tcg/ldst_helper.c +19 -21
index fdc192e9c14..81c0631a119 100644
@@ -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);
     size_t 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);
     size_t base_reglist = reglist & 0xf;
-    bool do_r31 = !!(reglist & 0x10);
+    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);
     size_t base_reglist = reglist & 0xf;
-    bool do_r31 = !!(reglist & 0x10);
+    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);
     size_t base_reglist = reglist & 0xf;
-    bool do_r31 = !!(reglist & 0x10);
+    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
index 4dca11b84b4..fb107eb91fe 100644
@@ -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
Reviewed-by on v4 1/4
#2 lore raw

Re: [PATCH v4 1/4] target/mips: Pass MemOpIdx argument to Load/Store Multiple helpers

In reply to Philippe Mathieu-Daudé
Quoted 8 lines · Philippe Mathieu-Daudé

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(-)

r~

#4 lore raw

Re: [PATCH v4 2/4] target/mips: Remove unnecessary target_ulong uses in LD/ST Multiple

In reply to Philippe Mathieu-Daudé
Quoted 13 lines · Philippe Mathieu-Daudé

@do_r31 is a boolean, @base_reglist a size (size_t) 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 +0 -0
index 7be2cad89d6..fdc192e9c14 100644

target/mips/tcg/ldst_helper.c void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, · line 231

Quoted 6 lines
target/mips/tcg/ldst_helper.c +1 -2
@@ -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;
+    size_t base_reglist = reglist & 0xf;

Why size_t, for what is clearly a 4-bit quantity...

target/mips/tcg/ldst_helper.c void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, · line 235

Quoted 7 lines
target/mips/tcg/ldst_helper.c +2 -3
+    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++) {

... which you later compare with plain 'unsigned'?

Using 'unsigned' everywhere is fine.

target/mips/tcg/ldst_helper.c void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist, · line 254

Quoted 8 lines
target/mips/tcg/ldst_helper.c +2 -2
@@ -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;
+    size_t base_reglist = reglist & 0xf;
+    bool do_r31 = !!(reglist & 0x10);

You don't need the "!!". That's implied in the assignment to bool.

r~

Reviewed-by on v4 3/4
#6 lore raw

Re: [PATCH v4 3/4] target/mips: Inline cpu_ld/st_mmuidx_ra() calls in LD/ST Multiple

In reply to Philippe Mathieu-Daudé
Quoted 9 lines · 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             | 40 +++++++++++------------
  target/mips/tcg/micromips_translate.c.inc |  2 ++
  2 files changed, 21 insertions(+), 21 deletions(-)

r~

Reviewed-by on v4 4/4
#8 lore raw

Re: [PATCH v4 4/4] target/mips: Check alignment for microMIPS pre-R6 LD/ST multiple

In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

Pre-REL6 microMIPS requires alignment while REL6 microMIPS does not. Pass the MemOp alignment as argument to gen_ldst_multiple(). Keep using MO_UNALN for REL6 decoder but use MO_ALIGN for the pre-REL6 part.

Fixes 3c824109da0 ("target-mips: microMIPS ASE support")
---
  target/mips/tcg/micromips_translate.c.inc | 16 +++++++++-------
  1 file changed, 9 insertions(+), 7 deletions(-)

r~

#9 lore raw

Re: [PATCH v4 4/4] target/mips: Check alignment for microMIPS pre-R6 LD/ST multiple

Quoted 6 lines · Richard Henderson
Quoted 5 lines · Philippe Mathieu-Daudé

Pre-REL6 microMIPS requires alignment while REL6 microMIPS does not. Pass the MemOp alignment as argument to gen_ldst_multiple(). Keep using MO_UNALN for REL6 decoder but use MO_ALIGN for the pre-REL6 part.

Quoted 8 lines
Quoted 6 lines
Fixes 3c824109da0 ("target-mips: microMIPS ASE support")

---
  target/mips/tcg/micromips_translate.c.inc | 16 +++++++++-------

  1 file changed, 9 insertions(+), 7 deletions(-)

I'm not sure about our testing coverage here; I think I should use default_tcg_memop_mask in a previous patch, see mips_tr_init_disas_context():

ctx->default_tcg_memop_mask = (!(ctx->insn_flags & ISA_NANOMIPS32) &&

                                  (ctx->insn_flags & (ISA_MIPS_R6 |
                                  INSN_LOONGSON3A))) ? MO_UNALN
                                                     : MO_ALIGN;
#10 lore raw

Re: [PATCH v4 4/4] target/mips: Check alignment for microMIPS pre-R6 LD/ST multiple

Quoted 16 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Richard Henderson
Quoted 5 lines · Philippe Mathieu-Daudé

Pre-REL6 microMIPS requires alignment while REL6 microMIPS does not. Pass the MemOp alignment as argument to gen_ldst_multiple(). Keep using MO_UNALN for REL6 decoder but use MO_ALIGN for the pre-REL6 part.

Quoted 8 lines
Quoted 6 lines
Fixes 3c824109da0 ("target-mips: microMIPS ASE support")

---
  target/mips/tcg/micromips_translate.c.inc | 16 +++++++++-------

  1 file changed, 9 insertions(+), 7 deletions(-)
Quoted 8 lines

I'm not sure about our testing coverage here; I think I should use default_tcg_memop_mask in a previous patch, see mips_tr_init_disas_context():

   ctx->default_tcg_memop_mask = (!(ctx->insn_flags & ISA_NANOMIPS32) && (ctx->insn_flags & (ISA_MIPS_R6 | INSN_LOONGSON3A))) ? MO_UNALN : MO_ALIGN;

That sounds good as well.

r~

#11 lore raw

Re: [PATCH v4 4/4] target/mips: Check alignment for microMIPS pre-R6 LD/ST multiple

In reply to Philippe Mathieu-Daudé
Quoted 16 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Richard Henderson
Quoted 5 lines · Philippe Mathieu-Daudé

Pre-REL6 microMIPS requires alignment while REL6 microMIPS does not. Pass the MemOp alignment as argument to gen_ldst_multiple(). Keep using MO_UNALN for REL6 decoder but use MO_ALIGN for the pre-REL6 part.

Quoted 8 lines
Quoted 6 lines
Fixes 3c824109da0 ("target-mips: microMIPS ASE support")

---
  target/mips/tcg/micromips_translate.c.inc | 16 +++++++++-------

  1 file changed, 9 insertions(+), 7 deletions(-)
Quoted 8 lines

I'm not sure about our testing coverage here; I think I should use default_tcg_memop_mask in a previous patch, see mips_tr_init_disas_context():

   ctx->default_tcg_memop_mask = (!(ctx->insn_flags & ISA_NANOMIPS32) && (ctx->insn_flags & (ISA_MIPS_R6 | INSN_LOONGSON3A))) ? MO_UNALN : MO_ALIGN;

This comes from commit be3a8c53b4f ("target-mips: Misaligned memory accesses for R6").

Thinking about it, 'default_tcg_memop_mask' might be a misleading name.

'[default_]mo_align' is clearly more explicit. Or maybe even better would be to make it explicit in the relevant call paths?