On 11/26/24 07:15, Philippe Mathieu-Daudé wrote:
Per 'MIPS® DSP Module for MIPS64™ Architecture, Revision 3.02',
  * 3.10 Additional Register State for the DSP Module
  ~Figure 3.5 MIPS® DSP Module Control Register (DSPControl) Format~

the DSPControl register is 32-bit wide.

Convert it from 'target_ulong' to 'uint32_t'.

Update TCG calls to truncate/extend from i32 to target_ulong.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
  target/mips/cpu.h                        |  2 +-
  target/mips/tcg/sysemu_helper.h.inc      |  4 +--
  target/mips/sysemu/machine.c             |  5 ++-
  target/mips/tcg/dsp_helper.c             | 10 +++---
  target/mips/tcg/sysemu/cp0_helper.c      |  4 +--
  target/mips/tcg/translate.c              | 40 +++++++++++++++++-------
  target/mips/tcg/nanomips_translate.c.inc | 16 +++++++---
  7 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index f80b05885b1..bc636510132 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -472,7 +472,7 @@ struct TCState {
      target_ulong HI[MIPS_DSP_ACC];
      target_ulong LO[MIPS_DSP_ACC];
      target_ulong ACX[MIPS_DSP_ACC];
-    target_ulong DSPControl;
+    uint32_t DSPControl;
      int32_t CP0_TCStatus;
  #define CP0TCSt_TCU3    31
  #define CP0TCSt_TCU2    30
diff --git a/target/mips/tcg/sysemu_helper.h.inc 
b/target/mips/tcg/sysemu_helper.h.inc
index 1861d538de1..36ce21f863b 100644
--- a/target/mips/tcg/sysemu_helper.h.inc
+++ b/target/mips/tcg/sysemu_helper.h.inc
@@ -144,12 +144,12 @@ DEF_HELPER_2(mftgpr, tl, env, i32)
  DEF_HELPER_2(mftlo, tl, env, i32)
  DEF_HELPER_2(mfthi, tl, env, i32)
  DEF_HELPER_2(mftacx, tl, env, i32)
-DEF_HELPER_1(mftdsp, tl, env)
+DEF_HELPER_1(mftdsp, i32, env)
  DEF_HELPER_3(mttgpr, void, env, tl, i32)
  DEF_HELPER_3(mttlo, void, env, tl, i32)
  DEF_HELPER_3(mtthi, void, env, tl, i32)
  DEF_HELPER_3(mttacx, void, env, tl, i32)
-DEF_HELPER_2(mttdsp, void, env, tl)
+DEF_HELPER_2(mttdsp, void, env, i32)
  DEF_HELPER_0(dmt, tl)
  DEF_HELPER_0(emt, tl)
  DEF_HELPER_1(dvpe, tl, env)
diff --git a/target/mips/sysemu/machine.c b/target/mips/sysemu/machine.c
index 823a49e2ca1..c1fb72864f6 100644
--- a/target/mips/sysemu/machine.c
+++ b/target/mips/sysemu/machine.c
@@ -88,7 +88,10 @@ static const VMStateField vmstate_tc_fields[] = {
      VMSTATE_UINTTL_ARRAY(HI, TCState, MIPS_DSP_ACC),
      VMSTATE_UINTTL_ARRAY(LO, TCState, MIPS_DSP_ACC),
      VMSTATE_UINTTL_ARRAY(ACX, TCState, MIPS_DSP_ACC),
-    VMSTATE_UINTTL(DSPControl, TCState),
+    VMSTATE_UINT32(DSPControl, TCState),
+#if defined(TARGET_MIPS64)
+    VMSTATE_UNUSED(4),
+#endif /* TARGET_MIPS64 */
      VMSTATE_INT32(CP0_TCStatus, TCState),
      VMSTATE_INT32(CP0_TCBind, TCState),
      VMSTATE_UINTTL(CP0_TCHalt, TCState),

This would go into the new subsection, and you wouldn't need padding, since we're already incrementing version numbers for migration.

Otherwise,
Reviewed-by: Richard Henderson <[email protected]>


r~

Reply via email to