Skip to contentSkip to conversation

target/mips: Decodetree housekeeping

PATCH In review Philippe Mathieu-Daudé 2 participants 10 messages Aug 1, 2021 – Aug 6, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover target/mips: Decodetree housekeeping

Minor cleanups while looking at converting more opcodes to decodetree.

Philippe Mathieu-Daudé (4):
target/mips: Simpify PREF opcode
target/mips: Decode vendor extensions before MIPS ISAs target/mips: Merge 32-bit/64-bit release6 decodetree definitions target/mips: Rename 'rtype' as 'r'

 target/mips/tcg/mips64r6.decode               | 27 --------
 target/mips/tcg/msa.decode                    |  4 +-
 .../mips/tcg/{mips32r6.decode => rel6.decode} | 17 ++++-
 target/mips/tcg/tx79.decode                   | 14 ++---
 target/mips/tcg/msa_translate.c               |  4 +-
 target/mips/tcg/rel6_translate.c              | 20 +++---
 target/mips/tcg/translate.c                   | 16 +++--
 target/mips/tcg/tx79_translate.c              | 62 +++++++++----------
 target/mips/tcg/meson.build                   |  3 +-
 9 files changed, 72 insertions(+), 95 deletions(-)
 delete mode 100644 target/mips/tcg/mips64r6.decode
 rename target/mips/tcg/{mips32r6.decode => rel6.decode} (64%)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/4 target/mips: Simpify PREF opcode

check_insn() checks for any bit in the set, and INSN_R5900 is just another bit added to the set. No need to special-case it.

---
 target/mips/tcg/translate.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
target/mips/tcg/translate.c +2 -6
index 34a96159d15..05efd25e29d 100644
@@ -15738,12 +15738,8 @@ static bool decode_opc_legacy(CPUMIPSState *env, DisasContext *ctx)
         /* Treat as NOP. */
         break;
     case OPC_PREF:
-        if (ctx->insn_flags & INSN_R5900) {
-            /* Treat as NOP. */
-        } else {
-            check_insn(ctx, ISA_MIPS4 | ISA_MIPS_R1);
-            /* Treat as NOP. */
-        }
+        check_insn(ctx, ISA_MIPS4 | ISA_MIPS_R1 | INSN_R5900);
+        /* Treat as NOP. */
         break;
 
     /* Floating point (COP1). */
Signature · 1 line
2.31.1
#3 lore raw

PATCH 2/4 target/mips: Decode vendor extensions before MIPS ISAs

In reply to Philippe Mathieu-Daudé

In commit ffc672aa977 ("target/mips/tx79: Move MFHI1 / MFLO1 opcodes to decodetree") we misplaced the decoder call. Move it to the correct place.

---
 target/mips/tcg/translate.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
target/mips/tcg/translate.c +5 -3
index 05efd25e29d..9572cc56947 100644
@@ -16093,6 +16093,11 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
 
     /* Transition to the auto-generated decoder.  */
 
+    /* Vendor extensions */
+    if (cpu_supports_isa(env, INSN_R5900) && decode_ext_txx9(ctx, ctx->opcode)) {
+        return;
+    }
+
     /* ISA extensions */
     if (ase_msa_available(env) && decode_ase_msa(ctx, ctx->opcode)) {
         return;
@@ -16102,9 +16107,6 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
     if (cpu_supports_isa(env, ISA_MIPS_R6) && decode_isa_rel6(ctx, ctx->opcode)) {
         return;
     }
-    if (cpu_supports_isa(env, INSN_R5900) && decode_ext_txx9(ctx, ctx->opcode)) {
-        return;
-    }
 
     if (decode_opc_legacy(env, ctx)) {
         return;
Signature · 1 line
2.31.1
Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH-for-6.2 2/4] target/mips: Decode vendor extensions before MIPS ISAs

Quoted 8 lines · Philippe Mathieu-Daudé

In commit ffc672aa977 ("target/mips/tx79: Move MFHI1 / MFLO1 opcodes to decodetree") we misplaced the decoder call. Move it to the correct place.

---
  target/mips/tcg/translate.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)

r~

#5 lore raw

PATCH 3/4 target/mips: Merge 32-bit/64-bit release6 decodetree definitions

In reply to Philippe Mathieu-Daudé

We don't need to maintain 2 sets of decodetree definitions. Merge them into a single file.

---
 target/mips/tcg/mips64r6.decode               | 27 -------------------
 .../mips/tcg/{mips32r6.decode => rel6.decode} | 13 +++++++++
 target/mips/tcg/rel6_translate.c              | 16 ++++-------
 target/mips/tcg/meson.build                   |  3 +--
 4 files changed, 19 insertions(+), 40 deletions(-)
 delete mode 100644 target/mips/tcg/mips64r6.decode
 rename target/mips/tcg/{mips32r6.decode => rel6.decode} (69%)
target/mips/tcg/mips64r6.decode deleted +0 -27
deleted file mode 100644
index b58d8009ccd..00000000000
@@ -1,27 +0,0 @@
-# MIPS64 Release 6 instruction set
-#
-# Copyright (C) 2020  Philippe Mathieu-Daudé
-#
-# SPDX-License-Identifier: LGPL-2.1-or-later
-#
-# Reference:
-#       MIPS Architecture for Programmers Volume II-A
-#       The MIPS64 Instruction Set Reference Manual, Revision 6.06
-#       (Document Number: MD00087-2B-MIPS64BIS-AFP-6.06)
-#
-
-&rtype              rs rt rd sa !extern
-
-&REMOVED            !extern
-
-@lsa                ...... rs:5 rt:5 rd:5 ... sa:2 ......   &rtype
-
-DLSA                000000 ..... ..... ..... 000 .. 010101  @lsa
-
-REMOVED             011010 ----- ----- ----------------     # LDL
-REMOVED             011011 ----- ----- ----------------     # LDR
-REMOVED             101100 ----- ----- ----------------     # SDL
-REMOVED             101101 ----- ----- ----------------     # SDR
-
-REMOVED             110100 ----- ----- ----------------     # LLD
-REMOVED             111100 ----- ----- ----------------     # SCD
target/mips/tcg/rel6.decode renamed from target/mips/tcg/mips32r6.decode +13 -0
similarity index 69%
rename from target/mips/tcg/mips32r6.decode
rename to target/mips/tcg/rel6.decode
index 837c991edc5..ed069c51662 100644
@@ -5,21 +5,29 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 #
 # Reference:
+#
 #       MIPS Architecture for Programmers Volume II-A
 #       The MIPS32 Instruction Set Reference Manual, Revision 6.06
 #       (Document Number: MD00086-2B-MIPS32BIS-AFP-06.06)
 #
+#       MIPS Architecture for Programmers Volume II-A
+#       The MIPS64 Instruction Set Reference Manual, Revision 6.06
+#       (Document Number: MD00087-2B-MIPS64BIS-AFP-6.06)
 
 &rtype              rs rt rd sa
 
 @lsa                ...... rs:5 rt:5 rd:5 ... sa:2 ......   &rtype
 
 LSA                 000000 ..... ..... ..... 000 .. 000101  @lsa
+DLSA                000000 ..... ..... ..... 000 .. 010101  @lsa
 
 REMOVED             010011 ----- ----- ----- ----- ------   # COP1X (COP3)
 
 REMOVED             011100 ----- ----- ----- ----- ------   # SPECIAL2
 
+REMOVED             011010 ----- ----- ----------------     # LDL
+REMOVED             011011 ----- ----- ----------------     # LDR
+
 REMOVED             011111 ----- ----- ----------  011001   # LWLE
 REMOVED             011111 ----- ----- ----------  011010   # LWRE
 REMOVED             011111 ----- ----- ----------  100001   # SWLE
@@ -28,9 +36,14 @@ REMOVED             011111 ----- ----- ----------  100010   # SWRE
 REMOVED             100010 ----- ----- ----------------     # LWL
 REMOVED             100110 ----- ----- ----------------     # LWR
 REMOVED             101010 ----- ----- ----------------     # SWL
+REMOVED             101100 ----- ----- ----------------     # SDL
+REMOVED             101101 ----- ----- ----------------     # SDR
 REMOVED             101110 ----- ----- ----------------     # SWR
 
 REMOVED             101111 ----- ----- ----------------     # CACHE
+
 REMOVED             110000 ----- ----- ----------------     # LL
 REMOVED             110011 ----- ----- ----------------     # PREF
+REMOVED             110100 ----- ----- ----------------     # LLD
 REMOVED             111000 ----- ----- ----------------     # SC
+REMOVED             111100 ----- ----- ----------------     # SCD
target/mips/tcg/rel6_translate.c +5 -11
index 0354370927d..ae2e023a817 100644
@@ -13,9 +13,8 @@
 #include "exec/helper-gen.h"
 #include "translate.h"
 
-/* Include the auto-generated decoder.  */
-#include "decode-mips32r6.c.inc"
-#include "decode-mips64r6.c.inc"
+/* Include the auto-generated decoders.  */
+#include "decode-rel6.c.inc"
 
 bool trans_REMOVED(DisasContext *ctx, arg_REMOVED *a)
 {
@@ -31,13 +30,8 @@ static bool trans_LSA(DisasContext *ctx, arg_rtype *a)
 
 static bool trans_DLSA(DisasContext *ctx, arg_rtype *a)
 {
+    if (TARGET_LONG_BITS != 64) {
+        return false;
+    }
     return gen_dlsa(ctx, a->rd, a->rt, a->rs, a->sa);
 }
-
-bool decode_isa_rel6(DisasContext *ctx, uint32_t insn)
-{
-    if (TARGET_LONG_BITS == 64 && decode_mips64r6(ctx, insn)) {
-        return true;
-    }
-    return decode_mips32r6(ctx, insn);
-}
target/mips/tcg/meson.build +1 -2
index bf4001e5741..70fa3dd57df 100644
@@ -1,6 +1,5 @@
 gen = [
-  decodetree.process('mips32r6.decode', extra_args: '--static-decode=decode_mips32r6'),
-  decodetree.process('mips64r6.decode', extra_args: '--static-decode=decode_mips64r6'),
+  decodetree.process('rel6.decode', extra_args: ['--decode=decode_isa_rel6']),
   decodetree.process('msa.decode', extra_args: '--decode=decode_ase_msa'),
   decodetree.process('tx79.decode', extra_args: '--static-decode=decode_tx79'),
 ]
Signature · 1 line
2.31.1
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH-for-6.2 3/4] target/mips: Merge 32-bit/64-bit release6 decodetree definitions

Quoted 4 lines · Philippe Mathieu-Daudé

We don't need to maintain 2 sets of decodetree definitions. Merge them into a single file.

Quoted 8 lines
---
  target/mips/tcg/mips64r6.decode               | 27 -------------------
  .../mips/tcg/{mips32r6.decode => rel6.decode} | 13 +++++++++
  target/mips/tcg/rel6_translate.c              | 16 ++++-------
  target/mips/tcg/meson.build                   |  3 +--
  4 files changed, 19 insertions(+), 40 deletions(-)

delete mode 100644 target/mips/tcg/mips64r6.decode rename target/mips/tcg/{mips32r6.decode => rel6.decode} (69%)

r~

#7 lore raw

PATCH 4/4 target/mips: Rename 'rtype' as 'r'

In reply to Philippe Mathieu-Daudé

We'll soon have more opcode and decoded arguments, and 'rtype' is not very helpful. Naming it simply 'r' ease reviewing the .decode files when we have many opcodes.

---
 target/mips/tcg/msa.decode       |  4 +--
 target/mips/tcg/rel6.decode      |  4 +--
 target/mips/tcg/tx79.decode      | 14 ++++----
 target/mips/tcg/msa_translate.c  |  4 +--
 target/mips/tcg/rel6_translate.c |  4 +--
 target/mips/tcg/tx79_translate.c | 62 ++++++++++++++++----------------
 6 files changed, 46 insertions(+), 46 deletions(-)
target/mips/tcg/msa.decode +2 -2
index bf132e36b9b..74d99f6862c 100644
@@ -11,11 +11,11 @@
 #       - The MIPS64 SIMD Architecture Module, Revision 1.12
 #         (Document Number: MD00868-1D-MSA64-AFP-01.12)
 
-&rtype              rs rt rd sa
+&r                  rs rt rd sa
 
 &msa_bz             df wt s16
 
-@lsa                ...... rs:5 rt:5 rd:5 ... sa:2 ......   &rtype
+@lsa                ...... rs:5 rt:5 rd:5 ... sa:2 ......   &r
 @bz                 ...... ... ..   wt:5 s16:16             &msa_bz df=3
 @bz_df              ...... ... df:2 wt:5 s16:16             &msa_bz
 
target/mips/tcg/rel6.decode +2 -2
index ed069c51662..d6989cf56e8 100644
@@ -14,9 +14,9 @@
 #       The MIPS64 Instruction Set Reference Manual, Revision 6.06
 #       (Document Number: MD00087-2B-MIPS64BIS-AFP-6.06)
 
-&rtype              rs rt rd sa
+&r                  rs rt rd sa
 
-@lsa                ...... rs:5 rt:5 rd:5 ... sa:2 ......   &rtype
+@lsa                ...... rs:5 rt:5 rd:5 ... sa:2 ......   &r
 
 LSA                 000000 ..... ..... ..... 000 .. 000101  @lsa
 DLSA                000000 ..... ..... ..... 000 .. 010101  @lsa
target/mips/tcg/tx79.decode +7 -7
index 03a25a5096d..57d87a2076a 100644
@@ -11,20 +11,20 @@
 # when creating helpers common to those for the individual
 # instruction patterns.
 
-&rtype           rs rt rd sa
+&r               rs rt rd sa
 
-&itype           base rt offset
+&i               base rt offset
 
 ###########################################################################
 # Named instruction formats.  These are generally used to
 # reduce the amount of duplication between instruction patterns.
 
-@rs_rt_rd       ...... rs:5  rt:5  rd:5  ..... ......   &rtype sa=0
-@rt_rd          ...... ..... rt:5  rd:5  ..... ......   &rtype rs=0 sa=0
-@rs             ...... rs:5  ..... ..........  ......   &rtype rt=0 rd=0 sa=0
-@rd             ...... ..........  rd:5  ..... ......   &rtype rs=0 rt=0 sa=0
+@rs_rt_rd       ...... rs:5  rt:5  rd:5  ..... ......   &r sa=0
+@rt_rd          ...... ..... rt:5  rd:5  ..... ......   &r sa=0 rs=0
+@rs             ...... rs:5  ..... ..........  ......   &r sa=0      rt=0 rd=0
+@rd             ...... ..........  rd:5  ..... ......   &r sa=0 rs=0 rt=0
 
-@ldst            ...... base:5 rt:5 offset:16            &itype
+@ldst            ...... base:5 rt:5 offset:16           &i
 
 ###########################################################################
 
target/mips/tcg/msa_translate.c +2 -2
index eed2eca6c92..8170a8df26b 100644
@@ -2261,12 +2261,12 @@ static bool trans_MSA(DisasContext *ctx, arg_MSA *a)
     return true;
 }
 
-static bool trans_LSA(DisasContext *ctx, arg_rtype *a)
+static bool trans_LSA(DisasContext *ctx, arg_r *a)
 {
     return gen_lsa(ctx, a->rd, a->rt, a->rs, a->sa);
 }
 
-static bool trans_DLSA(DisasContext *ctx, arg_rtype *a)
+static bool trans_DLSA(DisasContext *ctx, arg_r *a)
 {
     if (TARGET_LONG_BITS != 64) {
         return false;
target/mips/tcg/rel6_translate.c +2 -2
index ae2e023a817..d631851258a 100644
@@ -23,12 +23,12 @@ bool trans_REMOVED(DisasContext *ctx, arg_REMOVED *a)
     return true;
 }
 
-static bool trans_LSA(DisasContext *ctx, arg_rtype *a)
+static bool trans_LSA(DisasContext *ctx, arg_r *a)
 {
     return gen_lsa(ctx, a->rd, a->rt, a->rs, a->sa);
 }
 
-static bool trans_DLSA(DisasContext *ctx, arg_rtype *a)
+static bool trans_DLSA(DisasContext *ctx, arg_r *a)
 {
     if (TARGET_LONG_BITS != 64) {
         return false;
target/mips/tcg/tx79_translate.c +31 -31

236 lines not on this page · raw message

Signature · 1 line
2.31.1
Reviewed-by on v1 4/4
#8 lore raw

Re: [PATCH-for-6.2 4/4] target/mips: Rename 'rtype' as 'r'

Quoted 5 lines · Philippe Mathieu-Daudé

We'll soon have more opcode and decoded arguments, and 'rtype' is not very helpful. Naming it simply 'r' ease reviewing the .decode files when we have many opcodes.

Quoted 8 lines
---
  target/mips/tcg/msa.decode       |  4 +--
  target/mips/tcg/rel6.decode      |  4 +--
  target/mips/tcg/tx79.decode      | 14 ++++----
  target/mips/tcg/msa_translate.c  |  4 +--
  target/mips/tcg/rel6_translate.c |  4 +--
  target/mips/tcg/tx79_translate.c | 62 ++++++++++++++++----------------
  6 files changed, 46 insertions(+), 46 deletions(-)

r~

#9 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

Minor cleanups while looking at converting more opcodes to decodetree.

Philippe Mathieu-Daudé (4):
target/mips: Simpify PREF opcode
target/mips: Decode vendor extensions before MIPS ISAs target/mips: Merge 32-bit/64-bit release6 decodetree definitions target/mips: Rename 'rtype' as 'r'

Thanks, series applied to mips-next tree.