Skip to contentSkip to conversation

target/mips: Introduce disas_mt_available()

PATCH In review Philippe Mathieu-Daudé 2 participants 3 messages Oct 24, 2024 – Oct 25, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/mips: Introduce disas_mt_available()

Similarly to commit 17c2c320f3c ("Introduce ase_mt_available helper"), introduce the disas_mt_available() one which takes a DisasContext argument to determine whether Multi-Threading is available by checking the MT bit of the CP0_Config3 register.

Remove the then unused ASE_MT definition.

---
 target/mips/mips-defs.h     |   1 -
 target/mips/tcg/translate.h |   5 ++
 target/mips/tcg/translate.c | 136 ++++++++++++++++++------------------
 target/mips/cpu-defs.c.inc  |   4 +-
 4 files changed, 75 insertions(+), 71 deletions(-)
target/mips/mips-defs.h +0 -1
index 6b5cd0d8f53..9d4d292586c 100644
@@ -30,7 +30,6 @@
 #define ASE_DSP           0x0000000008000000ULL
 #define ASE_DSP_R2        0x0000000010000000ULL
 #define ASE_DSP_R3        0x0000000020000000ULL
-#define ASE_MT            0x0000000040000000ULL
 #define ASE_SMARTMIPS     0x0000000080000000ULL
 #define ASE_MICROMIPS     0x0000000100000000ULL
 /*
target/mips/tcg/translate.h +5 -0
index 5d196e69ac4..b613726ea42 100644
@@ -228,6 +228,11 @@ bool decode_ext_octeon(DisasContext *ctx, uint32_t insn);
 #endif
 bool decode_ext_vr54xx(DisasContext *ctx, uint32_t insn);
 
+static inline bool disas_mt_available(DisasContext *ctx)
+{
+    return ctx->CP0_Config3 & (1 << CP0C3_MT);
+}
+
 /*
  * Helpers for implementing sets of trans_* functions.
  * Defer the implementation of NAME to FUNC, with optional extra arguments.
target/mips/tcg/translate.c +68 -68

439 lines not on this page · raw message

target/mips/cpu-defs.c.inc +2 -2
index 09bd62d430a..922fc39138d 100644
@@ -314,7 +314,7 @@ const mips_def_t mips_defs[] =
                     (0x3fe << CP0SRSC4_SRS14) | (0x3fe << CP0SRSC4_SRS13),
         .SEGBITS = 32,
         .PABITS = 32,
-        .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_MT,
+        .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP,
         .mmu_type = MMU_TYPE_R4000,
     },
     {
@@ -543,7 +543,7 @@ const mips_def_t mips_defs[] =
         .SEGBITS = 32,
         .PABITS = 32,
         .insn_flags = CPU_MIPS32R6 | ISA_NANOMIPS32 |
-                      ASE_DSP | ASE_DSP_R2 | ASE_DSP_R3 | ASE_MT,
+                      ASE_DSP | ASE_DSP_R2 | ASE_DSP_R3,
         .mmu_type = MMU_TYPE_R4000,
     },
 #if defined(TARGET_MIPS64)
Signature · 1 line
2.45.2
#1 lore raw
Quoted 21 lines · Philippe Mathieu-Daudé

Similarly to commit 17c2c320f3c ("Introduce ase_mt_available helper"), introduce the disas_mt_available() one which takes a DisasContext argument to determine whether Multi-Threading is available by checking the MT bit of the CP0_Config3 register.

Remove the then unused ASE_MT definition.

---
  target/mips/mips-defs.h     |   1 -
  target/mips/tcg/translate.h |   5 ++
  target/mips/tcg/translate.c | 136 ++++++++++++++++++------------------
  target/mips/cpu-defs.c.inc  |   4 +-
  4 files changed, 75 insertions(+), 71 deletions(-)
target/mips/tcg/translate.h +0 -0
index 5d196e69ac4..b613726ea42 100644

target/mips/tcg/translate.h bool decode_ext_octeon(DisasContext *ctx, uint32_t insn); · line 234

Quoted 7 lines
target/mips/tcg/translate.h +4 -0
@@ -228,6 +228,11 @@ bool decode_ext_octeon(DisasContext *ctx, uint32_t insn);
  #endif
  bool decode_ext_vr54xx(DisasContext *ctx, uint32_t insn);
 
+static inline bool disas_mt_available(DisasContext *ctx)
+{
+    return ctx->CP0_Config3 & (1 << CP0C3_MT);
+}

BTW I considered inlining it in translate.c but the MT code will eventually be converted to decodetree so better keep this helper in the translate.h header.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

Similarly to commit 17c2c320f3c ("Introduce ase_mt_available helper"), introduce the disas_mt_available() one which takes a DisasContext argument to determine whether Multi-Threading is available by checking the MT bit of the CP0_Config3 register.

Remove the then unused ASE_MT definition.

Quoted 7 lines
---
  target/mips/mips-defs.h     |   1 -
  target/mips/tcg/translate.h |   5 ++
  target/mips/tcg/translate.c | 136 ++++++++++++++++++------------------
  target/mips/cpu-defs.c.inc  |   4 +-
  4 files changed, 75

r~