Skip to contentSkip to conversation

target/mips/mips-defs: Simplify ISA definitions

PATCH Superseded Philippe Mathieu-Daudé 2 participants 20 messages Dec 16, 2020

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover target/mips/mips-defs: Simplify ISA definitions

As we don't need to duplicate 32/64-bit ISA defititions, this series remove the duplicated 64-bit variants, simplifying the overall.

Changes done automatically with my editor using "find and replace".

While the 'ISA_MIPS_Rx' form is shorter than 'ISA_MIPS_RELx', which one is the clearer?

Regards,

Phil.

Philippe Mathieu-Daudé (11):
target/mips/mips-defs: Reorder CPU_MIPS5 definition target/mips/mips-defs: Use ISA_MIPS3 for ISA_MIPS64 target/mips/mips-defs: Use ISA_MIPS32R2 definition to check Release 2 target/mips/mips-defs: Use ISA_MIPS32R3 definition to check Release 3 target/mips/mips-defs: Use ISA_MIPS32R5 definition to check Release 5 target/mips/mips-defs: Use ISA_MIPS32R6 definition to check Release 6 target/mips/mips-defs: Rename ISA_MIPS32 as ISA_MIPS_R1 target/mips/mips-defs: Rename ISA_MIPS32R2 as ISA_MIPS_R2 target/mips/mips-defs: Rename ISA_MIPS32R3 as ISA_MIPS_R3 target/mips/mips-defs: Rename ISA_MIPS32R5 as ISA_MIPS_R5 target/mips/mips-defs: Rename ISA_MIPS32R6 as ISA_MIPS_R6

 target/mips/internal.h     |   8 +-
 target/mips/mips-defs.h    |  40 +--
 hw/mips/boston.c           |   2 +-
 linux-user/elfload.c       |   2 +-
 linux-user/mips/cpu_loop.c |   6 +-
 target/mips/cp0_helper.c   |  18 +-
 target/mips/cp0_timer.c    |   4 +-
 target/mips/cpu.c          |  12 +-
 target/mips/fpu_helper.c   |   4 +-
 target/mips/tlb_helper.c   |   6 +-
 target/mips/translate.c    | 620 ++++++++++++++++++-------------------
 11 files changed, 357 insertions(+), 365 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/11 target/mips/mips-defs: Reorder CPU_MIPS5 definition

Move CPU_MIPS5 after CPU_MIPS4 :)

---
 target/mips/mips-defs.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
target/mips/mips-defs.h +1 -2
index 805034b8956..f4d76e562d1 100644
@@ -70,13 +70,12 @@
 #define CPU_MIPS2       (CPU_MIPS1 | ISA_MIPS2)
 #define CPU_MIPS3       (CPU_MIPS2 | ISA_MIPS3)
 #define CPU_MIPS4       (CPU_MIPS3 | ISA_MIPS4)
+#define CPU_MIPS5       (CPU_MIPS4 | ISA_MIPS5)
 #define CPU_VR54XX      (CPU_MIPS4 | INSN_VR54XX)
 #define CPU_R5900       (CPU_MIPS3 | INSN_R5900)
 #define CPU_LOONGSON2E  (CPU_MIPS3 | INSN_LOONGSON2E)
 #define CPU_LOONGSON2F  (CPU_MIPS3 | INSN_LOONGSON2F | ASE_LMMI)
 
-#define CPU_MIPS5       (CPU_MIPS4 | ISA_MIPS5)
-
 /* MIPS Technologies "Release 1" */
 #define CPU_MIPS32      (CPU_MIPS2 | ISA_MIPS32)
 #define CPU_MIPS64      (CPU_MIPS5 | CPU_MIPS32 | ISA_MIPS64)
Signature · 1 line
2.26.2
#3 lore raw

PATCH 2/11 target/mips/mips-defs: Use ISA_MIPS3 for ISA_MIPS64

In reply to Philippe Mathieu-Daudé

MIPS 64-bit ISA is introduced with MIPS3.
No need for another bit/definition to check for 64-bit.

Simplify CPU_MIPS64 definition as CPU_MIPS5 contains CPU_MIPS4 which contains CPU_MIPS3 which contains ISA_MIPS3.

---
 target/mips/mips-defs.h |  5 ++---
 hw/mips/boston.c        |  2 +-
 target/mips/translate.c | 10 +++++-----
 3 files changed, 8 insertions(+), 9 deletions(-)
target/mips/mips-defs.h +2 -3
index f4d76e562d1..2756e72a9d6 100644
@@ -19,12 +19,11 @@
  */
 #define ISA_MIPS1         0x0000000000000001ULL
 #define ISA_MIPS2         0x0000000000000002ULL
-#define ISA_MIPS3         0x0000000000000004ULL
+#define ISA_MIPS3         0x0000000000000004ULL /* 64-bit */
 #define ISA_MIPS4         0x0000000000000008ULL
 #define ISA_MIPS5         0x0000000000000010ULL
 #define ISA_MIPS32        0x0000000000000020ULL
 #define ISA_MIPS32R2      0x0000000000000040ULL
-#define ISA_MIPS64        0x0000000000000080ULL
 #define ISA_MIPS64R2      0x0000000000000100ULL
 #define ISA_MIPS32R3      0x0000000000000200ULL
 #define ISA_MIPS64R3      0x0000000000000400ULL
@@ -78,7 +77,7 @@
 
 /* MIPS Technologies "Release 1" */
 #define CPU_MIPS32      (CPU_MIPS2 | ISA_MIPS32)
-#define CPU_MIPS64      (CPU_MIPS5 | CPU_MIPS32 | ISA_MIPS64)
+#define CPU_MIPS64      (CPU_MIPS5 | CPU_MIPS32)
 
 /* MIPS Technologies "Release 2" */
 #define CPU_MIPS32R2    (CPU_MIPS32 | ISA_MIPS32R2)
hw/mips/boston.c +1 -1
index c3b94c68e1b..f44f681fab5 100644
@@ -463,7 +463,7 @@ static void boston_mach_init(MachineState *machine)
         exit(1);
     }
 
-    is_64b = cpu_type_supports_isa(machine->cpu_type, ISA_MIPS64);
+    is_64b = cpu_type_supports_isa(machine->cpu_type, ISA_MIPS3);
 
     object_initialize_child(OBJECT(machine), "cps", &s->cps, TYPE_MIPS_CPS);
     object_property_set_str(OBJECT(&s->cps), "cpu-type", machine->cpu_type,
target/mips/translate.c +5 -5
index 15265485f76..8c0ecfa17e1 100644
@@ -8538,7 +8538,7 @@ static void gen_dmfc0(DisasContext *ctx, TCGv arg, int reg, int sel)
     const char *register_name = "invalid";
 
     if (sel != 0) {
-        check_insn(ctx, ISA_MIPS64);
+        check_insn(ctx, ISA_MIPS3);
     }
 
     switch (reg) {
@@ -9264,7 +9264,7 @@ static void gen_dmtc0(DisasContext *ctx, TCGv arg, int reg, int sel)
     const char *register_name = "invalid";
 
     if (sel != 0) {
-        check_insn(ctx, ISA_MIPS64);
+        check_insn(ctx, ISA_MIPS3);
     }
 
     if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
@@ -14502,12 +14502,12 @@ static int decode_mips16_opc(CPUMIPSState *env, DisasContext *ctx)
                 break;
 #if defined(TARGET_MIPS64)
             case RR_RY_CNVT_ZEW:
-                check_insn(ctx, ISA_MIPS64);
+                check_insn(ctx, ISA_MIPS3);
                 check_mips_64(ctx);
                 tcg_gen_ext32u_tl(cpu_gpr[rx], cpu_gpr[rx]);
                 break;
             case RR_RY_CNVT_SEW:
-                check_insn(ctx, ISA_MIPS64);
+                check_insn(ctx, ISA_MIPS3);
                 check_mips_64(ctx);
                 tcg_gen_ext32s_tl(cpu_gpr[rx], cpu_gpr[rx]);
                 break;
@@ -27203,7 +27203,7 @@ static void decode_opc_special2_legacy(CPUMIPSState *env, DisasContext *ctx)
 #if defined(TARGET_MIPS64)
     case OPC_DCLO:
     case OPC_DCLZ:
-        check_insn(ctx, ISA_MIPS64);
+        check_insn(ctx, ISA_MIPS3);
         check_mips_64(ctx);
         gen_cl(ctx, op1, rd, rs);
         break;
Signature · 1 line
2.26.2
Reviewed-by on v1 2/11
#4 lore raw

Re: [PATCH 02/11] target/mips/mips-defs: Use ISA_MIPS3 for ISA_MIPS64

Quoted 8 lines · Philippe Mathieu-Daudé

MIPS 64-bit ISA is introduced with MIPS3.
No need for another bit/definition to check for 64-bit.

Simplify CPU_MIPS64 definition as CPU_MIPS5 contains CPU_MIPS4 which contains CPU_MIPS3 which contains ISA_MIPS3.

Quoted 5 lines
---
  target/mips/mips-defs.h |  5 ++---
  hw/mips/boston.c        |  2 +-
  target/mips/translate.c | 10 +++++-----
  3 files changed, 8 insertions(+), 9 deletions(-)

- Jiaxun

#5 lore raw

Re: [PATCH 02/11] target/mips/mips-defs: Use ISA_MIPS3 for ISA_MIPS64

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

MIPS 64-bit ISA is introduced with MIPS3.
No need for another bit/definition to check for 64-bit.

Simplify CPU_MIPS64 definition as CPU_MIPS5 contains CPU_MIPS4 which contains CPU_MIPS3 which contains ISA_MIPS3.

Oops, I shall amend my reviewed by tag, just found a issue.

Quoted 54 lines
---
  target/mips/mips-defs.h |  5 ++---
  hw/mips/boston.c        |  2 +-
  target/mips/translate.c | 10 +++++-----
  3 files changed, 8 insertions(+), 9 deletions(-)
target/mips/mips-defs.h +2 -3
index f4d76e562d1..2756e72a9d6 100644
@@ -19,12 +19,11 @@
   */
  #define ISA_MIPS1         0x0000000000000001ULL
  #define ISA_MIPS2         0x0000000000000002ULL
-#define ISA_MIPS3         0x0000000000000004ULL
+#define ISA_MIPS3         0x0000000000000004ULL /* 64-bit */
  #define ISA_MIPS4         0x0000000000000008ULL
  #define ISA_MIPS5         0x0000000000000010ULL
  #define ISA_MIPS32        0x0000000000000020ULL
  #define ISA_MIPS32R2      0x0000000000000040ULL
-#define ISA_MIPS64        0x0000000000000080ULL
  #define ISA_MIPS64R2      0x0000000000000100ULL
  #define ISA_MIPS32R3      0x0000000000000200ULL
  #define ISA_MIPS64R3      0x0000000000000400ULL
@@ -78,7 +77,7 @@
 
  /* MIPS Technologies "Release 1" */
  #define CPU_MIPS32      (CPU_MIPS2 | ISA_MIPS32)
-#define CPU_MIPS64      (CPU_MIPS5 | CPU_MIPS32 | ISA_MIPS64)
+#define CPU_MIPS64      (CPU_MIPS5 | CPU_MIPS32)
 
  /* MIPS Technologies "Release 2" */
  #define CPU_MIPS32R2    (CPU_MIPS32 | ISA_MIPS32R2)
hw/mips/boston.c +1 -1
index c3b94c68e1b..f44f681fab5 100644
@@ -463,7 +463,7 @@ static void boston_mach_init(MachineState *machine)
          exit(1);
      }
 
-    is_64b = cpu_type_supports_isa(machine->cpu_type, ISA_MIPS64);
+    is_64b = cpu_type_supports_isa(machine->cpu_type, ISA_MIPS3);
 
      object_initialize_child(OBJECT(machine), "cps", &s->cps, TYPE_MIPS_CPS);
      object_property_set_str(OBJECT(&s->cps), "cpu-type", machine->cpu_type,
target/mips/translate.c +0 -0
index 15265485f76..8c0ecfa17e1 100644

target/mips/translate.c static void gen_dmfc0(DisasContext *ctx, TCGv arg, int reg, int sel) · line 8542

Quoted 6 lines
target/mips/translate.c +1 -1
@@ -8538,7 +8538,7 @@ static void gen_dmfc0(DisasContext *ctx, TCGv arg, int reg, int sel)
      const char *register_name = "invalid";
 
      if (sel != 0) {
-        check_insn(ctx, ISA_MIPS64);
+        check_insn(ctx, ISA_MIPS3);
      }

I think these ISA_MIPS64 should mean ISA_MIPS_R1?

target/mips/translate.c static void gen_dmtc0(DisasContext *ctx, TCGv arg, int reg, int sel) · line 9267

Quoted 8 lines
target/mips/translate.c +1 -1
      switch (reg) {
@@ -9264,7 +9264,7 @@ static void gen_dmtc0(DisasContext *ctx, TCGv arg, int reg, int sel)
      const char *register_name = "invalid";
 
      if (sel != 0) {
-        check_insn(ctx, ISA_MIPS64);
+        check_insn(ctx, ISA_MIPS3);

and so

target/mips/translate.c static int decode_mips16_opc(CPUMIPSState *env, DisasContext *ctx) · line 14505

Quoted 9 lines
target/mips/translate.c +1 -1
      }
 
      if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
@@ -14502,12 +14502,12 @@ static int decode_mips16_opc(CPUMIPSState *env, DisasContext *ctx)
                  break;
  #if defined(TARGET_MIPS64)
              case RR_RY_CNVT_ZEW:
-                check_insn(ctx, ISA_MIPS64);
+                check_insn(ctx, ISA_MIPS3);

and so

target/mips/translate.c static int decode_mips16_opc(CPUMIPSState *env, DisasContext *ctx) · line 14510

Quoted 6 lines
target/mips/translate.c +1 -1
                  check_mips_64(ctx);
                  tcg_gen_ext32u_tl(cpu_gpr[rx], cpu_gpr[rx]);
                  break;
              case RR_RY_CNVT_SEW:
-                check_insn(ctx, ISA_MIPS64);
+                check_insn(ctx, ISA_MIPS3);

and so....

target/mips/translate.c static void decode_opc_special2_legacy(CPUMIPSState *env, DisasContext *ctx) · line 27206

Quoted 9 lines
target/mips/translate.c +1 -1
                  check_mips_64(ctx);
                  tcg_gen_ext32s_tl(cpu_gpr[rx], cpu_gpr[rx]);
                  break;
@@ -27203,7 +27203,7 @@ static void decode_opc_special2_legacy(CPUMIPSState *env, DisasContext *ctx)
  #if defined(TARGET_MIPS64)
      case OPC_DCLO:
      case OPC_DCLZ:
-        check_insn(ctx, ISA_MIPS64);
+        check_insn(ctx, ISA_MIPS3);

and so...

Quoted 3 lines
target/mips/translate.c +0 -0
          check_mips_64(ctx);
          gen_cl(ctx, op1, rd, rs);
          break;
#6 lore raw

Re: [PATCH 02/11] target/mips/mips-defs: Use ISA_MIPS3 for ISA_MIPS64

Quoted 61 lines · Jiaxun Yang
Quoted 5 lines · Philippe Mathieu-Daudé

MIPS 64-bit ISA is introduced with MIPS3.
No need for another bit/definition to check for 64-bit.

Simplify CPU_MIPS64 definition as CPU_MIPS5 contains CPU_MIPS4 which contains CPU_MIPS3 which contains ISA_MIPS3.

Oops, I shall amend my reviewed by tag, just found a issue.

Quoted 52 lines

---
  target/mips/mips-defs.h |  5 ++--- hw/mips/boston.c        |  2 +- target/mips/translate.c | 10 +++++-----

  3 files changed, 8 insertions(+), 9 deletions(-)
target/mips/mips-defs.h +2 -3
index f4d76e562d1..2756e72a9d6 100644
@@ -19,12 +19,11 @@
    */
   #define ISA_MIPS1         0x0000000000000001ULL
   #define ISA_MIPS2         0x0000000000000002ULL
-#define ISA_MIPS3         0x0000000000000004ULL
+#define ISA_MIPS3         0x0000000000000004ULL /* 64-bit */
   #define ISA_MIPS4         0x0000000000000008ULL
   #define ISA_MIPS5         0x0000000000000010ULL
   #define ISA_MIPS32        0x0000000000000020ULL
   #define ISA_MIPS32R2      0x0000000000000040ULL
-#define ISA_MIPS64        0x0000000000000080ULL
   #define ISA_MIPS64R2      0x0000000000000100ULL
   #define ISA_MIPS32R3      0x0000000000000200ULL
   #define ISA_MIPS64R3      0x0000000000000400ULL
@@ -78,7 +77,7 @@
     /* MIPS Technologies "Release 1" */
   #define CPU_MIPS32      (CPU_MIPS2 | ISA_MIPS32)
-#define CPU_MIPS64      (CPU_MIPS5 | CPU_MIPS32 | ISA_MIPS64)
+#define CPU_MIPS64      (CPU_MIPS5 | CPU_MIPS32)
     /* MIPS Technologies "Release 2" */
   #define CPU_MIPS32R2    (CPU_MIPS32 | ISA_MIPS32R2)
hw/mips/boston.c +1 -0
index c3b94c68e1b..f44f681fab5 100644
@@ -463,7 +463,7 @@ static void boston_mach_init(MachineState *machine)
           exit(1);
       }
   -    is_64b = cpu_type_supports_isa(machine->cpu_type, ISA_MIPS64);
+    is_64b = cpu_type_supports_isa(machine->cpu_type, ISA_MIPS3);
         object_initialize_child(OBJECT(machine), "cps", &s->cps,
 TYPE_MIPS_CPS);
       object_property_set_str(OBJECT(&s->cps), "cpu-type",

machine->cpu_type,

target/mips/translate.c +0 -0
index 15265485f76..8c0ecfa17e1 100644
@@ -8538,7 +8538,7 @@ static void gen_dmfc0(DisasContext *ctx, TCGv
Quoted 8 lines

target/mips/translate.c static void gen_dmfc0(DisasContext *ctx, TCGv arg, int reg, int sel) · line 8542

Quoted 6 lines
target/mips/translate.c +1 -1
 arg, int reg, int sel)
       const char *register_name = "invalid";
         if (sel != 0) {
-        check_insn(ctx, ISA_MIPS64);
+        check_insn(ctx, ISA_MIPS3);
       }

I think these ISA_MIPS64 should mean ISA_MIPS_R1?

Good catch, thanks.

#7 lore raw

PATCH 3/11 target/mips/mips-defs: Use ISA_MIPS32R2 definition to check Release 2

In reply to Philippe Mathieu-Daudé

Use the single ISA_MIPS32R2 definition to check if the Release 2 ISA is supported, whether the CPU support 32/64-bit.

For now we keep '32' in the definition name, we will rename it as ISA_MIPS_R2 in few commits.

---
 target/mips/mips-defs.h    | 3 +--
 linux-user/mips/cpu_loop.c | 1 -
 target/mips/translate.c    | 4 ++--
 3 files changed, 3 insertions(+), 5 deletions(-)
target/mips/mips-defs.h +1 -2
index 2756e72a9d6..9cfa4c346bf 100644
@@ -24,7 +24,6 @@
 #define ISA_MIPS5         0x0000000000000010ULL
 #define ISA_MIPS32        0x0000000000000020ULL
 #define ISA_MIPS32R2      0x0000000000000040ULL
-#define ISA_MIPS64R2      0x0000000000000100ULL
 #define ISA_MIPS32R3      0x0000000000000200ULL
 #define ISA_MIPS64R3      0x0000000000000400ULL
 #define ISA_MIPS32R5      0x0000000000000800ULL
@@ -81,7 +80,7 @@
 
 /* MIPS Technologies "Release 2" */
 #define CPU_MIPS32R2    (CPU_MIPS32 | ISA_MIPS32R2)
-#define CPU_MIPS64R2    (CPU_MIPS64 | CPU_MIPS32R2 | ISA_MIPS64R2)
+#define CPU_MIPS64R2    (CPU_MIPS64 | ISA_MIPS32R2)
 
 /* MIPS Technologies "Release 3" */
 #define CPU_MIPS32R3    (CPU_MIPS32R2 | ISA_MIPS32R3)
linux-user/mips/cpu_loop.c +0 -1
index b58dbeb83d1..a2aa8167210 100644
@@ -386,7 +386,6 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
     prog_req.fre &= interp_req.fre;
 
     bool cpu_has_mips_r2_r6 = env->insn_flags & ISA_MIPS32R2 ||
-                              env->insn_flags & ISA_MIPS64R2 ||
                               env->insn_flags & ISA_MIPS32R6 ||
                               env->insn_flags & ISA_MIPS64R6;
 
target/mips/translate.c +2 -2
index 8c0ecfa17e1..0923dfdf451 100644
@@ -28212,7 +28212,7 @@ static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx)
     case OPC_DINSM:
     case OPC_DINSU:
     case OPC_DINS:
-        check_insn(ctx, ISA_MIPS64R2);
+        check_insn(ctx, ISA_MIPS32R2);
         check_mips_64(ctx);
         gen_bitops(ctx, op1, rt, rs, sa, rd);
         break;
@@ -28232,7 +28232,7 @@ static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx)
             decode_opc_special3_r6(env, ctx);
             break;
         default:
-            check_insn(ctx, ISA_MIPS64R2);
+            check_insn(ctx, ISA_MIPS32R2);
             check_mips_64(ctx);
             op2 = MASK_DBSHFL(ctx->opcode);
             gen_bshfl(ctx, op2, rt, rd);
Signature · 1 line
2.26.2
#8 lore raw

Re: [PATCH 03/11] target/mips/mips-defs: Use ISA_MIPS32R2 definition to check Release 2

Quoted 51 lines · Philippe Mathieu-Daudé

Use the single ISA_MIPS32R2 definition to check if the Release 2 ISA is supported, whether the CPU support 32/64-bit.

For now we keep '32' in the definition name, we will rename it as ISA_MIPS_R2 in few commits.

---
  target/mips/mips-defs.h    | 3 +--
  linux-user/mips/cpu_loop.c | 1 -
  target/mips/translate.c    | 4 ++--
  3 files changed, 3 insertions(+), 5 deletions(-)
target/mips/mips-defs.h +1 -2
index 2756e72a9d6..9cfa4c346bf 100644
@@ -24,7 +24,6 @@
  #define ISA_MIPS5         0x0000000000000010ULL
  #define ISA_MIPS32        0x0000000000000020ULL
  #define ISA_MIPS32R2      0x0000000000000040ULL
-#define ISA_MIPS64R2      0x0000000000000100ULL
  #define ISA_MIPS32R3      0x0000000000000200ULL
  #define ISA_MIPS64R3      0x0000000000000400ULL
  #define ISA_MIPS32R5      0x0000000000000800ULL
@@ -81,7 +80,7 @@
 
  /* MIPS Technologies "Release 2" */
  #define CPU_MIPS32R2    (CPU_MIPS32 | ISA_MIPS32R2)
-#define CPU_MIPS64R2    (CPU_MIPS64 | CPU_MIPS32R2 | ISA_MIPS64R2)
+#define CPU_MIPS64R2    (CPU_MIPS64 | ISA_MIPS32R2)
 
  /* MIPS Technologies "Release 3" */
  #define CPU_MIPS32R3    (CPU_MIPS32R2 | ISA_MIPS32R3)
linux-user/mips/cpu_loop.c +0 -1
index b58dbeb83d1..a2aa8167210 100644
@@ -386,7 +386,6 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
      prog_req.fre &= interp_req.fre;
 
      bool cpu_has_mips_r2_r6 = env->insn_flags & ISA_MIPS32R2 ||
-                              env->insn_flags & ISA_MIPS64R2 ||
                                env->insn_flags & ISA_MIPS32R6 ||
                                env->insn_flags & ISA_MIPS64R6;
 
target/mips/translate.c +0 -0
index 8c0ecfa17e1..0923dfdf451 100644

target/mips/translate.c static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx) · line 28216

Quoted 6 lines
target/mips/translate.c +1 -1
@@ -28212,7 +28212,7 @@ static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx)
      case OPC_DINSM:
      case OPC_DINSU:
      case OPC_DINS:
-        check_insn(ctx, ISA_MIPS64R2);
+        check_insn(ctx, ISA_MIPS32R2);
          check_mips_64(ctx);

After this change, 32-bit CPUs emulated with TARGET_MIPS64 and got CP0.Status.KX and CP0.Status.UX accidentally set won't emit RI exception.

Probably we need to check ISA_MIPS64 when calculating MIPS_HFLAG_64 and setting ksux in cpu_mips_store_status?

Thanks.

- Jiaxun

Quoted 11 lines
target/mips/translate.c +1 -1
          gen_bitops(ctx, op1, rt, rs, sa, rd);
          break;
@@ -28232,7 +28232,7 @@ static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx)
              decode_opc_special3_r6(env, ctx);
              break;
          default:
-            check_insn(ctx, ISA_MIPS64R2);
+            check_insn(ctx, ISA_MIPS32R2);
              check_mips_64(ctx);
              op2 = MASK_DBSHFL(ctx->opcode);
              gen_bshfl(ctx, op2, rt, rd);
#9 lore raw

Re: [PATCH 03/11] target/mips/mips-defs: Use ISA_MIPS32R2 definition to check Release 2

Quoted 48 lines · Jiaxun Yang
Quoted 47 lines · Philippe Mathieu-Daudé

Use the single ISA_MIPS32R2 definition to check if the Release 2 ISA is supported, whether the CPU support 32/64-bit.

For now we keep '32' in the definition name, we will rename it as ISA_MIPS_R2 in few commits.

---
  target/mips/mips-defs.h    | 3 +--
  linux-user/mips/cpu_loop.c | 1 -
  target/mips/translate.c    | 4 ++--

  3 files changed, 3 insertions(+), 5 deletions(-)
target/mips/mips-defs.h +1 -2
index 2756e72a9d6..9cfa4c346bf 100644
@@ -24,7 +24,6 @@
   #define ISA_MIPS5         0x0000000000000010ULL
   #define ISA_MIPS32        0x0000000000000020ULL
   #define ISA_MIPS32R2      0x0000000000000040ULL
-#define ISA_MIPS64R2      0x0000000000000100ULL
   #define ISA_MIPS32R3      0x0000000000000200ULL
   #define ISA_MIPS64R3      0x0000000000000400ULL
   #define ISA_MIPS32R5      0x0000000000000800ULL
@@ -81,7 +80,7 @@
     /* MIPS Technologies "Release 2" */
   #define CPU_MIPS32R2    (CPU_MIPS32 | ISA_MIPS32R2)
-#define CPU_MIPS64R2    (CPU_MIPS64 | CPU_MIPS32R2 | ISA_MIPS64R2)
+#define CPU_MIPS64R2    (CPU_MIPS64 | ISA_MIPS32R2)
     /* MIPS Technologies "Release 3" */
   #define CPU_MIPS32R3    (CPU_MIPS32R2 | ISA_MIPS32R3)
linux-user/mips/cpu_loop.c +0 -0
index b58dbeb83d1..a2aa8167210 100644
@@ -386,7 +386,6 @@ void target_cpu_copy_regs(CPUArchState *env,
 struct target_pt_regs *regs)
       prog_req.fre &= interp_req.fre;

        bool cpu_has_mips_r2_r6 = env->insn_flags & ISA_MIPS32R2 || -                              env->insn_flags & ISA_MIPS64R2 || env->insn_flags & ISA_MIPS32R6 || env->insn_flags & ISA_MIPS64R6; diff --git a/target/mips/translate.c b/target/mips/translate.c index 8c0ecfa17e1..0923dfdf451 100644

target/mips/translate.c +0 -0
Quoted 9 lines
Quoted 8 lines
target/mips/translate.c +0 -0
@@ -28212,7 +28212,7 @@ static void decode_opc_special3(CPUMIPSState
 *env, DisasContext *ctx)

      case OPC_DINSM:
      case OPC_DINSU:
      case OPC_DINS:
-        check_insn(ctx, ISA_MIPS64R2);
+        check_insn(ctx, ISA_MIPS32R2);
          check_mips_64(ctx);

Sorry I respin v2 before noticing this reply.

Quoted 3 lines

After this change, 32-bit CPUs emulated with TARGET_MIPS64 and got CP0.Status.KX and CP0.Status.UX accidentally set won't emit RI exception.

32-bit CPUs shouldn't have MIPS_HFLAG_64 set, regardless the build used. So check_mips_64() will emit it...

Anyhow, I'd rather remove 32-bit CPUs from 64-bit build unless we are sure this works.

Quoted 21 lines

Probably we need to check ISA_MIPS64 when calculating MIPS_HFLAG_64 and setting ksux in cpu_mips_store_status?

Thanks.

- Jiaxun

Quoted 12 lines

          gen_bitops(ctx, op1, rt, rs, sa, rd);
          break;

target/mips/translate.c +0 -0
@@ -28232,7 +28232,7 @@ static void decode_opc_special3(CPUMIPSState
 *env, DisasContext *ctx)
               decode_opc_special3_r6(env, ctx);
               break;

          default:
-            check_insn(ctx, ISA_MIPS64R2);
+            check_insn(ctx, ISA_MIPS32R2);
              check_mips_64(ctx);
              op2 = MASK_DBSHFL(ctx->opcode);
              gen_bshfl(ctx, op2, rt, rd);

#10 lore raw

Re: [PATCH 03/11] target/mips/mips-defs: Use ISA_MIPS32R2 definition to check Release 2

Quoted 65 lines · Philippe Mathieu-Daudé
Quoted 48 lines · Jiaxun Yang
Quoted 47 lines · Philippe Mathieu-Daudé

Use the single ISA_MIPS32R2 definition to check if the Release 2 ISA is supported, whether the CPU support 32/64-bit.

For now we keep '32' in the definition name, we will rename it as ISA_MIPS_R2 in few commits.

---
  target/mips/mips-defs.h    | 3 +--
  linux-user/mips/cpu_loop.c | 1 -
  target/mips/translate.c    | 4 ++--

  3 files changed, 3 insertions(+), 5 deletions(-)
target/mips/mips-defs.h +1 -2
index 2756e72a9d6..9cfa4c346bf 100644
@@ -24,7 +24,6 @@
   #define ISA_MIPS5         0x0000000000000010ULL
   #define ISA_MIPS32        0x0000000000000020ULL
   #define ISA_MIPS32R2      0x0000000000000040ULL
-#define ISA_MIPS64R2      0x0000000000000100ULL
   #define ISA_MIPS32R3      0x0000000000000200ULL
   #define ISA_MIPS64R3      0x0000000000000400ULL
   #define ISA_MIPS32R5      0x0000000000000800ULL
@@ -81,7 +80,7 @@
     /* MIPS Technologies "Release 2" */
   #define CPU_MIPS32R2    (CPU_MIPS32 | ISA_MIPS32R2)
-#define CPU_MIPS64R2    (CPU_MIPS64 | CPU_MIPS32R2 | ISA_MIPS64R2)
+#define CPU_MIPS64R2    (CPU_MIPS64 | ISA_MIPS32R2)
     /* MIPS Technologies "Release 3" */
   #define CPU_MIPS32R3    (CPU_MIPS32R2 | ISA_MIPS32R3)
linux-user/mips/cpu_loop.c +0 -0
index b58dbeb83d1..a2aa8167210 100644
@@ -386,7 +386,6 @@ void target_cpu_copy_regs(CPUArchState *env,
 struct target_pt_regs *regs)
       prog_req.fre &= interp_req.fre;

        bool cpu_has_mips_r2_r6 = env->insn_flags & ISA_MIPS32R2 || -                              env->insn_flags & ISA_MIPS64R2 || env->insn_flags & ISA_MIPS32R6 || env->insn_flags & ISA_MIPS64R6; diff --git a/target/mips/translate.c b/target/mips/translate.c index 8c0ecfa17e1..0923dfdf451 100644

target/mips/translate.c +0 -0
Quoted 9 lines
Quoted 8 lines
target/mips/translate.c +0 -0
@@ -28212,7 +28212,7 @@ static void decode_opc_special3(CPUMIPSState
 *env, DisasContext *ctx)

      case OPC_DINSM:
      case OPC_DINSU:
      case OPC_DINS:
-        check_insn(ctx, ISA_MIPS64R2);
+        check_insn(ctx, ISA_MIPS32R2);
          check_mips_64(ctx);

Sorry I respin v2 before noticing this reply.

Quoted 3 lines

After this change, 32-bit CPUs emulated with TARGET_MIPS64 and got CP0.Status.KX and CP0.Status.UX accidentally set won't emit RI exception.

Quoted 5 lines

32-bit CPUs shouldn't have MIPS_HFLAG_64 set, regardless the build used. So check_mips_64() will emit it...

Anyhow, I'd rather remove 32-bit CPUs from 64-bit build unless we are sure this works.

$ qemu-system-mips64el -M malta -S -monitor stdio \
    -bios /dev/null -smp 2 -cpu 4Kc
QEMU 5.2.50 monitor - type 'help' for more information
(qemu) info qom-tree
/machine (malta-machine)
  /peripheral (container)
  /peripheral-anon (container)
  /unattached (container)
    /bios.1fc[0] (qemu:memory-region)
    /device[0] (mips-malta)
      /cpu-refclk (clock)
      /cpu[0] (4Kc-mips64-cpu)
        /clk-in (clock)
      /cpu[1] (4Kc-mips64-cpu)
        /clk-in (clock)

"4Kc-mips64"???

#11 lore raw

PATCH 4/11 target/mips/mips-defs: Use ISA_MIPS32R3 definition to check Release 3

In reply to Philippe Mathieu-Daudé

Use the single ISA_MIPS32R3 definition to check if the Release 3 ISA is supported, whether the CPU support 32/64-bit.

For now we keep '32' in the definition name, we will rename it as ISA_MIPS_R3 in few commits.

---
 target/mips/mips-defs.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
target/mips/mips-defs.h +1 -2
index 9cfa4c346bf..0d906ca64b3 100644
@@ -25,7 +25,6 @@
 #define ISA_MIPS32        0x0000000000000020ULL
 #define ISA_MIPS32R2      0x0000000000000040ULL
 #define ISA_MIPS32R3      0x0000000000000200ULL
-#define ISA_MIPS64R3      0x0000000000000400ULL
 #define ISA_MIPS32R5      0x0000000000000800ULL
 #define ISA_MIPS64R5      0x0000000000001000ULL
 #define ISA_MIPS32R6      0x0000000000002000ULL
@@ -84,7 +83,7 @@
 
 /* MIPS Technologies "Release 3" */
 #define CPU_MIPS32R3    (CPU_MIPS32R2 | ISA_MIPS32R3)
-#define CPU_MIPS64R3    (CPU_MIPS64R2 | CPU_MIPS32R3 | ISA_MIPS64R3)
+#define CPU_MIPS64R3    (CPU_MIPS64R2 | CPU_MIPS32R3)
 
 /* MIPS Technologies "Release 5" */
 #define CPU_MIPS32R5    (CPU_MIPS32R3 | ISA_MIPS32R5)
Signature · 1 line
2.26.2
#12 lore raw

PATCH 5/11 target/mips/mips-defs: Use ISA_MIPS32R5 definition to check Release 5

In reply to Philippe Mathieu-Daudé

Use the single ISA_MIPS32R5 definition to check if the Release 5 ISA is supported, whether the CPU support 32/64-bit.

For now we keep '32' in the definition name, we will rename it as ISA_MIPS_R5 in few commits.

---
 target/mips/mips-defs.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
target/mips/mips-defs.h +1 -2
index 0d906ca64b3..ea9dcc7c98e 100644
@@ -26,7 +26,6 @@
 #define ISA_MIPS32R2      0x0000000000000040ULL
 #define ISA_MIPS32R3      0x0000000000000200ULL
 #define ISA_MIPS32R5      0x0000000000000800ULL
-#define ISA_MIPS64R5      0x0000000000001000ULL
 #define ISA_MIPS32R6      0x0000000000002000ULL
 #define ISA_MIPS64R6      0x0000000000004000ULL
 #define ISA_NANOMIPS32    0x0000000000008000ULL
@@ -87,7 +86,7 @@
 
 /* MIPS Technologies "Release 5" */
 #define CPU_MIPS32R5    (CPU_MIPS32R3 | ISA_MIPS32R5)
-#define CPU_MIPS64R5    (CPU_MIPS64R3 | CPU_MIPS32R5 | ISA_MIPS64R5)
+#define CPU_MIPS64R5    (CPU_MIPS64R3 | CPU_MIPS32R5)
 
 /* MIPS Technologies "Release 6" */
 #define CPU_MIPS32R6    (CPU_MIPS32R5 | ISA_MIPS32R6)
Signature · 1 line
2.26.2
#13 lore raw

PATCH 6/11 target/mips/mips-defs: Use ISA_MIPS32R6 definition to check Release 6

In reply to Philippe Mathieu-Daudé

Use the single ISA_MIPS32R6 definition to check if the Release 6 ISA is supported, whether the CPU support 32/64-bit.

For now we keep '32' in the definition name, we will rename it as ISA_MIPS_R6 in few commits.

---
 target/mips/internal.h     | 2 +-
 target/mips/mips-defs.h    | 3 +--
 linux-user/elfload.c       | 2 +-
 linux-user/mips/cpu_loop.c | 3 +--
 target/mips/tlb_helper.c   | 6 +++---
 target/mips/translate.c    | 2 +-
 6 files changed, 8 insertions(+), 10 deletions(-)
target/mips/internal.h +1 -1
index 76269cfc7bb..97899dbd3c8 100644
@@ -308,7 +308,7 @@ static inline void compute_hflags(CPUMIPSState *env)
     } else if (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM) &&
                !(env->CP0_Status & (1 << CP0St_UX))) {
         env->hflags |= MIPS_HFLAG_AWRAP;
-    } else if (env->insn_flags & ISA_MIPS64R6) {
+    } else if (env->insn_flags & ISA_MIPS32R6) {
         /* Address wrapping for Supervisor and Kernel is specified in R6 */
         if ((((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_SM) &&
              !(env->CP0_Status & (1 << CP0St_SX))) ||
target/mips/mips-defs.h +1 -2
index ea9dcc7c98e..df2ffae5718 100644
@@ -27,7 +27,6 @@
 #define ISA_MIPS32R3      0x0000000000000200ULL
 #define ISA_MIPS32R5      0x0000000000000800ULL
 #define ISA_MIPS32R6      0x0000000000002000ULL
-#define ISA_MIPS64R6      0x0000000000004000ULL
 #define ISA_NANOMIPS32    0x0000000000008000ULL
 /*
  *   bits 24-39: MIPS ASEs
@@ -90,7 +89,7 @@
 
 /* MIPS Technologies "Release 6" */
 #define CPU_MIPS32R6    (CPU_MIPS32R5 | ISA_MIPS32R6)
-#define CPU_MIPS64R6    (CPU_MIPS64R5 | CPU_MIPS32R6 | ISA_MIPS64R6)
+#define CPU_MIPS64R6    (CPU_MIPS64R5 | CPU_MIPS32R6)
 
 /* Wave Computing: "nanoMIPS" */
 #define CPU_NANOMIPS32  (CPU_MIPS32R6 | ISA_NANOMIPS32)
linux-user/elfload.c +1 -1
index 0b02a926025..e875a5387cc 100644
@@ -997,7 +997,7 @@ static uint32_t get_elf_hwcap(void)
 #define GET_FEATURE(flag, hwcap) \
     do { if (cpu->env.insn_flags & (flag)) { hwcaps |= hwcap; } } while (0)
 
-    GET_FEATURE(ISA_MIPS32R6 | ISA_MIPS64R6, HWCAP_MIPS_R6);
+    GET_FEATURE(ISA_MIPS32R6, HWCAP_MIPS_R6);
     GET_FEATURE(ASE_MSA, HWCAP_MIPS_MSA);
 
 #undef GET_FEATURE
linux-user/mips/cpu_loop.c +1 -2
index a2aa8167210..1e4acf3d6e3 100644
@@ -386,8 +386,7 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
     prog_req.fre &= interp_req.fre;
 
     bool cpu_has_mips_r2_r6 = env->insn_flags & ISA_MIPS32R2 ||
-                              env->insn_flags & ISA_MIPS32R6 ||
-                              env->insn_flags & ISA_MIPS64R6;
+                              env->insn_flags & ISA_MIPS32R6;
 
     if (prog_req.fre && !prog_req.frdefault && !prog_req.fr1) {
         env->CP0_Config5 |= (1 << CP0C5_FRE);
target/mips/tlb_helper.c +3 -3
index 94a482e3dbe..68d766f90a3 100644
@@ -1025,7 +1025,7 @@ void mips_cpu_do_interrupt(CPUState *cs)
  enter_debug_mode:
         if (env->insn_flags & ISA_MIPS3) {
             env->hflags |= MIPS_HFLAG_64;
-            if (!(env->insn_flags & ISA_MIPS64R6) ||
+            if (!(env->insn_flags & ISA_MIPS32R6) ||
                 env->CP0_Status & (1 << CP0St_KX)) {
                 env->hflags &= ~MIPS_HFLAG_AWRAP;
             }
@@ -1054,7 +1054,7 @@ void mips_cpu_do_interrupt(CPUState *cs)
         env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV);
         if (env->insn_flags & ISA_MIPS3) {
             env->hflags |= MIPS_HFLAG_64;
-            if (!(env->insn_flags & ISA_MIPS64R6) ||
+            if (!(env->insn_flags & ISA_MIPS32R6) ||
                 env->CP0_Status & (1 << CP0St_KX)) {
                 env->hflags &= ~MIPS_HFLAG_AWRAP;
             }
@@ -1240,7 +1240,7 @@ void mips_cpu_do_interrupt(CPUState *cs)
             env->CP0_Status |= (1 << CP0St_EXL);
             if (env->insn_flags & ISA_MIPS3) {
                 env->hflags |= MIPS_HFLAG_64;
-                if (!(env->insn_flags & ISA_MIPS64R6) ||
+                if (!(env->insn_flags & ISA_MIPS32R6) ||
                     env->CP0_Status & (1 << CP0St_KX)) {
                     env->hflags &= ~MIPS_HFLAG_AWRAP;
                 }
target/mips/translate.c +1 -1
index 0923dfdf451..38fbc55ff1e 100644
@@ -29078,7 +29078,7 @@ static void mips_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
 #else
         ctx->mem_idx = hflags_mmu_index(ctx->hflags);
 #endif
-    ctx->default_tcg_memop_mask = (ctx->insn_flags & (ISA_MIPS32R6 | ISA_MIPS64R6 |
+    ctx->default_tcg_memop_mask = (ctx->insn_flags & (ISA_MIPS32R6 |
                                   INSN_LOONGSON3A)) ? MO_UNALN : MO_ALIGN;
 
     LOG_DISAS("\ntb %p idx %d hflags %04x\n", ctx->base.tb, ctx->mem_idx,
Signature · 1 line
2.26.2
#14 lore raw

PATCH 7/11 target/mips/mips-defs: Rename ISA_MIPS32 as ISA_MIPS_R1

In reply to Philippe Mathieu-Daudé

The MIPS ISA release '1' is common to 32/64-bit CPUs.

---
 target/mips/internal.h  |  2 +-
 target/mips/mips-defs.h |  4 ++--
 target/mips/translate.c | 44 ++++++++++++++++++++---------------------
 3 files changed, 25 insertions(+), 25 deletions(-)
target/mips/internal.h +1 -1
index 97899dbd3c8..f71c617a1fe 100644
@@ -365,7 +365,7 @@ static inline void compute_hflags(CPUMIPSState *env)
         if (env->active_fpu.fcr0 & (1 << FCR0_F64)) {
             env->hflags |= MIPS_HFLAG_COP1X;
         }
-    } else if (env->insn_flags & ISA_MIPS32) {
+    } else if (env->insn_flags & ISA_MIPS_R1) {
         if (env->hflags & MIPS_HFLAG_64) {
             env->hflags |= MIPS_HFLAG_COP1X;
         }
target/mips/mips-defs.h +2 -2
index df2ffae5718..31c02cc20ef 100644
@@ -22,7 +22,7 @@
 #define ISA_MIPS3         0x0000000000000004ULL /* 64-bit */
 #define ISA_MIPS4         0x0000000000000008ULL
 #define ISA_MIPS5         0x0000000000000010ULL
-#define ISA_MIPS32        0x0000000000000020ULL
+#define ISA_MIPS_R1       0x0000000000000020ULL
 #define ISA_MIPS32R2      0x0000000000000040ULL
 #define ISA_MIPS32R3      0x0000000000000200ULL
 #define ISA_MIPS32R5      0x0000000000000800ULL
@@ -72,7 +72,7 @@
 #define CPU_LOONGSON2F  (CPU_MIPS3 | INSN_LOONGSON2F | ASE_LMMI)
 
 /* MIPS Technologies "Release 1" */
-#define CPU_MIPS32      (CPU_MIPS2 | ISA_MIPS32)
+#define CPU_MIPS32      (CPU_MIPS2 | ISA_MIPS_R1)
 #define CPU_MIPS64      (CPU_MIPS5 | CPU_MIPS32)
 
 /* MIPS Technologies "Release 2" */
target/mips/translate.c +22 -22

176 lines not on this page · raw message

Signature · 1 line
2.26.2
#15 lore raw

PATCH 8/11 target/mips/mips-defs: Rename ISA_MIPS32R2 as ISA_MIPS_R2

In reply to Philippe Mathieu-Daudé

The MIPS ISA release 2 is common to 32/64-bit CPUs.

---
 target/mips/internal.h     |   2 +-
 target/mips/mips-defs.h    |   6 +-
 linux-user/mips/cpu_loop.c |   2 +-
 target/mips/cp0_timer.c    |   4 +-
 target/mips/cpu.c          |   2 +-
 target/mips/translate.c    | 138 ++++++++++++++++++-------------------
 6 files changed, 77 insertions(+), 77 deletions(-)
target/mips/internal.h +1 -1
index f71c617a1fe..b14671a9a51 100644
@@ -361,7 +361,7 @@ static inline void compute_hflags(CPUMIPSState *env)
         }
 
     }
-    if (env->insn_flags & ISA_MIPS32R2) {
+    if (env->insn_flags & ISA_MIPS_R2) {
         if (env->active_fpu.fcr0 & (1 << FCR0_F64)) {
             env->hflags |= MIPS_HFLAG_COP1X;
         }
target/mips/mips-defs.h +3 -3
index 31c02cc20ef..9ef3f517aaa 100644
@@ -23,7 +23,7 @@
 #define ISA_MIPS4         0x0000000000000008ULL
 #define ISA_MIPS5         0x0000000000000010ULL
 #define ISA_MIPS_R1       0x0000000000000020ULL
-#define ISA_MIPS32R2      0x0000000000000040ULL
+#define ISA_MIPS_R2       0x0000000000000040ULL
 #define ISA_MIPS32R3      0x0000000000000200ULL
 #define ISA_MIPS32R5      0x0000000000000800ULL
 #define ISA_MIPS32R6      0x0000000000002000ULL
@@ -76,8 +76,8 @@
 #define CPU_MIPS64      (CPU_MIPS5 | CPU_MIPS32)
 
 /* MIPS Technologies "Release 2" */
-#define CPU_MIPS32R2    (CPU_MIPS32 | ISA_MIPS32R2)
-#define CPU_MIPS64R2    (CPU_MIPS64 | ISA_MIPS32R2)
+#define CPU_MIPS32R2    (CPU_MIPS32 | ISA_MIPS_R2)
+#define CPU_MIPS64R2    (CPU_MIPS64 | ISA_MIPS_R2)
 
 /* MIPS Technologies "Release 3" */
 #define CPU_MIPS32R3    (CPU_MIPS32R2 | ISA_MIPS32R3)
linux-user/mips/cpu_loop.c +1 -1
index 1e4acf3d6e3..fc5446ade37 100644
@@ -385,7 +385,7 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
     prog_req.frdefault &= interp_req.frdefault;
     prog_req.fre &= interp_req.fre;
 
-    bool cpu_has_mips_r2_r6 = env->insn_flags & ISA_MIPS32R2 ||
+    bool cpu_has_mips_r2_r6 = env->insn_flags & ISA_MIPS_R2 ||
                               env->insn_flags & ISA_MIPS32R6;
 
     if (prog_req.fre && !prog_req.frdefault && !prog_req.fr1) {
target/mips/cp0_timer.c +2 -2
index 5ec0d6249e9..70de95d338f 100644
@@ -44,7 +44,7 @@ static void cpu_mips_timer_update(CPUMIPSState *env)
 static void cpu_mips_timer_expire(CPUMIPSState *env)
 {
     cpu_mips_timer_update(env);
-    if (env->insn_flags & ISA_MIPS32R2) {
+    if (env->insn_flags & ISA_MIPS_R2) {
         env->CP0_Cause |= 1 << CP0Ca_TI;
     }
     qemu_irq_raise(env->irq[(env->CP0_IntCtl >> CP0IntCtl_IPTI) & 0x7]);
@@ -93,7 +93,7 @@ void cpu_mips_store_compare(CPUMIPSState *env, uint32_t value)
     if (!(env->CP0_Cause & (1 << CP0Ca_DC))) {
         cpu_mips_timer_update(env);
     }
-    if (env->insn_flags & ISA_MIPS32R2) {
+    if (env->insn_flags & ISA_MIPS_R2) {
         env->CP0_Cause &= ~(1 << CP0Ca_TI);
     }
     qemu_irq_lower(env->irq[(env->CP0_IntCtl >> CP0IntCtl_IPTI) & 0x7]);
target/mips/cpu.c +1 -1
index 112eb0d9f47..5c571434134 100644
@@ -111,7 +111,7 @@ void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val)
     uint32_t old = env->CP0_Cause;
     int i;
 
-    if (env->insn_flags & ISA_MIPS32R2) {
+    if (env->insn_flags & ISA_MIPS_R2) {
         mask |= 1 << CP0Ca_DC;
     }
     if (env->insn_flags & ISA_MIPS32R6) {
target/mips/translate.c +69 -69

497 lines not on this page · raw message

Signature · 1 line
2.26.2
#16 lore raw

PATCH 9/11 target/mips/mips-defs: Rename ISA_MIPS32R3 as ISA_MIPS_R3

In reply to Philippe Mathieu-Daudé

The MIPS ISA release 3 is common to 32/64-bit CPUs.

To avoid holes in the insn_flags type, update the
definition with the next available bit.

---
 target/mips/mips-defs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/mips/mips-defs.h +2 -2
index 9ef3f517aaa..171d94c16dc 100644
@@ -24,7 +24,7 @@
 #define ISA_MIPS5         0x0000000000000010ULL
 #define ISA_MIPS_R1       0x0000000000000020ULL
 #define ISA_MIPS_R2       0x0000000000000040ULL
-#define ISA_MIPS32R3      0x0000000000000200ULL
+#define ISA_MIPS_R3       0x0000000000000080ULL
 #define ISA_MIPS32R5      0x0000000000000800ULL
 #define ISA_MIPS32R6      0x0000000000002000ULL
 #define ISA_NANOMIPS32    0x0000000000008000ULL
@@ -80,7 +80,7 @@
 #define CPU_MIPS64R2    (CPU_MIPS64 | ISA_MIPS_R2)
 
 /* MIPS Technologies "Release 3" */
-#define CPU_MIPS32R3    (CPU_MIPS32R2 | ISA_MIPS32R3)
+#define CPU_MIPS32R3    (CPU_MIPS32R2 | ISA_MIPS_R3)
 #define CPU_MIPS64R3    (CPU_MIPS64R2 | CPU_MIPS32R3)
 
 /* MIPS Technologies "Release 5" */
Signature · 1 line
2.26.2
#17 lore raw

PATCH 10/11 target/mips/mips-defs: Rename ISA_MIPS32R5 as ISA_MIPS_R5

In reply to Philippe Mathieu-Daudé

The MIPS ISA release 5 is common to 32/64-bit CPUs.

To avoid holes in the insn_flags type, update the
definition with the next available bit.

---
 target/mips/mips-defs.h | 4 ++--
 target/mips/translate.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
target/mips/mips-defs.h +2 -2
index 171d94c16dc..068fe9c8a19 100644
@@ -25,7 +25,7 @@
 #define ISA_MIPS_R1       0x0000000000000020ULL
 #define ISA_MIPS_R2       0x0000000000000040ULL
 #define ISA_MIPS_R3       0x0000000000000080ULL
-#define ISA_MIPS32R5      0x0000000000000800ULL
+#define ISA_MIPS_R5       0x0000000000000100ULL
 #define ISA_MIPS32R6      0x0000000000002000ULL
 #define ISA_NANOMIPS32    0x0000000000008000ULL
 /*
@@ -84,7 +84,7 @@
 #define CPU_MIPS64R3    (CPU_MIPS64R2 | CPU_MIPS32R3)
 
 /* MIPS Technologies "Release 5" */
-#define CPU_MIPS32R5    (CPU_MIPS32R3 | ISA_MIPS32R5)
+#define CPU_MIPS32R5    (CPU_MIPS32R3 | ISA_MIPS_R5)
 #define CPU_MIPS64R5    (CPU_MIPS64R3 | CPU_MIPS32R5)
 
 /* MIPS Technologies "Release 6" */
target/mips/translate.c +1 -1
index 842db4490ce..6406596293c 100644
@@ -10588,7 +10588,7 @@ static void gen_cp0(CPUMIPSState *env, DisasContext *ctx, uint32_t opc,
             if (ctx->opcode & (1 << bit_shift)) {
                 /* OPC_ERETNC */
                 opn = "eretnc";
-                check_insn(ctx, ISA_MIPS32R5);
+                check_insn(ctx, ISA_MIPS_R5);
                 gen_helper_eretnc(cpu_env);
             } else {
                 /* OPC_ERET */
Signature · 1 line
2.26.2
#18 lore raw

PATCH 11/11 target/mips/mips-defs: Rename ISA_MIPS32R6 as ISA_MIPS_R6

In reply to Philippe Mathieu-Daudé

The MIPS ISA release 6 is common to 32/64-bit CPUs.

To avoid holes in the insn_flags type, update the
definition with the next available bit.

---
 target/mips/internal.h     |   4 +-
 target/mips/mips-defs.h    |   4 +-
 linux-user/elfload.c       |   2 +-
 linux-user/mips/cpu_loop.c |   2 +-
 target/mips/cp0_helper.c   |  18 +-
 target/mips/cpu.c          |  10 +-
 target/mips/fpu_helper.c   |   4 +-
 target/mips/tlb_helper.c   |   6 +-
 target/mips/translate.c    | 426 ++++++++++++++++++-------------------
 9 files changed, 238 insertions(+), 238 deletions(-)
target/mips/internal.h +2 -2
index b14671a9a51..5dd17ff7333 100644
@@ -308,7 +308,7 @@ static inline void compute_hflags(CPUMIPSState *env)
     } else if (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM) &&
                !(env->CP0_Status & (1 << CP0St_UX))) {
         env->hflags |= MIPS_HFLAG_AWRAP;
-    } else if (env->insn_flags & ISA_MIPS32R6) {
+    } else if (env->insn_flags & ISA_MIPS_R6) {
         /* Address wrapping for Supervisor and Kernel is specified in R6 */
         if ((((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_SM) &&
              !(env->CP0_Status & (1 << CP0St_SX))) ||
@@ -319,7 +319,7 @@ static inline void compute_hflags(CPUMIPSState *env)
     }
 #endif
     if (((env->CP0_Status & (1 << CP0St_CU0)) &&
-         !(env->insn_flags & ISA_MIPS32R6)) ||
+         !(env->insn_flags & ISA_MIPS_R6)) ||
         !(env->hflags & MIPS_HFLAG_KSU)) {
         env->hflags |= MIPS_HFLAG_CP0;
     }
target/mips/mips-defs.h +2 -2
index 068fe9c8a19..32c4c5cf6c4 100644
@@ -26,7 +26,7 @@
 #define ISA_MIPS_R2       0x0000000000000040ULL
 #define ISA_MIPS_R3       0x0000000000000080ULL
 #define ISA_MIPS_R5       0x0000000000000100ULL
-#define ISA_MIPS32R6      0x0000000000002000ULL
+#define ISA_MIPS_R6       0x0000000000000200ULL
 #define ISA_NANOMIPS32    0x0000000000008000ULL
 /*
  *   bits 24-39: MIPS ASEs
@@ -88,7 +88,7 @@
 #define CPU_MIPS64R5    (CPU_MIPS64R3 | CPU_MIPS32R5)
 
 /* MIPS Technologies "Release 6" */
-#define CPU_MIPS32R6    (CPU_MIPS32R5 | ISA_MIPS32R6)
+#define CPU_MIPS32R6    (CPU_MIPS32R5 | ISA_MIPS_R6)
 #define CPU_MIPS64R6    (CPU_MIPS64R5 | CPU_MIPS32R6)
 
 /* Wave Computing: "nanoMIPS" */
linux-user/elfload.c +1 -1
index e875a5387cc..5f8bc98e5c5 100644
@@ -997,7 +997,7 @@ static uint32_t get_elf_hwcap(void)
 #define GET_FEATURE(flag, hwcap) \
     do { if (cpu->env.insn_flags & (flag)) { hwcaps |= hwcap; } } while (0)
 
-    GET_FEATURE(ISA_MIPS32R6, HWCAP_MIPS_R6);
+    GET_FEATURE(ISA_MIPS_R6, HWCAP_MIPS_R6);
     GET_FEATURE(ASE_MSA, HWCAP_MIPS_MSA);
 
 #undef GET_FEATURE
linux-user/mips/cpu_loop.c +1 -1
index fc5446ade37..9d813ece4e7 100644
@@ -386,7 +386,7 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
     prog_req.fre &= interp_req.fre;
 
     bool cpu_has_mips_r2_r6 = env->insn_flags & ISA_MIPS_R2 ||
-                              env->insn_flags & ISA_MIPS32R6;
+                              env->insn_flags & ISA_MIPS_R6;
 
     if (prog_req.fre && !prog_req.frdefault && !prog_req.fr1) {
         env->CP0_Config5 |= (1 << CP0C5_FRE);
target/mips/cp0_helper.c +9 -9
index 36a92857bfb..aae2af6eccc 100644
@@ -527,7 +527,7 @@ void helper_mtc0_index(CPUMIPSState *env, target_ulong arg1)
     uint32_t index_p = env->CP0_Index & 0x80000000;
     uint32_t tlb_index = arg1 & 0x7fffffff;
     if (tlb_index < env->tlb->nb_tlb) {
-        if (env->insn_flags & ISA_MIPS32R6) {
+        if (env->insn_flags & ISA_MIPS_R6) {
             index_p |= arg1 & 0x80000000;
         }
         env->CP0_Index = index_p | tlb_index;
@@ -960,7 +960,7 @@ void helper_mtc0_pwfield(CPUMIPSState *env, target_ulong arg1)
     uint32_t old_ptei = (env->CP0_PWField >> CP0PF_PTEI) & 0x3FULL;
     uint32_t new_ptei = (arg1 >> CP0PF_PTEI) & 0x3FULL;
 
-    if ((env->insn_flags & ISA_MIPS32R6)) {
+    if ((env->insn_flags & ISA_MIPS_R6)) {
         if (((arg1 >> CP0PF_BDI) & 0x3FULL) < 12) {
             mask &= ~(0x3FULL << CP0PF_BDI);
         }
@@ -980,7 +980,7 @@ void helper_mtc0_pwfield(CPUMIPSState *env, target_ulong arg1)
     env->CP0_PWField = arg1 & mask;
 
     if ((new_ptei >= 32) ||
-            ((env->insn_flags & ISA_MIPS32R6) &&
+            ((env->insn_flags & ISA_MIPS_R6) &&
                     (new_ptei == 0 || new_ptei == 1))) {
         env->CP0_PWField = (env->CP0_PWField & ~0x3FULL) |
                 (old_ptei << CP0PF_PTEI);
@@ -990,7 +990,7 @@ void helper_mtc0_pwfield(CPUMIPSState *env, target_ulong arg1)
     uint32_t old_ptew = (env->CP0_PWField >> CP0PF_PTEW) & 0x3F;
     uint32_t new_ptew = (arg1 >> CP0PF_PTEW) & 0x3F;
 
-    if ((env->insn_flags & ISA_MIPS32R6)) {
+    if ((env->insn_flags & ISA_MIPS_R6)) {
         if (((arg1 >> CP0PF_GDW) & 0x3F) < 12) {
             mask &= ~(0x3F << CP0PF_GDW);
         }
@@ -1007,7 +1007,7 @@ void helper_mtc0_pwfield(CPUMIPSState *env, target_ulong arg1)
     env->CP0_PWField = arg1 & mask;
 
     if ((new_ptew >= 32) ||
-            ((env->insn_flags & ISA_MIPS32R6) &&
+            ((env->insn_flags & ISA_MIPS_R6) &&
                     (new_ptew == 0 || new_ptew == 1))) {
         env->CP0_PWField = (env->CP0_PWField & ~0x3F) |
                 (old_ptew << CP0PF_PTEW);
@@ -1026,7 +1026,7 @@ void helper_mtc0_pwsize(CPUMIPSState *env, target_ulong arg1)
 
 void helper_mtc0_wired(CPUMIPSState *env, target_ulong arg1)
 {
-    if (env->insn_flags & ISA_MIPS32R6) {
+    if (env->insn_flags & ISA_MIPS_R6) {
         if (arg1 < env->tlb->nb_tlb) {
             env->CP0_Wired = arg1;
         }
@@ -1075,10 +1075,10 @@ void helper_mtc0_hwrena(CPUMIPSState *env, target_ulong arg1)
     uint32_t mask = 0x0000000F;
 
     if ((env->CP0_Config1 & (1 << CP0C1_PC)) &&
-        (env->insn_flags & ISA_MIPS32R6)) {
+        (env->insn_flags & ISA_MIPS_R6)) {
         mask |= (1 << 4);
     }
-    if (env->insn_flags & ISA_MIPS32R6) {
+    if (env->insn_flags & ISA_MIPS_R6) {
         mask |= (1 << 5);
     }
     if (env->CP0_Config3 & (1 << CP0C3_ULRI)) {
@@ -1149,7 +1149,7 @@ void helper_mtc0_entryhi(CPUMIPSState *env, target_ulong arg1)
 
     /* 1k pages not implemented */
 #if defined(TARGET_MIPS64)
-    if (env->insn_flags & ISA_MIPS32R6) {
+    if (env->insn_flags & ISA_MIPS_R6) {
         int entryhi_r = extract64(arg1, 62, 2);
         int config0_at = extract32(env->CP0_Config0, 13, 2);
         bool no_supervisor = (env->CP0_Status_rw_bitmask & 0x8) == 0;
target/mips/cpu.c +5 -5
index 5c571434134..905772a394b 100644
@@ -77,7 +77,7 @@ void cpu_mips_store_status(CPUMIPSState *env, target_ulong val)
     uint32_t mask = env->CP0_Status_rw_bitmask;
     target_ulong old = env->CP0_Status;
 
-    if (env->insn_flags & ISA_MIPS32R6) {
+    if (env->insn_flags & ISA_MIPS_R6) {
         bool has_supervisor = extract32(mask, CP0St_KSU, 2) == 0x3;
 #if defined(TARGET_MIPS64)
         uint32_t ksux = (1 << CP0St_KX) & val;
@@ -114,7 +114,7 @@ void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val)
     if (env->insn_flags & ISA_MIPS_R2) {
         mask |= 1 << CP0Ca_DC;
     }
-    if (env->insn_flags & ISA_MIPS32R6) {
+    if (env->insn_flags & ISA_MIPS_R6) {
         mask &= ~((1 << CP0Ca_WP) & val);
     }
 
@@ -281,7 +281,7 @@ static bool mips_cpu_has_work(CPUState *cs)
     if ((cs->interrupt_request & CPU_INTERRUPT_HARD) &&
         cpu_mips_hw_interrupts_pending(env)) {
         if (cpu_mips_hw_interrupts_enabled(env) ||
-            (env->insn_flags & ISA_MIPS32R6)) {
+            (env->insn_flags & ISA_MIPS_R6)) {
             has_work = true;
         }
     }
@@ -503,13 +503,13 @@ static void mips_cpu_reset(DeviceState *dev)
     /* XKPhys (note, SegCtl2.XR = 0, so XAM won't be used) */
     env->CP0_SegCtl1 |= (CP0SC_AM_UK << CP0SC1_XAM);
 #endif /* !CONFIG_USER_ONLY */
-    if ((env->insn_flags & ISA_MIPS32R6) &&
+    if ((env->insn_flags & ISA_MIPS_R6) &&
         (env->active_fpu.fcr0 & (1 << FCR0_F64))) {
         /* Status.FR = 0 mode in 64-bit FPU not allowed in R6 */
         env->CP0_Status |= (1 << CP0St_FR);
     }
 
-    if (env->insn_flags & ISA_MIPS32R6) {
+    if (env->insn_flags & ISA_MIPS_R6) {
         /* PTW  =  1 */
         env->CP0_PWSize = 0x40;
         /* GDI  = 12 */
target/mips/fpu_helper.c +2 -2
index a3c05160b35..6dd853259e2 100644
@@ -146,7 +146,7 @@ void helper_ctc1(CPUMIPSState *env, target_ulong arg1, uint32_t fs, uint32_t rt)
         }
         break;
     case 25:
-        if ((env->insn_flags & ISA_MIPS32R6) || (arg1 & 0xffffff00)) {
+        if ((env->insn_flags & ISA_MIPS_R6) || (arg1 & 0xffffff00)) {
             return;
         }
         env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0x017fffff) |
@@ -173,7 +173,7 @@ void helper_ctc1(CPUMIPSState *env, target_ulong arg1, uint32_t fs, uint32_t rt)
                (env->active_fpu.fcr31 & ~(env->active_fpu.fcr31_rw_bitmask));
         break;
     default:
-        if (env->insn_flags & ISA_MIPS32R6) {
+        if (env->insn_flags & ISA_MIPS_R6) {
             do_raise_exception(env, EXCP_RI, GETPC());
         }
         return;
target/mips/tlb_helper.c +3 -3
index 68d766f90a3..082c17928d3 100644
@@ -1025,7 +1025,7 @@ void mips_cpu_do_interrupt(CPUState *cs)
  enter_debug_mode:
         if (env->insn_flags & ISA_MIPS3) {
             env->hflags |= MIPS_HFLAG_64;
-            if (!(env->insn_flags & ISA_MIPS32R6) ||
+            if (!(env->insn_flags & ISA_MIPS_R6) ||
                 env->CP0_Status & (1 << CP0St_KX)) {
                 env->hflags &= ~MIPS_HFLAG_AWRAP;
             }
@@ -1054,7 +1054,7 @@ void mips_cpu_do_interrupt(CPUState *cs)
         env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV);
         if (env->insn_flags & ISA_MIPS3) {
             env->hflags |= MIPS_HFLAG_64;
-            if (!(env->insn_flags & ISA_MIPS32R6) ||
+            if (!(env->insn_flags & ISA_MIPS_R6) ||
                 env->CP0_Status & (1 << CP0St_KX)) {
                 env->hflags &= ~MIPS_HFLAG_AWRAP;
             }
@@ -1240,7 +1240,7 @@ void mips_cpu_do_interrupt(CPUState *cs)
             env->CP0_Status |= (1 << CP0St_EXL);
             if (env->insn_flags & ISA_MIPS3) {
                 env->hflags |= MIPS_HFLAG_64;
-                if (!(env->insn_flags & ISA_MIPS32R6) ||
+                if (!(env->insn_flags & ISA_MIPS_R6) ||
                     env->CP0_Status & (1 << CP0St_KX)) {
                     env->hflags &= ~MIPS_HFLAG_AWRAP;
                 }
target/mips/translate.c +213 -213

1,511 lines not on this page · raw message

Signature · 1 line
2.26.2
#19 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 5 lines · Philippe Mathieu-Daudé

As we don't need to duplicate 32/64-bit ISA defititions,

this series remove the duplicated 64-bit variants,

simplifying the overall.

Thanks, that makes things much more clear!

Quoted 5 lines

Changes done automatically with my editor using "find

Quoted 7 lines

and replace".

While the 'ISA_MIPS_Rx' form is shorter than 'ISA_MIPS_RELx',

which one is the clearer?

I'd perfer Rx to keep consistent with wording elsewhere.

Thanks.

- Jiaxun

Quoted 63 lines

Regards,

Phil.

Philippe Mathieu-Daudé (11):

target/mips/mips-defs: Reorder CPU_MIPS5 definition

target/mips/mips-defs: Use ISA_MIPS3 for ISA_MIPS64

target/mips/mips-defs: Use ISA_MIPS32R2 definition to check Release 2

target/mips/mips-defs: Use ISA_MIPS32R3 definition to check Release 3

target/mips/mips-defs: Use ISA_MIPS32R5 definition to check Release 5

target/mips/mips-defs: Use ISA_MIPS32R6 definition to check Release 6

target/mips/mips-defs: Rename ISA_MIPS32 as ISA_MIPS_R1

target/mips/mips-defs: Rename ISA_MIPS32R2 as ISA_MIPS_R2

target/mips/mips-defs: Rename ISA_MIPS32R3 as ISA_MIPS_R3

target/mips/mips-defs: Rename ISA_MIPS32R5 as ISA_MIPS_R5

target/mips/mips-defs: Rename ISA_MIPS32R6 as ISA_MIPS_R6

  target/mips/internal.h     |   8 +-
  target/mips/mips-defs.h    |  40 +--
  hw/mips/boston.c           |   2 +-
  linux-user/elfload.c       |   2 +-
  linux-user/mips/cpu_loop.c |   6 +-
  target/mips/cp0_helper.c   |  18 +-
  target/mips/cp0_timer.c    |   4 +-
  target/mips/cpu.c          |  12 +-
  target/mips/fpu_helper.c   |   4 +-
  target/mips/tlb_helper.c   |   6 +-
  target/mips/translate.c    | 620 ++++++++++++++++++-------------------
  11 files changed, 357 insertions(+), 365 deletions(-)