Skip to contentSkip to conversation

disas/riscv: Reorganize the disassembler

RFC PATCH Superseded Richard Henderson 3 participants 119 messages Aug 9 – Aug 12 RISC-V Page 1 of 3

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover disas/riscv: Reorganize the disassembler

One of my pet peeves is the non-automatic addition of indexes to rv_op which must match entries in rvi_opcode_data[].

Reorganize the disassembler to pass around pointers to individual opcodes rather than pointer to table + index. To do that, rewrite how pseudo ops are processed, replacing indexes with pointers. Merge the decompression of compressed opcodes into the pseudo ops mechanism.

Fix quite a few bugs found in the process, mostly related to isa level.

I grabbed Tiancheng's bug fixes to start, to avoid reworking those.

r~

Richard Henderson (51):
disas/riscv: Move operand extractors earlier in file disas/riscv: Reduce rv_insn to uint32_t
disas/riscv: Tidy dec initialization in disasm_inst disas/riscv: Pass rv_opcode_data pointer to decode_inst_operands disas/riscv: Pass rv_opcode_data pointer to/from
decode_inst_decompress
disas/riscv: Pass rv_opcode_data pointer to/from
decode_inst_lift_pseudo
disas/riscv: Pass rv_opcode_data pointer to format_inst disas/riscv: Tidy disasm_inst main loop
disas/riscv: Set dec->opcode_data in decode function disas/riscv: Drop explicit zero of rv_opcode_data fields disas/riscv: Drop useless const in structures disas/riscv: Drop codec from rv_decode
disas/riscv: Handle c.addi4spn imm != 0 during decode disas/riscv: Simplify c.addi
disas/riscv: Handle c.lui imm != 0 during decode disas/riscv: Handle c.{srli,srai} imm during decode disas/riscv: Handle c.slli imm != 0 during decode disas/riscv: Do not recognize c.{addw,subw} with rv32 disas/riscv: Remove rvcd_imm_nz
disas/riscv: Unify decomp_rv{32,64,128}
disas/riscv: Drop always true branch psudeos disas/riscv: Handle aliases of csrrw during decode disas/riscv: Handle aliases of csrrs during decode disas/riscv: Handle aliases of csrrwi during decode disas/riscv: Break pseudo loop for jal and jalr disas/riscv: Allow decode_inst_lift_pseudo to loop disas/riscv: Handle decompression via decode_inst_lift_pseudo disas/riscv: Drop format from DECOMP insns disas/riscv: Tidy rv_comp_data terminators disas/riscv: Chain "ret" pseudo off "jr" pseudo disas/riscv: Chain "nop" pseudo off "mv" pseudo disas/riscv: Use rv_codec_illegal for pseudos disas/riscv: Simplify some insn decompressions disas/riscv: Store op pointer in rv_comp_data disas/riscv: Return rv_opcode_data pointer from decoders disas/riscv: Reject all of OP-32 and OP-IMM-32 for RV32 disas/riscv: Fix rv32 encoding of zext.h
disas/riscv: Fix isa decoding of rev8
disas/riscv: Fix typo in th.lbib format
disas/riscv: Split ventana_opcode_data
disas/riscv: Split xlrbr_opcode_data
disas/riscv: Split xthead_opcode_data
disas/riscv: Move rv_op_illegal to riscv.c disas/riscv: Split out riscv-op.c.inc
disas/riscv: Merge all mop.r.n to one pattern disas/riscv: Merge all mop.rr.n to one pattern disas/riscv: Merge all c.mop.n to one pattern disas/riscv: Tidy decode of c.mop.n
disas/riscv: Tidy decode of mop.r.n and mop.rr.n disas/riscv: Split rvi_opcode_data
disas/riscv: Sort riscv-op.c.inc

TANG Tiancheng (5):
disas/riscv: Fix th.srri decoding
disas/riscv: Fix 6-bit immediate extraction disas/riscv: Use signed type for vector immediates disas/riscv: Decode unsigned vector immediates as unsigned disas/riscv: Use extract helpers for operand fields

 disas/riscv-xlrbr.h           |    4 +-
 disas/riscv-xthead.h          |   24 +-
 disas/riscv-xventana.h        |    4 +-
 disas/riscv.h                 |   47 +-
 disas/riscv-xlrbr.c           |   57 +-
 disas/riscv-xthead.c          |  507 +---
 disas/riscv-xventana.c        |   23 +-
 disas/riscv.c                 | 5255 ++++++++++-----------------------
 disas/riscv-op.c.inc          |  913 ++++++
 disas/riscv-xlrbr-op.c.inc    |    8 +
 disas/riscv-xthead-op.c.inc   |  125 +
 disas/riscv-xventana-op.c.inc |    2 +
 12 files changed, 2852 insertions(+), 4117 deletions(-)
 create mode 100644 disas/riscv-op.c.inc
 create mode 100644 disas/riscv-xlrbr-op.c.inc
 create mode 100644 disas/riscv-xthead-op.c.inc
 create mode 100644 disas/riscv-xventana-op.c.inc
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/56 disas/riscv: Fix th.srri decoding

From: TANG Tiancheng <[email protected]>

target/riscv/xthead.decode defines th.srri as funct6=000100 in bits 31:26, with the 6-bit immediate in bits 25:20.

decode_xtheadbb() switches on bits 31:25, i.e. funct6 plus imm[5]. Therefore valid th.srri encodings are 0001000 and 0001001. The current 0000100 and 0000101 cases use the wrong funct6 value and decode valid th.srri instructions as illegal.

Fix the cases to match funct6=000100 with both imm[5] values.

Fixes 318df7238b9f ("disas/riscv: Add support for XThead* instructions")

Message-Id: <20260703-b4-disas-xthead-fix-riscv-next-v4-1-84c566330bc7@linux.alibaba.com>

---
 disas/riscv-xthead.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
disas/riscv-xthead.c +4 -2
index fcca326d1c..2f2ddb8dd9 100644
@@ -315,8 +315,10 @@ void decode_xtheadbb(rv_decode *dec, rv_isa isa)
                         op = rv_op_th_revw;
                     }
                     break;
-                case 0b0000100:
-                case 0b0000101: op = rv_op_th_srri; break;
+                case 0b0001000:
+                case 0b0001001:
+                    op = rv_op_th_srri;
+                    break;
                 }
                 break;
             case 2: op = rv_op_th_ext; break;
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 1/56
#2 lore raw

Re: [PATCH 01/56] disas/riscv: Fix th.srri decoding

Quoted 13 lines · Richard Henderson

From: TANG Tiancheng <[email protected]>

target/riscv/xthead.decode defines th.srri as funct6=000100 in bits 31:26, with the 6-bit immediate in bits 25:20.

decode_xtheadbb() switches on bits 31:25, i.e. funct6 plus imm[5]. Therefore valid th.srri encodings are 0001000 and 0001001. The current 0000100 and 0000101 cases use the wrong funct6 value and decode valid th.srri instructions as illegal.

Fix the cases to match funct6=000100 with both imm[5] values.

Fixes 318df7238b9f ("disas/riscv: Add support for XThead*
Quoted 8 lines

instructions")

Reviewed-by Daniel Henrique Barboza

<[email protected]>
Message-Id:
<20260703-b4-disas-xthead-fix-riscv-next-v4-1-84c566330bc7@linux.alib aba.com>

Alistair

Quoted 21 lines

---
 disas/riscv-xthead.c | 6 ++++--

 1 file changed, 4 insertions(+), 2 deletions(-)
disas/riscv-xthead.c +4 -2
index fcca326d1c..2f2ddb8dd9 100644
@@ -315,8 +315,10 @@ void decode_xtheadbb(rv_decode *dec, rv_isa isa)
                          op = rv_op_th_revw;
                      }
                      break;
-                case 0b0000100:
-                case 0b0000101: op = rv_op_th_srri; break;
+                case 0b0001000:
+                case 0b0001001:
+                    op = rv_op_th_srri;
+                    break;
                  }
                  break;
              case 2: op = rv_op_th_ext; break;
#3 lore raw

PATCH 2/56 disas/riscv: Fix 6-bit immediate extraction

In reply to Richard Henderson

From: TANG Tiancheng <[email protected]>

rv_codec_r2_imm6 is used for XThead instructions whose 6-bit immediate field is encoded in bits 25:20. The old expression left-shifted by 38 and then right-shifted by 60, so it kept only bits 25:22.

Use extract32() to decode bits 25:20 directly. This fixes the immediate printed for th.srri and th.tst.

Fixes 318df7238b9f ("disas/riscv: Add support for XThead* instructions")

Message-Id: <20260703-b4-disas-xthead-fix-riscv-next-v4-2-84c566330bc7@linux.alibaba.com>

---
 disas/riscv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
disas/riscv.c +1 -1
index 7f1b262773..fdf75a12ef 100644
@@ -4546,7 +4546,7 @@ static uint32_t operand_zcmp_rlist(rv_inst inst)
 
 static uint32_t operand_imm6(rv_inst inst)
 {
-    return (inst << 38) >> 60;
+    return extract32(inst, 20, 6);
 }
 
 static uint32_t operand_imm2(rv_inst inst)
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 2/56
#4 lore raw

Re: [PATCH 02/56] disas/riscv: Fix 6-bit immediate extraction

Quoted 12 lines · Richard Henderson

From: TANG Tiancheng <[email protected]>

rv_codec_r2_imm6 is used for XThead instructions whose 6-bit immediate field is encoded in bits 25:20. The old expression left-shifted by 38 and then right-shifted by 60, so it kept only bits 25:22.

Use extract32() to decode bits 25:20 directly. This fixes the immediate printed for th.srri and th.tst.

Fixes 318df7238b9f ("disas/riscv: Add support for XThead*

instructions")

Quoted 8 lines
Reviewed-by Daniel Henrique Barboza

<[email protected]>
Message-Id:
<20260703-b4-disas-xthead-fix-riscv-next-v4-2-84c566330bc7@linux.alib aba.com>

Alistair

Quoted 18 lines

---
 disas/riscv.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
disas/riscv.c +0 -0
index 7f1b262773..fdf75a12ef 100644
@@ -4546,7 +4546,7 @@ static uint32_t operand_zcmp_rlist(rv_inst
 inst)


 static uint32_t operand_imm6(rv_inst inst)
 {
-    return (inst << 38) >> 60;
+    return extract32(inst, 20, 6);
 }

 static uint32_t operand_imm2(rv_inst inst)

#5 lore raw

PATCH 3/56 disas/riscv: Use signed type for vector immediates

In reply to Richard Henderson

From: TANG Tiancheng <[email protected]>

operand_vimm() sign-extends the 5-bit vector immediate field in bits 19:15, but returns uint32_t. This sends negative immediates through an unsigned type before they are assigned to rv_decode.imm.

Return int32_t to match the signed value extracted by the helper.

Message-Id: <20260703-b4-disas-xthead-fix-riscv-next-v4-3-84c566330bc7@linux.alibaba.com>

---
 disas/riscv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
disas/riscv.c +1 -1
index fdf75a12ef..967739bdbb 100644
@@ -4487,7 +4487,7 @@ static uint32_t operand_cimmq(rv_inst inst)
         ((inst << 57) >> 62) << 6;
 }
 
-static uint32_t operand_vimm(rv_inst inst)
+static int32_t operand_vimm(rv_inst inst)
 {
     return (int64_t)(inst << 44) >> 59;
 }
Signature · 1 line
2.43.0
Reviewed-by on v1 3/56
#6 lore raw

Re: [PATCH 03/56] disas/riscv: Use signed type for vector immediates

Quoted 10 lines · Richard Henderson

From: TANG Tiancheng <[email protected]>

operand_vimm() sign-extends the 5-bit vector immediate field in bits 19:15, but returns uint32_t. This sends negative immediates through an unsigned type before they are assigned to rv_decode.imm.

Return int32_t to match the signed value extracted by the helper.

(Missing your S-o-b)

Quoted 4 lines

Message-Id: <20260703-b4-disas-xthead-fix-riscv-next-v4-3-84c566330bc7@linux.alibaba.com>

---
  disas/riscv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by Alistair Francis on v1 3/56
#7 lore raw

Re: [PATCH 03/56] disas/riscv: Use signed type for vector immediates

In reply to Richard Henderson
Quoted 7 lines · Richard Henderson

From: TANG Tiancheng <[email protected]>

operand_vimm() sign-extends the 5-bit vector immediate field in bits 19:15, but returns uint32_t. This sends negative immediates through an
unsigned type before they are assigned to rv_decode.imm.

Quoted 7 lines

Return int32_t to match the signed value extracted by the helper.

Message-Id:
<20260703-b4-disas-xthead-fix-riscv-next-v4-3-84c566330bc7@linux.alib aba.com>

Alistair

Quoted 17 lines

---
 disas/riscv.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
disas/riscv.c +0 -0
index fdf75a12ef..967739bdbb 100644
@@ -4487,7 +4487,7 @@ static uint32_t operand_cimmq(rv_inst inst)
          ((inst << 57) >> 62) << 6;
  }

disas/riscv.c +1 -1
-static uint32_t operand_vimm(rv_inst inst)
+static int32_t operand_vimm(rv_inst inst)

 {
     return (int64_t)(inst << 44) >> 59;
 }

#8 lore raw

PATCH 4/56 disas/riscv: Decode unsigned vector immediates as unsigned

In reply to Richard Henderson

From: TANG Tiancheng <[email protected]>

rv_codec_v_i decodes all .vi operands with operand_vimm(), which sign-extends bits 19:15. That matches spec operands named imm, but not the .vi forms whose operand is uimm; uimm=31 is decoded as -1 and printed by the shared 6-bit 'u' formatter as 63.

Add rv_codec_v_i_u/operand_vuimm() for the 5-bit uimm forms: vsll.vi, vsrl.vi, vsra.vi, vnsrl.wi, vnsra.wi, vssrl.vi, vssra.vi, vnclipu.wi, vnclip.wi, vslideup.vi, vslidedown.vi, vrgather.vi, vaeskf1.vi, vaeskf2.vi, vsm3c.vi, vsm4k.vi and vwsll.vi. The remaining rv_codec_v_i entries are the signed imm forms.

Fixes 07f4964d1785 ("disas/riscv.c: rvv: Add disas support for vector instructions")
Fixes 9d92f56d4a44 ("disas/riscv: Add support for vector crypto extensions")

Message-Id: <20260703-b4-disas-xthead-fix-riscv-next-v4-4-84c566330bc7@linux.alibaba.com>

---
 disas/riscv.h |  1 +
 disas/riscv.c | 45 ++++++++++++++++++++++++++++-----------------
 2 files changed, 29 insertions(+), 17 deletions(-)
disas/riscv.h +1 -0
index 379e642ec8..91ada8b531 100644
@@ -149,6 +149,7 @@ typedef enum {
     rv_codec_v_r,
     rv_codec_v_ldst,
     rv_codec_v_i,
+    rv_codec_v_i_u,
     rv_codec_vsetvli,
     rv_codec_vsetivli,
     rv_codec_vror_vi,
disas/riscv.c +28 -17

112 lines not on this page · raw message

Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 4/56
#9 lore raw

Re: [PATCH 04/56] disas/riscv: Decode unsigned vector immediates as unsigned

Quoted 17 lines · Richard Henderson

From: TANG Tiancheng <[email protected]>

rv_codec_v_i decodes all .vi operands with operand_vimm(), which sign-extends bits 19:15. That matches spec operands named imm, but not the
.vi forms whose operand is uimm; uimm=31 is decoded as -1 and printed by
the shared 6-bit 'u' formatter as 63.

Add rv_codec_v_i_u/operand_vuimm() for the 5-bit uimm forms: vsll.vi, vsrl.vi, vsra.vi, vnsrl.wi, vnsra.wi, vssrl.vi, vssra.vi, vnclipu.wi, vnclip.wi, vslideup.vi, vslidedown.vi, vrgather.vi, vaeskf1.vi, vaeskf2.vi, vsm3c.vi, vsm4k.vi and vwsll.vi. The remaining rv_codec_v_i
entries are the signed imm forms.

Fixes 07f4964d1785 ("disas/riscv.c: rvv: Add disas support for
Quoted 8 lines

vector instructions")

Fixes 9d92f56d4a44 ("disas/riscv: Add support for vector crypto

extensions")

Message-Id:
<20260703-b4-disas-xthead-fix-riscv-next-v4-4-84c566330bc7@linux.alib aba.com>

Alistair

Quoted 217 lines

---
 disas/riscv.h |  1 +
 disas/riscv.c | 45 ++++++++++++++++++++++++++++-----------------

 2 files changed, 29 insertions(+), 17 deletions(-)
disas/riscv.h +1 -0
index 379e642ec8..91ada8b531 100644
@@ -149,6 +149,7 @@ typedef enum {
      rv_codec_v_r,
      rv_codec_v_ldst,
      rv_codec_v_i,
+    rv_codec_v_i_u,
      rv_codec_vsetvli,
      rv_codec_vsetivli,
      rv_codec_vror_vi,
disas/riscv.c +0 -0
index 967739bdbb..82b962dc71 100644
@@ -1803,19 +1803,19 @@ const rv_opcode_data rvi_opcode_data[] = {

     { "vxor.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
     { "vsll.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vsll.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vsll.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
+    { "vsll.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
     { "vsrl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vsrl.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vsrl.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
+    { "vsrl.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
     { "vsra.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vsra.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vsra.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
+    { "vsra.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
     { "vnsrl.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vnsrl.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vnsrl.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
+    { "vnsrl.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
     { "vnsra.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vnsra.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vnsra.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
+    { "vnsra.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
     { "vmseq.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vmseq.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
     { "vmseq.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },

disas/riscv.c +0 -0
@@ -1909,16 +1909,16 @@ const rv_opcode_data rvi_opcode_data[] = {

     { "vsmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
     { "vssrl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vssrl.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vssrl.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
+    { "vssrl.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
     { "vssra.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vssra.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vssra.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
+    { "vssra.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
     { "vnclipu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vnclipu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vnclipu.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
+    { "vnclipu.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
     { "vnclip.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vnclip.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vnclip.wi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
+    { "vnclip.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
     { "vfadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vfadd.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
     { "vfsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },

disas/riscv.c +2 -2
@@ -2048,15 +2048,15 @@ const rv_opcode_data rvi_opcode_data[] = {
      { "vfmv.f.s", rv_codec_v_r, rv_fmt_fd_vs2, NULL, 0, 0, 0 },
      { "vfmv.s.f", rv_codec_v_r, rv_fmt_vd_fs1, NULL, 0, 0, 0 },
      { "vslideup.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0,
 0 },
-    { "vslideup.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0,
 0, 0 },
+    { "vslideup.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0,
 0, 0 },
      { "vslide1up.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0,
 0, 0 },
      { "vslidedown.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0,
 0, 0 },
-    { "vslidedown.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0,
 0, 0 },
+    { "vslidedown.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL,
 0, 0, 0 },
      { "vslide1down.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0,

0, 0 },
     { "vrgather.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vrgatherei16.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vrgather.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vrgather.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
+    { "vrgather.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
     { "vcompress.vm", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 },
     { "vmv1r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, { "vmv2r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },

disas/riscv.c +2 -2
@@ -2144,8 +2144,8 @@ const rv_opcode_data rvi_opcode_data[] = {
      { "vaesef.vs", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
      { "vaesem.vv", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
      { "vaesem.vs", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
-    { "vaeskf1.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm, NULL, 0, 0, 0
 },
-    { "vaeskf2.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm, NULL, 0, 0, 0
 },
+    { "vaeskf1.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm, NULL, 0, 0,
 0 },
+    { "vaeskf2.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm, NULL, 0, 0,

0 },
     { "vaesz.vs", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, { "vandn.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vandn.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },

disas/riscv.c +0 -0
@@ -2169,14 +2169,14 @@ const rv_opcode_data rvi_opcode_data[] = {

     { "vsha2ch.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 },
     { "vsha2cl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 },
     { "vsha2ms.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 },
-    { "vsm3c.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm, NULL, 0, 0, 0 }, +    { "vsm3c.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm, NULL, 0, 0, 0 },
     { "vsm3me.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 }, -    { "vsm4k.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm, NULL, 0, 0, 0 }, +    { "vsm4k.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm, NULL, 0, 0, 0 },
     { "vsm4r.vv", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, { "vsm4r.vs", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, { "vwsll.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
     { "vwsll.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vwsll.vi", rv_codec_v_i, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
+    { "vwsll.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
     { "amocas.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
     { "amocas.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
     { "amocas.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },

disas/riscv.c +0 -0
@@ -4492,6 +4492,11 @@ static int32_t operand_vimm(rv_inst inst)
      return (int64_t)(inst << 44) >> 59;
  }

disas/riscv.c +5 -0
+static uint32_t operand_vuimm(rv_inst inst)
+{
+    return extract32(inst, 15, 5);
+}
+

 static uint32_t operand_vzimm11(rv_inst inst)
 {
     return (inst << 33) >> 53;

disas/riscv.c +6 -0
@@ -4895,6 +4900,12 @@ static void decode_inst_operands(rv_decode
 *dec, rv_isa isa)
          dec->imm = operand_vimm(inst);
          dec->vm = operand_vm(inst);
          break;
+    case rv_codec_v_i_u:
+        dec->rd = operand_rd(inst);
+        dec->rs2 = operand_rs2(inst);
+        dec->imm = operand_vuimm(inst);
+        dec->vm = operand_vm(inst);
+        break;

     case rv_codec_vror_vi:
         dec->rd = operand_rd(inst);
         dec->rs2 = operand_rs2(inst);

#10 lore raw

PATCH 5/56 disas/riscv: Use extract helpers for operand fields

In reply to Richard Henderson

From: TANG Tiancheng <[email protected]>

Replace shift-based operand extraction with extract32() and sextract32(). For signed immediates, use sextract32() on the field that carries the sign bit and combine it with the remaining extract32() fields.

The RISC-V disassembler currently follows target/riscv/internals.h:
insn_len() and decodes only 16-bit or 32-bit instruction lengths, so the converted fields are all in the low 32 bits of rv_inst.

Message-Id: <20260703-b4-disas-xthead-fix-riscv-next-v4-5-84c566330bc7@linux.alibaba.com>

---
 disas/riscv.c | 214 +++++++++++++++++++++++++-------------------------
 1 file changed, 107 insertions(+), 107 deletions(-)
disas/riscv.c +107 -107
index 82b962dc71..2ba0a6a73a 100644
@@ -4202,82 +4202,82 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
 
 static uint32_t operand_rd(rv_inst inst)
 {
-    return (inst << 52) >> 59;
+    return extract32(inst, 7, 5);
 }
 
 static uint32_t operand_rs1(rv_inst inst)
 {
-    return (inst << 44) >> 59;
+    return extract32(inst, 15, 5);
 }
 
 static uint32_t operand_rs2(rv_inst inst)
 {
-    return (inst << 39) >> 59;
+    return extract32(inst, 20, 5);
 }
 
 static uint32_t operand_rs3(rv_inst inst)
 {
-    return (inst << 32) >> 59;
+    return extract32(inst, 27, 5);
 }
 
 static uint32_t operand_aq(rv_inst inst)
 {
-    return (inst << 37) >> 63;
+    return extract32(inst, 26, 1);
 }
 
 static uint32_t operand_rl(rv_inst inst)
 {
-    return (inst << 38) >> 63;
+    return extract32(inst, 25, 1);
 }
 
 static uint32_t operand_pred(rv_inst inst)
 {
-    return (inst << 36) >> 60;
+    return extract32(inst, 24, 4);
 }
 
 static uint32_t operand_succ(rv_inst inst)
 {
-    return (inst << 40) >> 60;
+    return extract32(inst, 20, 4);
 }
 
 static uint32_t operand_rm(rv_inst inst)
 {
-    return (inst << 49) >> 61;
+    return extract32(inst, 12, 3);
 }
 
 static uint32_t operand_shamt5(rv_inst inst)
 {
-    return (inst << 39) >> 59;
+    return extract32(inst, 20, 5);
 }
 
 static uint32_t operand_shamt6(rv_inst inst)
 {
-    return (inst << 38) >> 58;
+    return extract32(inst, 20, 6);
 }
 
 static uint32_t operand_shamt7(rv_inst inst)
 {
-    return (inst << 37) >> 57;
+    return extract32(inst, 20, 7);
 }
 
 static uint32_t operand_crdq(rv_inst inst)
 {
-    return (inst << 59) >> 61;
+    return extract32(inst, 2, 3);
 }
 
 static uint32_t operand_crs1q(rv_inst inst)
 {
-    return (inst << 54) >> 61;
+    return extract32(inst, 7, 3);
 }
 
 static uint32_t operand_crs1rdq(rv_inst inst)
 {
-    return (inst << 54) >> 61;
+    return extract32(inst, 7, 3);
 }
 
 static uint32_t operand_crs2q(rv_inst inst)
 {
-    return (inst << 59) >> 61;
+    return extract32(inst, 2, 3);
 }
 
 static uint32_t calculate_xreg(uint32_t sreg)
@@ -4287,80 +4287,80 @@ static uint32_t calculate_xreg(uint32_t sreg)
 
 static uint32_t operand_sreg1(rv_inst inst)
 {
-    return calculate_xreg((inst << 54) >> 61);
+    return calculate_xreg(extract32(inst, 7, 3));
 }
 
 static uint32_t operand_sreg2(rv_inst inst)
 {
-    return calculate_xreg((inst << 59) >> 61);
+    return calculate_xreg(extract32(inst, 2, 3));
 }
 
 static uint32_t operand_crd(rv_inst inst)
 {
-    return (inst << 52) >> 59;
+    return extract32(inst, 7, 5);
 }
 
 static uint32_t operand_crs1(rv_inst inst)
 {
-    return (inst << 52) >> 59;
+    return extract32(inst, 7, 5);
 }
 
 static uint32_t operand_crs1rd(rv_inst inst)
 {
-    return (inst << 52) >> 59;
+    return extract32(inst, 7, 5);
 }
 
 static uint32_t operand_crs2(rv_inst inst)
 {
-    return (inst << 57) >> 59;
+    return extract32(inst, 2, 5);
 }
 
 static uint32_t operand_cimmsh5(rv_inst inst)
 {
-    return (inst << 57) >> 59;
+    return extract32(inst, 2, 5);
 }
 
 static uint32_t operand_csr12(rv_inst inst)
 {
-    return (inst << 32) >> 52;
+    return extract32(inst, 20, 12);
 }
 
 static int32_t operand_imm12(rv_inst inst)
 {
-    return ((int64_t)inst << 32) >> 52;
+    return sextract32(inst, 20, 12);
 }
 
 static int32_t operand_imm20(rv_inst inst)
 {
-    return (((int64_t)inst << 32) >> 44) << 12;
+    return sextract32(inst, 12, 20) << 12;
 }
 
 static int32_t operand_jimm20(rv_inst inst)
 {
-    return (((int64_t)inst << 32) >> 63) << 20 |
-        ((inst << 33) >> 54) << 1 |
-        ((inst << 43) >> 63) << 11 |
-        ((inst << 44) >> 56) << 12;
+    return sextract32(inst, 31, 1) << 20 |
+        extract32(inst, 21, 10) << 1 |
+        extract32(inst, 20, 1) << 11 |
+        extract32(inst, 12, 8) << 12;
 }
 
 static int32_t operand_simm12(rv_inst inst)
 {
-    return (((int64_t)inst << 32) >> 57) << 5 |
-        (inst << 52) >> 59;
+    return sextract32(inst, 25, 7) << 5 |
+        extract32(inst, 7, 5);
 }
 
 static int32_t operand_sbimm12(rv_inst inst)
 {
-    return (((int64_t)inst << 32) >> 63) << 12 |
-        ((inst << 33) >> 58) << 5 |
-        ((inst << 52) >> 60) << 1 |
-        ((inst << 56) >> 63) << 11;
+    return sextract32(inst, 31, 1) << 12 |
+        extract32(inst, 25, 6) << 5 |
+        extract32(inst, 8, 4) << 1 |
+        extract32(inst, 7, 1) << 11;
 }
 
 static uint32_t operand_cimmshl6(rv_inst inst, rv_isa isa)
 {
-    int imm = ((inst << 51) >> 63) << 5 |
-        (inst << 57) >> 59;
+    int imm = extract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
     if (isa == rv128) {
         imm = imm ? imm : 64;
     }
@@ -4369,8 +4369,8 @@ static uint32_t operand_cimmshl6(rv_inst inst, rv_isa isa)
 
 static uint32_t operand_cimmshr6(rv_inst inst, rv_isa isa)
 {
-    int imm = ((inst << 51) >> 63) << 5 |
-        (inst << 57) >> 59;
+    int imm = extract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
     if (isa == rv128) {
         imm = imm | (imm & 32) << 1;
         imm = imm ? imm : 64;
@@ -4380,116 +4380,116 @@ static uint32_t operand_cimmshr6(rv_inst inst, rv_isa isa)
 
 static int32_t operand_cimmi(rv_inst inst)
 {
-    return (((int64_t)inst << 51) >> 63) << 5 |
-        (inst << 57) >> 59;
+    return sextract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
 }
 
 static int32_t operand_cimmui(rv_inst inst)
 {
-    return (((int64_t)inst << 51) >> 63) << 17 |
-        ((inst << 57) >> 59) << 12;
+    return sextract32(inst, 12, 1) << 17 |
+        extract32(inst, 2, 5) << 12;
 }
 
 static uint32_t operand_cimmlwsp(rv_inst inst)
 {
-    return ((inst << 51) >> 63) << 5 |
-        ((inst << 57) >> 61) << 2 |
-        ((inst << 60) >> 62) << 6;
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 4, 3) << 2 |
+        extract32(inst, 2, 2) << 6;
 }
 
 static uint32_t operand_cimmldsp(rv_inst inst)
 {
-    return ((inst << 51) >> 63) << 5 |
-        ((inst << 57) >> 62) << 3 |
-        ((inst << 59) >> 61) << 6;
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 5, 2) << 3 |
+        extract32(inst, 2, 3) << 6;
 }
 
 static uint32_t operand_cimmlqsp(rv_inst inst)
 {
-    return ((inst << 51) >> 63) << 5 |
-        ((inst << 57) >> 63) << 4 |
-        ((inst << 58) >> 60) << 6;
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 6, 1) << 4 |
+        extract32(inst, 2, 4) << 6;
 }
 
 static int32_t operand_cimm16sp(rv_inst inst)
 {
-    return (((int64_t)inst << 51) >> 63) << 9 |
-        ((inst << 57) >> 63) << 4 |
-        ((inst << 58) >> 63) << 6 |
-        ((inst << 59) >> 62) << 7 |
-        ((inst << 61) >> 63) << 5;
+    return sextract32(inst, 12, 1) << 9 |
+        extract32(inst, 6, 1) << 4 |
+        extract32(inst, 5, 1) << 6 |
+        extract32(inst, 3, 2) << 7 |
+        extract32(inst, 2, 1) << 5;
 }
 
 static int32_t operand_cimmj(rv_inst inst)
 {
-    return (((int64_t)inst << 51) >> 63) << 11 |
-        ((inst << 52) >> 63) << 4 |
-        ((inst << 53) >> 62) << 8 |
-        ((inst << 55) >> 63) << 10 |
-        ((inst << 56) >> 63) << 6 |
-        ((inst << 57) >> 63) << 7 |
-        ((inst << 58) >> 61) << 1 |
-        ((inst << 61) >> 63) << 5;
+    return sextract32(inst, 12, 1) << 11 |
+        extract32(inst, 11, 1) << 4 |
+        extract32(inst, 9, 2) << 8 |
+        extract32(inst, 8, 1) << 10 |
+        extract32(inst, 7, 1) << 6 |
+        extract32(inst, 6, 1) << 7 |
+        extract32(inst, 3, 3) << 1 |
+        extract32(inst, 2, 1) << 5;
 }
 
 static int32_t operand_cimmb(rv_inst inst)
 {
-    return (((int64_t)inst << 51) >> 63) << 8 |
-        ((inst << 52) >> 62) << 3 |
-        ((inst << 57) >> 62) << 6 |
-        ((inst << 59) >> 62) << 1 |
-        ((inst << 61) >> 63) << 5;
+    return sextract32(inst, 12, 1) << 8 |
+        extract32(inst, 10, 2) << 3 |
+        extract32(inst, 5, 2) << 6 |
+        extract32(inst, 3, 2) << 1 |
+        extract32(inst, 2, 1) << 5;
 }
 
 static uint32_t operand_cimmswsp(rv_inst inst)
 {
-    return ((inst << 51) >> 60) << 2 |
-        ((inst << 55) >> 62) << 6;
+    return extract32(inst, 9, 4) << 2 |
+        extract32(inst, 7, 2) << 6;
 }
 
 static uint32_t operand_cimmsdsp(rv_inst inst)
 {
-    return ((inst << 51) >> 61) << 3 |
-        ((inst << 54) >> 61) << 6;
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 7, 3) << 6;
 }
 
 static uint32_t operand_cimmsqsp(rv_inst inst)
 {
-    return ((inst << 51) >> 62) << 4 |
-        ((inst << 53) >> 60) << 6;
+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 7, 4) << 6;
 }
 
 static uint32_t operand_cimm4spn(rv_inst inst)
 {
-    return ((inst << 51) >> 62) << 4 |
-        ((inst << 53) >> 60) << 6 |
-        ((inst << 57) >> 63) << 2 |
-        ((inst << 58) >> 63) << 3;
+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 7, 4) << 6 |
+        extract32(inst, 6, 1) << 2 |
+        extract32(inst, 5, 1) << 3;
 }
 
 static uint32_t operand_cimmw(rv_inst inst)
 {
-    return ((inst << 51) >> 61) << 3 |
-        ((inst << 57) >> 63) << 2 |
-        ((inst << 58) >> 63) << 6;
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 6, 1) << 2 |
+        extract32(inst, 5, 1) << 6;
 }
 
 static uint32_t operand_cimmd(rv_inst inst)
 {
-    return ((inst << 51) >> 61) << 3 |
-        ((inst << 57) >> 62) << 6;
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 5, 2) << 6;
 }
 
 static uint32_t operand_cimmq(rv_inst inst)
 {
-    return ((inst << 51) >> 62) << 4 |
-        ((inst << 53) >> 63) << 8 |
-        ((inst << 57) >> 62) << 6;
+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 10, 1) << 8 |
+        extract32(inst, 5, 2) << 6;
 }
 
 static int32_t operand_vimm(rv_inst inst)
 {
-    return (int64_t)(inst << 44) >> 59;
+    return sextract32(inst, 15, 5);
 }
 
 static uint32_t operand_vuimm(rv_inst inst)
@@ -4499,54 +4499,54 @@ static uint32_t operand_vuimm(rv_inst inst)
 
 static uint32_t operand_vzimm11(rv_inst inst)
 {
-    return (inst << 33) >> 53;
+    return extract32(inst, 20, 11);
 }
 
 static uint32_t operand_vzimm10(rv_inst inst)
 {
-    return (inst << 34) >> 54;
+    return extract32(inst, 20, 10);
 }
 
 static uint32_t operand_vzimm6(rv_inst inst)
 {
-    return ((inst << 37) >> 63) << 5 |
-        ((inst << 44) >> 59);
+    return extract32(inst, 26, 1) << 5 |
+        extract32(inst, 15, 5);
 }
 
 static uint32_t operand_bs(rv_inst inst)
 {
-    return (inst << 32) >> 62;
+    return extract32(inst, 30, 2);
 }
 
 static uint32_t operand_rnum(rv_inst inst)
 {
-    return (inst << 40) >> 60;
+    return extract32(inst, 20, 4);
 }
 
 static uint32_t operand_vm(rv_inst inst)
 {
-    return (inst << 38) >> 63;
+    return extract32(inst, 25, 1);
 }
 
 static uint32_t operand_uimm_c_lb(rv_inst inst)
 {
-    return (((inst << 58) >> 63) << 1) |
-        ((inst << 57) >> 63);
+    return extract32(inst, 5, 1) << 1 |
+        extract32(inst, 6, 1);
 }
 
 static uint32_t operand_uimm_c_lh(rv_inst inst)
 {
-    return (((inst << 58) >> 63) << 1);
+    return extract32(inst, 5, 1) << 1;
 }
 
 static uint32_t operand_zcmp_spimm(rv_inst inst)
 {
-    return ((inst << 60) >> 62) << 4;
+    return extract32(inst, 2, 2) << 4;
 }
 
 static uint32_t operand_zcmp_rlist(rv_inst inst)
 {
-    return ((inst << 56) >> 60);
+    return extract32(inst, 4, 4);
 }
 
 static uint32_t operand_imm6(rv_inst inst)
@@ -4556,17 +4556,17 @@ static uint32_t operand_imm6(rv_inst inst)
 
 static uint32_t operand_imm2(rv_inst inst)
 {
-    return (inst << 37) >> 62;
+    return extract32(inst, 25, 2);
 }
 
 static uint32_t operand_immh(rv_inst inst)
 {
-    return (inst << 32) >> 58;
+    return extract32(inst, 26, 6);
 }
 
 static uint32_t operand_imml(rv_inst inst)
 {
-    return (inst << 38) >> 58;
+    return extract32(inst, 20, 6);
 }
 
 static uint32_t calculate_stack_adj(rv_isa isa, uint32_t rlist, uint32_t spimm)
@@ -4585,12 +4585,12 @@ static uint32_t operand_zcmp_stack_adj(rv_inst inst, rv_isa isa)
 
 static uint32_t operand_tbl_index(rv_inst inst)
 {
-    return ((inst << 54) >> 56);
+    return extract32(inst, 2, 8);
 }
 
 static uint32_t operand_lpl(rv_inst inst)
 {
-    return inst >> 12;
+    return extract32(inst, 12, 20);
 }
 
 /* decode operands */
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 5/56
#11 lore raw

Re: [PATCH 05/56] disas/riscv: Use extract helpers for operand fields

Quoted 13 lines · Richard Henderson

From: TANG Tiancheng <[email protected]>

Replace shift-based operand extraction with extract32() and sextract32().
For signed immediates, use sextract32() on the field that carries the sign
bit and combine it with the remaining extract32() fields.

The RISC-V disassembler currently follows target/riscv/internals.h:
insn_len() and decodes only 16-bit or 32-bit instruction lengths, so the
converted fields are all in the low 32 bits of rv_inst.

Quoted 6 lines

Message-Id:
<20260703-b4-disas-xthead-fix-riscv-next-v4-5-84c566330bc7@linux.alib aba.com>

Alistair

Quoted 497 lines

---
 disas/riscv.c | 214 +++++++++++++++++++++++++----------------------- --

 1 file changed, 107 insertions(+), 107 deletions(-)
disas/riscv.c +0 -0
index 82b962dc71..2ba0a6a73a 100644
@@ -4202,82 +4202,82 @@ static void decode_inst_opcode(rv_decode
 *dec, rv_isa isa)


 static uint32_t operand_rd(rv_inst inst)
 {
-    return (inst << 52) >> 59;
+    return extract32(inst, 7, 5);
 }

 static uint32_t operand_rs1(rv_inst inst)
 {
-    return (inst << 44) >> 59;
+    return extract32(inst, 15, 5);
 }

 static uint32_t operand_rs2(rv_inst inst)
 {
-    return (inst << 39) >> 59;
+    return extract32(inst, 20, 5);
 }

 static uint32_t operand_rs3(rv_inst inst)
 {
-    return (inst << 32) >> 59;
+    return extract32(inst, 27, 5);
 }

 static uint32_t operand_aq(rv_inst inst)
 {
-    return (inst << 37) >> 63;
+    return extract32(inst, 26, 1);
 }

 static uint32_t operand_rl(rv_inst inst)
 {
-    return (inst << 38) >> 63;
+    return extract32(inst, 25, 1);
 }

 static uint32_t operand_pred(rv_inst inst)
 {
-    return (inst << 36) >> 60;
+    return extract32(inst, 24, 4);
 }

 static uint32_t operand_succ(rv_inst inst)
 {
-    return (inst << 40) >> 60;
+    return extract32(inst, 20, 4);
 }

 static uint32_t operand_rm(rv_inst inst)
 {
-    return (inst << 49) >> 61;
+    return extract32(inst, 12, 3);
 }

 static uint32_t operand_shamt5(rv_inst inst)
 {
-    return (inst << 39) >> 59;
+    return extract32(inst, 20, 5);
 }

 static uint32_t operand_shamt6(rv_inst inst)
 {
-    return (inst << 38) >> 58;
+    return extract32(inst, 20, 6);
 }

 static uint32_t operand_shamt7(rv_inst inst)
 {
-    return (inst << 37) >> 57;
+    return extract32(inst, 20, 7);
 }

 static uint32_t operand_crdq(rv_inst inst)
 {
-    return (inst << 59) >> 61;
+    return extract32(inst, 2, 3);
 }

 static uint32_t operand_crs1q(rv_inst inst)
 {
-    return (inst << 54) >> 61;
+    return extract32(inst, 7, 3);
 }

 static uint32_t operand_crs1rdq(rv_inst inst)
 {
-    return (inst << 54) >> 61;
+    return extract32(inst, 7, 3);
 }

 static uint32_t operand_crs2q(rv_inst inst)
 {
-    return (inst << 59) >> 61;
+    return extract32(inst, 2, 3);
 }

 static uint32_t calculate_xreg(uint32_t sreg)

disas/riscv.c +0 -0
@@ -4287,80 +4287,80 @@ static uint32_t calculate_xreg(uint32_t sreg)


 static uint32_t operand_sreg1(rv_inst inst) {
-    return calculate_xreg((inst << 54) >> 61); +    return calculate_xreg(extract32(inst, 7, 3)); }

 static uint32_t operand_sreg2(rv_inst inst) {
-    return calculate_xreg((inst << 59) >> 61); +    return calculate_xreg(extract32(inst, 2, 3)); }

 static uint32_t operand_crd(rv_inst inst) {
-    return (inst << 52) >> 59;
+    return extract32(inst, 7, 5);
 }

 static uint32_t operand_crs1(rv_inst inst) {
-    return (inst << 52) >> 59;
+    return extract32(inst, 7, 5);
 }

 static uint32_t operand_crs1rd(rv_inst inst) {
-    return (inst << 52) >> 59;
+    return extract32(inst, 7, 5);
 }

 static uint32_t operand_crs2(rv_inst inst) {
-    return (inst << 57) >> 59;
+    return extract32(inst, 2, 5);
 }

 static uint32_t operand_cimmsh5(rv_inst inst) {
-    return (inst << 57) >> 59;
+    return extract32(inst, 2, 5);
 }

 static uint32_t operand_csr12(rv_inst inst) {
-    return (inst << 32) >> 52;
+    return extract32(inst, 20, 12);
 }

 static int32_t operand_imm12(rv_inst inst) {
-    return ((int64_t)inst << 32) >> 52;
+    return sextract32(inst, 20, 12);
 }

 static int32_t operand_imm20(rv_inst inst) {
-    return (((int64_t)inst << 32) >> 44) << 12; +    return sextract32(inst, 12, 20) << 12; }

 static int32_t operand_jimm20(rv_inst inst) {
-    return (((int64_t)inst << 32) >> 63) << 20 | -        ((inst << 33) >> 54) << 1 |
-        ((inst << 43) >> 63) << 11 |
-        ((inst << 44) >> 56) << 12;

+    return sextract32(inst, 31, 1) << 20 |
+        extract32(inst, 21, 10) << 1 |
+        extract32(inst, 20, 1) << 11 |

+        extract32(inst, 12, 8) << 12;
 }

 static int32_t operand_simm12(rv_inst inst)
 {
-    return (((int64_t)inst << 32) >> 57) << 5 |
-        (inst << 52) >> 59;
+    return sextract32(inst, 25, 7) << 5 |
+        extract32(inst, 7, 5);
 }

 static int32_t operand_sbimm12(rv_inst inst)
 {
-    return (((int64_t)inst << 32) >> 63) << 12 | -        ((inst << 33) >> 58) << 5 |
-        ((inst << 52) >> 60) << 1 |
-        ((inst << 56) >> 63) << 11;
+    return sextract32(inst, 31, 1) << 12 |
+        extract32(inst, 25, 6) << 5 |
+        extract32(inst, 8, 4) << 1 |
+        extract32(inst, 7, 1) << 11;
 }

 static uint32_t operand_cimmshl6(rv_inst inst, rv_isa isa) {
-    int imm = ((inst << 51) >> 63) << 5 |
-        (inst << 57) >> 59;
+    int imm = extract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
     if (isa == rv128) {
         imm = imm ? imm : 64;
     }

disas/riscv.c +0 -0
@@ -4369,8 +4369,8 @@ static uint32_t operand_cimmshl6(rv_inst inst,
 rv_isa isa)


 static uint32_t operand_cimmshr6(rv_inst inst, rv_isa isa) {
-    int imm = ((inst << 51) >> 63) << 5 |
-        (inst << 57) >> 59;
+    int imm = extract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
     if (isa == rv128) {
         imm = imm | (imm & 32) << 1;
         imm = imm ? imm : 64;

disas/riscv.c +0 -0
@@ -4380,116 +4380,116 @@ static uint32_t operand_cimmshr6(rv_inst
 inst, rv_isa isa)


 static int32_t operand_cimmi(rv_inst inst)
 {
-    return (((int64_t)inst << 51) >> 63) << 5 |
-        (inst << 57) >> 59;
+    return sextract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
 }

 static int32_t operand_cimmui(rv_inst inst)
 {
-    return (((int64_t)inst << 51) >> 63) << 17 |
-        ((inst << 57) >> 59) << 12;
+    return sextract32(inst, 12, 1) << 17 |
+        extract32(inst, 2, 5) << 12;
 }

 static uint32_t operand_cimmlwsp(rv_inst inst)
 {
-    return ((inst << 51) >> 63) << 5 |
-        ((inst << 57) >> 61) << 2 |
-        ((inst << 60) >> 62) << 6;
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 4, 3) << 2 |
+        extract32(inst, 2, 2) << 6;
 }

 static uint32_t operand_cimmldsp(rv_inst inst)
 {
-    return ((inst << 51) >> 63) << 5 |
-        ((inst << 57) >> 62) << 3 |
-        ((inst << 59) >> 61) << 6;
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 5, 2) << 3 |
+        extract32(inst, 2, 3) << 6;
 }

 static uint32_t operand_cimmlqsp(rv_inst inst)
 {
-    return ((inst << 51) >> 63) << 5 |
-        ((inst << 57) >> 63) << 4 |
-        ((inst << 58) >> 60) << 6;
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 6, 1) << 4 |
+        extract32(inst, 2, 4) << 6;
 }

 static int32_t operand_cimm16sp(rv_inst inst)
 {
-    return (((int64_t)inst << 51) >> 63) << 9 |

-        ((inst << 57) >> 63) << 4 |
-        ((inst << 58) >> 63) << 6 |
-        ((inst << 59) >> 62) << 7 |
-        ((inst << 61) >> 63) << 5;
+    return sextract32(inst, 12, 1) << 9 |
+        extract32(inst, 6, 1) << 4 |
+        extract32(inst, 5, 1) << 6 |
+        extract32(inst, 3, 2) << 7 |

+        extract32(inst, 2, 1) << 5;
 }

 static int32_t operand_cimmj(rv_inst inst)
 {
-    return (((int64_t)inst << 51) >> 63) << 11 |
-        ((inst << 52) >> 63) << 4 |
-        ((inst << 53) >> 62) << 8 |
-        ((inst << 55) >> 63) << 10 |

-        ((inst << 56) >> 63) << 6 |
-        ((inst << 57) >> 63) << 7 |
-        ((inst << 58) >> 61) << 1 |

-        ((inst << 61) >> 63) << 5;
+    return sextract32(inst, 12, 1) << 11 |
+        extract32(inst, 11, 1) << 4 |
+        extract32(inst, 9, 2) << 8 |
+        extract32(inst, 8, 1) << 10 |

+        extract32(inst, 7, 1) << 6 |
+        extract32(inst, 6, 1) << 7 |
+        extract32(inst, 3, 3) << 1 |

+        extract32(inst, 2, 1) << 5;
 }

 static int32_t operand_cimmb(rv_inst inst)
 {
-    return (((int64_t)inst << 51) >> 63) << 8 |

-        ((inst << 52) >> 62) << 3 |
-        ((inst << 57) >> 62) << 6 |
-        ((inst << 59) >> 62) << 1 |

-        ((inst << 61) >> 63) << 5;
+    return sextract32(inst, 12, 1) << 8 |
+        extract32(inst, 10, 2) << 3 |
+        extract32(inst, 5, 2) << 6 |
+        extract32(inst, 3, 2) << 1 |
+        extract32(inst, 2, 1) << 5;
 }

 static uint32_t operand_cimmswsp(rv_inst inst)
 {
-    return ((inst << 51) >> 60) << 2 |
-        ((inst << 55) >> 62) << 6;
+    return extract32(inst, 9, 4) << 2 |
+        extract32(inst, 7, 2) << 6;
 }

 static uint32_t operand_cimmsdsp(rv_inst inst)
 {
-    return ((inst << 51) >> 61) << 3 |
-        ((inst << 54) >> 61) << 6;
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 7, 3) << 6;
 }

 static uint32_t operand_cimmsqsp(rv_inst inst)
 {
-    return ((inst << 51) >> 62) << 4 |
-        ((inst << 53) >> 60) << 6;
+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 7, 4) << 6;
 }

 static uint32_t operand_cimm4spn(rv_inst inst)
 {
-    return ((inst << 51) >> 62) << 4 |
-        ((inst << 53) >> 60) << 6 |
-        ((inst << 57) >> 63) << 2 |
-        ((inst << 58) >> 63) << 3;

+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 7, 4) << 6 |
+        extract32(inst, 6, 1) << 2 |

+        extract32(inst, 5, 1) << 3;
 }

 static uint32_t operand_cimmw(rv_inst inst)
 {
-    return ((inst << 51) >> 61) << 3 |
-        ((inst << 57) >> 63) << 2 |
-        ((inst << 58) >> 63) << 6;
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 6, 1) << 2 |
+        extract32(inst, 5, 1) << 6;
 }

 static uint32_t operand_cimmd(rv_inst inst)
 {
-    return ((inst << 51) >> 61) << 3 |
-        ((inst << 57) >> 62) << 6;
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 5, 2) << 6;
 }

 static uint32_t operand_cimmq(rv_inst inst)
 {
-    return ((inst << 51) >> 62) << 4 |
-        ((inst << 53) >> 63) << 8 |
-        ((inst << 57) >> 62) << 6;
+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 10, 1) << 8 |
+        extract32(inst, 5, 2) << 6;
 }

 static int32_t operand_vimm(rv_inst inst)
 {
-    return (int64_t)(inst << 44) >> 59;
+    return sextract32(inst, 15, 5);
 }

 static uint32_t operand_vuimm(rv_inst inst)

disas/riscv.c +0 -0
@@ -4499,54 +4499,54 @@ static uint32_t operand_vuimm(rv_inst inst)


 static uint32_t operand_vzimm11(rv_inst inst)
 {
-    return (inst << 33) >> 53;
+    return extract32(inst, 20, 11);
 }

 static uint32_t operand_vzimm10(rv_inst inst)
 {
-    return (inst << 34) >> 54;
+    return extract32(inst, 20, 10);
 }

 static uint32_t operand_vzimm6(rv_inst inst)
 {
-    return ((inst << 37) >> 63) << 5 |
-        ((inst << 44) >> 59);
+    return extract32(inst, 26, 1) << 5 |
+        extract32(inst, 15, 5);
 }

 static uint32_t operand_bs(rv_inst inst)
 {
-    return (inst << 32) >> 62;
+    return extract32(inst, 30, 2);
 }

 static uint32_t operand_rnum(rv_inst inst)
 {
-    return (inst << 40) >> 60;
+    return extract32(inst, 20, 4);
 }

 static uint32_t operand_vm(rv_inst inst)
 {
-    return (inst << 38) >> 63;
+    return extract32(inst, 25, 1);
 }

 static uint32_t operand_uimm_c_lb(rv_inst inst)
 {
-    return (((inst << 58) >> 63) << 1) |
-        ((inst << 57) >> 63);
+    return extract32(inst, 5, 1) << 1 |
+        extract32(inst, 6, 1);
 }

 static uint32_t operand_uimm_c_lh(rv_inst inst)
 {
-    return (((inst << 58) >> 63) << 1);
+    return extract32(inst, 5, 1) << 1;
 }

 static uint32_t operand_zcmp_spimm(rv_inst inst)
 {
-    return ((inst << 60) >> 62) << 4;
+    return extract32(inst, 2, 2) << 4;
 }

 static uint32_t operand_zcmp_rlist(rv_inst inst)
 {
-    return ((inst << 56) >> 60);
+    return extract32(inst, 4, 4);
 }

 static uint32_t operand_imm6(rv_inst inst)

disas/riscv.c +0 -0
@@ -4556,17 +4556,17 @@ static uint32_t operand_imm6(rv_inst inst)


 static uint32_t operand_imm2(rv_inst inst)
 {
-    return (inst << 37) >> 62;
+    return extract32(inst, 25, 2);
 }

 static uint32_t operand_immh(rv_inst inst)
 {
-    return (inst << 32) >> 58;
+    return extract32(inst, 26, 6);
 }

 static uint32_t operand_imml(rv_inst inst)
 {
-    return (inst << 38) >> 58;
+    return extract32(inst, 20, 6);
 }

 static uint32_t calculate_stack_adj(rv_isa isa, uint32_t rlist, uint32_t spimm)

disas/riscv.c +0 -0
@@ -4585,12 +4585,12 @@ static uint32_t
 operand_zcmp_stack_adj(rv_inst inst, rv_isa isa)


 static uint32_t operand_tbl_index(rv_inst inst)
 {
-    return ((inst << 54) >> 56);
+    return extract32(inst, 2, 8);
 }

 static uint32_t operand_lpl(rv_inst inst)
 {
-    return inst >> 12;
+    return extract32(inst, 12, 20);
 }

 /* decode operands */

#12 lore raw

PATCH 6/56 disas/riscv: Move operand extractors earlier in file

In reply to Richard Henderson
---
 disas/riscv.c | 790 +++++++++++++++++++++++++-------------------------
 1 file changed, 395 insertions(+), 395 deletions(-)
disas/riscv.c +395 -395
index 2ba0a6a73a..e3fbc26626 100644
@@ -1259,6 +1259,401 @@ static const rv_comp_data rvcp_fsgnjx_q[] = {
     { rv_op_illegal, NULL }
 };
 
+/* operand extractors */
+
+static uint32_t operand_rd(rv_inst inst)
+{
+    return extract32(inst, 7, 5);
+}
+
+static uint32_t operand_rs1(rv_inst inst)
+{
+    return extract32(inst, 15, 5);
+}
+
+static uint32_t operand_rs2(rv_inst inst)
+{
+    return extract32(inst, 20, 5);
+}
+
+static uint32_t operand_rs3(rv_inst inst)
+{
+    return extract32(inst, 27, 5);
+}
+
+static uint32_t operand_aq(rv_inst inst)
+{
+    return extract32(inst, 26, 1);
+}
+
+static uint32_t operand_rl(rv_inst inst)
+{
+    return extract32(inst, 25, 1);
+}
+
+static uint32_t operand_pred(rv_inst inst)
+{
+    return extract32(inst, 24, 4);
+}
+
+static uint32_t operand_succ(rv_inst inst)
+{
+    return extract32(inst, 20, 4);
+}
+
+static uint32_t operand_rm(rv_inst inst)
+{
+    return extract32(inst, 12, 3);
+}
+
+static uint32_t operand_shamt5(rv_inst inst)
+{
+    return extract32(inst, 20, 5);
+}
+
+static uint32_t operand_shamt6(rv_inst inst)
+{
+    return extract32(inst, 20, 6);
+}
+
+static uint32_t operand_shamt7(rv_inst inst)
+{
+    return extract32(inst, 20, 7);
+}
+
+static uint32_t operand_crdq(rv_inst inst)
+{
+    return extract32(inst, 2, 3);
+}
+
+static uint32_t operand_crs1q(rv_inst inst)
+{
+    return extract32(inst, 7, 3);
+}
+
+static uint32_t operand_crs1rdq(rv_inst inst)
+{
+    return extract32(inst, 7, 3);
+}
+
+static uint32_t operand_crs2q(rv_inst inst)
+{
+    return extract32(inst, 2, 3);
+}
+
+static uint32_t calculate_xreg(uint32_t sreg)
+{
+    return sreg < 2 ? sreg + 8 : sreg + 16;
+}
+
+static uint32_t operand_sreg1(rv_inst inst)
+{
+    return calculate_xreg(extract32(inst, 7, 3));
+}
+
+static uint32_t operand_sreg2(rv_inst inst)
+{
+    return calculate_xreg(extract32(inst, 2, 3));
+}
+
+static uint32_t operand_crd(rv_inst inst)
+{
+    return extract32(inst, 7, 5);
+}
+
+static uint32_t operand_crs1(rv_inst inst)
+{
+    return extract32(inst, 7, 5);
+}
+
+static uint32_t operand_crs1rd(rv_inst inst)
+{
+    return extract32(inst, 7, 5);
+}
+
+static uint32_t operand_crs2(rv_inst inst)
+{
+    return extract32(inst, 2, 5);
+}
+
+static uint32_t operand_cimmsh5(rv_inst inst)
+{
+    return extract32(inst, 2, 5);
+}
+
+static uint32_t operand_csr12(rv_inst inst)
+{
+    return extract32(inst, 20, 12);
+}
+
+static int32_t operand_imm12(rv_inst inst)
+{
+    return sextract32(inst, 20, 12);
+}
+
+static int32_t operand_imm20(rv_inst inst)
+{
+    return sextract32(inst, 12, 20) << 12;
+}
+
+static int32_t operand_jimm20(rv_inst inst)
+{
+    return sextract32(inst, 31, 1) << 20 |
+        extract32(inst, 21, 10) << 1 |
+        extract32(inst, 20, 1) << 11 |
+        extract32(inst, 12, 8) << 12;
+}
+
+static int32_t operand_simm12(rv_inst inst)
+{
+    return sextract32(inst, 25, 7) << 5 |
+        extract32(inst, 7, 5);
+}
+
+static int32_t operand_sbimm12(rv_inst inst)
+{
+    return sextract32(inst, 31, 1) << 12 |
+        extract32(inst, 25, 6) << 5 |
+        extract32(inst, 8, 4) << 1 |
+        extract32(inst, 7, 1) << 11;
+}
+
+static uint32_t operand_cimmshl6(rv_inst inst, rv_isa isa)
+{
+    int imm = extract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
+    if (isa == rv128) {
+        imm = imm ? imm : 64;
+    }
+    return imm;
+}
+
+static uint32_t operand_cimmshr6(rv_inst inst, rv_isa isa)
+{
+    int imm = extract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
+    if (isa == rv128) {
+        imm = imm | (imm & 32) << 1;
+        imm = imm ? imm : 64;
+    }
+    return imm;
+}
+
+static int32_t operand_cimmi(rv_inst inst)
+{
+    return sextract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
+}
+
+static int32_t operand_cimmui(rv_inst inst)
+{
+    return sextract32(inst, 12, 1) << 17 |
+        extract32(inst, 2, 5) << 12;
+}
+
+static uint32_t operand_cimmlwsp(rv_inst inst)
+{
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 4, 3) << 2 |
+        extract32(inst, 2, 2) << 6;
+}
+
+static uint32_t operand_cimmldsp(rv_inst inst)
+{
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 5, 2) << 3 |
+        extract32(inst, 2, 3) << 6;
+}
+
+static uint32_t operand_cimmlqsp(rv_inst inst)
+{
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 6, 1) << 4 |
+        extract32(inst, 2, 4) << 6;
+}
+
+static int32_t operand_cimm16sp(rv_inst inst)
+{
+    return sextract32(inst, 12, 1) << 9 |
+        extract32(inst, 6, 1) << 4 |
+        extract32(inst, 5, 1) << 6 |
+        extract32(inst, 3, 2) << 7 |
+        extract32(inst, 2, 1) << 5;
+}
+
+static int32_t operand_cimmj(rv_inst inst)
+{
+    return sextract32(inst, 12, 1) << 11 |
+        extract32(inst, 11, 1) << 4 |
+        extract32(inst, 9, 2) << 8 |
+        extract32(inst, 8, 1) << 10 |
+        extract32(inst, 7, 1) << 6 |
+        extract32(inst, 6, 1) << 7 |
+        extract32(inst, 3, 3) << 1 |
+        extract32(inst, 2, 1) << 5;
+}
+
+static int32_t operand_cimmb(rv_inst inst)
+{
+    return sextract32(inst, 12, 1) << 8 |
+        extract32(inst, 10, 2) << 3 |
+        extract32(inst, 5, 2) << 6 |
+        extract32(inst, 3, 2) << 1 |
+        extract32(inst, 2, 1) << 5;
+}
+
+static uint32_t operand_cimmswsp(rv_inst inst)
+{
+    return extract32(inst, 9, 4) << 2 |
+        extract32(inst, 7, 2) << 6;
+}
+
+static uint32_t operand_cimmsdsp(rv_inst inst)
+{
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 7, 3) << 6;
+}
+
+static uint32_t operand_cimmsqsp(rv_inst inst)
+{
+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 7, 4) << 6;
+}
+
+static uint32_t operand_cimm4spn(rv_inst inst)
+{
+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 7, 4) << 6 |
+        extract32(inst, 6, 1) << 2 |
+        extract32(inst, 5, 1) << 3;
+}
+
+static uint32_t operand_cimmw(rv_inst inst)
+{
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 6, 1) << 2 |
+        extract32(inst, 5, 1) << 6;
+}
+
+static uint32_t operand_cimmd(rv_inst inst)
+{
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 5, 2) << 6;
+}
+
+static uint32_t operand_cimmq(rv_inst inst)
+{
+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 10, 1) << 8 |
+        extract32(inst, 5, 2) << 6;
+}
+
+static int32_t operand_vimm(rv_inst inst)
+{
+    return sextract32(inst, 15, 5);
+}
+
+static uint32_t operand_vuimm(rv_inst inst)
+{
+    return extract32(inst, 15, 5);
+}
+
+static uint32_t operand_vzimm11(rv_inst inst)
+{
+    return extract32(inst, 20, 11);
+}
+
+static uint32_t operand_vzimm10(rv_inst inst)
+{
+    return extract32(inst, 20, 10);
+}
+
+static uint32_t operand_vzimm6(rv_inst inst)
+{
+    return extract32(inst, 26, 1) << 5 |
+        extract32(inst, 15, 5);
+}
+
+static uint32_t operand_bs(rv_inst inst)
+{
+    return extract32(inst, 30, 2);
+}
+
+static uint32_t operand_rnum(rv_inst inst)
+{
+    return extract32(inst, 20, 4);
+}
+
+static uint32_t operand_vm(rv_inst inst)
+{
+    return extract32(inst, 25, 1);
+}
+
+static uint32_t operand_uimm_c_lb(rv_inst inst)
+{
+    return extract32(inst, 5, 1) << 1 |
+        extract32(inst, 6, 1);
+}
+
+static uint32_t operand_uimm_c_lh(rv_inst inst)
+{
+    return extract32(inst, 5, 1) << 1;
+}
+
+static uint32_t operand_zcmp_spimm(rv_inst inst)
+{
+    return extract32(inst, 2, 2) << 4;
+}
+
+static uint32_t operand_zcmp_rlist(rv_inst inst)
+{
+    return extract32(inst, 4, 4);
+}
+
+static uint32_t operand_imm6(rv_inst inst)
+{
+    return extract32(inst, 20, 6);
+}
+
+static uint32_t operand_imm2(rv_inst inst)
+{
+    return extract32(inst, 25, 2);
+}
+
+static uint32_t operand_immh(rv_inst inst)
+{
+    return extract32(inst, 26, 6);
+}
+
+static uint32_t operand_imml(rv_inst inst)
+{
+    return extract32(inst, 20, 6);
+}
+
+static uint32_t calculate_stack_adj(rv_isa isa, uint32_t rlist, uint32_t spimm)
+{
+    int xlen_bytes_log2 = isa == rv64 ? 3 : 2;
+    int regs = rlist == 15 ? 13 : rlist - 3;
+    uint32_t stack_adj_base = ROUND_UP(regs << xlen_bytes_log2, 16);
+    return stack_adj_base + spimm;
+}
+
+static uint32_t operand_zcmp_stack_adj(rv_inst inst, rv_isa isa)
+{
+    return calculate_stack_adj(isa, operand_zcmp_rlist(inst),
+                               operand_zcmp_spimm(inst));
+}
+
+static uint32_t operand_tbl_index(rv_inst inst)
+{
+    return extract32(inst, 2, 8);
+}
+
+static uint32_t operand_lpl(rv_inst inst)
+{
+    return extract32(inst, 12, 20);
+}
+
 /* instruction metadata */
 
 const rv_opcode_data rvi_opcode_data[] = {
@@ -4198,401 +4593,6 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
     dec->op = op;
 }
 
-/* operand extractors */
-
-static uint32_t operand_rd(rv_inst inst)
-{
-    return extract32(inst, 7, 5);
-}
-
-static uint32_t operand_rs1(rv_inst inst)
-{
-    return extract32(inst, 15, 5);
-}
-
-static uint32_t operand_rs2(rv_inst inst)
-{
-    return extract32(inst, 20, 5);
-}
-
-static uint32_t operand_rs3(rv_inst inst)
-{
-    return extract32(inst, 27, 5);
-}
-
-static uint32_t operand_aq(rv_inst inst)
-{
-    return extract32(inst, 26, 1);
-}
-
-static uint32_t operand_rl(rv_inst inst)
-{
-    return extract32(inst, 25, 1);
-}
-
-static uint32_t operand_pred(rv_inst inst)
-{
-    return extract32(inst, 24, 4);
-}
-
-static uint32_t operand_succ(rv_inst inst)
-{
-    return extract32(inst, 20, 4);
-}
-
-static uint32_t operand_rm(rv_inst inst)
-{
-    return extract32(inst, 12, 3);
-}
-
-static uint32_t operand_shamt5(rv_inst inst)
-{
-    return extract32(inst, 20, 5);
-}
-
-static uint32_t operand_shamt6(rv_inst inst)
-{
-    return extract32(inst, 20, 6);
-}
-
-static uint32_t operand_shamt7(rv_inst inst)
-{
-    return extract32(inst, 20, 7);
-}
-
-static uint32_t operand_crdq(rv_inst inst)
-{
-    return extract32(inst, 2, 3);
-}
-
-static uint32_t operand_crs1q(rv_inst inst)
-{
-    return extract32(inst, 7, 3);
-}
-
-static uint32_t operand_crs1rdq(rv_inst inst)
-{
-    return extract32(inst, 7, 3);
-}
-
-static uint32_t operand_crs2q(rv_inst inst)
-{
-    return extract32(inst, 2, 3);
-}
-
-static uint32_t calculate_xreg(uint32_t sreg)
-{
-    return sreg < 2 ? sreg + 8 : sreg + 16;
-}
-
-static uint32_t operand_sreg1(rv_inst inst)
-{
-    return calculate_xreg(extract32(inst, 7, 3));
-}
-
-static uint32_t operand_sreg2(rv_inst inst)
-{
-    return calculate_xreg(extract32(inst, 2, 3));
-}
-
-static uint32_t operand_crd(rv_inst inst)
-{
-    return extract32(inst, 7, 5);
-}
-
-static uint32_t operand_crs1(rv_inst inst)
-{
-    return extract32(inst, 7, 5);
-}
-
-static uint32_t operand_crs1rd(rv_inst inst)
-{
-    return extract32(inst, 7, 5);
-}
-
-static uint32_t operand_crs2(rv_inst inst)
-{
-    return extract32(inst, 2, 5);
-}
-
-static uint32_t operand_cimmsh5(rv_inst inst)
-{
-    return extract32(inst, 2, 5);
-}
-
-static uint32_t operand_csr12(rv_inst inst)
-{
-    return extract32(inst, 20, 12);
-}
-
-static int32_t operand_imm12(rv_inst inst)
-{
-    return sextract32(inst, 20, 12);
-}
-
-static int32_t operand_imm20(rv_inst inst)
-{
-    return sextract32(inst, 12, 20) << 12;
-}
-
-static int32_t operand_jimm20(rv_inst inst)
-{
-    return sextract32(inst, 31, 1) << 20 |
-        extract32(inst, 21, 10) << 1 |
-        extract32(inst, 20, 1) << 11 |
-        extract32(inst, 12, 8) << 12;
-}
-
-static int32_t operand_simm12(rv_inst inst)
-{
-    return sextract32(inst, 25, 7) << 5 |
-        extract32(inst, 7, 5);
-}
-
-static int32_t operand_sbimm12(rv_inst inst)
-{
-    return sextract32(inst, 31, 1) << 12 |
-        extract32(inst, 25, 6) << 5 |
-        extract32(inst, 8, 4) << 1 |
-        extract32(inst, 7, 1) << 11;
-}
-
-static uint32_t operand_cimmshl6(rv_inst inst, rv_isa isa)
-{
-    int imm = extract32(inst, 12, 1) << 5 |
-        extract32(inst, 2, 5);
-    if (isa == rv128) {
-        imm = imm ? imm : 64;
-    }
-    return imm;
-}
-
-static uint32_t operand_cimmshr6(rv_inst inst, rv_isa isa)
-{
-    int imm = extract32(inst, 12, 1) << 5 |
-        extract32(inst, 2, 5);
-    if (isa == rv128) {
-        imm = imm | (imm & 32) << 1;
-        imm = imm ? imm : 64;
-    }
-    return imm;
-}
-
-static int32_t operand_cimmi(rv_inst inst)
-{
-    return sextract32(inst, 12, 1) << 5 |
-        extract32(inst, 2, 5);
-}
-
-static int32_t operand_cimmui(rv_inst inst)
-{
-    return sextract32(inst, 12, 1) << 17 |
-        extract32(inst, 2, 5) << 12;
-}
-
-static uint32_t operand_cimmlwsp(rv_inst inst)
-{
-    return extract32(inst, 12, 1) << 5 |
-        extract32(inst, 4, 3) << 2 |
-        extract32(inst, 2, 2) << 6;
-}
-
-static uint32_t operand_cimmldsp(rv_inst inst)
-{
-    return extract32(inst, 12, 1) << 5 |
-        extract32(inst, 5, 2) << 3 |
-        extract32(inst, 2, 3) << 6;
-}
-
-static uint32_t operand_cimmlqsp(rv_inst inst)
-{
-    return extract32(inst, 12, 1) << 5 |
-        extract32(inst, 6, 1) << 4 |
-        extract32(inst, 2, 4) << 6;
-}
-
-static int32_t operand_cimm16sp(rv_inst inst)
-{
-    return sextract32(inst, 12, 1) << 9 |
-        extract32(inst, 6, 1) << 4 |
-        extract32(inst, 5, 1) << 6 |
-        extract32(inst, 3, 2) << 7 |
-        extract32(inst, 2, 1) << 5;
-}
-
-static int32_t operand_cimmj(rv_inst inst)
-{
-    return sextract32(inst, 12, 1) << 11 |
-        extract32(inst, 11, 1) << 4 |
-        extract32(inst, 9, 2) << 8 |
-        extract32(inst, 8, 1) << 10 |
-        extract32(inst, 7, 1) << 6 |
-        extract32(inst, 6, 1) << 7 |
-        extract32(inst, 3, 3) << 1 |
-        extract32(inst, 2, 1) << 5;
-}
-
-static int32_t operand_cimmb(rv_inst inst)
-{
-    return sextract32(inst, 12, 1) << 8 |
-        extract32(inst, 10, 2) << 3 |
-        extract32(inst, 5, 2) << 6 |
-        extract32(inst, 3, 2) << 1 |
-        extract32(inst, 2, 1) << 5;
-}
-
-static uint32_t operand_cimmswsp(rv_inst inst)
-{
-    return extract32(inst, 9, 4) << 2 |
-        extract32(inst, 7, 2) << 6;
-}
-
-static uint32_t operand_cimmsdsp(rv_inst inst)
-{
-    return extract32(inst, 10, 3) << 3 |
-        extract32(inst, 7, 3) << 6;
-}
-
-static uint32_t operand_cimmsqsp(rv_inst inst)
-{
-    return extract32(inst, 11, 2) << 4 |
-        extract32(inst, 7, 4) << 6;
-}
-
-static uint32_t operand_cimm4spn(rv_inst inst)
-{
-    return extract32(inst, 11, 2) << 4 |
-        extract32(inst, 7, 4) << 6 |
-        extract32(inst, 6, 1) << 2 |
-        extract32(inst, 5, 1) << 3;
-}
-
-static uint32_t operand_cimmw(rv_inst inst)
-{
-    return extract32(inst, 10, 3) << 3 |
-        extract32(inst, 6, 1) << 2 |
-        extract32(inst, 5, 1) << 6;
-}
-
-static uint32_t operand_cimmd(rv_inst inst)
-{
-    return extract32(inst, 10, 3) << 3 |
-        extract32(inst, 5, 2) << 6;
-}
-
-static uint32_t operand_cimmq(rv_inst inst)
-{
-    return extract32(inst, 11, 2) << 4 |
-        extract32(inst, 10, 1) << 8 |
-        extract32(inst, 5, 2) << 6;
-}
-
-static int32_t operand_vimm(rv_inst inst)
-{
-    return sextract32(inst, 15, 5);
-}
-
-static uint32_t operand_vuimm(rv_inst inst)
-{
-    return extract32(inst, 15, 5);
-}
-
-static uint32_t operand_vzimm11(rv_inst inst)
-{
-    return extract32(inst, 20, 11);
-}
-
-static uint32_t operand_vzimm10(rv_inst inst)
-{
-    return extract32(inst, 20, 10);
-}
-
-static uint32_t operand_vzimm6(rv_inst inst)
-{
-    return extract32(inst, 26, 1) << 5 |
-        extract32(inst, 15, 5);
-}
-
-static uint32_t operand_bs(rv_inst inst)
-{
-    return extract32(inst, 30, 2);
-}
-
-static uint32_t operand_rnum(rv_inst inst)
-{
-    return extract32(inst, 20, 4);
-}
-
-static uint32_t operand_vm(rv_inst inst)
-{
-    return extract32(inst, 25, 1);
-}
-
-static uint32_t operand_uimm_c_lb(rv_inst inst)
-{
-    return extract32(inst, 5, 1) << 1 |
-        extract32(inst, 6, 1);
-}
-
-static uint32_t operand_uimm_c_lh(rv_inst inst)
-{
-    return extract32(inst, 5, 1) << 1;
-}
-
-static uint32_t operand_zcmp_spimm(rv_inst inst)
-{
-    return extract32(inst, 2, 2) << 4;
-}
-
-static uint32_t operand_zcmp_rlist(rv_inst inst)
-{
-    return extract32(inst, 4, 4);
-}
-
-static uint32_t operand_imm6(rv_inst inst)
-{
-    return extract32(inst, 20, 6);
-}
-
-static uint32_t operand_imm2(rv_inst inst)
-{
-    return extract32(inst, 25, 2);
-}
-
-static uint32_t operand_immh(rv_inst inst)
-{
-    return extract32(inst, 26, 6);
-}
-
-static uint32_t operand_imml(rv_inst inst)
-{
-    return extract32(inst, 20, 6);
-}
-
-static uint32_t calculate_stack_adj(rv_isa isa, uint32_t rlist, uint32_t spimm)
-{
-    int xlen_bytes_log2 = isa == rv64 ? 3 : 2;
-    int regs = rlist == 15 ? 13 : rlist - 3;
-    uint32_t stack_adj_base = ROUND_UP(regs << xlen_bytes_log2, 16);
-    return stack_adj_base + spimm;
-}
-
-static uint32_t operand_zcmp_stack_adj(rv_inst inst, rv_isa isa)
-{
-    return calculate_stack_adj(isa, operand_zcmp_rlist(inst),
-                               operand_zcmp_spimm(inst));
-}
-
-static uint32_t operand_tbl_index(rv_inst inst)
-{
-    return extract32(inst, 2, 8);
-}
-
-static uint32_t operand_lpl(rv_inst inst)
-{
-    return extract32(inst, 12, 20);
-}
-
 /* decode operands */
 
 static void decode_inst_operands(rv_decode *dec, rv_isa isa)
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 6/56
#13 lore raw

Re: [PATCH 06/56] disas/riscv: Move operand extractors earlier in file

Quoted 1 line · Richard Henderson

Alistair

Quoted 816 lines

---
 disas/riscv.c | 790 +++++++++++++++++++++++++----------------------- --

 1 file changed, 395 insertions(+), 395 deletions(-)
disas/riscv.c +0 -0
index 2ba0a6a73a..e3fbc26626 100644
@@ -1259,6 +1259,401 @@ static const rv_comp_data rvcp_fsgnjx_q[] = {
      { rv_op_illegal, NULL }
  };

disas/riscv.c +372 -0
+/* operand extractors */
+
+static uint32_t operand_rd(rv_inst inst)
+{
+    return extract32(inst, 7, 5);
+}
+
+static uint32_t operand_rs1(rv_inst inst)
+{
+    return extract32(inst, 15, 5);
+}
+
+static uint32_t operand_rs2(rv_inst inst)
+{
+    return extract32(inst, 20, 5);
+}
+
+static uint32_t operand_rs3(rv_inst inst)
+{
+    return extract32(inst, 27, 5);
+}
+
+static uint32_t operand_aq(rv_inst inst)
+{
+    return extract32(inst, 26, 1);
+}
+
+static uint32_t operand_rl(rv_inst inst)
+{
+    return extract32(inst, 25, 1);
+}
+
+static uint32_t operand_pred(rv_inst inst)
+{
+    return extract32(inst, 24, 4);
+}
+
+static uint32_t operand_succ(rv_inst inst)
+{
+    return extract32(inst, 20, 4);
+}
+
+static uint32_t operand_rm(rv_inst inst)
+{
+    return extract32(inst, 12, 3);
+}
+
+static uint32_t operand_shamt5(rv_inst inst)
+{
+    return extract32(inst, 20, 5);
+}
+
+static uint32_t operand_shamt6(rv_inst inst)
+{
+    return extract32(inst, 20, 6);
+}
+
+static uint32_t operand_shamt7(rv_inst inst)
+{
+    return extract32(inst, 20, 7);
+}
+
+static uint32_t operand_crdq(rv_inst inst)
+{
+    return extract32(inst, 2, 3);
+}
+
+static uint32_t operand_crs1q(rv_inst inst)
+{
+    return extract32(inst, 7, 3);
+}
+
+static uint32_t operand_crs1rdq(rv_inst inst)
+{
+    return extract32(inst, 7, 3);
+}
+
+static uint32_t operand_crs2q(rv_inst inst)
+{
+    return extract32(inst, 2, 3);
+}
+
+static uint32_t calculate_xreg(uint32_t sreg)
+{
+    return sreg < 2 ? sreg + 8 : sreg + 16;
+}
+
+static uint32_t operand_sreg1(rv_inst inst)
+{
+    return calculate_xreg(extract32(inst, 7, 3));
+}
+
+static uint32_t operand_sreg2(rv_inst inst)
+{
+    return calculate_xreg(extract32(inst, 2, 3));
+}
+
+static uint32_t operand_crd(rv_inst inst)
+{
+    return extract32(inst, 7, 5);
+}
+
+static uint32_t operand_crs1(rv_inst inst)
+{
+    return extract32(inst, 7, 5);
+}
+
+static uint32_t operand_crs1rd(rv_inst inst)
+{
+    return extract32(inst, 7, 5);
+}
+
+static uint32_t operand_crs2(rv_inst inst)
+{
+    return extract32(inst, 2, 5);
+}
+
+static uint32_t operand_cimmsh5(rv_inst inst)
+{
+    return extract32(inst, 2, 5);
+}
+
+static uint32_t operand_csr12(rv_inst inst)
+{
+    return extract32(inst, 20, 12);
+}
+
+static int32_t operand_imm12(rv_inst inst)
+{
+    return sextract32(inst, 20, 12);
+}
+
+static int32_t operand_imm20(rv_inst inst)
+{
+    return sextract32(inst, 12, 20) << 12;
+}
+
+static int32_t operand_jimm20(rv_inst inst)
+{
+    return sextract32(inst, 31, 1) << 20 |
+        extract32(inst, 21, 10) << 1 |
+        extract32(inst, 20, 1) << 11 |
+        extract32(inst, 12, 8) << 12;
+}
+
+static int32_t operand_simm12(rv_inst inst)
+{
+    return sextract32(inst, 25, 7) << 5 |
+        extract32(inst, 7, 5);
+}
+
+static int32_t operand_sbimm12(rv_inst inst)
+{
+    return sextract32(inst, 31, 1) << 12 |
+        extract32(inst, 25, 6) << 5 |
+        extract32(inst, 8, 4) << 1 |
+        extract32(inst, 7, 1) << 11;
+}
+
+static uint32_t operand_cimmshl6(rv_inst inst, rv_isa isa)
+{
+    int imm = extract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
+    if (isa == rv128) {
+        imm = imm ? imm : 64;
+    }
+    return imm;
+}
+
+static uint32_t operand_cimmshr6(rv_inst inst, rv_isa isa)
+{
+    int imm = extract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
+    if (isa == rv128) {
+        imm = imm | (imm & 32) << 1;
+        imm = imm ? imm : 64;
+    }
+    return imm;
+}
+
+static int32_t operand_cimmi(rv_inst inst)
+{
+    return sextract32(inst, 12, 1) << 5 |
+        extract32(inst, 2, 5);
+}
+
+static int32_t operand_cimmui(rv_inst inst)
+{
+    return sextract32(inst, 12, 1) << 17 |
+        extract32(inst, 2, 5) << 12;
+}
+
+static uint32_t operand_cimmlwsp(rv_inst inst)
+{
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 4, 3) << 2 |
+        extract32(inst, 2, 2) << 6;
+}
+
+static uint32_t operand_cimmldsp(rv_inst inst)
+{
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 5, 2) << 3 |
+        extract32(inst, 2, 3) << 6;
+}
+
+static uint32_t operand_cimmlqsp(rv_inst inst)
+{
+    return extract32(inst, 12, 1) << 5 |
+        extract32(inst, 6, 1) << 4 |
+        extract32(inst, 2, 4) << 6;
+}
+
+static int32_t operand_cimm16sp(rv_inst inst)
+{
+    return sextract32(inst, 12, 1) << 9 |
+        extract32(inst, 6, 1) << 4 |
+        extract32(inst, 5, 1) << 6 |
+        extract32(inst, 3, 2) << 7 |
+        extract32(inst, 2, 1) << 5;
+}
+
+static int32_t operand_cimmj(rv_inst inst)
+{
+    return sextract32(inst, 12, 1) << 11 |
+        extract32(inst, 11, 1) << 4 |
+        extract32(inst, 9, 2) << 8 |
+        extract32(inst, 8, 1) << 10 |
+        extract32(inst, 7, 1) << 6 |
+        extract32(inst, 6, 1) << 7 |
+        extract32(inst, 3, 3) << 1 |
+        extract32(inst, 2, 1) << 5;
+}
+
+static int32_t operand_cimmb(rv_inst inst)
+{
+    return sextract32(inst, 12, 1) << 8 |
+        extract32(inst, 10, 2) << 3 |
+        extract32(inst, 5, 2) << 6 |
+        extract32(inst, 3, 2) << 1 |
+        extract32(inst, 2, 1) << 5;
+}
+
+static uint32_t operand_cimmswsp(rv_inst inst)
+{
+    return extract32(inst, 9, 4) << 2 |
+        extract32(inst, 7, 2) << 6;
+}
+
+static uint32_t operand_cimmsdsp(rv_inst inst)
+{
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 7, 3) << 6;
+}
+
+static uint32_t operand_cimmsqsp(rv_inst inst)
+{
+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 7, 4) << 6;
+}
+
+static uint32_t operand_cimm4spn(rv_inst inst)
+{
+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 7, 4) << 6 |
+        extract32(inst, 6, 1) << 2 |
+        extract32(inst, 5, 1) << 3;
+}
+
+static uint32_t operand_cimmw(rv_inst inst)
+{
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 6, 1) << 2 |
+        extract32(inst, 5, 1) << 6;
+}
+
+static uint32_t operand_cimmd(rv_inst inst)
+{
+    return extract32(inst, 10, 3) << 3 |
+        extract32(inst, 5, 2) << 6;
+}
+
+static uint32_t operand_cimmq(rv_inst inst)
+{
+    return extract32(inst, 11, 2) << 4 |
+        extract32(inst, 10, 1) << 8 |
+        extract32(inst, 5, 2) << 6;
+}
+
+static int32_t operand_vimm(rv_inst inst)
+{
+    return sextract32(inst, 15, 5);
+}
+
+static uint32_t operand_vuimm(rv_inst inst)
+{
+    return extract32(inst, 15, 5);
+}
+
+static uint32_t operand_vzimm11(rv_inst inst)
+{
+    return extract32(inst, 20, 11);
+}
+
+static uint32_t operand_vzimm10(rv_inst inst)
+{
+    return extract32(inst, 20, 10);
+}
+
+static uint32_t operand_vzimm6(rv_inst inst)
+{
+    return extract32(inst, 26, 1) << 5 |
+        extract32(inst, 15, 5);
+}
+
+static uint32_t operand_bs(rv_inst inst)
+{
+    return extract32(inst, 30, 2);
+}
+
+static uint32_t operand_rnum(rv_inst inst)
+{
+    return extract32(inst, 20, 4);
+}
+
+static uint32_t operand_vm(rv_inst inst)
+{
+    return extract32(inst, 25, 1);
+}
+
+static uint32_t operand_uimm_c_lb(rv_inst inst)
+{
+    return extract32(inst, 5, 1) << 1 |
+        extract32(inst, 6, 1);
+}
+
+static uint32_t operand_uimm_c_lh(rv_inst inst)
+{
+    return extract32(inst, 5, 1) << 1;
+}
+
+static uint32_t operand_zcmp_spimm(rv_inst inst)
+{
+    return extract32(inst, 2, 2) << 4;
+}
+
+static uint32_t operand_zcmp_rlist(rv_inst inst)
+{
+    return extract32(inst, 4, 4);
+}
+
+static uint32_t operand_imm6(rv_inst inst)
+{
+    return extract32(inst, 20, 6);
+}
+
+static uint32_t operand_imm2(rv_inst inst)
+{
+    return extract32(inst, 25, 2);
+}
+
+static uint32_t operand_immh(rv_inst inst)
+{
+    return extract32(inst, 26, 6);
+}
+
+static uint32_t operand_imml(rv_inst inst)
+{
+    return extract32(inst, 20, 6);
+}
+
+static uint32_t calculate_stack_adj(rv_isa isa, uint32_t rlist,

uint32_t spimm)

disas/riscv.c +23 -0
+{
+    int xlen_bytes_log2 = isa == rv64 ? 3 : 2;
+    int regs = rlist == 15 ? 13 : rlist - 3;
+    uint32_t stack_adj_base = ROUND_UP(regs << xlen_bytes_log2, 16);
+    return stack_adj_base + spimm;
+}
+
+static uint32_t operand_zcmp_stack_adj(rv_inst inst, rv_isa isa)
+{
+    return calculate_stack_adj(isa, operand_zcmp_rlist(inst),
+                               operand_zcmp_spimm(inst));
+}
+
+static uint32_t operand_tbl_index(rv_inst inst)
+{
+    return extract32(inst, 2, 8);
+}
+
+static uint32_t operand_lpl(rv_inst inst)
+{
+    return extract32(inst, 12, 20);
+}
+

 /* instruction metadata */

 const rv_opcode_data rvi_opcode_data[] = {

disas/riscv.c +0 -0
@@ -4198,401 +4593,6 @@ static void decode_inst_opcode(rv_decode
 *dec, rv_isa isa)
      dec->op = op;
  }

disas/riscv.c +0 -372
-/* operand extractors */
-
-static uint32_t operand_rd(rv_inst inst)
-{
-    return extract32(inst, 7, 5);
-}
-
-static uint32_t operand_rs1(rv_inst inst)
-{
-    return extract32(inst, 15, 5);
-}
-
-static uint32_t operand_rs2(rv_inst inst)
-{
-    return extract32(inst, 20, 5);
-}
-
-static uint32_t operand_rs3(rv_inst inst)
-{
-    return extract32(inst, 27, 5);
-}
-
-static uint32_t operand_aq(rv_inst inst)
-{
-    return extract32(inst, 26, 1);
-}
-
-static uint32_t operand_rl(rv_inst inst)
-{
-    return extract32(inst, 25, 1);
-}
-
-static uint32_t operand_pred(rv_inst inst)
-{
-    return extract32(inst, 24, 4);
-}
-
-static uint32_t operand_succ(rv_inst inst)
-{
-    return extract32(inst, 20, 4);
-}
-
-static uint32_t operand_rm(rv_inst inst)
-{
-    return extract32(inst, 12, 3);
-}
-
-static uint32_t operand_shamt5(rv_inst inst)
-{
-    return extract32(inst, 20, 5);
-}
-
-static uint32_t operand_shamt6(rv_inst inst)
-{
-    return extract32(inst, 20, 6);
-}
-
-static uint32_t operand_shamt7(rv_inst inst)
-{
-    return extract32(inst, 20, 7);
-}
-
-static uint32_t operand_crdq(rv_inst inst)
-{
-    return extract32(inst, 2, 3);
-}
-
-static uint32_t operand_crs1q(rv_inst inst)
-{
-    return extract32(inst, 7, 3);
-}
-
-static uint32_t operand_crs1rdq(rv_inst inst)
-{
-    return extract32(inst, 7, 3);
-}
-
-static uint32_t operand_crs2q(rv_inst inst)
-{
-    return extract32(inst, 2, 3);
-}
-
-static uint32_t calculate_xreg(uint32_t sreg)
-{
-    return sreg < 2 ? sreg + 8 : sreg + 16;
-}
-
-static uint32_t operand_sreg1(rv_inst inst)
-{
-    return calculate_xreg(extract32(inst, 7, 3));
-}
-
-static uint32_t operand_sreg2(rv_inst inst)
-{
-    return calculate_xreg(extract32(inst, 2, 3));
-}
-
-static uint32_t operand_crd(rv_inst inst)
-{
-    return extract32(inst, 7, 5);
-}
-
-static uint32_t operand_crs1(rv_inst inst)
-{
-    return extract32(inst, 7, 5);
-}
-
-static uint32_t operand_crs1rd(rv_inst inst)
-{
-    return extract32(inst, 7, 5);
-}
-
-static uint32_t operand_crs2(rv_inst inst)
-{
-    return extract32(inst, 2, 5);
-}
-
-static uint32_t operand_cimmsh5(rv_inst inst)
-{
-    return extract32(inst, 2, 5);
-}
-
-static uint32_t operand_csr12(rv_inst inst)
-{
-    return extract32(inst, 20, 12);
-}
-
-static int32_t operand_imm12(rv_inst inst)
-{
-    return sextract32(inst, 20, 12);
-}
-
-static int32_t operand_imm20(rv_inst inst)
-{
-    return sextract32(inst, 12, 20) << 12;
-}
-
-static int32_t operand_jimm20(rv_inst inst)
-{
-    return sextract32(inst, 31, 1) << 20 |
-        extract32(inst, 21, 10) << 1 |
-        extract32(inst, 20, 1) << 11 |
-        extract32(inst, 12, 8) << 12;
-}
-
-static int32_t operand_simm12(rv_inst inst)
-{
-    return sextract32(inst, 25, 7) << 5 |
-        extract32(inst, 7, 5);
-}
-
-static int32_t operand_sbimm12(rv_inst inst)
-{
-    return sextract32(inst, 31, 1) << 12 |
-        extract32(inst, 25, 6) << 5 |
-        extract32(inst, 8, 4) << 1 |
-        extract32(inst, 7, 1) << 11;
-}
-
-static uint32_t operand_cimmshl6(rv_inst inst, rv_isa isa)
-{
-    int imm = extract32(inst, 12, 1) << 5 |
-        extract32(inst, 2, 5);
-    if (isa == rv128) {
-        imm = imm ? imm : 64;
-    }
-    return imm;
-}
-
-static uint32_t operand_cimmshr6(rv_inst inst, rv_isa isa)
-{
-    int imm = extract32(inst, 12, 1) << 5 |
-        extract32(inst, 2, 5);
-    if (isa == rv128) {
-        imm = imm | (imm & 32) << 1;
-        imm = imm ? imm : 64;
-    }
-    return imm;
-}
-
-static int32_t operand_cimmi(rv_inst inst)
-{
-    return sextract32(inst, 12, 1) << 5 |
-        extract32(inst, 2, 5);
-}
-
-static int32_t operand_cimmui(rv_inst inst)
-{
-    return sextract32(inst, 12, 1) << 17 |
-        extract32(inst, 2, 5) << 12;
-}
-
-static uint32_t operand_cimmlwsp(rv_inst inst)
-{
-    return extract32(inst, 12, 1) << 5 |
-        extract32(inst, 4, 3) << 2 |
-        extract32(inst, 2, 2) << 6;
-}
-
-static uint32_t operand_cimmldsp(rv_inst inst)
-{
-    return extract32(inst, 12, 1) << 5 |
-        extract32(inst, 5, 2) << 3 |
-        extract32(inst, 2, 3) << 6;
-}
-
-static uint32_t operand_cimmlqsp(rv_inst inst)
-{
-    return extract32(inst, 12, 1) << 5 |
-        extract32(inst, 6, 1) << 4 |
-        extract32(inst, 2, 4) << 6;
-}
-
-static int32_t operand_cimm16sp(rv_inst inst)
-{
-    return sextract32(inst, 12, 1) << 9 |
-        extract32(inst, 6, 1) << 4 |
-        extract32(inst, 5, 1) << 6 |
-        extract32(inst, 3, 2) << 7 |
-        extract32(inst, 2, 1) << 5;
-}
-
-static int32_t operand_cimmj(rv_inst inst)
-{
-    return sextract32(inst, 12, 1) << 11 |
-        extract32(inst, 11, 1) << 4 |
-        extract32(inst, 9, 2) << 8 |
-        extract32(inst, 8, 1) << 10 |
-        extract32(inst, 7, 1) << 6 |
-        extract32(inst, 6, 1) << 7 |
-        extract32(inst, 3, 3) << 1 |
-        extract32(inst, 2, 1) << 5;
-}
-
-static int32_t operand_cimmb(rv_inst inst)
-{
-    return sextract32(inst, 12, 1) << 8 |
-        extract32(inst, 10, 2) << 3 |
-        extract32(inst, 5, 2) << 6 |
-        extract32(inst, 3, 2) << 1 |
-        extract32(inst, 2, 1) << 5;
-}
-
-static uint32_t operand_cimmswsp(rv_inst inst)
-{
-    return extract32(inst, 9, 4) << 2 |
-        extract32(inst, 7, 2) << 6;
-}
-
-static uint32_t operand_cimmsdsp(rv_inst inst)
-{
-    return extract32(inst, 10, 3) << 3 |
-        extract32(inst, 7, 3) << 6;
-}
-
-static uint32_t operand_cimmsqsp(rv_inst inst)
-{
-    return extract32(inst, 11, 2) << 4 |
-        extract32(inst, 7, 4) << 6;
-}
-
-static uint32_t operand_cimm4spn(rv_inst inst)
-{
-    return extract32(inst, 11, 2) << 4 |
-        extract32(inst, 7, 4) << 6 |
-        extract32(inst, 6, 1) << 2 |
-        extract32(inst, 5, 1) << 3;
-}
-
-static uint32_t operand_cimmw(rv_inst inst)
-{
-    return extract32(inst, 10, 3) << 3 |
-        extract32(inst, 6, 1) << 2 |
-        extract32(inst, 5, 1) << 6;
-}
-
-static uint32_t operand_cimmd(rv_inst inst)
-{
-    return extract32(inst, 10, 3) << 3 |
-        extract32(inst, 5, 2) << 6;
-}
-
-static uint32_t operand_cimmq(rv_inst inst)
-{
-    return extract32(inst, 11, 2) << 4 |
-        extract32(inst, 10, 1) << 8 |
-        extract32(inst, 5, 2) << 6;
-}
-
-static int32_t operand_vimm(rv_inst inst)
-{
-    return sextract32(inst, 15, 5);
-}
-
-static uint32_t operand_vuimm(rv_inst inst)
-{
-    return extract32(inst, 15, 5);
-}
-
-static uint32_t operand_vzimm11(rv_inst inst)
-{
-    return extract32(inst, 20, 11);
-}
-
-static uint32_t operand_vzimm10(rv_inst inst)
-{
-    return extract32(inst, 20, 10);
-}
-
-static uint32_t operand_vzimm6(rv_inst inst)
-{
-    return extract32(inst, 26, 1) << 5 |
-        extract32(inst, 15, 5);
-}
-
-static uint32_t operand_bs(rv_inst inst)
-{
-    return extract32(inst, 30, 2);
-}
-
-static uint32_t operand_rnum(rv_inst inst)
-{
-    return extract32(inst, 20, 4);
-}
-
-static uint32_t operand_vm(rv_inst inst)
-{
-    return extract32(inst, 25, 1);
-}
-
-static uint32_t operand_uimm_c_lb(rv_inst inst)
-{
-    return extract32(inst, 5, 1) << 1 |
-        extract32(inst, 6, 1);
-}
-
-static uint32_t operand_uimm_c_lh(rv_inst inst)
-{
-    return extract32(inst, 5, 1) << 1;
-}
-
-static uint32_t operand_zcmp_spimm(rv_inst inst)
-{
-    return extract32(inst, 2, 2) << 4;
-}
-
-static uint32_t operand_zcmp_rlist(rv_inst inst)
-{
-    return extract32(inst, 4, 4);
-}
-
-static uint32_t operand_imm6(rv_inst inst)
-{
-    return extract32(inst, 20, 6);
-}
-
-static uint32_t operand_imm2(rv_inst inst)
-{
-    return extract32(inst, 25, 2);
-}
-
-static uint32_t operand_immh(rv_inst inst)
-{
-    return extract32(inst, 26, 6);
-}
-
-static uint32_t operand_imml(rv_inst inst)
-{
-    return extract32(inst, 20, 6);
-}
-
-static uint32_t calculate_stack_adj(rv_isa isa, uint32_t rlist,

uint32_t spimm)

disas/riscv.c +0 -23
-{
-    int xlen_bytes_log2 = isa == rv64 ? 3 : 2;
-    int regs = rlist == 15 ? 13 : rlist - 3;
-    uint32_t stack_adj_base = ROUND_UP(regs << xlen_bytes_log2, 16);
-    return stack_adj_base + spimm;
-}
-
-static uint32_t operand_zcmp_stack_adj(rv_inst inst, rv_isa isa)
-{
-    return calculate_stack_adj(isa, operand_zcmp_rlist(inst),
-                               operand_zcmp_spimm(inst));
-}
-
-static uint32_t operand_tbl_index(rv_inst inst)
-{
-    return extract32(inst, 2, 8);
-}
-
-static uint32_t operand_lpl(rv_inst inst)
-{
-    return extract32(inst, 12, 20);
-}
-

 /* decode operands */

 static void decode_inst_operands(rv_decode *dec, rv_isa isa)

#14 lore raw

PATCH 7/56 disas/riscv: Reduce rv_insn to uint32_t

In reply to Richard Henderson

Since 758dce9c98a, the only possible values for
instruction length are 2 and 4.

---
 disas/riscv.h |  2 +-
 disas/riscv.c | 12 +++---------
 2 files changed, 4 insertions(+), 10 deletions(-)
disas/riscv.h +1 -1
index 91ada8b531..eabe193b4f 100644
@@ -11,7 +11,7 @@
 
 /* types */
 
-typedef uint64_t rv_inst;
+typedef uint32_t rv_inst;
 typedef uint16_t rv_opcode;
 
 /* enums */
disas/riscv.c +3 -9
index e3fbc26626..012f90fce6 100644
@@ -5491,10 +5491,8 @@ static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
     return format_inst(24, &dec);
 }
 
-#define INST_FMT_2 "%04" PRIx64 "              "
-#define INST_FMT_4 "%08" PRIx64 "          "
-#define INST_FMT_6 "%012" PRIx64 "      "
-#define INST_FMT_8 "%016" PRIx64 "  "
+#define INST_FMT_2 "%04x              "
+#define INST_FMT_4 "%08x          "
 
 static int
 print_insn_riscv(bfd_vma memaddr, struct disassemble_info *info, rv_isa isa)
@@ -5530,12 +5528,8 @@ print_insn_riscv(bfd_vma memaddr, struct disassemble_info *info, rv_isa isa)
         case 4:
             (*info->fprintf_func)(info->stream, INST_FMT_4, inst);
             break;
-        case 6:
-            (*info->fprintf_func)(info->stream, INST_FMT_6, inst);
-            break;
         default:
-            (*info->fprintf_func)(info->stream, INST_FMT_8, inst);
-            break;
+            g_assert_not_reached();
         }
     }
 
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 7/56
#16 lore raw

Re: [PATCH 07/56] disas/riscv: Reduce rv_insn to uint32_t

In reply to Richard Henderson
Quoted 4 lines · Richard Henderson

Since 758dce9c98a, the only possible values for
instruction length are 2 and 4.

Alistair

Quoted 52 lines

---
 disas/riscv.h |  2 +-
 disas/riscv.c | 12 +++---------

 2 files changed, 4 insertions(+), 10 deletions(-)
disas/riscv.h +0 -0
index 91ada8b531..eabe193b4f 100644
@@ -11,7 +11,7 @@


 /* types */

disas/riscv.h +1 -1
-typedef uint64_t rv_inst;
+typedef uint32_t rv_inst;

 typedef uint16_t rv_opcode;

 /* enums */

disas/riscv.c +0 -0
index e3fbc26626..012f90fce6 100644
@@ -5491,10 +5491,8 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,
      return format_inst(24, &dec);
  }

disas/riscv.c +2 -4
-#define INST_FMT_2 "%04" PRIx64 "              "
-#define INST_FMT_4 "%08" PRIx64 "          "
-#define INST_FMT_6 "%012" PRIx64 "      "
-#define INST_FMT_8 "%016" PRIx64 "  "
+#define INST_FMT_2 "%04x              "
+#define INST_FMT_4 "%08x          "


 static int
 print_insn_riscv(bfd_vma memaddr, struct disassemble_info *info, rv_isa isa)

disas/riscv.c +0 -0
@@ -5530,12 +5528,8 @@ print_insn_riscv(bfd_vma memaddr, struct
 disassemble_info *info, rv_isa isa)

         case 4:
             (*info->fprintf_func)(info->stream, INST_FMT_4, inst); break;
-        case 6:
-            (*info->fprintf_func)(info->stream, INST_FMT_6, inst); -            break;
         default:
-            (*info->fprintf_func)(info->stream, INST_FMT_8, inst); -            break;
+            g_assert_not_reached();
         }
     }

#17 lore raw

PATCH 8/56 disas/riscv: Tidy dec initialization in disasm_inst

In reply to Richard Henderson
---
 disas/riscv.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
disas/riscv.c +5 -4
index 012f90fce6..986dc6b752 100644
@@ -5441,10 +5441,11 @@ static void decode_inst_decompress(rv_decode *dec, rv_isa isa)
 static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
                             const RISCVCPUConfig *cfg)
 {
-    rv_decode dec = { 0 };
-    dec.pc = pc;
-    dec.inst = inst;
-    dec.cfg = cfg;
+    rv_decode dec = {
+        .pc = pc,
+        .inst = inst,
+        .cfg = cfg,
+    };
 
     static const struct {
         bool (*guard_func)(const RISCVCPUConfig *);
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 8/56
#19 lore raw

Re: [PATCH 08/56] disas/riscv: Tidy dec initialization in disasm_inst

In reply to Richard Henderson
Quoted 1 line · Richard Henderson

Alistair

Quoted 25 lines

---
 disas/riscv.c | 9 +++++----

 1 file changed, 5 insertions(+), 4 deletions(-)
disas/riscv.c +5 -4
index 012f90fce6..986dc6b752 100644
@@ -5441,10 +5441,11 @@ static void decode_inst_decompress(rv_decode
 *dec, rv_isa isa)
  static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
                              const RISCVCPUConfig *cfg)
  {
-    rv_decode dec = { 0 };
-    dec.pc = pc;
-    dec.inst = inst;
-    dec.cfg = cfg;
+    rv_decode dec = {
+        .pc = pc,
+        .inst = inst,
+        .cfg = cfg,
+    };


     static const struct {
         bool (*guard_func)(const RISCVCPUConfig *);

#20 lore raw

PATCH 9/56 disas/riscv: Pass rv_opcode_data pointer to decode_inst_operands

In reply to Richard Henderson
---
 disas/riscv.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
disas/riscv.c +8 -4
index 986dc6b752..af43940732 100644
@@ -4595,11 +4595,12 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
 
 /* decode operands */
 
-static void decode_inst_operands(rv_decode *dec, rv_isa isa)
+static void decode_inst_operands(rv_decode *dec, rv_isa isa,
+                                 const rv_opcode_data *op)
 {
-    const rv_opcode_data *opcode_data = dec->opcode_data;
     rv_inst inst = dec->inst;
-    dec->codec = opcode_data[dec->op].codec;
+
+    dec->codec = op->codec;
     switch (dec->codec) {
     case rv_codec_none:
         dec->rd = dec->rs1 = dec->rs2 = rv_ireg_zero;
@@ -5468,6 +5469,8 @@ static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
         { has_xlrbr_p, rv_xlrbr_opcode_data, decode_xlrbr },
     };
 
+    const rv_opcode_data *op;
+
     for (size_t i = 0; i < ARRAY_SIZE(decoders); i++) {
         bool (*guard_func)(const RISCVCPUConfig *) = decoders[i].guard_func;
         const rv_opcode_data *opcode_data = decoders[i].opcode_data;
@@ -5486,7 +5489,8 @@ static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
         dec.opcode_data = rvi_opcode_data;
     }
 
-    decode_inst_operands(&dec, isa);
+    op = &dec.opcode_data[dec.op];
+    decode_inst_operands(&dec, isa, op);
     decode_inst_decompress(&dec, isa);
     decode_inst_lift_pseudo(&dec);
     return format_inst(24, &dec);
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 9/56
#21 lore raw

Re: [PATCH 09/56] disas/riscv: Pass rv_opcode_data pointer to decode_inst_operands

Quoted 1 line · Richard Henderson

Alistair

Quoted 47 lines

---
 disas/riscv.c | 12 ++++++++----

 1 file changed, 8 insertions(+), 4 deletions(-)
disas/riscv.c +0 -0
index 986dc6b752..af43940732 100644
@@ -4595,11 +4595,12 @@ static void decode_inst_opcode(rv_decode
 *dec, rv_isa isa)


 /* decode operands */

disas/riscv.c +2 -1
-static void decode_inst_operands(rv_decode *dec, rv_isa isa)
+static void decode_inst_operands(rv_decode *dec, rv_isa isa,
+                                 const rv_opcode_data *op)

 {
-    const rv_opcode_data *opcode_data = dec->opcode_data; rv_inst inst = dec->inst;
-    dec->codec = opcode_data[dec->op].codec;
+
+    dec->codec = op->codec;
     switch (dec->codec) {
     case rv_codec_none:
         dec->rd = dec->rs1 = dec->rs2 = rv_ireg_zero;

disas/riscv.c +0 -0
@@ -5468,6 +5469,8 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,
          { has_xlrbr_p, rv_xlrbr_opcode_data, decode_xlrbr },
      };


+    const rv_opcode_data *op;
+
     for (size_t i = 0; i < ARRAY_SIZE(decoders); i++) { bool (*guard_func)(const RISCVCPUConfig *) = decoders[i].guard_func;
         const rv_opcode_data *opcode_data = decoders[i].opcode_data;

disas/riscv.c +0 -0
@@ -5486,7 +5489,8 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,
          dec.opcode_data = rvi_opcode_data;
      }


-    decode_inst_operands(&dec, isa);
+    op = &dec.opcode_data[dec.op];
+    decode_inst_operands(&dec, isa, op);
     decode_inst_decompress(&dec, isa);
     decode_inst_lift_pseudo(&dec);
     return format_inst(24, &dec);

#22 lore raw

PATCH 10/56 disas/riscv: Pass rv_opcode_data pointer to/from decode_inst_decompress

In reply to Richard Henderson

Unify 4 functions, sharing code.

---
 disas/riscv.c | 70 ++++++++++++++++-----------------------------------
 1 file changed, 21 insertions(+), 49 deletions(-)
disas/riscv.c +21 -49
index af43940732..47fae7316c 100644
@@ -5377,64 +5377,36 @@ static void decode_inst_lift_pseudo(rv_decode *dec)
 
 /* decompress instruction */
 
-static void decode_inst_decompress_rv32(rv_decode *dec)
+static const rv_opcode_data *decode_inst_decompress(rv_decode *dec, rv_isa isa,
+                                                    const rv_opcode_data *op)
 {
-    const rv_opcode_data *opcode_data = dec->opcode_data;
-    int decomp_op = opcode_data[dec->op].decomp_rv32;
-    if (decomp_op != rv_op_illegal) {
-        if ((opcode_data[dec->op].decomp_data & rvcd_imm_nz)
-            && dec->imm == 0) {
-            dec->op = rv_op_illegal;
-        } else {
-            dec->op = decomp_op;
-            dec->codec = opcode_data[decomp_op].codec;
-        }
-    }
-}
+    int decomp_op;
 
-static void decode_inst_decompress_rv64(rv_decode *dec)
-{
-    const rv_opcode_data *opcode_data = dec->opcode_data;
-    int decomp_op = opcode_data[dec->op].decomp_rv64;
-    if (decomp_op != rv_op_illegal) {
-        if ((opcode_data[dec->op].decomp_data & rvcd_imm_nz)
-            && dec->imm == 0) {
-            dec->op = rv_op_illegal;
-        } else {
-            dec->op = decomp_op;
-            dec->codec = opcode_data[decomp_op].codec;
-        }
-    }
-}
-
-static void decode_inst_decompress_rv128(rv_decode *dec)
-{
-    const rv_opcode_data *opcode_data = dec->opcode_data;
-    int decomp_op = opcode_data[dec->op].decomp_rv128;
-    if (decomp_op != rv_op_illegal) {
-        if ((opcode_data[dec->op].decomp_data & rvcd_imm_nz)
-            && dec->imm == 0) {
-            dec->op = rv_op_illegal;
-        } else {
-            dec->op = decomp_op;
-            dec->codec = opcode_data[decomp_op].codec;
-        }
-    }
-}
-
-static void decode_inst_decompress(rv_decode *dec, rv_isa isa)
-{
     switch (isa) {
     case rv32:
-        decode_inst_decompress_rv32(dec);
+        decomp_op = op->decomp_rv32;
         break;
     case rv64:
-        decode_inst_decompress_rv64(dec);
+        decomp_op = op->decomp_rv64;
         break;
     case rv128:
-        decode_inst_decompress_rv128(dec);
+        decomp_op = op->decomp_rv128;
         break;
+    default:
+        g_assert_not_reached();
     }
+
+    if (decomp_op != rv_op_illegal) {
+        if ((op->decomp_data & rvcd_imm_nz) && dec->imm == 0) {
+            dec->opcode_data = rvi_opcode_data;
+            dec->op = rv_op_illegal;
+        } else {
+            dec->op = decomp_op;
+        }
+        op = &dec->opcode_data[decomp_op];
+        dec->codec = op->codec;
+    }
+    return op;
 }
 
 /* disassemble instruction */
@@ -5491,7 +5463,7 @@ static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
 
     op = &dec.opcode_data[dec.op];
     decode_inst_operands(&dec, isa, op);
-    decode_inst_decompress(&dec, isa);
+    op = decode_inst_decompress(&dec, isa, op);
     decode_inst_lift_pseudo(&dec);
     return format_inst(24, &dec);
 }
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 10/56
#23 lore raw

Re: [PATCH 10/56] disas/riscv: Pass rv_opcode_data pointer to/from decode_inst_decompress

Quoted 3 lines · Richard Henderson

Unify 4 functions, sharing code.

Alistair

Quoted 107 lines

---
 disas/riscv.c | 70 ++++++++++++++++--------------------------------- --

 1 file changed, 21 insertions(+), 49 deletions(-)
disas/riscv.c +0 -0
index af43940732..47fae7316c 100644
@@ -5377,64 +5377,36 @@ static void decode_inst_lift_pseudo(rv_decode
 *dec)


 /* decompress instruction */

disas/riscv.c +1 -1
-static void decode_inst_decompress_rv32(rv_decode *dec)
+static const rv_opcode_data *decode_inst_decompress(rv_decode *dec,

rv_isa isa,
+                                                    const rv_opcode_data *op)
 {
-    const rv_opcode_data *opcode_data = dec->opcode_data; -    int decomp_op = opcode_data[dec->op].decomp_rv32; -    if (decomp_op != rv_op_illegal) {
-        if ((opcode_data[dec->op].decomp_data & rvcd_imm_nz) -            && dec->imm == 0) {
-            dec->op = rv_op_illegal;
-        } else {
-            dec->op = decomp_op;
-            dec->codec = opcode_data[decomp_op].codec; -        }
-    }
-}
+    int decomp_op;

disas/riscv.c +0 -32
-static void decode_inst_decompress_rv64(rv_decode *dec)
-{
-    const rv_opcode_data *opcode_data = dec->opcode_data;
-    int decomp_op = opcode_data[dec->op].decomp_rv64;
-    if (decomp_op != rv_op_illegal) {
-        if ((opcode_data[dec->op].decomp_data & rvcd_imm_nz)
-            && dec->imm == 0) {
-            dec->op = rv_op_illegal;
-        } else {
-            dec->op = decomp_op;
-            dec->codec = opcode_data[decomp_op].codec;
-        }
-    }
-}
-
-static void decode_inst_decompress_rv128(rv_decode *dec)
-{
-    const rv_opcode_data *opcode_data = dec->opcode_data;
-    int decomp_op = opcode_data[dec->op].decomp_rv128;
-    if (decomp_op != rv_op_illegal) {
-        if ((opcode_data[dec->op].decomp_data & rvcd_imm_nz)
-            && dec->imm == 0) {
-            dec->op = rv_op_illegal;
-        } else {
-            dec->op = decomp_op;
-            dec->codec = opcode_data[decomp_op].codec;
-        }
-    }
-}
-
-static void decode_inst_decompress(rv_decode *dec, rv_isa isa)
-{

     switch (isa) {
     case rv32:
-        decode_inst_decompress_rv32(dec);
+        decomp_op = op->decomp_rv32;
         break;
     case rv64:
-        decode_inst_decompress_rv64(dec);
+        decomp_op = op->decomp_rv64;
         break;
     case rv128:
-        decode_inst_decompress_rv128(dec);
+        decomp_op = op->decomp_rv128;
         break;
+    default:
+        g_assert_not_reached();
     }
+
+    if (decomp_op != rv_op_illegal) {
+        if ((op->decomp_data & rvcd_imm_nz) && dec->imm == 0) { +            dec->opcode_data = rvi_opcode_data;
+            dec->op = rv_op_illegal;
+        } else {
+            dec->op = decomp_op;
+        }
+        op = &dec->opcode_data[decomp_op];
+        dec->codec = op->codec;
+    }
+    return op;
 }

 /* disassemble instruction */

disas/riscv.c +0 -0
@@ -5491,7 +5463,7 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,


     op = &dec.opcode_data[dec.op];
     decode_inst_operands(&dec, isa, op);
-    decode_inst_decompress(&dec, isa);
+    op = decode_inst_decompress(&dec, isa, op);
     decode_inst_lift_pseudo(&dec);
     return format_inst(24, &dec);
 }

#24 lore raw

PATCH 11/56 disas/riscv: Pass rv_opcode_data pointer to/from decode_inst_lift_pseudo

In reply to Richard Henderson
---
 disas/riscv.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
disas/riscv.c +14 -13
index 47fae7316c..0be2f07612 100644
@@ -5358,21 +5358,22 @@ static GString *format_inst(size_t tab, rv_decode *dec)
 
 /* lift instruction to pseudo-instruction */
 
-static void decode_inst_lift_pseudo(rv_decode *dec)
+static const rv_opcode_data *decode_inst_lift_pseudo(rv_decode *dec,
+                                                     const rv_opcode_data *op)
 {
-    const rv_opcode_data *opcode_data = dec->opcode_data;
-    const rv_comp_data *comp_data = opcode_data[dec->op].pseudo;
-    if (!comp_data) {
-        return;
-    }
-    while (comp_data->constraints) {
-        if (check_constraints(dec, comp_data->constraints)) {
-            dec->op = comp_data->op;
-            dec->codec = opcode_data[dec->op].codec;
-            return;
+    const rv_comp_data *comp_data = op->pseudo;
+    if (comp_data) {
+        while (comp_data->constraints) {
+            if (check_constraints(dec, comp_data->constraints)) {
+                dec->op = comp_data->op;
+                op = &dec->opcode_data[dec->op];
+                dec->codec = op->codec;
+                break;
+            }
+            comp_data++;
         }
-        comp_data++;
     }
+    return op;
 }
 
 /* decompress instruction */
@@ -5464,7 +5465,7 @@ static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
     op = &dec.opcode_data[dec.op];
     decode_inst_operands(&dec, isa, op);
     op = decode_inst_decompress(&dec, isa, op);
-    decode_inst_lift_pseudo(&dec);
+    op = decode_inst_lift_pseudo(&dec, op);
     return format_inst(24, &dec);
 }
 
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 11/56
#25 lore raw

Re: [PATCH 11/56] disas/riscv: Pass rv_opcode_data pointer to/from decode_inst_lift_pseudo

Quoted 1 line · Richard Henderson

Alistair

Quoted 55 lines

---
 disas/riscv.c | 27 ++++++++++++++-------------

 1 file changed, 14 insertions(+), 13 deletions(-)
disas/riscv.c +0 -0
index 47fae7316c..0be2f07612 100644
@@ -5358,21 +5358,22 @@ static GString *format_inst(size_t tab,
 rv_decode *dec)


 /* lift instruction to pseudo-instruction */

disas/riscv.c +2 -1
-static void decode_inst_lift_pseudo(rv_decode *dec)
+static const rv_opcode_data *decode_inst_lift_pseudo(rv_decode *dec,
+                                                     const

rv_opcode_data *op)
 {
-    const rv_opcode_data *opcode_data = dec->opcode_data; -    const rv_comp_data *comp_data = opcode_data[dec->op].pseudo; -    if (!comp_data) {
-        return;
-    }
-    while (comp_data->constraints) {
-        if (check_constraints(dec, comp_data->constraints)) { -            dec->op = comp_data->op;
-            dec->codec = opcode_data[dec->op].codec;
-            return;
+    const rv_comp_data *comp_data = op->pseudo;
+    if (comp_data) {
+        while (comp_data->constraints) {
+            if (check_constraints(dec, comp_data->constraints)) { +                dec->op = comp_data->op;
+                op = &dec->opcode_data[dec->op];
+                dec->codec = op->codec;
+                break;
+            }
+            comp_data++;
         }
-        comp_data++;
     }
+    return op;
 }

 /* decompress instruction */

disas/riscv.c +1 -1
@@ -5464,7 +5465,7 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,
      op = &dec.opcode_data[dec.op];
      decode_inst_operands(&dec, isa, op);
      op = decode_inst_decompress(&dec, isa, op);
-    decode_inst_lift_pseudo(&dec);
+    op = decode_inst_lift_pseudo(&dec, op);
      return format_inst(24, &dec);
  }

#26 lore raw

PATCH 12/56 disas/riscv: Pass rv_opcode_data pointer to format_inst

In reply to Richard Henderson
---
 disas/riscv.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
disas/riscv.c +5 -6
index 0be2f07612..70ea41f125 100644
@@ -5111,17 +5111,16 @@ static size_t inst_length(rv_inst inst)
 
 /* format instruction */
 
-static GString *format_inst(size_t tab, rv_decode *dec)
+static GString *format_inst(size_t tab, rv_decode *dec,
+                            const rv_opcode_data *op)
 {
-    const rv_opcode_data *opcode_data = dec->opcode_data;
     GString *buf = g_string_sized_new(64);
-    const char *fmt;
+    const char *fmt = op->format;
 
-    fmt = opcode_data[dec->op].format;
     while (*fmt) {
         switch (*fmt) {
         case 'O':
-            g_string_append(buf, opcode_data[dec->op].name);
+            g_string_append(buf, op->name);
             break;
         case '(':
         case ',':
@@ -5466,7 +5465,7 @@ static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
     decode_inst_operands(&dec, isa, op);
     op = decode_inst_decompress(&dec, isa, op);
     op = decode_inst_lift_pseudo(&dec, op);
-    return format_inst(24, &dec);
+    return format_inst(24, &dec, op);
 }
 
 #define INST_FMT_2 "%04x              "
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 12/56
#27 lore raw

Re: [PATCH 12/56] disas/riscv: Pass rv_opcode_data pointer to format_inst

Quoted 1 line · Richard Henderson

Alistair

Quoted 40 lines

---
 disas/riscv.c | 11 +++++------

 1 file changed, 5 insertions(+), 6 deletions(-)
disas/riscv.c +0 -0
index 0be2f07612..70ea41f125 100644
@@ -5111,17 +5111,16 @@ static size_t inst_length(rv_inst inst)


 /* format instruction */

disas/riscv.c +2 -1
-static GString *format_inst(size_t tab, rv_decode *dec)
+static GString *format_inst(size_t tab, rv_decode *dec,
+                            const rv_opcode_data *op)

 {
-    const rv_opcode_data *opcode_data = dec->opcode_data; GString *buf = g_string_sized_new(64);
-    const char *fmt;
+    const char *fmt = op->format;

-    fmt = opcode_data[dec->op].format;
     while (*fmt) {
         switch (*fmt) {
         case 'O':
-            g_string_append(buf, opcode_data[dec->op].name); +            g_string_append(buf, op->name);
             break;
         case '(':
         case ',':

disas/riscv.c +1 -1
@@ -5466,7 +5465,7 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,
      decode_inst_operands(&dec, isa, op);
      op = decode_inst_decompress(&dec, isa, op);
      op = decode_inst_lift_pseudo(&dec, op);
-    return format_inst(24, &dec);
+    return format_inst(24, &dec, op);
  }


 #define INST_FMT_2 "%04x              "

#28 lore raw

PATCH 13/56 disas/riscv: Tidy disasm_inst main loop

In reply to Richard Henderson

Unroll first iteration, so that always_true_p is not used, Drop some local variables and use 'decoders' directly.

---
 disas/riscv.c | 63 +++++++++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 32 deletions(-)
disas/riscv.c +31 -32
index 70ea41f125..9880b8de20 100644
@@ -5419,41 +5419,40 @@ static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
         .inst = inst,
         .cfg = cfg,
     };
-
-    static const struct {
-        bool (*guard_func)(const RISCVCPUConfig *);
-        const rv_opcode_data *opcode_data;
-        void (*decode_func)(rv_decode *, rv_isa);
-    } decoders[] = {
-        { always_true_p, rvi_opcode_data, decode_inst_opcode },
-        { has_xtheadba_p, xthead_opcode_data, decode_xtheadba },
-        { has_xtheadbb_p, xthead_opcode_data, decode_xtheadbb },
-        { has_xtheadbs_p, xthead_opcode_data, decode_xtheadbs },
-        { has_xtheadcmo_p, xthead_opcode_data, decode_xtheadcmo },
-        { has_xtheadcondmov_p, xthead_opcode_data, decode_xtheadcondmov },
-        { has_xtheadfmemidx_p, xthead_opcode_data, decode_xtheadfmemidx },
-        { has_xtheadfmv_p, xthead_opcode_data, decode_xtheadfmv },
-        { has_xtheadmac_p, xthead_opcode_data, decode_xtheadmac },
-        { has_xtheadmemidx_p, xthead_opcode_data, decode_xtheadmemidx },
-        { has_xtheadmempair_p, xthead_opcode_data, decode_xtheadmempair },
-        { has_xtheadsync_p, xthead_opcode_data, decode_xtheadsync },
-        { has_XVentanaCondOps_p, ventana_opcode_data, decode_xventanacondops },
-        { has_xlrbr_p, rv_xlrbr_opcode_data, decode_xlrbr },
-    };
-
     const rv_opcode_data *op;
 
-    for (size_t i = 0; i < ARRAY_SIZE(decoders); i++) {
-        bool (*guard_func)(const RISCVCPUConfig *) = decoders[i].guard_func;
-        const rv_opcode_data *opcode_data = decoders[i].opcode_data;
-        void (*decode_func)(rv_decode *, rv_isa) = decoders[i].decode_func;
+    dec.opcode_data = rvi_opcode_data;
+    decode_inst_opcode(&dec, isa);
 
-        /* always_true_p don't dereference cfg */
-        if (((i == 0) || cfg) && guard_func(cfg)) {
-            dec.opcode_data = opcode_data;
-            decode_func(&dec, isa);
-            if (dec.op != rv_op_illegal)
-                break;
+    if (dec.op == rv_op_illegal && cfg) {
+        static const struct {
+            bool (*guard_func)(const RISCVCPUConfig *);
+            const rv_opcode_data *opcode_data;
+            void (*decode_func)(rv_decode *, rv_isa);
+        } decoders[] = {
+            { has_xtheadba_p, xthead_opcode_data, decode_xtheadba },
+            { has_xtheadbb_p, xthead_opcode_data, decode_xtheadbb },
+            { has_xtheadbs_p, xthead_opcode_data, decode_xtheadbs },
+            { has_xtheadcmo_p, xthead_opcode_data, decode_xtheadcmo },
+            { has_xtheadcondmov_p, xthead_opcode_data, decode_xtheadcondmov },
+            { has_xtheadfmemidx_p, xthead_opcode_data, decode_xtheadfmemidx },
+            { has_xtheadfmv_p, xthead_opcode_data, decode_xtheadfmv },
+            { has_xtheadmac_p, xthead_opcode_data, decode_xtheadmac },
+            { has_xtheadmemidx_p, xthead_opcode_data, decode_xtheadmemidx },
+            { has_xtheadmempair_p, xthead_opcode_data, decode_xtheadmempair },
+            { has_xtheadsync_p, xthead_opcode_data, decode_xtheadsync },
+            { has_XVentanaCondOps_p, ventana_opcode_data, decode_xventanacondops },
+            { has_xlrbr_p, rv_xlrbr_opcode_data, decode_xlrbr },
+        };
+
+        for (size_t i = 0; i < ARRAY_SIZE(decoders); i++) {
+            if (decoders[i].guard_func(cfg)) {
+                dec.opcode_data = decoders[i].opcode_data;
+                decoders[i].decode_func(&dec, isa);
+                if (dec.op != rv_op_illegal) {
+                    break;
+                }
+            }
         }
     }
 
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 13/56
#29 lore raw

Re: [PATCH 13/56] disas/riscv: Tidy disasm_inst main loop

Quoted 4 lines · Richard Henderson

Unroll first iteration, so that always_true_p is not used, Drop some local variables and use 'decoders' directly.

Alistair

Quoted 99 lines

---
 disas/riscv.c | 63 +++++++++++++++++++++++++------------------------ --

 1 file changed, 31 insertions(+), 32 deletions(-)
disas/riscv.c +0 -22
index 70ea41f125..9880b8de20 100644
@@ -5419,41 +5419,40 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,
          .inst = inst,
          .cfg = cfg,
      };
-
-    static const struct {
-        bool (*guard_func)(const RISCVCPUConfig *);
-        const rv_opcode_data *opcode_data;
-        void (*decode_func)(rv_decode *, rv_isa);
-    } decoders[] = {
-        { always_true_p, rvi_opcode_data, decode_inst_opcode },
-        { has_xtheadba_p, xthead_opcode_data, decode_xtheadba },
-        { has_xtheadbb_p, xthead_opcode_data, decode_xtheadbb },
-        { has_xtheadbs_p, xthead_opcode_data, decode_xtheadbs },
-        { has_xtheadcmo_p, xthead_opcode_data, decode_xtheadcmo },
-        { has_xtheadcondmov_p, xthead_opcode_data,
 decode_xtheadcondmov },
-        { has_xtheadfmemidx_p, xthead_opcode_data,
 decode_xtheadfmemidx },
-        { has_xtheadfmv_p, xthead_opcode_data, decode_xtheadfmv },
-        { has_xtheadmac_p, xthead_opcode_data, decode_xtheadmac },
-        { has_xtheadmemidx_p, xthead_opcode_data,
 decode_xtheadmemidx },
-        { has_xtheadmempair_p, xthead_opcode_data,
 decode_xtheadmempair },
-        { has_xtheadsync_p, xthead_opcode_data, decode_xtheadsync },
-        { has_XVentanaCondOps_p, ventana_opcode_data,
 decode_xventanacondops },
-        { has_xlrbr_p, rv_xlrbr_opcode_data, decode_xlrbr },
-    };
-
      const rv_opcode_data *op;


-    for (size_t i = 0; i < ARRAY_SIZE(decoders); i++) {
-        bool (*guard_func)(const RISCVCPUConfig *) = decoders[i].guard_func;
-        const rv_opcode_data *opcode_data = decoders[i].opcode_data; -        void (*decode_func)(rv_decode *, rv_isa) = decoders[i].decode_func;
+    dec.opcode_data = rvi_opcode_data;
+    decode_inst_opcode(&dec, isa);

-        /* always_true_p don't dereference cfg */
-        if (((i == 0) || cfg) && guard_func(cfg)) {
-            dec.opcode_data = opcode_data;
-            decode_func(&dec, isa);
-            if (dec.op != rv_op_illegal)
-                break;
+    if (dec.op == rv_op_illegal && cfg) {
+        static const struct {
+            bool (*guard_func)(const RISCVCPUConfig *);
+            const rv_opcode_data *opcode_data;
+            void (*decode_func)(rv_decode *, rv_isa);
+        } decoders[] = {
+            { has_xtheadba_p, xthead_opcode_data, decode_xtheadba }, +            { has_xtheadbb_p, xthead_opcode_data, decode_xtheadbb }, +            { has_xtheadbs_p, xthead_opcode_data, decode_xtheadbs }, +            { has_xtheadcmo_p, xthead_opcode_data, decode_xtheadcmo },
+            { has_xtheadcondmov_p, xthead_opcode_data, decode_xtheadcondmov },
+            { has_xtheadfmemidx_p, xthead_opcode_data, decode_xtheadfmemidx },
+            { has_xtheadfmv_p, xthead_opcode_data, decode_xtheadfmv },
+            { has_xtheadmac_p, xthead_opcode_data, decode_xtheadmac },
+            { has_xtheadmemidx_p, xthead_opcode_data, decode_xtheadmemidx },
+            { has_xtheadmempair_p, xthead_opcode_data, decode_xtheadmempair },
+            { has_xtheadsync_p, xthead_opcode_data, decode_xtheadsync },
+            { has_XVentanaCondOps_p, ventana_opcode_data, decode_xventanacondops },
+            { has_xlrbr_p, rv_xlrbr_opcode_data, decode_xlrbr }, +        };
+
+        for (size_t i = 0; i < ARRAY_SIZE(decoders); i++) { +            if (decoders[i].guard_func(cfg)) {
+                dec.opcode_data = decoders[i].opcode_data; +                decoders[i].decode_func(&dec, isa);
+                if (dec.op != rv_op_illegal) {
+                    break;
+                }
+            }
         }
     }

#30 lore raw

PATCH 14/56 disas/riscv: Set dec->opcode_data in decode function

In reply to Richard Henderson

This allows each opcode table to be private to the decode file.

---
 disas/riscv-xlrbr.h    |  2 --
 disas/riscv-xthead.h   |  2 --
 disas/riscv-xventana.h |  2 --
 disas/riscv-xlrbr.c    |  4 +++-
 disas/riscv-xthead.c   | 13 ++++++++++++-
 disas/riscv-xventana.c |  3 ++-
 disas/riscv.c          | 34 +++++++++++++++++-----------------
 7 files changed, 34 insertions(+), 26 deletions(-)
disas/riscv-xlrbr.h +0 -2
index 939a69ea6d..ebf3d4c133 100644
@@ -12,8 +12,6 @@
 
 #include "disas/riscv.h"
 
-extern const rv_opcode_data rv_xlrbr_opcode_data[];
-
 void decode_xlrbr(rv_decode *, rv_isa);
 
 #endif /* DISAS_RISCV_XLRBR_H */
disas/riscv-xthead.h +0 -2
index fcd42746e7..0c65c8e0af 100644
@@ -11,8 +11,6 @@
 
 #include "disas/riscv.h"
 
-extern const rv_opcode_data xthead_opcode_data[];
-
 void decode_xtheadba(rv_decode *, rv_isa);
 void decode_xtheadbb(rv_decode *, rv_isa);
 void decode_xtheadbs(rv_decode *, rv_isa);
disas/riscv-xventana.h +0 -2
index 72be9ffa16..1006c3be00 100644
@@ -11,8 +11,6 @@
 
 #include "disas/riscv.h"
 
-extern const rv_opcode_data ventana_opcode_data[];
-
 void decode_xventanacondops(rv_decode*, rv_isa);
 
 #endif /* DISAS_RISCV_XVENTANA_H */
disas/riscv-xlrbr.c +3 -1
index 57cb434523..f61028fce9 100644
@@ -24,7 +24,7 @@ typedef enum {
     rv_op_crc32c_d = 8,
 } rv_xlrbr_op;
 
-const rv_opcode_data rv_xlrbr_opcode_data[] = {
+static const rv_opcode_data xlrbr_opcode_data[] = {
     { "illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 },
     { "crc32.b", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
     { "crc32.h", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
@@ -75,5 +75,7 @@ void decode_xlrbr(rv_decode *dec, rv_isa isa)
         }
         break;
     }
+
+    dec->opcode_data = xlrbr_opcode_data;
     dec->op = op;
 }
disas/riscv-xthead.c +12 -1
index 2f2ddb8dd9..96f80bc8e5 100644
@@ -127,7 +127,7 @@ typedef enum {
     rv_op_th_sync_s,
 } rv_xthead_op;
 
-const rv_opcode_data xthead_opcode_data[] = {
+static const rv_opcode_data xthead_opcode_data[] = {
     { "th.illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 },
     /* XTheadBa */
     { "th.addsl", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
@@ -272,6 +272,7 @@ void decode_xtheadba(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }
 
@@ -330,6 +331,7 @@ void decode_xtheadbb(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }
 
@@ -356,6 +358,7 @@ void decode_xtheadbs(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }
 
@@ -434,6 +437,7 @@ void decode_xtheadcmo(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }
 
@@ -461,6 +465,7 @@ void decode_xtheadcondmov(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }
 
@@ -498,6 +503,7 @@ void decode_xtheadfmemidx(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }
 
@@ -533,6 +539,7 @@ void decode_xtheadfmv(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }
 
@@ -564,6 +571,7 @@ void decode_xtheadmac(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }
 
@@ -638,6 +646,7 @@ void decode_xtheadmemidx(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }
 
@@ -672,6 +681,7 @@ void decode_xtheadmempair(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }
 
@@ -706,5 +716,6 @@ void decode_xtheadsync(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }
disas/riscv-xventana.c +2 -1
index cd694f15f3..4539173d95 100644
@@ -14,7 +14,7 @@ typedef enum {
     ventana_op_vt_maskcn = 2,
 } rv_ventana_op;
 
-const rv_opcode_data ventana_opcode_data[] = {
+static const rv_opcode_data ventana_opcode_data[] = {
     { "vt.illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 },
     { "vt.maskc", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
     { "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
@@ -38,5 +38,6 @@ void decode_xventanacondops(rv_decode *dec, rv_isa isa)
         break;
     }
 
+    dec->opcode_data = ventana_opcode_data;
     dec->op = op;
 }
disas/riscv.c +17 -17
index 9880b8de20..eb6d132a2c 100644
@@ -1656,7 +1656,7 @@ static uint32_t operand_lpl(rv_inst inst)
 
 /* instruction metadata */
 
-const rv_opcode_data rvi_opcode_data[] = {
+static const rv_opcode_data rvi_opcode_data[] = {
     { "illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 },
     { "lui", rv_codec_u, rv_fmt_rd_uimm, NULL, 0, 0, 0 },
     { "auipc", rv_codec_u, rv_fmt_rd_uoffset, NULL, 0, 0, 0 },
@@ -2948,6 +2948,7 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;
+
     switch ((inst >> 0) & 0b11) {
     case 0:
         switch ((inst >> 13) & 0b111) {
@@ -4590,6 +4591,8 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
         }
         break;
     }
+
+    dec->opcode_data = rvi_opcode_data;
     dec->op = op;
 }
 
@@ -5421,33 +5424,30 @@ static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
     };
     const rv_opcode_data *op;
 
-    dec.opcode_data = rvi_opcode_data;
     decode_inst_opcode(&dec, isa);
 
     if (dec.op == rv_op_illegal && cfg) {
         static const struct {
             bool (*guard_func)(const RISCVCPUConfig *);
-            const rv_opcode_data *opcode_data;
             void (*decode_func)(rv_decode *, rv_isa);
         } decoders[] = {
-            { has_xtheadba_p, xthead_opcode_data, decode_xtheadba },
-            { has_xtheadbb_p, xthead_opcode_data, decode_xtheadbb },
-            { has_xtheadbs_p, xthead_opcode_data, decode_xtheadbs },
-            { has_xtheadcmo_p, xthead_opcode_data, decode_xtheadcmo },
-            { has_xtheadcondmov_p, xthead_opcode_data, decode_xtheadcondmov },
-            { has_xtheadfmemidx_p, xthead_opcode_data, decode_xtheadfmemidx },
-            { has_xtheadfmv_p, xthead_opcode_data, decode_xtheadfmv },
-            { has_xtheadmac_p, xthead_opcode_data, decode_xtheadmac },
-            { has_xtheadmemidx_p, xthead_opcode_data, decode_xtheadmemidx },
-            { has_xtheadmempair_p, xthead_opcode_data, decode_xtheadmempair },
-            { has_xtheadsync_p, xthead_opcode_data, decode_xtheadsync },
-            { has_XVentanaCondOps_p, ventana_opcode_data, decode_xventanacondops },
-            { has_xlrbr_p, rv_xlrbr_opcode_data, decode_xlrbr },
+            { has_xtheadba_p, decode_xtheadba },
+            { has_xtheadbb_p, decode_xtheadbb },
+            { has_xtheadbs_p, decode_xtheadbs },
+            { has_xtheadcmo_p, decode_xtheadcmo },
+            { has_xtheadcondmov_p, decode_xtheadcondmov },
+            { has_xtheadfmemidx_p, decode_xtheadfmemidx },
+            { has_xtheadfmv_p, decode_xtheadfmv },
+            { has_xtheadmac_p, decode_xtheadmac },
+            { has_xtheadmemidx_p, decode_xtheadmemidx },
+            { has_xtheadmempair_p, decode_xtheadmempair },
+            { has_xtheadsync_p, decode_xtheadsync },
+            { has_XVentanaCondOps_p, decode_xventanacondops },
+            { has_xlrbr_p, decode_xlrbr },
         };
 
         for (size_t i = 0; i < ARRAY_SIZE(decoders); i++) {
             if (decoders[i].guard_func(cfg)) {
-                dec.opcode_data = decoders[i].opcode_data;
                 decoders[i].decode_func(&dec, isa);
                 if (dec.op != rv_op_illegal) {
                     break;
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 14/56
#31 lore raw

Re: [PATCH 14/56] disas/riscv: Set dec->opcode_data in decode function

Quoted 3 lines · Richard Henderson

This allows each opcode table to be private to the decode file.

Alistair

Quoted 286 lines

---
 disas/riscv-xlrbr.h    |  2 --
 disas/riscv-xthead.h   |  2 -- disas/riscv-xventana.h |  2 --
 disas/riscv-xlrbr.c    |  4 +++- disas/riscv-xthead.c   | 13 ++++++++++++- disas/riscv-xventana.c |  3 ++-
 disas/riscv.c          | 34 +++++++++++++++++-----------------

 7 files changed, 34 insertions(+), 26 deletions(-)
disas/riscv-xlrbr.h +0 -0
index 939a69ea6d..ebf3d4c133 100644
@@ -12,8 +12,6 @@


 #include "disas/riscv.h"

disas/riscv-xlrbr.h +0 -2
-extern const rv_opcode_data rv_xlrbr_opcode_data[];
-

 void decode_xlrbr(rv_decode *, rv_isa);

 #endif /* DISAS_RISCV_XLRBR_H */

disas/riscv-xthead.h +0 -0
index fcd42746e7..0c65c8e0af 100644
@@ -11,8 +11,6 @@


 #include "disas/riscv.h"

disas/riscv-xthead.h +0 -2
-extern const rv_opcode_data xthead_opcode_data[];
-

 void decode_xtheadba(rv_decode *, rv_isa);
 void decode_xtheadbb(rv_decode *, rv_isa);
 void decode_xtheadbs(rv_decode *, rv_isa);

disas/riscv-xventana.h +0 -0
index 72be9ffa16..1006c3be00 100644
@@ -11,8 +11,6 @@


 #include "disas/riscv.h"

disas/riscv-xventana.h +0 -2
-extern const rv_opcode_data ventana_opcode_data[];
-

 void decode_xventanacondops(rv_decode*, rv_isa);

 #endif /* DISAS_RISCV_XVENTANA_H */

disas/riscv-xlrbr.c +0 -0
index 57cb434523..f61028fce9 100644
@@ -24,7 +24,7 @@ typedef enum {
      rv_op_crc32c_d = 8,
  } rv_xlrbr_op;

disas/riscv-xlrbr.c +1 -1
-const rv_opcode_data rv_xlrbr_opcode_data[] = {
+static const rv_opcode_data xlrbr_opcode_data[] = {

     { "illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 }, { "crc32.b", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, { "crc32.h", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },

disas/riscv-xlrbr.c +2 -0
@@ -75,5 +75,7 @@ void decode_xlrbr(rv_decode *dec, rv_isa isa)
          }
          break;
      }
+
+    dec->opcode_data = xlrbr_opcode_data;
      dec->op = op;
  }
disas/riscv-xthead.c +0 -0
index 2f2ddb8dd9..96f80bc8e5 100644
@@ -127,7 +127,7 @@ typedef enum {
      rv_op_th_sync_s,
  } rv_xthead_op;

disas/riscv-xthead.c +1 -1
-const rv_opcode_data xthead_opcode_data[] = {
+static const rv_opcode_data xthead_opcode_data[] = {

     { "th.illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 }, /* XTheadBa */
     { "th.addsl", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },

disas/riscv-xthead.c +0 -0
@@ -272,6 +272,7 @@ void decode_xtheadba(rv_decode *dec, rv_isa isa)
          break;
      }


+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }

disas/riscv-xthead.c +0 -0
@@ -330,6 +331,7 @@ void decode_xtheadbb(rv_decode *dec, rv_isa isa)
          break;
      }


+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }

disas/riscv-xthead.c +0 -0
@@ -356,6 +358,7 @@ void decode_xtheadbs(rv_decode *dec, rv_isa isa)
          break;
      }


+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }

disas/riscv-xthead.c +0 -0
@@ -434,6 +437,7 @@ void decode_xtheadcmo(rv_decode *dec, rv_isa isa)
          break;
      }


+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }

disas/riscv-xthead.c +0 -0
@@ -461,6 +465,7 @@ void decode_xtheadcondmov(rv_decode *dec, rv_isa
 isa)
          break;
      }


+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }

disas/riscv-xthead.c +0 -0
@@ -498,6 +503,7 @@ void decode_xtheadfmemidx(rv_decode *dec, rv_isa
 isa)
          break;
      }


+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }

disas/riscv-xthead.c +0 -0
@@ -533,6 +539,7 @@ void decode_xtheadfmv(rv_decode *dec, rv_isa isa)
          break;
      }


+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }

disas/riscv-xthead.c +0 -0
@@ -564,6 +571,7 @@ void decode_xtheadmac(rv_decode *dec, rv_isa isa)
          break;
      }


+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }

disas/riscv-xthead.c +0 -0
@@ -638,6 +646,7 @@ void decode_xtheadmemidx(rv_decode *dec, rv_isa
 isa)
          break;
      }


+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }

disas/riscv-xthead.c +0 -0
@@ -672,6 +681,7 @@ void decode_xtheadmempair(rv_decode *dec, rv_isa
 isa)
          break;
      }


+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }

disas/riscv-xthead.c +0 -0
@@ -706,5 +716,6 @@ void decode_xtheadsync(rv_decode *dec, rv_isa
 isa)
          break;
      }


+    dec->opcode_data = xthead_opcode_data;
     dec->op = op;
 }

disas/riscv-xventana.c +0 -0
index cd694f15f3..4539173d95 100644
@@ -14,7 +14,7 @@ typedef enum {
      ventana_op_vt_maskcn = 2,
  } rv_ventana_op;

disas/riscv-xventana.c +1 -1
-const rv_opcode_data ventana_opcode_data[] = {
+static const rv_opcode_data ventana_opcode_data[] = {

     { "vt.illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 }, { "vt.maskc", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, { "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },

disas/riscv-xventana.c +0 -0
@@ -38,5 +38,6 @@ void decode_xventanacondops(rv_decode *dec, rv_isa
 isa)
          break;
      }


+    dec->opcode_data = ventana_opcode_data;
     dec->op = op;
 }

disas/riscv.c +0 -0
index 9880b8de20..eb6d132a2c 100644
@@ -1656,7 +1656,7 @@ static uint32_t operand_lpl(rv_inst inst)


 /* instruction metadata */

disas/riscv.c +1 -1
-const rv_opcode_data rvi_opcode_data[] = {
+static const rv_opcode_data rvi_opcode_data[] = {

     { "illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 }, { "lui", rv_codec_u, rv_fmt_rd_uimm, NULL, 0, 0, 0 }, { "auipc", rv_codec_u, rv_fmt_rd_uoffset, NULL, 0, 0, 0 },

disas/riscv.c +1 -0
@@ -2948,6 +2948,7 @@ static void decode_inst_opcode(rv_decode *dec,
 rv_isa isa)
  {
      rv_inst inst = dec->inst;
      rv_opcode op = rv_op_illegal;
+
      switch ((inst >> 0) & 0b11) {

     case 0:
         switch ((inst >> 13) & 0b111) {

disas/riscv.c +2 -0
@@ -4590,6 +4591,8 @@ static void decode_inst_opcode(rv_decode *dec,
 rv_isa isa)
          }
          break;
      }
+
+    dec->opcode_data = rvi_opcode_data;
      dec->op = op;
  }

disas/riscv.c +0 -0
@@ -5421,33 +5424,30 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,
      };
      const rv_opcode_data *op;


-    dec.opcode_data = rvi_opcode_data; decode_inst_opcode(&dec, isa);

     if (dec.op == rv_op_illegal && cfg) {
         static const struct {
             bool (*guard_func)(const RISCVCPUConfig *);
-            const rv_opcode_data *opcode_data;
             void (*decode_func)(rv_decode *, rv_isa);
         } decoders[] = {
-            { has_xtheadba_p, xthead_opcode_data, decode_xtheadba }, -            { has_xtheadbb_p, xthead_opcode_data, decode_xtheadbb }, -            { has_xtheadbs_p, xthead_opcode_data, decode_xtheadbs }, -            { has_xtheadcmo_p, xthead_opcode_data, decode_xtheadcmo },
-            { has_xtheadcondmov_p, xthead_opcode_data, decode_xtheadcondmov },
-            { has_xtheadfmemidx_p, xthead_opcode_data, decode_xtheadfmemidx },
-            { has_xtheadfmv_p, xthead_opcode_data, decode_xtheadfmv },
-            { has_xtheadmac_p, xthead_opcode_data, decode_xtheadmac },
-            { has_xtheadmemidx_p, xthead_opcode_data, decode_xtheadmemidx },
-            { has_xtheadmempair_p, xthead_opcode_data, decode_xtheadmempair },
-            { has_xtheadsync_p, xthead_opcode_data, decode_xtheadsync },
-            { has_XVentanaCondOps_p, ventana_opcode_data, decode_xventanacondops },
-            { has_xlrbr_p, rv_xlrbr_opcode_data, decode_xlrbr }, +            { has_xtheadba_p, decode_xtheadba },
+            { has_xtheadbb_p, decode_xtheadbb },
+            { has_xtheadbs_p, decode_xtheadbs },
+            { has_xtheadcmo_p, decode_xtheadcmo },
+            { has_xtheadcondmov_p, decode_xtheadcondmov }, +            { has_xtheadfmemidx_p, decode_xtheadfmemidx }, +            { has_xtheadfmv_p, decode_xtheadfmv },
+            { has_xtheadmac_p, decode_xtheadmac },
+            { has_xtheadmemidx_p, decode_xtheadmemidx }, +            { has_xtheadmempair_p, decode_xtheadmempair }, +            { has_xtheadsync_p, decode_xtheadsync },
+            { has_XVentanaCondOps_p, decode_xventanacondops }, +            { has_xlrbr_p, decode_xlrbr },
         };

         for (size_t i = 0; i < ARRAY_SIZE(decoders); i++) { if (decoders[i].guard_func(cfg)) {
-                dec.opcode_data = decoders[i].opcode_data; decoders[i].decode_func(&dec, isa);
                 if (dec.op != rv_op_illegal) {
                     break;

#32 lore raw

PATCH 15/56 disas/riscv: Drop explicit zero of rv_opcode_data fields

In reply to Richard Henderson

Mechanical

s/, NULL, 0, 0, 0 }/ }/
s/, 0, 0, 0 }/ }/
s/, NULL, 0, 0 }/ }/
s/, NULL, 0 }/ }/

---
 disas/riscv-xlrbr.c    |   18 +-
 disas/riscv-xthead.c   |  210 ++---
 disas/riscv-xventana.c |    6 +-
 disas/riscv.c          | 1826 ++++++++++++++++++++--------------------
 4 files changed, 1030 insertions(+), 1030 deletions(-)
disas/riscv-xlrbr.c +9 -9
index f61028fce9..d0092e9edd 100644
@@ -25,15 +25,15 @@ typedef enum {
 } rv_xlrbr_op;
 
 static const rv_opcode_data xlrbr_opcode_data[] = {
-    { "illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 },
-    { "crc32.b", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "crc32.h", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "crc32.w", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "crc32.d", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "crc32c.b", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "crc32c.h", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "crc32c.w", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "crc32c.d", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
+    { "illegal", rv_codec_illegal, rv_fmt_none },
+    { "crc32.b", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32.h", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32.w", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32.d", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32c.b", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32c.h", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32c.w", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32c.d", rv_codec_r, rv_fmt_rd_rs1 },
 };
 
 void decode_xlrbr(rv_decode *dec, rv_isa isa)
disas/riscv-xthead.c +105 -105

227 lines not on this page · raw message

disas/riscv-xventana.c +3 -3
index 4539173d95..4fb9a29d0b 100644
@@ -15,9 +15,9 @@ typedef enum {
 } rv_ventana_op;
 
 static const rv_opcode_data ventana_opcode_data[] = {
-    { "vt.illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 },
-    { "vt.maskc", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
+    { "vt.illegal", rv_codec_illegal, rv_fmt_none },
+    { "vt.maskc", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2 },
 };
 
 void decode_xventanacondops(rv_decode *dec, rv_isa isa)
disas/riscv.c +913 -913

1,842 lines not on this page · raw message

Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 15/56
#33 lore raw

Re: [PATCH 15/56] disas/riscv: Drop explicit zero of rv_opcode_data fields

Quoted 8 lines · Richard Henderson

Mechanical

s/, NULL, 0, 0, 0 }/ }/
s/, 0, 0, 0 }/ }/
s/, NULL, 0, 0 }/ }/
s/, NULL, 0 }/ }/

Alistair

Quoted 2,701 lines

---
 disas/riscv-xlrbr.c    |   18 +-
 disas/riscv-xthead.c   |  210 ++--- disas/riscv-xventana.c |    6 +-
 disas/riscv.c          | 1826 ++++++++++++++++++++------------------ --

 4 files changed, 1030 insertions(+), 1030 deletions(-)
disas/riscv-xlrbr.c +0 -0
index f61028fce9..d0092e9edd 100644
@@ -25,15 +25,15 @@ typedef enum {
  } rv_xlrbr_op;


 static const rv_opcode_data xlrbr_opcode_data[] = {
-    { "illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 }, -    { "crc32.b", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, -    { "crc32.h", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, -    { "crc32.w", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, -    { "crc32.d", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, -    { "crc32c.b", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, -    { "crc32c.h", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, -    { "crc32c.w", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, -    { "crc32c.d", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, +    { "illegal", rv_codec_illegal, rv_fmt_none },
+    { "crc32.b", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32.h", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32.w", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32.d", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32c.b", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32c.h", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32c.w", rv_codec_r, rv_fmt_rd_rs1 },
+    { "crc32c.d", rv_codec_r, rv_fmt_rd_rs1 },
 };

 void decode_xlrbr(rv_decode *dec, rv_isa isa)

disas/riscv-xthead.c +0 -0
index 96f80bc8e5..757d6ff39f 100644
@@ -128,122 +128,122 @@ typedef enum {
  } rv_xthead_op;


 static const rv_opcode_data xthead_opcode_data[] = {
-    { "th.illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 }, +    { "th.illegal", rv_codec_illegal, rv_fmt_none },
     /* XTheadBa */
-    { "th.addsl", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
+    { "th.addsl", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, /* XTheadBb */
-    { "th.srri", rv_codec_r2_imm6, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 },
-    { "th.srriw", rv_codec_r2_imm5, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 },
-    { "th.ext", rv_codec_r2_immhl, rv_fmt_rd_rs1_immh_imml, NULL, 0, 0, 0 },
-    { "th.extu", rv_codec_r2_immhl, rv_fmt_rd_rs1_immh_imml, NULL, 0, 0, 0 },
-    { "th.ff0", rv_codec_r2, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, -    { "th.ff1", rv_codec_r2, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, -    { "th.rev", rv_codec_r2, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, -    { "th.revw", rv_codec_r2, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, -    { "th.tstnbz", rv_codec_r2, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, +    { "th.srri", rv_codec_r2_imm6, rv_fmt_rd_rs1_imm },
+    { "th.srriw", rv_codec_r2_imm5, rv_fmt_rd_rs1_imm }, +    { "th.ext", rv_codec_r2_immhl, rv_fmt_rd_rs1_immh_imml }, +    { "th.extu", rv_codec_r2_immhl, rv_fmt_rd_rs1_immh_imml }, +    { "th.ff0", rv_codec_r2, rv_fmt_rd_rs1 },
+    { "th.ff1", rv_codec_r2, rv_fmt_rd_rs1 },
+    { "th.rev", rv_codec_r2, rv_fmt_rd_rs1 },
+    { "th.revw", rv_codec_r2, rv_fmt_rd_rs1 },
+    { "th.tstnbz", rv_codec_r2, rv_fmt_rd_rs1 },
     /* XTheadBs */
-    { "th.tst", rv_codec_r2_imm6, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 },
+    { "th.tst", rv_codec_r2_imm6, rv_fmt_rd_rs1_imm },
     /* XTheadCmo */
-    { "th.dcache.call", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "th.dcache.ciall", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 },
-    { "th.dcache.iall", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "th.dcache.cpa", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.dcache.cipa", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.dcache.ipa", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.dcache.cva", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.dcache.civa", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.dcache.iva", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.dcache.csw", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.dcache.cisw", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.dcache.isw", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.dcache.cpal1", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.dcache.cval1", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.icache.iall", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "th.icache.ialls", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 },
-    { "th.icache.ipa", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.icache.iva", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "th.l2cache.call", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 },
-    { "th.l2cache.ciall", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 },
-    { "th.l2cache.iall", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 },
+    { "th.dcache.call", rv_codec_none, rv_fmt_none },
+    { "th.dcache.ciall", rv_codec_none, rv_fmt_none },
+    { "th.dcache.iall", rv_codec_none, rv_fmt_none },
+    { "th.dcache.cpa", rv_codec_r, rv_fmt_rs1 },
+    { "th.dcache.cipa", rv_codec_r, rv_fmt_rs1 },
+    { "th.dcache.ipa", rv_codec_r, rv_fmt_rs1 },
+    { "th.dcache.cva", rv_codec_r, rv_fmt_rs1 },
+    { "th.dcache.civa", rv_codec_r, rv_fmt_rs1 },
+    { "th.dcache.iva", rv_codec_r, rv_fmt_rs1 },
+    { "th.dcache.csw", rv_codec_r, rv_fmt_rs1 },
+    { "th.dcache.cisw", rv_codec_r, rv_fmt_rs1 },
+    { "th.dcache.isw", rv_codec_r, rv_fmt_rs1 },
+    { "th.dcache.cpal1", rv_codec_r, rv_fmt_rs1 },
+    { "th.dcache.cval1", rv_codec_r, rv_fmt_rs1 },
+    { "th.icache.iall", rv_codec_none, rv_fmt_none },
+    { "th.icache.ialls", rv_codec_none, rv_fmt_none },
+    { "th.icache.ipa", rv_codec_r, rv_fmt_rs1 },
+    { "th.icache.iva", rv_codec_r, rv_fmt_rs1 },
+    { "th.l2cache.call", rv_codec_none, rv_fmt_none },
+    { "th.l2cache.ciall", rv_codec_none, rv_fmt_none },
+    { "th.l2cache.iall", rv_codec_none, rv_fmt_none },
     /* XTheadCondMov */
-    { "th.mveqz", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "th.mvnez", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, +    { "th.mveqz", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "th.mvnez", rv_codec_r, rv_fmt_rd_rs1_rs2 },
     /* XTheadFMemIdx */
-    { "th.flrd", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.flrw", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.flurd", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.flurw", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.fsrd", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.fsrw", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.fsurd", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.fsurw", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm, NULL, 0, 0, 0 },
+    { "th.flrd", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm }, +    { "th.flrw", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm }, +    { "th.flurd", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm }, +    { "th.flurw", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm }, +    { "th.fsrd", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm }, +    { "th.fsrw", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm }, +    { "th.fsurd", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm }, +    { "th.fsurw", rv_codec_r_imm2, rv_fmt_frd_rs1_rs2_imm }, /* XTheadFmv */
-    { "th.fmv.hw.x", rv_codec_r, rv_fmt_rd_frs1, NULL, 0, 0, 0 }, -    { "th.fmv.x.hw", rv_codec_r, rv_fmt_rd_frs1, NULL, 0, 0, 0 }, +    { "th.fmv.hw.x", rv_codec_r, rv_fmt_rd_frs1 },
+    { "th.fmv.x.hw", rv_codec_r, rv_fmt_rd_frs1 },
     /* XTheadMac */
-    { "th.mula", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "th.mulaw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "th.mulah", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "th.muls", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "th.mulsw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "th.mulsh", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, +    { "th.mula", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "th.mulaw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "th.mulah", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "th.muls", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "th.mulsw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "th.mulsh", rv_codec_r, rv_fmt_rd_rs1_rs2 },
     /* XTheadMemIdx */
-    { "th.lbia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.lbib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml, NULL, 0, 0, 0 },
-    { "th.lbuia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.lbuib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.lhia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.lhib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.lhuia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.lhuib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.lwia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.lwib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.lwuia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.lwuib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.ldia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.ldib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.sbia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.sbib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.shia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.shib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.swia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.swib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.sdia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.sdib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr, NULL, 0, 0, 0 },
-    { "th.lrb", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lrbu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lrh", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lrhu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lrw", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lrwu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lrd", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.srb", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.srh", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.srw", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.srd", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lurb", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lurbu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lurh", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lurhu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lurw", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lurwu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.lurd", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.surb", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.surh", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.surw", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
-    { "th.surd", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm, NULL, 0, 0, 0 },
+    { "th.lbia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.lbib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml }, +    { "th.lbuia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.lbuib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.lhia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.lhib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.lhuia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.lhuib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.lwia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.lwib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.lwuia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.lwuib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.ldia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.ldib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.sbia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.sbib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.shia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.shib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.swia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.swib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.sdia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.sdib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
+    { "th.lrb", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lrbu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lrh", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lrhu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lrw", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lrwu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lrd", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.srb", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.srh", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.srw", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.srd", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lurb", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lurbu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lurh", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lurhu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lurw", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lurwu", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.lurd", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.surb", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.surh", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.surw", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, +    { "th.surd", rv_codec_r_imm2, rv_fmt_rd_rs1_rs2_imm }, /* XTheadMemPair */
-    { "th.ldd", rv_codec_r_imm2, rv_fmt_rd2_imm, NULL, 0, 0, 0 }, -    { "th.lwd", rv_codec_r_imm2, rv_fmt_rd2_imm, NULL, 0, 0, 0 }, -    { "th.lwud", rv_codec_r_imm2, rv_fmt_rd2_imm, NULL, 0, 0, 0 }, -    { "th.sdd", rv_codec_r_imm2, rv_fmt_rd2_imm, NULL, 0, 0, 0 }, -    { "th.swd", rv_codec_r_imm2, rv_fmt_rd2_imm, NULL, 0, 0, 0 }, +    { "th.ldd", rv_codec_r_imm2, rv_fmt_rd2_imm },
+    { "th.lwd", rv_codec_r_imm2, rv_fmt_rd2_imm },
+    { "th.lwud", rv_codec_r_imm2, rv_fmt_rd2_imm },
+    { "th.sdd", rv_codec_r_imm2, rv_fmt_rd2_imm },
+    { "th.swd", rv_codec_r_imm2, rv_fmt_rd2_imm },
     /* XTheadSync */
-    { "th.sfence.vmas", rv_codec_r, rv_fmt_rs1_rs2, NULL, 0, 0, 0 }, -    { "th.sync", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "th.sync.i", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "th.sync.is", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "th.sync.s", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, +    { "th.sfence.vmas", rv_codec_r, rv_fmt_rs1_rs2 },
+    { "th.sync", rv_codec_none, rv_fmt_none },
+    { "th.sync.i", rv_codec_none, rv_fmt_none },
+    { "th.sync.is", rv_codec_none, rv_fmt_none },
+    { "th.sync.s", rv_codec_none, rv_fmt_none },
 };

 void decode_xtheadba(rv_decode *dec, rv_isa isa)

disas/riscv-xventana.c +0 -0
index 4539173d95..4fb9a29d0b 100644
@@ -15,9 +15,9 @@ typedef enum {
  } rv_ventana_op;


 static const rv_opcode_data ventana_opcode_data[] = {
-    { "vt.illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 }, -    { "vt.maskc", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, +    { "vt.illegal", rv_codec_illegal, rv_fmt_none },
+    { "vt.maskc", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2 },
 };

 void decode_xventanacondops(rv_decode *dec, rv_isa isa)

disas/riscv.c +0 -0
index eb6d132a2c..ec40abb618 100644
@@ -1657,233 +1657,233 @@ static uint32_t operand_lpl(rv_inst inst)
  /* instruction metadata */


 static const rv_opcode_data rvi_opcode_data[] = {
-    { "illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 }, -    { "lui", rv_codec_u, rv_fmt_rd_uimm, NULL, 0, 0, 0 }, -    { "auipc", rv_codec_u, rv_fmt_rd_uoffset, NULL, 0, 0, 0 }, -    { "jal", rv_codec_uj, rv_fmt_rd_offset, rvcp_jal, 0, 0, 0 }, -    { "jalr", rv_codec_i, rv_fmt_rd_rs1_offset, rvcp_jalr, 0, 0, 0 },
-    { "beq", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_beq, 0, 0, 0 },
-    { "bne", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bne, 0, 0, 0 },
-    { "blt", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_blt, 0, 0, 0 },
-    { "bge", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bge, 0, 0, 0 },
-    { "bltu", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bltu, 0, 0, 0 },
-    { "bgeu", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bgeu, 0, 0, 0 },
-    { "lb", rv_codec_i, rv_fmt_rd_offset_rs1, NULL, 0, 0, 0 }, -    { "lh", rv_codec_i, rv_fmt_rd_offset_rs1, NULL, 0, 0, 0 }, -    { "lw", rv_codec_i, rv_fmt_rd_offset_rs1, NULL, 0, 0, 0 }, -    { "lbu", rv_codec_i, rv_fmt_rd_offset_rs1, NULL, 0, 0, 0 }, -    { "lhu", rv_codec_i, rv_fmt_rd_offset_rs1, NULL, 0, 0, 0 }, -    { "sb", rv_codec_s, rv_fmt_rs2_offset_rs1, NULL, 0, 0, 0 }, -    { "sh", rv_codec_s, rv_fmt_rs2_offset_rs1, NULL, 0, 0, 0 }, -    { "sw", rv_codec_s, rv_fmt_rs2_offset_rs1, NULL, 0, 0, 0 }, -    { "addi", rv_codec_i, rv_fmt_rd_rs1_imm, rvcp_addi, 0, 0, 0 }, -    { "slti", rv_codec_i, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "sltiu", rv_codec_i, rv_fmt_rd_rs1_imm, rvcp_sltiu, 0, 0, 0 }, -    { "xori", rv_codec_i, rv_fmt_rd_rs1_imm, rvcp_xori, 0, 0, 0 }, -    { "ori", rv_codec_i, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "andi", rv_codec_i, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "slli", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "srli", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "srai", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "add", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "sub", rv_codec_r, rv_fmt_rd_rs1_rs2, rvcp_sub, 0, 0, 0 }, -    { "sll", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "slt", rv_codec_r, rv_fmt_rd_rs1_rs2, rvcp_slt, 0, 0, 0 }, -    { "sltu", rv_codec_r, rv_fmt_rd_rs1_rs2, rvcp_sltu, 0, 0, 0 }, -    { "xor", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "srl", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "sra", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "or", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "and", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "fence", rv_codec_r_f, rv_fmt_pred_succ, NULL, 0, 0, 0 }, -    { "fence.i", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "lwu", rv_codec_i, rv_fmt_rd_offset_rs1, NULL, 0, 0, 0 }, -    { "ld", rv_codec_i, rv_fmt_rd_offset_rs1, NULL, 0, 0, 0 }, -    { "sd", rv_codec_s, rv_fmt_rs2_offset_rs1, NULL, 0, 0, 0 }, -    { "addiw", rv_codec_i, rv_fmt_rd_rs1_imm, rvcp_addiw, 0, 0, 0 }, -    { "slliw", rv_codec_i_sh5, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "srliw", rv_codec_i_sh5, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "sraiw", rv_codec_i_sh5, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "addw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "subw", rv_codec_r, rv_fmt_rd_rs1_rs2, rvcp_subw, 0, 0, 0 }, -    { "sllw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "srlw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "sraw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "ldu", rv_codec_i, rv_fmt_rd_offset_rs1, NULL, 0, 0, 0 }, -    { "lq", rv_codec_i, rv_fmt_rd_offset_rs1, NULL, 0, 0, 0 }, -    { "sq", rv_codec_s, rv_fmt_rs2_offset_rs1, NULL, 0, 0, 0 }, -    { "addid", rv_codec_i, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "sllid", rv_codec_i_sh6, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "srlid", rv_codec_i_sh6, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "sraid", rv_codec_i_sh6, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, -    { "addd", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "subd", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "slld", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "srld", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "srad", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mul", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mulh", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mulhsu", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mulhu", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "div", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "divu", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "rem", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "remu", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mulw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "divw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "divuw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "remw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "remuw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "muld", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "divd", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "divud", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "remd", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "remud", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "lr.w", rv_codec_r_l, rv_fmt_aqrl_rd_rs1, NULL, 0, 0, 0 }, -    { "sc.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, -    { "amoswap.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoadd.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoxor.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoor.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoand.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomin.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomax.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amominu.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomaxu.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "lr.d", rv_codec_r_l, rv_fmt_aqrl_rd_rs1, NULL, 0, 0, 0 }, -    { "sc.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, -    { "amoswap.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoadd.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoxor.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoor.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoand.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomin.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomax.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amominu.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomaxu.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "lr.q", rv_codec_r_l, rv_fmt_aqrl_rd_rs1, NULL, 0, 0, 0 }, -    { "sc.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, -    { "amoswap.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoadd.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoxor.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoor.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoand.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomin.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomax.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amominu.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomaxu.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "ecall", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "ebreak", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "uret", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "sret", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "hret", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "mret", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "dret", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "sfence.vm", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "sfence.vma", rv_codec_r, rv_fmt_rs1_rs2, NULL, 0, 0, 0 }, -    { "wfi", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "csrrw", rv_codec_i_csr, rv_fmt_rd_csr_rs1, rvcp_csrrw, 0, 0, 0 },
-    { "csrrs", rv_codec_i_csr, rv_fmt_rd_csr_rs1, rvcp_csrrs, 0, 0, 0 },
-    { "csrrc", rv_codec_i_csr, rv_fmt_rd_csr_rs1, NULL, 0, 0, 0 }, -    { "csrrwi", rv_codec_i_csr, rv_fmt_rd_csr_zimm, rvcp_csrrwi, 0, 0, 0 },
-    { "csrrsi", rv_codec_i_csr, rv_fmt_rd_csr_zimm, NULL, 0, 0, 0 }, -    { "csrrci", rv_codec_i_csr, rv_fmt_rd_csr_zimm, NULL, 0, 0, 0 }, -    { "flw", rv_codec_i, rv_fmt_frd_offset_rs1, NULL, 0, 0, 0 }, -    { "fsw", rv_codec_s, rv_fmt_frs2_offset_rs1, NULL, 0, 0, 0 }, -    { "fmadd.s", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fmsub.s", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fnmsub.s", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fnmadd.s", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fadd.s", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fsub.s", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fmul.s", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fdiv.s", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fsgnj.s", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnj_s, 0, 0, 0 },
-    { "fsgnjn.s", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjn_s, 0, 0, 0 },
-    { "fsgnjx.s", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjx_s, 0, 0, 0 },
-    { "fmin.s", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fmax.s", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fsqrt.s", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "fle.s", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "flt.s", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "feq.s", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fcvt.w.s", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.wu.s", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.s.w", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fcvt.s.wu", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fmv.x.s", rv_codec_r, rv_fmt_rd_frs1, NULL, 0, 0, 0 }, -    { "fclass.s", rv_codec_r, rv_fmt_rd_frs1, NULL, 0, 0, 0 }, -    { "fmv.s.x", rv_codec_r, rv_fmt_frd_rs1, NULL, 0, 0, 0 }, -    { "fcvt.l.s", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.lu.s", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.s.l", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fcvt.s.lu", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fld", rv_codec_i, rv_fmt_frd_offset_rs1, NULL, 0, 0, 0 }, -    { "fsd", rv_codec_s, rv_fmt_frs2_offset_rs1, NULL, 0, 0, 0 }, -    { "fmadd.d", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fmsub.d", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fnmsub.d", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fnmadd.d", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fadd.d", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fsub.d", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fmul.d", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fdiv.d", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fsgnj.d", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnj_d, 0, 0, 0 },
-    { "fsgnjn.d", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjn_d, 0, 0, 0 },
-    { "fsgnjx.d", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjx_d, 0, 0, 0 },
-    { "fmin.d", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fmax.d", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fcvt.s.d", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.d.s", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "fsqrt.d", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "fle.d", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "flt.d", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "feq.d", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fcvt.w.d", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.wu.d", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.d.w", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fcvt.d.wu", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fclass.d", rv_codec_r, rv_fmt_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.l.d", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.lu.d", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fmv.x.d", rv_codec_r, rv_fmt_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.d.l", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fcvt.d.lu", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fmv.d.x", rv_codec_r, rv_fmt_frd_rs1, NULL, 0, 0, 0 }, -    { "flq", rv_codec_i, rv_fmt_frd_offset_rs1, NULL, 0, 0, 0 }, -    { "fsq", rv_codec_s, rv_fmt_frs2_offset_rs1, NULL, 0, 0, 0 }, -    { "fmadd.q", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fmsub.q", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fnmsub.q", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fnmadd.q", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3, NULL, 0, 0, 0 },
-    { "fadd.q", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fsub.q", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fmul.q", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fdiv.q", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2, NULL, 0, 0, 0 },
-    { "fsgnj.q", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnj_q, 0, 0, 0 },
-    { "fsgnjn.q", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjn_q, 0, 0, 0 },
-    { "fsgnjx.q", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjx_q, 0, 0, 0 },
-    { "fmin.q", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fmax.q", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fcvt.s.q", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.q.s", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.d.q", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.q.d", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "fsqrt.q", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "fle.q", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "flt.q", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "feq.q", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fcvt.w.q", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.wu.q", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.q.w", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fcvt.q.wu", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fclass.q", rv_codec_r, rv_fmt_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.l.q", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.lu.q", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 }, -    { "fcvt.q.l", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fcvt.q.lu", rv_codec_r_m, rv_fmt_rm_frd_rs1, NULL, 0, 0, 0 }, -    { "fmv.x.q", rv_codec_r, rv_fmt_rd_frs1, NULL, 0, 0, 0 }, -    { "fmv.q.x", rv_codec_r, rv_fmt_frd_rs1, NULL, 0, 0, 0 }, +    { "illegal", rv_codec_illegal, rv_fmt_none },
+    { "lui", rv_codec_u, rv_fmt_rd_uimm },
+    { "auipc", rv_codec_u, rv_fmt_rd_uoffset },
+    { "jal", rv_codec_uj, rv_fmt_rd_offset, rvcp_jal },
+    { "jalr", rv_codec_i, rv_fmt_rd_rs1_offset, rvcp_jalr }, +    { "beq", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_beq }, +    { "bne", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bne }, +    { "blt", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_blt }, +    { "bge", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bge }, +    { "bltu", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bltu }, +    { "bgeu", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bgeu }, +    { "lb", rv_codec_i, rv_fmt_rd_offset_rs1 },
+    { "lh", rv_codec_i, rv_fmt_rd_offset_rs1 },
+    { "lw", rv_codec_i, rv_fmt_rd_offset_rs1 },
+    { "lbu", rv_codec_i, rv_fmt_rd_offset_rs1 },
+    { "lhu", rv_codec_i, rv_fmt_rd_offset_rs1 },
+    { "sb", rv_codec_s, rv_fmt_rs2_offset_rs1 },
+    { "sh", rv_codec_s, rv_fmt_rs2_offset_rs1 },
+    { "sw", rv_codec_s, rv_fmt_rs2_offset_rs1 },
+    { "addi", rv_codec_i, rv_fmt_rd_rs1_imm, rvcp_addi }, +    { "slti", rv_codec_i, rv_fmt_rd_rs1_imm },
+    { "sltiu", rv_codec_i, rv_fmt_rd_rs1_imm, rvcp_sltiu }, +    { "xori", rv_codec_i, rv_fmt_rd_rs1_imm, rvcp_xori }, +    { "ori", rv_codec_i, rv_fmt_rd_rs1_imm },
+    { "andi", rv_codec_i, rv_fmt_rd_rs1_imm },
+    { "slli", rv_codec_i_sh7, rv_fmt_rd_rs1_imm },
+    { "srli", rv_codec_i_sh7, rv_fmt_rd_rs1_imm },
+    { "srai", rv_codec_i_sh7, rv_fmt_rd_rs1_imm },
+    { "add", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sub", rv_codec_r, rv_fmt_rd_rs1_rs2, rvcp_sub },
+    { "sll", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "slt", rv_codec_r, rv_fmt_rd_rs1_rs2, rvcp_slt },
+    { "sltu", rv_codec_r, rv_fmt_rd_rs1_rs2, rvcp_sltu }, +    { "xor", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "srl", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sra", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "or", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "and", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "fence", rv_codec_r_f, rv_fmt_pred_succ },
+    { "fence.i", rv_codec_none, rv_fmt_none },
+    { "lwu", rv_codec_i, rv_fmt_rd_offset_rs1 },
+    { "ld", rv_codec_i, rv_fmt_rd_offset_rs1 },
+    { "sd", rv_codec_s, rv_fmt_rs2_offset_rs1 },
+    { "addiw", rv_codec_i, rv_fmt_rd_rs1_imm, rvcp_addiw }, +    { "slliw", rv_codec_i_sh5, rv_fmt_rd_rs1_imm },
+    { "srliw", rv_codec_i_sh5, rv_fmt_rd_rs1_imm },
+    { "sraiw", rv_codec_i_sh5, rv_fmt_rd_rs1_imm },
+    { "addw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "subw", rv_codec_r, rv_fmt_rd_rs1_rs2, rvcp_subw }, +    { "sllw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "srlw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sraw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "ldu", rv_codec_i, rv_fmt_rd_offset_rs1 },
+    { "lq", rv_codec_i, rv_fmt_rd_offset_rs1 },
+    { "sq", rv_codec_s, rv_fmt_rs2_offset_rs1 },
+    { "addid", rv_codec_i, rv_fmt_rd_rs1_imm },
+    { "sllid", rv_codec_i_sh6, rv_fmt_rd_rs1_imm },
+    { "srlid", rv_codec_i_sh6, rv_fmt_rd_rs1_imm },
+    { "sraid", rv_codec_i_sh6, rv_fmt_rd_rs1_imm },
+    { "addd", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "subd", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "slld", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "srld", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "srad", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mul", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mulh", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mulhsu", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mulhu", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "div", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "divu", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "rem", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "remu", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mulw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "divw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "divuw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "remw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "remuw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "muld", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "divd", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "divud", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "remd", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "remud", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "lr.w", rv_codec_r_l, rv_fmt_aqrl_rd_rs1 },
+    { "sc.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 },
+    { "amoswap.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoadd.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoxor.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoor.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoand.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomin.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomax.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amominu.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomaxu.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "lr.d", rv_codec_r_l, rv_fmt_aqrl_rd_rs1 },
+    { "sc.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 },
+    { "amoswap.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoadd.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoxor.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoor.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoand.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomin.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomax.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amominu.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomaxu.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "lr.q", rv_codec_r_l, rv_fmt_aqrl_rd_rs1 },
+    { "sc.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 },
+    { "amoswap.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoadd.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoxor.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoor.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoand.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomin.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomax.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amominu.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomaxu.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "ecall", rv_codec_none, rv_fmt_none },
+    { "ebreak", rv_codec_none, rv_fmt_none },
+    { "uret", rv_codec_none, rv_fmt_none },
+    { "sret", rv_codec_none, rv_fmt_none },
+    { "hret", rv_codec_none, rv_fmt_none },
+    { "mret", rv_codec_none, rv_fmt_none },
+    { "dret", rv_codec_none, rv_fmt_none },
+    { "sfence.vm", rv_codec_r, rv_fmt_rs1 },
+    { "sfence.vma", rv_codec_r, rv_fmt_rs1_rs2 },
+    { "wfi", rv_codec_none, rv_fmt_none },
+    { "csrrw", rv_codec_i_csr, rv_fmt_rd_csr_rs1, rvcp_csrrw }, +    { "csrrs", rv_codec_i_csr, rv_fmt_rd_csr_rs1, rvcp_csrrs }, +    { "csrrc", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
+    { "csrrwi", rv_codec_i_csr, rv_fmt_rd_csr_zimm, rvcp_csrrwi }, +    { "csrrsi", rv_codec_i_csr, rv_fmt_rd_csr_zimm },
+    { "csrrci", rv_codec_i_csr, rv_fmt_rd_csr_zimm },
+    { "flw", rv_codec_i, rv_fmt_frd_offset_rs1 },
+    { "fsw", rv_codec_s, rv_fmt_frs2_offset_rs1 },
+    { "fmadd.s", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fmsub.s", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fnmsub.s", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fnmadd.s", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fadd.s", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fsub.s", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fmul.s", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fdiv.s", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fsgnj.s", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnj_s }, +    { "fsgnjn.s", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjn_s }, +    { "fsgnjx.s", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjx_s }, +    { "fmin.s", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fmax.s", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fsqrt.s", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fle.s", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "flt.s", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "feq.s", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "fcvt.w.s", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fcvt.wu.s", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fcvt.s.w", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fcvt.s.wu", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fmv.x.s", rv_codec_r, rv_fmt_rd_frs1 },
+    { "fclass.s", rv_codec_r, rv_fmt_rd_frs1 },
+    { "fmv.s.x", rv_codec_r, rv_fmt_frd_rs1 },
+    { "fcvt.l.s", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fcvt.lu.s", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fcvt.s.l", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fcvt.s.lu", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fld", rv_codec_i, rv_fmt_frd_offset_rs1 },
+    { "fsd", rv_codec_s, rv_fmt_frs2_offset_rs1 },
+    { "fmadd.d", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fmsub.d", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fnmsub.d", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fnmadd.d", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fadd.d", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fsub.d", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fmul.d", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fdiv.d", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fsgnj.d", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnj_d }, +    { "fsgnjn.d", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjn_d }, +    { "fsgnjx.d", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjx_d }, +    { "fmin.d", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fmax.d", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fcvt.s.d", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fcvt.d.s", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fsqrt.d", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fle.d", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "flt.d", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "feq.d", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "fcvt.w.d", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fcvt.wu.d", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fcvt.d.w", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fcvt.d.wu", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fclass.d", rv_codec_r, rv_fmt_rd_frs1 },
+    { "fcvt.l.d", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fcvt.lu.d", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fmv.x.d", rv_codec_r, rv_fmt_rd_frs1 },
+    { "fcvt.d.l", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fcvt.d.lu", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fmv.d.x", rv_codec_r, rv_fmt_frd_rs1 },
+    { "flq", rv_codec_i, rv_fmt_frd_offset_rs1 },
+    { "fsq", rv_codec_s, rv_fmt_frs2_offset_rs1 },
+    { "fmadd.q", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fmsub.q", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fnmsub.q", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fnmadd.q", rv_codec_r4_m, rv_fmt_rm_frd_frs1_frs2_frs3 }, +    { "fadd.q", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fsub.q", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fmul.q", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fdiv.q", rv_codec_r_m, rv_fmt_rm_frd_frs1_frs2 }, +    { "fsgnj.q", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnj_q }, +    { "fsgnjn.q", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjn_q }, +    { "fsgnjx.q", rv_codec_r, rv_fmt_frd_frs1_frs2, rvcp_fsgnjx_q }, +    { "fmin.q", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fmax.q", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fcvt.s.q", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fcvt.q.s", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fcvt.d.q", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fcvt.q.d", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fsqrt.q", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fle.q", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "flt.q", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "feq.q", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "fcvt.w.q", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fcvt.wu.q", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fcvt.q.w", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fcvt.q.wu", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fclass.q", rv_codec_r, rv_fmt_rd_frs1 },
+    { "fcvt.l.q", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fcvt.lu.q", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fcvt.q.l", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fcvt.q.lu", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
+    { "fmv.x.q", rv_codec_r, rv_fmt_rd_frs1 },
+    { "fmv.q.x", rv_codec_r, rv_fmt_frd_rs1 },
     { "c.addi4spn", rv_codec_ciw_4spn, rv_fmt_rd_rs1_imm, NULL, rv_op_addi,
       rv_op_addi, rv_op_addi, rvcd_imm_nz },
     { "c.fld", rv_codec_cl_ld, rv_fmt_frd_offset_rs1, NULL, rv_op_fld,

disas/riscv.c +0 -412
@@ -1970,696 +1970,696 @@ static const rv_opcode_data
 rvi_opcode_data[] = {
      { "c.lqsp", rv_codec_ci_lqsp, rv_fmt_rd_offset_rs1, NULL, 0, 0,
 rv_op_lq },
      { "c.sqsp", rv_codec_css_sqsp, rv_fmt_rs2_offset_rs1, NULL, 0,
 0,
        rv_op_sq },
-    { "nop", rv_codec_i, rv_fmt_none, NULL, 0, 0, 0 },
-    { "mv", rv_codec_i, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "not", rv_codec_i, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "neg", rv_codec_r, rv_fmt_rd_rs2, NULL, 0, 0, 0 },
-    { "negw", rv_codec_r, rv_fmt_rd_rs2, NULL, 0, 0, 0 },
-    { "sext.w", rv_codec_i, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "seqz", rv_codec_i, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "snez", rv_codec_r, rv_fmt_rd_rs2, NULL, 0, 0, 0 },
-    { "sltz", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "sgtz", rv_codec_r, rv_fmt_rd_rs2, NULL, 0, 0, 0 },
-    { "fmv.s", rv_codec_r, rv_fmt_frd_frs1, NULL, 0, 0, 0 },
-    { "fabs.s", rv_codec_r, rv_fmt_frd_frs1, NULL, 0, 0, 0 },
-    { "fneg.s", rv_codec_r, rv_fmt_frd_frs1, NULL, 0, 0, 0 },
-    { "fmv.d", rv_codec_r, rv_fmt_frd_frs1, NULL, 0, 0, 0 },
-    { "fabs.d", rv_codec_r, rv_fmt_frd_frs1, NULL, 0, 0, 0 },
-    { "fneg.d", rv_codec_r, rv_fmt_frd_frs1, NULL, 0, 0, 0 },
-    { "fmv.q", rv_codec_r, rv_fmt_frd_frs1, NULL, 0, 0, 0 },
-    { "fabs.q", rv_codec_r, rv_fmt_frd_frs1, NULL, 0, 0, 0 },
-    { "fneg.q", rv_codec_r, rv_fmt_frd_frs1, NULL, 0, 0, 0 },
-    { "beqz", rv_codec_sb, rv_fmt_rs1_offset, NULL, 0, 0, 0 },
-    { "bnez", rv_codec_sb, rv_fmt_rs1_offset, NULL, 0, 0, 0 },
-    { "blez", rv_codec_sb, rv_fmt_rs2_offset, NULL, 0, 0, 0 },
-    { "bgez", rv_codec_sb, rv_fmt_rs1_offset, NULL, 0, 0, 0 },
-    { "bltz", rv_codec_sb, rv_fmt_rs1_offset, NULL, 0, 0, 0 },
-    { "bgtz", rv_codec_sb, rv_fmt_rs2_offset, NULL, 0, 0, 0 },
-    { "ble", rv_codec_sb, rv_fmt_rs2_rs1_offset, NULL, 0, 0, 0 },
-    { "bleu", rv_codec_sb, rv_fmt_rs2_rs1_offset, NULL, 0, 0, 0 },
-    { "bgt", rv_codec_sb, rv_fmt_rs2_rs1_offset, NULL, 0, 0, 0 },
-    { "bgtu", rv_codec_sb, rv_fmt_rs2_rs1_offset, NULL, 0, 0, 0 },
-    { "j", rv_codec_uj, rv_fmt_offset, NULL, 0, 0, 0 },
-    { "ret", rv_codec_i, rv_fmt_none, NULL, 0, 0, 0 },
-    { "jr", rv_codec_i, rv_fmt_rs1, NULL, 0, 0, 0 },
-    { "rdcycle", rv_codec_i_csr, rv_fmt_rd, NULL, 0, 0, 0 },
-    { "rdtime", rv_codec_i_csr, rv_fmt_rd, NULL, 0, 0, 0 },
-    { "rdinstret", rv_codec_i_csr, rv_fmt_rd, NULL, 0, 0, 0 },
-    { "rdcycleh", rv_codec_i_csr, rv_fmt_rd, NULL, 0, 0, 0 },
-    { "rdtimeh", rv_codec_i_csr, rv_fmt_rd, NULL, 0, 0, 0 },
-    { "rdinstreth", rv_codec_i_csr, rv_fmt_rd, NULL, 0, 0, 0 },
-    { "frcsr", rv_codec_i_csr, rv_fmt_rd, NULL, 0, 0, 0 },
-    { "frrm", rv_codec_i_csr, rv_fmt_rd, NULL, 0, 0, 0 },
-    { "frflags", rv_codec_i_csr, rv_fmt_rd, NULL, 0, 0, 0 },
-    { "fscsr", rv_codec_i_csr, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "fsrm", rv_codec_i_csr, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "fsflags", rv_codec_i_csr, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "fsrmi", rv_codec_i_csr, rv_fmt_rd_zimm, NULL, 0, 0, 0 },
-    { "fsflagsi", rv_codec_i_csr, rv_fmt_rd_zimm, NULL, 0, 0, 0 },
-    { "bseti", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 },
-    { "bclri", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 },
-    { "binvi", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 },
-    { "bexti", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 },
-    { "rori", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 },
-    { "clz", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "ctz", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "cpop", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "sext.h", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "sext.b", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "xnor", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "orn", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "andn", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "rol", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "ror", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sh1add", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sh2add", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sh3add", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sh1add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sh2add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sh3add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "clmul", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "clmulr", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "clmulh", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "min", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "minu", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "max", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "maxu", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "clzw", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "ctzw", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "cpopw", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "slli.uw", rv_codec_i_sh6, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 },
-    { "add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "rolw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "rorw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "rev8", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "zext.h", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "roriw", rv_codec_i_sh5, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 },
-    { "orc.b", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "bset", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "bclr", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "binv", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "bext", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "aes32esmi", rv_codec_k_bs, rv_fmt_rs1_rs2_bs, NULL, 0, 0, 0
 },
-    { "aes32esi", rv_codec_k_bs, rv_fmt_rs1_rs2_bs, NULL, 0, 0, 0 },
-    { "aes32dsmi", rv_codec_k_bs, rv_fmt_rs1_rs2_bs, NULL, 0, 0, 0
 },
-    { "aes32dsi", rv_codec_k_bs, rv_fmt_rs1_rs2_bs, NULL, 0, 0, 0 },
-    { "aes64ks1i", rv_codec_k_rnum, rv_fmt_rd_rs1_rnum, NULL, 0, 0,
 0 },
-    { "aes64ks2", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "aes64im", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 },
-    { "aes64esm", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "aes64es", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "aes64dsm", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "aes64ds", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sha256sig0", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 },
-    { "sha256sig1", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 },
-    { "sha256sum0", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 },
-    { "sha256sum1", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 },
-    { "sha512sig0", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sha512sig1", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sha512sum0", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sha512sum1", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sha512sum0r", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sha512sum1r", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sha512sig0l", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sha512sig0h", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sha512sig1l", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sha512sig1h", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "sm3p0", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 },
-    { "sm3p1", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 },
-    { "sm4ed", rv_codec_k_bs, rv_fmt_rs1_rs2_bs, NULL, 0, 0, 0 },
-    { "sm4ks", rv_codec_k_bs, rv_fmt_rs1_rs2_bs, NULL, 0, 0, 0 },
-    { "brev8", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "pack", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "packh", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "packw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "unzip", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "zip", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "xperm4", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
-    { "xperm8", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 },
-    { "vle8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vle16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vle32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vle64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vse8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vse16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vse32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vse64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vlm.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0
 },
-    { "vsm.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0, 0
 },
-    { "vlse8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0,
 0, 0 },
-    { "vlse16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0,
 0, 0 },
-    { "vlse32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0,
 0, 0 },
-    { "vlse64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0,
 0, 0 },
-    { "vsse8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0,
 0, 0 },
-    { "vsse16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0,
 0, 0 },
-    { "vsse32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0,
 0, 0 },
-    { "vsse64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm, NULL, 0,
 0, 0 },
-    { "vluxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0,
 0, 0 },
-    { "vluxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vluxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vluxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vloxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0,
 0, 0 },
-    { "vloxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vloxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vloxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vsuxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0,
 0, 0 },
-    { "vsuxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vsuxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vsuxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vsoxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL, 0,
 0, 0 },
-    { "vsoxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vsoxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vsoxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm, NULL,
 0, 0, 0 },
-    { "vle8ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vle16ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vle32ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vle64ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl1re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl1re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl1re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl1re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl2re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl2re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl2re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl2re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl4re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl4re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl4re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl4re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl8re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl8re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl8re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vl8re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0,
 0, 0 },
-    { "vs1r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vs2r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vs4r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vs8r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm, NULL, 0, 0,
 0 },
-    { "vadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vadd.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vrsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vrsub.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vwaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vwaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vwadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vwadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vwsubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vwsubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vwsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vwsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vwaddu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vwaddu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vwadd.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vwadd.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vwsubu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vwsubu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vwsub.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vwsub.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vadc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, 0, 0, 0
 },
-    { "vadc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, 0, 0, 0
 },
-    { "vadc.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl, NULL, 0, 0, 0
 },
-    { "vmadc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, 0, 0, 0
 },
-    { "vmadc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, 0, 0, 0
 },
-    { "vmadc.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl, NULL, 0, 0, 0
 },
-    { "vsbc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, 0, 0, 0
 },
-    { "vsbc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, 0, 0, 0
 },
-    { "vmsbc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, 0, 0, 0
 },
-    { "vmsbc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, 0, 0, 0
 },
-    { "vand.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vand.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vand.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vor.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vor.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vor.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0 },
-    { "vxor.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vxor.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vxor.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vsll.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vsll.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vsll.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0,
 0 },
-    { "vsrl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vsrl.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vsrl.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0,
 0 },
-    { "vsra.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vsra.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vsra.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0,
 0 },
-    { "vnsrl.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vnsrl.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vnsrl.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0,
 0 },
-    { "vnsra.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vnsra.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vnsra.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0,
 0 },
-    { "vmseq.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmseq.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmseq.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vmsne.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmsne.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmsne.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vmsltu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmsltu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmslt.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmslt.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmsleu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmsleu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmsleu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vmsle.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmsle.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmsle.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vmsgtu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmsgtu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vmsgt.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmsgt.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vminu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vminu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmin.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmin.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmaxu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmaxu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmax.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmax.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmulh.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmulh.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmulhu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmulhu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmulhsu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0,
 0 },
-    { "vmulhsu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0,
 0 },
-    { "vdivu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vdivu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vdiv.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vdiv.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vremu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vremu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vrem.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vrem.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vwmulu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vwmulu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vwmulsu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0,
 0 },
-    { "vwmulsu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0,
 0 },
-    { "vwmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vwmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vmacc.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vnmsac.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vmadd.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vnmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vnmsub.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vwmaccu.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vwmaccu.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vwmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vwmacc.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vwmaccsu.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vwmaccsu.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vwmaccus.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vmv.v.v", rv_codec_v_r, rv_fmt_vd_vs1, NULL, 0, 0, 0 },
-    { "vmv.v.x", rv_codec_v_r, rv_fmt_vd_rs1, NULL, 0, 0, 0 },
-    { "vmv.v.i", rv_codec_v_i, rv_fmt_vd_imm, NULL, 0, 0, 0 },
-    { "vmerge.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl, NULL, 0, 0,
 0 },
-    { "vmerge.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl, NULL, 0, 0,
 0 },
-    { "vmerge.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl, NULL, 0, 0,
 0 },
-    { "vsaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vsaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vsaddu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vsadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vsadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vsadd.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm, NULL, 0, 0, 0
 },
-    { "vssubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vssubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vssub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vssub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vaadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vaadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vaaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vaaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vasub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vasub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vasubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vasubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vsmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vsmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vssrl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vssrl.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vssrl.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0,
 0 },
-    { "vssra.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vssra.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vssra.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0,
 0 },
-    { "vnclipu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0,
 0 },
-    { "vnclipu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0,
 0 },
-    { "vnclipu.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0,
 0, 0 },
-    { "vnclip.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vnclip.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0
 },
-    { "vnclip.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0,
 0, 0 },
-    { "vfadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfadd.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfrsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfwadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfwadd.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfwadd.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfwadd.wf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfwsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfwsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfwsub.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfwsub.wf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfmul.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfdiv.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfdiv.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfrdiv.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfwmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfwmul.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vfmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vfnmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfnmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vfmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vfnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfnmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vfmadd.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vfnmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfnmadd.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vfmsub.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0
 },
-    { "vfnmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfnmsub.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfwmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfwmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfwnmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfwnmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfwmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfwmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfwnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfwnmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0,
 0 },
-    { "vfsqrt.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
-    { "vfrsqrt7.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
-    { "vfrec7.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 },
-    { "vfmin.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfmin.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfmax.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfmax.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfsgnj.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vfsgnj.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vfsgnjn.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0,
 0 },
-    { "vfsgnjn.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0,
 0 },
-    { "vfsgnjx.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0,
 0 },
-    { "vfsgnjx.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0,
 0 },
-    { "vfslide1up.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0,
 0, 0 },
-    { "vfslide1down.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL,
 0, 0, 0 },
-    { "vmfeq.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmfeq.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vmfne.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmfne.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vmflt.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmflt.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vmfle.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0
 },
-    { "vmfle.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0
 },
-    { "vmfgt.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0

},
-    { "vmfge.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm, NULL, 0, 0, 0 },
-    { "vfclass.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vfmerge.vfm", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vl, NULL, 0, 0, 0 },
-    { "vfmv.v.f", rv_codec_v_r, rv_fmt_vd_fs1, NULL, 0, 0, 0 }, -    { "vfcvt.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfcvt.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfcvt.f.xu.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfcvt.f.x.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfcvt.rtz.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfcvt.rtz.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfwcvt.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfwcvt.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfwcvt.f.xu.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfwcvt.f.x.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfwcvt.f.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfwcvt.rtz.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfwcvt.rtz.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfncvt.xu.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfncvt.x.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfncvt.f.xu.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfncvt.f.x.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfncvt.f.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfncvt.rod.f.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfncvt.rtz.xu.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfncvt.rtz.x.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vredsum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vredand.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vredor.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vredxor.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vredminu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vredmin.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vredmaxu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vredmax.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vwredsumu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vwredsum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vfredusum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vfredosum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vfredmin.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vfredmax.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vfwredusum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vfwredosum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vmand.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vmnand.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vmandn.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vmxor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vmor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vmnor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vmorn.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vmxnor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vcpop.m", rv_codec_v_r, rv_fmt_rd_vs2_vm, NULL, 0, 0, 0 }, -    { "vfirst.m", rv_codec_v_r, rv_fmt_rd_vs2_vm, NULL, 0, 0, 0 }, -    { "vmsbf.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vmsif.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vmsof.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "viota.m", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vid.v", rv_codec_v_r, rv_fmt_vd_vm, NULL, 0, 0, 0 }, -    { "vmv.x.s", rv_codec_v_r, rv_fmt_rd_vs2, NULL, 0, 0, 0 }, -    { "vmv.s.x", rv_codec_v_r, rv_fmt_vd_rs1, NULL, 0, 0, 0 }, -    { "vfmv.f.s", rv_codec_v_r, rv_fmt_fd_vs2, NULL, 0, 0, 0 }, -    { "vfmv.s.f", rv_codec_v_r, rv_fmt_vd_fs1, NULL, 0, 0, 0 }, -    { "vslideup.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vslideup.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
-    { "vslide1up.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vslidedown.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vslidedown.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
-    { "vslide1down.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vrgather.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vrgatherei16.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vrgather.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vrgather.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
-    { "vcompress.vm", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 },
-    { "vmv1r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vmv2r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vmv4r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vmv8r.v", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vzext.vf2", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vzext.vf4", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vzext.vf8", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vsext.vf2", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vsext.vf4", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vsext.vf8", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vsetvli", rv_codec_vsetvli, rv_fmt_vsetvli, NULL, 0, 0, 0 }, -    { "vsetivli", rv_codec_vsetivli, rv_fmt_vsetivli, NULL, 0, 0, 0 },
-    { "vsetvl", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "c.zext.b", rv_codec_zcb_ext, rv_fmt_rd, NULL, 0 }, -    { "c.sext.b", rv_codec_zcb_ext, rv_fmt_rd, NULL, 0 }, -    { "c.zext.h", rv_codec_zcb_ext, rv_fmt_rd, NULL, 0 }, -    { "c.sext.h", rv_codec_zcb_ext, rv_fmt_rd, NULL, 0 }, -    { "c.zext.w", rv_codec_zcb_ext, rv_fmt_rd, NULL, 0 }, -    { "c.not", rv_codec_zcb_ext, rv_fmt_rd, NULL, 0 },
-    { "c.mul", rv_codec_zcb_mul, rv_fmt_rd_rs2, NULL, 0, 0 }, -    { "c.lbu", rv_codec_zcb_lb, rv_fmt_rs1_rs2_zce_ldst, NULL, 0, 0, 0 },
-    { "c.lhu", rv_codec_zcb_lh, rv_fmt_rs1_rs2_zce_ldst, NULL, 0, 0, 0 },
-    { "c.lh", rv_codec_zcb_lh, rv_fmt_rs1_rs2_zce_ldst, NULL, 0, 0, 0 },
-    { "c.sb", rv_codec_zcb_lb, rv_fmt_rs1_rs2_zce_ldst, NULL, 0, 0, 0 },
-    { "c.sh", rv_codec_zcb_lh, rv_fmt_rs1_rs2_zce_ldst, NULL, 0, 0, 0 },
-    { "cm.push", rv_codec_zcmp_cm_pushpop, rv_fmt_push_rlist, NULL, 0, 0 },
-    { "cm.pop", rv_codec_zcmp_cm_pushpop, rv_fmt_pop_rlist, NULL, 0, 0 },
-    { "cm.popret", rv_codec_zcmp_cm_pushpop, rv_fmt_pop_rlist, NULL, 0, 0, 0 },
-    { "cm.popretz", rv_codec_zcmp_cm_pushpop, rv_fmt_pop_rlist, NULL, 0, 0 },
-    { "cm.mva01s", rv_codec_zcmp_cm_mv, rv_fmt_rd_rs2, NULL, 0, 0, 0 },
-    { "cm.mvsa01", rv_codec_zcmp_cm_mv, rv_fmt_rd_rs2, NULL, 0, 0, 0 },
-    { "cm.jt", rv_codec_zcmt_jt, rv_fmt_zcmt_index, NULL, 0 }, -    { "cm.jalt", rv_codec_zcmt_jt, rv_fmt_zcmt_index, NULL, 0 }, -    { "czero.eqz", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "czero.nez", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "fcvt.bf16.s", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 },
-    { "fcvt.s.bf16", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 },
-    { "vfncvtbf16.f.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfwcvtbf16.f.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 },
-    { "vfwmaccbf16.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm, NULL, 0, 0, 0 },
-    { "vfwmaccbf16.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm, NULL, 0, 0, 0 },
-    { "flh", rv_codec_i, rv_fmt_frd_offset_rs1, NULL, 0, 0, 0 }, -    { "fsh", rv_codec_s, rv_fmt_frs2_offset_rs1, NULL, 0, 0, 0 }, -    { "fmv.h.x", rv_codec_r, rv_fmt_frd_rs1, NULL, 0, 0, 0 }, -    { "fmv.x.h", rv_codec_r, rv_fmt_rd_frs1, NULL, 0, 0, 0 }, -    { "fli.s", rv_codec_fli, rv_fmt_fli, NULL, 0, 0, 0 }, -    { "fli.d", rv_codec_fli, rv_fmt_fli, NULL, 0, 0, 0 }, -    { "fli.q", rv_codec_fli, rv_fmt_fli, NULL, 0, 0, 0 }, -    { "fli.h", rv_codec_fli, rv_fmt_fli, NULL, 0, 0, 0 }, -    { "fminm.s", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fmaxm.s", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fminm.d", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fmaxm.d", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fminm.q", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fmaxm.q", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fminm.h", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fmaxm.h", rv_codec_r, rv_fmt_frd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fround.s", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "froundnx.s", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 },
-    { "fround.d", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "froundnx.d", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 },
-    { "fround.q", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "froundnx.q", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 },
-    { "fround.h", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 }, -    { "froundnx.h", rv_codec_r_m, rv_fmt_rm_frd_frs1, NULL, 0, 0, 0 },
-    { "fcvtmod.w.d", rv_codec_r_m, rv_fmt_rm_rd_frs1, NULL, 0, 0, 0 },
-    { "fmvh.x.d", rv_codec_r, rv_fmt_rd_frs1, NULL, 0, 0, 0 }, -    { "fmvp.d.x", rv_codec_r, rv_fmt_frd_rs1_rs2, NULL, 0, 0, 0 }, -    { "fmvh.x.q", rv_codec_r, rv_fmt_rd_frs1, NULL, 0, 0, 0 }, -    { "fmvp.q.x", rv_codec_r, rv_fmt_frd_rs1_rs2, NULL, 0, 0, 0 }, -    { "fleq.s", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fltq.s", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fleq.d", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fltq.d", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fleq.q", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fltq.q", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fleq.h", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "fltq.h", rv_codec_r, rv_fmt_rd_frs1_frs2, NULL, 0, 0, 0 }, -    { "vaesdf.vv", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vaesdf.vs", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vaesdm.vv", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vaesdm.vs", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vaesef.vv", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vaesef.vs", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vaesem.vv", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vaesem.vs", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vaeskf1.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm, NULL, 0, 0, 0 },
-    { "vaeskf2.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm, NULL, 0, 0, 0 },
-    { "vaesz.vs", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vandn.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vandn.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vbrev.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vbrev8.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vclmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vclmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vclmulh.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vclmulh.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vclz.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vcpop.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vctz.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vghsh.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 }, -    { "vgmul.vv", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vrev8.v", rv_codec_v_r, rv_fmt_vd_vs2_vm, NULL, 0, 0, 0 }, -    { "vrol.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vrol.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vror.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vror.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vror.vi", rv_codec_vror_vi, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
-    { "vsha2ch.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 },
-    { "vsha2cl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 },
-    { "vsha2ms.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 },
-    { "vsm3c.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm, NULL, 0, 0, 0 },
-    { "vsm3me.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1, NULL, 0, 0, 0 }, -    { "vsm4k.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm, NULL, 0, 0, 0 },
-    { "vsm4r.vv", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vsm4r.vs", rv_codec_v_r, rv_fmt_vd_vs2, NULL, 0, 0, 0 }, -    { "vwsll.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm, NULL, 0, 0, 0 },
-    { "vwsll.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm, NULL, 0, 0, 0 },
-    { "vwsll.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm, NULL, 0, 0, 0 },
-    { "amocas.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amocas.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amocas.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "mop.r.0", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.1", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.2", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.3", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.4", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.5", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.6", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.7", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.8", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.9", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.10", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.11", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.12", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.13", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.14", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.15", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.16", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.17", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.18", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.19", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.20", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.21", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.22", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.23", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.24", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.25", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.26", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.27", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.28", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.29", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.30", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.r.31", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0 }, -    { "mop.rr.0", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mop.rr.1", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mop.rr.2", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mop.rr.3", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mop.rr.4", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mop.rr.5", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mop.rr.6", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "mop.rr.7", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, -    { "c.mop.1", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "c.mop.3", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "c.mop.5", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "c.mop.7", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "c.mop.9", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "c.mop.11", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "c.mop.13", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "c.mop.15", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "amoswap.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoadd.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoxor.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoor.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoand.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomin.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomax.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amominu.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomaxu.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoswap.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoadd.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoxor.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoor.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amoand.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomin.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomax.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amominu.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amomaxu.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amocas.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "amocas.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "wrs.sto", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "wrs.nto", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, -    { "lpad", rv_codec_lp, rv_fmt_imm, NULL, 0, 0, 0 },
-    { "sspush", rv_codec_r, rv_fmt_rs2, NULL, 0, 0, 0 }, -    { "sspopchk", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -    { "ssrdp", rv_codec_r, rv_fmt_rd, NULL, 0, 0, 0 },
-    { "ssamoswap.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
-    { "ssamoswap.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 },
+    { "nop", rv_codec_i, rv_fmt_none },
+    { "mv", rv_codec_i, rv_fmt_rd_rs1 },
+    { "not", rv_codec_i, rv_fmt_rd_rs1 },
+    { "neg", rv_codec_r, rv_fmt_rd_rs2 },
+    { "negw", rv_codec_r, rv_fmt_rd_rs2 },
+    { "sext.w", rv_codec_i, rv_fmt_rd_rs1 },
+    { "seqz", rv_codec_i, rv_fmt_rd_rs1 },
+    { "snez", rv_codec_r, rv_fmt_rd_rs2 },
+    { "sltz", rv_codec_r, rv_fmt_rd_rs1 },
+    { "sgtz", rv_codec_r, rv_fmt_rd_rs2 },
+    { "fmv.s", rv_codec_r, rv_fmt_frd_frs1 },
+    { "fabs.s", rv_codec_r, rv_fmt_frd_frs1 },
+    { "fneg.s", rv_codec_r, rv_fmt_frd_frs1 },
+    { "fmv.d", rv_codec_r, rv_fmt_frd_frs1 },
+    { "fabs.d", rv_codec_r, rv_fmt_frd_frs1 },
+    { "fneg.d", rv_codec_r, rv_fmt_frd_frs1 },
+    { "fmv.q", rv_codec_r, rv_fmt_frd_frs1 },
+    { "fabs.q", rv_codec_r, rv_fmt_frd_frs1 },
+    { "fneg.q", rv_codec_r, rv_fmt_frd_frs1 },
+    { "beqz", rv_codec_sb, rv_fmt_rs1_offset },
+    { "bnez", rv_codec_sb, rv_fmt_rs1_offset },
+    { "blez", rv_codec_sb, rv_fmt_rs2_offset },
+    { "bgez", rv_codec_sb, rv_fmt_rs1_offset },
+    { "bltz", rv_codec_sb, rv_fmt_rs1_offset },
+    { "bgtz", rv_codec_sb, rv_fmt_rs2_offset },
+    { "ble", rv_codec_sb, rv_fmt_rs2_rs1_offset },
+    { "bleu", rv_codec_sb, rv_fmt_rs2_rs1_offset },
+    { "bgt", rv_codec_sb, rv_fmt_rs2_rs1_offset },
+    { "bgtu", rv_codec_sb, rv_fmt_rs2_rs1_offset },
+    { "j", rv_codec_uj, rv_fmt_offset },
+    { "ret", rv_codec_i, rv_fmt_none },
+    { "jr", rv_codec_i, rv_fmt_rs1 },
+    { "rdcycle", rv_codec_i_csr, rv_fmt_rd },
+    { "rdtime", rv_codec_i_csr, rv_fmt_rd },
+    { "rdinstret", rv_codec_i_csr, rv_fmt_rd },
+    { "rdcycleh", rv_codec_i_csr, rv_fmt_rd },
+    { "rdtimeh", rv_codec_i_csr, rv_fmt_rd },
+    { "rdinstreth", rv_codec_i_csr, rv_fmt_rd },
+    { "frcsr", rv_codec_i_csr, rv_fmt_rd },
+    { "frrm", rv_codec_i_csr, rv_fmt_rd },
+    { "frflags", rv_codec_i_csr, rv_fmt_rd },
+    { "fscsr", rv_codec_i_csr, rv_fmt_rd_rs1 },
+    { "fsrm", rv_codec_i_csr, rv_fmt_rd_rs1 },
+    { "fsflags", rv_codec_i_csr, rv_fmt_rd_rs1 },
+    { "fsrmi", rv_codec_i_csr, rv_fmt_rd_zimm },
+    { "fsflagsi", rv_codec_i_csr, rv_fmt_rd_zimm },
+    { "bseti", rv_codec_i_sh7, rv_fmt_rd_rs1_imm },
+    { "bclri", rv_codec_i_sh7, rv_fmt_rd_rs1_imm },
+    { "binvi", rv_codec_i_sh7, rv_fmt_rd_rs1_imm },
+    { "bexti", rv_codec_i_sh7, rv_fmt_rd_rs1_imm },
+    { "rori", rv_codec_i_sh7, rv_fmt_rd_rs1_imm },
+    { "clz", rv_codec_r, rv_fmt_rd_rs1 },
+    { "ctz", rv_codec_r, rv_fmt_rd_rs1 },
+    { "cpop", rv_codec_r, rv_fmt_rd_rs1 },
+    { "sext.h", rv_codec_r, rv_fmt_rd_rs1 },
+    { "sext.b", rv_codec_r, rv_fmt_rd_rs1 },
+    { "xnor", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "orn", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "andn", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "rol", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "ror", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sh1add", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sh2add", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sh3add", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sh1add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sh2add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sh3add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "clmul", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "clmulr", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "clmulh", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "min", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "minu", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "max", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "maxu", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "clzw", rv_codec_r, rv_fmt_rd_rs1 },
+    { "ctzw", rv_codec_r, rv_fmt_rd_rs1 },
+    { "cpopw", rv_codec_r, rv_fmt_rd_rs1 },
+    { "slli.uw", rv_codec_i_sh6, rv_fmt_rd_rs1_imm },
+    { "add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "rolw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "rorw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "rev8", rv_codec_r, rv_fmt_rd_rs1 },
+    { "zext.h", rv_codec_r, rv_fmt_rd_rs1 },
+    { "roriw", rv_codec_i_sh5, rv_fmt_rd_rs1_imm },
+    { "orc.b", rv_codec_r, rv_fmt_rd_rs1 },
+    { "bset", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "bclr", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "binv", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "bext", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "aes32esmi", rv_codec_k_bs, rv_fmt_rs1_rs2_bs },
+    { "aes32esi", rv_codec_k_bs, rv_fmt_rs1_rs2_bs },
+    { "aes32dsmi", rv_codec_k_bs, rv_fmt_rs1_rs2_bs },
+    { "aes32dsi", rv_codec_k_bs, rv_fmt_rs1_rs2_bs },
+    { "aes64ks1i", rv_codec_k_rnum, rv_fmt_rd_rs1_rnum }, +    { "aes64ks2", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "aes64im", rv_codec_r, rv_fmt_rd_rs1 },
+    { "aes64esm", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "aes64es", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "aes64dsm", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "aes64ds", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sha256sig0", rv_codec_r, rv_fmt_rd_rs1 },
+    { "sha256sig1", rv_codec_r, rv_fmt_rd_rs1 },
+    { "sha256sum0", rv_codec_r, rv_fmt_rd_rs1 },
+    { "sha256sum1", rv_codec_r, rv_fmt_rd_rs1 },
+    { "sha512sig0", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sha512sig1", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sha512sum0", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sha512sum1", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sha512sum0r", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sha512sum1r", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sha512sig0l", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sha512sig0h", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sha512sig1l", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sha512sig1h", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "sm3p0", rv_codec_r, rv_fmt_rd_rs1 },
+    { "sm3p1", rv_codec_r, rv_fmt_rd_rs1 },
+    { "sm4ed", rv_codec_k_bs, rv_fmt_rs1_rs2_bs },
+    { "sm4ks", rv_codec_k_bs, rv_fmt_rs1_rs2_bs },
+    { "brev8", rv_codec_r, rv_fmt_rd_rs1 },
+    { "pack", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "packh", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "packw", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "unzip", rv_codec_r, rv_fmt_rd_rs1 },
+    { "zip", rv_codec_r, rv_fmt_rd_rs1 },
+    { "xperm4", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "xperm8", rv_codec_r, rv_fmt_rd_rs1 },
+    { "vle8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vle16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vle32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vle64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vse8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vse16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vse32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vse64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vlm.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vsm.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vlse8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm }, +    { "vlse16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm }, +    { "vlse32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm }, +    { "vlse64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm }, +    { "vsse8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm }, +    { "vsse16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm }, +    { "vsse32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm }, +    { "vsse64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_rs2_vm }, +    { "vluxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vluxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vluxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vluxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vloxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vloxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vloxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vloxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vsuxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vsuxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vsuxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vsuxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vsoxei8.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vsoxei16.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vsoxei32.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vsoxei64.v", rv_codec_v_r, rv_fmt_ldst_vd_rs1_vs2_vm }, +    { "vle8ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vle16ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vle32ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vle64ff.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl1re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl1re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl1re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl1re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl2re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl2re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl2re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl2re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl4re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl4re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl4re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl4re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl8re8.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl8re16.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl8re32.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vl8re64.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vs1r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vs2r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vs4r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vs8r.v", rv_codec_v_ldst, rv_fmt_ldst_vd_rs1_vm }, +    { "vadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vadd.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm },
+    { "vsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vrsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vrsub.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm },
+    { "vwaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vwaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vwadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vwadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vwsubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vwsubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vwsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vwsub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vwaddu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vwaddu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vwadd.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vwadd.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vwsubu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vwsubu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vwsub.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vwsub.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vadc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl },
+    { "vadc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl },
+    { "vadc.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl },
+    { "vmadc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl }, +    { "vmadc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl }, +    { "vmadc.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl }, +    { "vsbc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl },
+    { "vsbc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl },
+    { "vmsbc.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl }, +    { "vmsbc.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl }, +    { "vand.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vand.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vand.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm },
+    { "vor.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vor.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vor.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm },
+    { "vxor.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vxor.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vxor.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm },
+    { "vsll.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vsll.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vsll.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vsrl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vsrl.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vsrl.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vsra.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vsra.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vsra.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vnsrl.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vnsrl.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vnsrl.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vnsra.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vnsra.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vnsra.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vmseq.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmseq.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmseq.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm },
+    { "vmsne.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmsne.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmsne.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm },
+    { "vmsltu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vmsltu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vmslt.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmslt.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmsleu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vmsleu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vmsleu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm }, +    { "vmsle.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmsle.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmsle.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm },
+    { "vmsgtu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vmsgtu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm }, +    { "vmsgt.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmsgt.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm },
+    { "vminu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vminu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmin.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmin.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmaxu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmaxu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmax.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmax.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmulh.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmulh.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmulhu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vmulhu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vmulhsu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vmulhsu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vdivu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vdivu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vdiv.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vdiv.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vremu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vremu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vrem.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vrem.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vwmulu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vwmulu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vwmulsu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vwmulsu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vwmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vwmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm },
+    { "vmacc.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm },
+    { "vnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vnmsac.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm }, +    { "vmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm },
+    { "vmadd.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm },
+    { "vnmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vnmsub.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm }, +    { "vwmaccu.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vwmaccu.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm }, +    { "vwmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vwmacc.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm }, +    { "vwmaccsu.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vwmaccsu.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm }, +    { "vwmaccus.vx", rv_codec_v_r, rv_fmt_vd_rs1_vs2_vm }, +    { "vmv.v.v", rv_codec_v_r, rv_fmt_vd_vs1 },
+    { "vmv.v.x", rv_codec_v_r, rv_fmt_vd_rs1 },
+    { "vmv.v.i", rv_codec_v_i, rv_fmt_vd_imm },
+    { "vmerge.vvm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vl }, +    { "vmerge.vxm", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vl }, +    { "vmerge.vim", rv_codec_v_i, rv_fmt_vd_vs2_imm_vl }, +    { "vsaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vsaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vsaddu.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm }, +    { "vsadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vsadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vsadd.vi", rv_codec_v_i, rv_fmt_vd_vs2_imm_vm },
+    { "vssubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vssubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vssub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vssub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vaadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vaadd.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vaaddu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vaaddu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vasub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vasub.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vasubu.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vasubu.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vsmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vsmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vssrl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vssrl.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vssrl.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vssra.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vssra.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vssra.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vnclipu.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vnclipu.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vnclipu.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vnclip.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vnclip.wx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vnclip.wi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vfadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vfadd.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vfsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vfsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vfrsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vfwadd.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfwadd.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vfwadd.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfwadd.wf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vfwsub.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfwsub.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vfwsub.wv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfwsub.wf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vfmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vfmul.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vfdiv.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vfdiv.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vfrdiv.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vfwmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfwmul.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vfmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfnmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfnmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfnmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfmadd.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfnmadd.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfnmadd.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfmsub.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfnmsub.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfnmsub.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfwmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfwmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfwnmacc.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfwnmacc.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfwmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfwmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfwnmsac.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfwnmsac.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "vfsqrt.v", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vfrsqrt7.v", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vfrec7.v", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vfmin.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vfmin.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vfmax.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vfmax.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vfsgnj.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfsgnj.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vfsgnjn.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfsgnjn.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vfsgnjx.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfsgnjx.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vfslide1up.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vfslide1down.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm }, +    { "vmfeq.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmfeq.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vmfne.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmfne.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vmflt.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmflt.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vmfle.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmfle.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vmfgt.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vmfge.vf", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vm },
+    { "vfclass.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vfmerge.vfm", rv_codec_v_r, rv_fmt_vd_vs2_fs1_vl }, +    { "vfmv.v.f", rv_codec_v_r, rv_fmt_vd_fs1 },
+    { "vfcvt.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vfcvt.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vfcvt.f.xu.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vfcvt.f.x.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vfcvt.rtz.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfcvt.rtz.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfwcvt.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfwcvt.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vfwcvt.f.xu.v", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfwcvt.f.x.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vfwcvt.f.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vfwcvt.rtz.xu.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfwcvt.rtz.x.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfncvt.xu.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfncvt.x.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vfncvt.f.xu.w", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfncvt.f.x.w", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vfncvt.f.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vfncvt.rod.f.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfncvt.rtz.xu.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfncvt.rtz.x.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vredsum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vredand.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vredor.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vredxor.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vredminu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vredmin.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vredmaxu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vredmax.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vwredsumu.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vwredsum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfredusum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfredosum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfredmin.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfredmax.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfwredusum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vfwredosum.vs", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vmand.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmnand.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vmandn.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vmxor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmnor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmorn.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vmxnor.mm", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vcpop.m", rv_codec_v_r, rv_fmt_rd_vs2_vm },
+    { "vfirst.m", rv_codec_v_r, rv_fmt_rd_vs2_vm },
+    { "vmsbf.m", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vmsif.m", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vmsof.m", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "viota.m", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vid.v", rv_codec_v_r, rv_fmt_vd_vm },
+    { "vmv.x.s", rv_codec_v_r, rv_fmt_rd_vs2 },
+    { "vmv.s.x", rv_codec_v_r, rv_fmt_vd_rs1 },
+    { "vfmv.f.s", rv_codec_v_r, rv_fmt_fd_vs2 },
+    { "vfmv.s.f", rv_codec_v_r, rv_fmt_vd_fs1 },
+    { "vslideup.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vslideup.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vslide1up.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vslidedown.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vslidedown.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vslide1down.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vrgather.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vrgatherei16.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vrgather.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vrgather.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "vcompress.vm", rv_codec_v_r, rv_fmt_vd_vs2_vs1 }, +    { "vmv1r.v", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vmv2r.v", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vmv4r.v", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vmv8r.v", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vzext.vf2", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vzext.vf4", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vzext.vf8", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vsext.vf2", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vsext.vf4", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vsext.vf8", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vsetvli", rv_codec_vsetvli, rv_fmt_vsetvli },
+    { "vsetivli", rv_codec_vsetivli, rv_fmt_vsetivli },
+    { "vsetvl", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "c.zext.b", rv_codec_zcb_ext, rv_fmt_rd },
+    { "c.sext.b", rv_codec_zcb_ext, rv_fmt_rd },
+    { "c.zext.h", rv_codec_zcb_ext, rv_fmt_rd },
+    { "c.sext.h", rv_codec_zcb_ext, rv_fmt_rd },
+    { "c.zext.w", rv_codec_zcb_ext, rv_fmt_rd },
+    { "c.not", rv_codec_zcb_ext, rv_fmt_rd },
+    { "c.mul", rv_codec_zcb_mul, rv_fmt_rd_rs2 },
+    { "c.lbu", rv_codec_zcb_lb, rv_fmt_rs1_rs2_zce_ldst }, +    { "c.lhu", rv_codec_zcb_lh, rv_fmt_rs1_rs2_zce_ldst }, +    { "c.lh", rv_codec_zcb_lh, rv_fmt_rs1_rs2_zce_ldst }, +    { "c.sb", rv_codec_zcb_lb, rv_fmt_rs1_rs2_zce_ldst }, +    { "c.sh", rv_codec_zcb_lh, rv_fmt_rs1_rs2_zce_ldst }, +    { "cm.push", rv_codec_zcmp_cm_pushpop, rv_fmt_push_rlist }, +    { "cm.pop", rv_codec_zcmp_cm_pushpop, rv_fmt_pop_rlist }, +    { "cm.popret", rv_codec_zcmp_cm_pushpop, rv_fmt_pop_rlist }, +    { "cm.popretz", rv_codec_zcmp_cm_pushpop, rv_fmt_pop_rlist }, +    { "cm.mva01s", rv_codec_zcmp_cm_mv, rv_fmt_rd_rs2 }, +    { "cm.mvsa01", rv_codec_zcmp_cm_mv, rv_fmt_rd_rs2 }, +    { "cm.jt", rv_codec_zcmt_jt, rv_fmt_zcmt_index },
+    { "cm.jalt", rv_codec_zcmt_jt, rv_fmt_zcmt_index },
+    { "czero.eqz", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "czero.nez", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "fcvt.bf16.s", rv_codec_r_m, rv_fmt_rm_frd_frs1 }, +    { "fcvt.s.bf16", rv_codec_r_m, rv_fmt_rm_frd_frs1 }, +    { "vfncvtbf16.f.f.w", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfwcvtbf16.f.f.v", rv_codec_v_r, rv_fmt_vd_vs2_vm }, +    { "vfwmaccbf16.vv", rv_codec_v_r, rv_fmt_vd_vs1_vs2_vm }, +    { "vfwmaccbf16.vf", rv_codec_v_r, rv_fmt_vd_fs1_vs2_vm }, +    { "flh", rv_codec_i, rv_fmt_frd_offset_rs1 },
+    { "fsh", rv_codec_s, rv_fmt_frs2_offset_rs1 },
+    { "fmv.h.x", rv_codec_r, rv_fmt_frd_rs1 },
+    { "fmv.x.h", rv_codec_r, rv_fmt_rd_frs1 },
+    { "fli.s", rv_codec_fli, rv_fmt_fli },
+    { "fli.d", rv_codec_fli, rv_fmt_fli },
+    { "fli.q", rv_codec_fli, rv_fmt_fli },
+    { "fli.h", rv_codec_fli, rv_fmt_fli },
+    { "fminm.s", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fmaxm.s", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fminm.d", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fmaxm.d", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fminm.q", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fmaxm.q", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fminm.h", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fmaxm.h", rv_codec_r, rv_fmt_frd_frs1_frs2 },
+    { "fround.s", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "froundnx.s", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fround.d", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "froundnx.d", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fround.q", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "froundnx.q", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fround.h", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "froundnx.h", rv_codec_r_m, rv_fmt_rm_frd_frs1 },
+    { "fcvtmod.w.d", rv_codec_r_m, rv_fmt_rm_rd_frs1 },
+    { "fmvh.x.d", rv_codec_r, rv_fmt_rd_frs1 },
+    { "fmvp.d.x", rv_codec_r, rv_fmt_frd_rs1_rs2 },
+    { "fmvh.x.q", rv_codec_r, rv_fmt_rd_frs1 },
+    { "fmvp.q.x", rv_codec_r, rv_fmt_frd_rs1_rs2 },
+    { "fleq.s", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "fltq.s", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "fleq.d", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "fltq.d", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "fleq.q", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "fltq.q", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "fleq.h", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "fltq.h", rv_codec_r, rv_fmt_rd_frs1_frs2 },
+    { "vaesdf.vv", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vaesdf.vs", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vaesdm.vv", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vaesdm.vs", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vaesef.vv", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vaesef.vs", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vaesem.vv", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vaesem.vs", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vaeskf1.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm }, +    { "vaeskf2.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm }, +    { "vaesz.vs", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vandn.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vandn.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vbrev.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vbrev8.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vclmul.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vclmul.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vclmulh.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm }, +    { "vclmulh.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm }, +    { "vclz.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vcpop.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vctz.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vghsh.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1 },
+    { "vgmul.vv", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vrev8.v", rv_codec_v_r, rv_fmt_vd_vs2_vm },
+    { "vrol.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vrol.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vror.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vror.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vror.vi", rv_codec_vror_vi, rv_fmt_vd_vs2_uimm_vm }, +    { "vsha2ch.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1 },
+    { "vsha2cl.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1 },
+    { "vsha2ms.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1 },
+    { "vsm3c.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm },
+    { "vsm3me.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1 },
+    { "vsm4k.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm },
+    { "vsm4r.vv", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vsm4r.vs", rv_codec_v_r, rv_fmt_vd_vs2 },
+    { "vwsll.vv", rv_codec_v_r, rv_fmt_vd_vs2_vs1_vm },
+    { "vwsll.vx", rv_codec_v_r, rv_fmt_vd_vs2_rs1_vm },
+    { "vwsll.vi", rv_codec_v_i_u, rv_fmt_vd_vs2_uimm_vm }, +    { "amocas.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amocas.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amocas.q", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "mop.r.0", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.1", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.2", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.3", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.4", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.5", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.6", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.7", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.8", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.9", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.10", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.11", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.12", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.13", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.14", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.15", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.16", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.17", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.18", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.19", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.20", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.21", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.22", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.23", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.24", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.25", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.26", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.27", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.28", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.29", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.30", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.r.31", rv_codec_r, rv_fmt_rd_rs1 },
+    { "mop.rr.0", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mop.rr.1", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mop.rr.2", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mop.rr.3", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mop.rr.4", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mop.rr.5", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mop.rr.6", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "mop.rr.7", rv_codec_r, rv_fmt_rd_rs1_rs2 },
+    { "c.mop.1", rv_codec_ci_none, rv_fmt_none },
+    { "c.mop.3", rv_codec_ci_none, rv_fmt_none },
+    { "c.mop.5", rv_codec_ci_none, rv_fmt_none },
+    { "c.mop.7", rv_codec_ci_none, rv_fmt_none },
+    { "c.mop.9", rv_codec_ci_none, rv_fmt_none },
+    { "c.mop.11", rv_codec_ci_none, rv_fmt_none },
+    { "c.mop.13", rv_codec_ci_none, rv_fmt_none },
+    { "c.mop.15", rv_codec_ci_none, rv_fmt_none },
+    { "amoswap.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoadd.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoxor.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoor.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoand.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomin.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomax.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amominu.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomaxu.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoswap.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoadd.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoxor.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoor.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amoand.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomin.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomax.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amominu.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amomaxu.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amocas.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "amocas.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "wrs.sto", rv_codec_none, rv_fmt_none },
+    { "wrs.nto", rv_codec_none, rv_fmt_none },
+    { "lpad", rv_codec_lp, rv_fmt_imm },
+    { "sspush", rv_codec_r, rv_fmt_rs2 },
+    { "sspopchk", rv_codec_r, rv_fmt_rs1 },
+    { "ssrdp", rv_codec_r, rv_fmt_rd },
+    { "ssamoswap.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, +    { "ssamoswap.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 }, { "c.sspush", rv_codec_cmop_ss, rv_fmt_rs2, NULL, rv_op_sspush, rv_op_sspush, 0 },
     { "c.sspopchk", rv_codec_cmop_ss, rv_fmt_rs1, NULL, rv_op_sspopchk,
       rv_op_sspopchk, 0 },
-   { "cbo.inval", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -   { "cbo.clean", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -   { "cbo.flush", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -   { "cbo.zero", rv_codec_r, rv_fmt_rs1, NULL, 0, 0, 0 }, -   { "mnret", rv_codec_none, rv_fmt_none, NULL, 0, 0, 0 }, +   { "cbo.inval", rv_codec_r, rv_fmt_rs1 },
+   { "cbo.clean", rv_codec_r, rv_fmt_rs1 },
+   { "cbo.flush", rv_codec_r, rv_fmt_rs1 },
+   { "cbo.zero", rv_codec_r, rv_fmt_rs1 },
+   { "mnret", rv_codec_none, rv_fmt_none },
 };

 /* CSR names */

#34 lore raw

PATCH 16/56 disas/riscv: Drop useless const in structures

In reply to Richard Henderson

Individual fields should not be const, only full structures.

---
 disas/riscv.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
disas/riscv.h +8 -8
index eabe193b4f..3325b7b4ef 100644
@@ -174,19 +174,19 @@ typedef enum {
 /* structures */
 
 typedef struct {
-    const int op;
+    int op;
     const rvc_constraint *constraints;
 } rv_comp_data;
 
 typedef struct {
-    const char * const name;
-    const rv_codec codec;
-    const char * const format;
+    const char *name;
+    rv_codec codec;
+    const char *format;
     const rv_comp_data *pseudo;
-    const short decomp_rv32;
-    const short decomp_rv64;
-    const short decomp_rv128;
-    const short decomp_data;
+    short decomp_rv32;
+    short decomp_rv64;
+    short decomp_rv128;
+    short decomp_data;
 } rv_opcode_data;
 
 typedef struct {
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 16/56
#36 lore raw

Re: [PATCH 16/56] disas/riscv: Drop useless const in structures

In reply to Richard Henderson
Quoted 3 lines · Richard Henderson

Individual fields should not be const, only full structures.

Alistair

Quoted 36 lines

---
 disas/riscv.h | 16 ++++++++--------

 1 file changed, 8 insertions(+), 8 deletions(-)
disas/riscv.h +0 -0
index eabe193b4f..3325b7b4ef 100644
@@ -174,19 +174,19 @@ typedef enum {
  /* structures */


 typedef struct {
-    const int op;
+    int op;
     const rvc_constraint *constraints;
 } rv_comp_data;

 typedef struct {
-    const char * const name;
-    const rv_codec codec;
-    const char * const format;
+    const char *name;
+    rv_codec codec;
+    const char *format;
     const rv_comp_data *pseudo;
-    const short decomp_rv32;
-    const short decomp_rv64;
-    const short decomp_rv128;
-    const short decomp_data;
+    short decomp_rv32;
+    short decomp_rv64;
+    short decomp_rv128;
+    short decomp_data;
 } rv_opcode_data;

 typedef struct {

#37 lore raw

PATCH 17/56 disas/riscv: Drop codec from rv_decode

In reply to Richard Henderson

This is mostly write-only, only used in one place; other updates are ignored.

---
 disas/riscv.h | 1 -
 disas/riscv.c | 7 +++----
 2 files changed, 3 insertions(+), 5 deletions(-)
disas/riscv.h +0 -1
index 3325b7b4ef..31bb0db86c 100644
@@ -197,7 +197,6 @@ typedef struct {
     int32_t   imm;
     int32_t   imm1;
     uint16_t  op;
-    uint8_t   codec;
     uint8_t   rd;
     uint8_t   rs1;
     uint8_t   rs2;
disas/riscv.c +3 -4
index ec40abb618..9813d75feb 100644
@@ -4603,8 +4603,9 @@ static void decode_inst_operands(rv_decode *dec, rv_isa isa,
 {
     rv_inst inst = dec->inst;
 
-    dec->codec = op->codec;
-    switch (dec->codec) {
+    switch (op->codec) {
+    case rv_codec_illegal:
+        break;
     case rv_codec_none:
         dec->rd = dec->rs1 = dec->rs2 = rv_ireg_zero;
         dec->imm = 0;
@@ -5369,7 +5370,6 @@ static const rv_opcode_data *decode_inst_lift_pseudo(rv_decode *dec,
             if (check_constraints(dec, comp_data->constraints)) {
                 dec->op = comp_data->op;
                 op = &dec->opcode_data[dec->op];
-                dec->codec = op->codec;
                 break;
             }
             comp_data++;
@@ -5407,7 +5407,6 @@ static const rv_opcode_data *decode_inst_decompress(rv_decode *dec, rv_isa isa,
             dec->op = decomp_op;
         }
         op = &dec->opcode_data[decomp_op];
-        dec->codec = op->codec;
     }
     return op;
 }
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 17/56
#38 lore raw

Re: [PATCH 17/56] disas/riscv: Drop codec from rv_decode

Quoted 4 lines · Richard Henderson

This is mostly write-only, only used in one place; other updates are ignored.

Alistair

Quoted 52 lines

---
 disas/riscv.h | 1 -
 disas/riscv.c | 7 +++----

 2 files changed, 3 insertions(+), 5 deletions(-)
disas/riscv.h +0 -1
index 3325b7b4ef..31bb0db86c 100644
@@ -197,7 +197,6 @@ typedef struct {
      int32_t   imm;
      int32_t   imm1;
      uint16_t  op;
-    uint8_t   codec;
      uint8_t   rd;
      uint8_t   rs1;
      uint8_t   rs2;
disas/riscv.c +0 -0
index ec40abb618..9813d75feb 100644
@@ -4603,8 +4603,9 @@ static void decode_inst_operands(rv_decode
 *dec, rv_isa isa,
  {
      rv_inst inst = dec->inst;


-    dec->codec = op->codec;
-    switch (dec->codec) {
+    switch (op->codec) {
+    case rv_codec_illegal:
+        break;
     case rv_codec_none:
         dec->rd = dec->rs1 = dec->rs2 = rv_ireg_zero; dec->imm = 0;

disas/riscv.c +0 -1
@@ -5369,7 +5370,6 @@ static const rv_opcode_data
 *decode_inst_lift_pseudo(rv_decode *dec,
              if (check_constraints(dec, comp_data->constraints)) {
                  dec->op = comp_data->op;
                  op = &dec->opcode_data[dec->op];
-                dec->codec = op->codec;
                  break;
              }

             comp_data++;

disas/riscv.c +0 -1
@@ -5407,7 +5407,6 @@ static const rv_opcode_data
 *decode_inst_decompress(rv_decode *dec, rv_isa isa,
              dec->op = decomp_op;
          }
          op = &dec->opcode_data[decomp_op];
-        dec->codec = op->codec;
      }
      return op;

 }

#39 lore raw

PATCH 18/56 disas/riscv: Handle c.addi4spn imm != 0 during decode

In reply to Richard Henderson
---
 disas/riscv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
disas/riscv.c +6 -2
index 9813d75feb..8a957e6a1e 100644
@@ -1885,7 +1885,7 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "fmv.x.q", rv_codec_r, rv_fmt_rd_frs1 },
     { "fmv.q.x", rv_codec_r, rv_fmt_frd_rs1 },
     { "c.addi4spn", rv_codec_ciw_4spn, rv_fmt_rd_rs1_imm, NULL, rv_op_addi,
-      rv_op_addi, rv_op_addi, rvcd_imm_nz },
+      rv_op_addi, rv_op_addi },
     { "c.fld", rv_codec_cl_ld, rv_fmt_frd_offset_rs1, NULL, rv_op_fld,
       rv_op_fld, 0 },
     { "c.lw", rv_codec_cl_lw, rv_fmt_rd_offset_rs1, NULL, rv_op_lw, rv_op_lw,
@@ -2952,7 +2952,11 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
     switch ((inst >> 0) & 0b11) {
     case 0:
         switch ((inst >> 13) & 0b111) {
-        case 0: op = rv_op_c_addi4spn; break;
+        case 0:
+            if ((inst >> 5) & 0xff) {
+                op = rv_op_c_addi4spn;
+            }
+            break;
         case 1:
             if (isa == rv128) {
                 op = rv_op_c_lq;
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 18/56
#40 lore raw

Re: [PATCH 18/56] disas/riscv: Handle c.addi4spn imm != 0 during decode

Quoted 1 line · Richard Henderson

Alistair

Quoted 35 lines

---
 disas/riscv.c | 8 ++++++--

 1 file changed, 6 insertions(+), 2 deletions(-)
disas/riscv.c +1 -1
index 9813d75feb..8a957e6a1e 100644
@@ -1885,7 +1885,7 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "fmv.x.q", rv_codec_r, rv_fmt_rd_frs1 },
      { "fmv.q.x", rv_codec_r, rv_fmt_frd_rs1 },
      { "c.addi4spn", rv_codec_ciw_4spn, rv_fmt_rd_rs1_imm, NULL,
 rv_op_addi,
-      rv_op_addi, rv_op_addi, rvcd_imm_nz },
+      rv_op_addi, rv_op_addi },
      { "c.fld", rv_codec_cl_ld, rv_fmt_frd_offset_rs1, NULL,

rv_op_fld,
       rv_op_fld, 0 },
     { "c.lw", rv_codec_cl_lw, rv_fmt_rd_offset_rs1, NULL, rv_op_lw, rv_op_lw,

disas/riscv.c +0 -0
@@ -2952,7 +2952,11 @@ static void decode_inst_opcode(rv_decode *dec,
 rv_isa isa)
      switch ((inst >> 0) & 0b11) {

     case 0:
         switch ((inst >> 13) & 0b111) {
-        case 0: op = rv_op_c_addi4spn; break;
+        case 0:
+            if ((inst >> 5) & 0xff) {
+                op = rv_op_c_addi4spn;
+            }
+            break;
         case 1:
             if (isa == rv128) {
                 op = rv_op_c_lq;

#41 lore raw

PATCH 19/56 disas/riscv: Simplify c.addi

In reply to Richard Henderson

While c.addi with imm == 0 and rd == 0 is c.nop, other c.addi with imm == 0 and rd != 0 are not illegal, but are reserved as HINTs. Go ahead and disassemble as c.addi rather than falling back to invalid.

Further, there's no reason to differentiate c.nop, since we have
c.addi -> addi -> nop
vs
c.nop -> addi -> nop
via decompress and pseudo translation steps.

---
 disas/riscv.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
disas/riscv.c +3 -8
index 8a957e6a1e..7978ffb378 100644
@@ -263,7 +263,6 @@ typedef enum {
     rv_op_c_fsd = 231,
     rv_op_c_sw = 232,
     rv_op_c_fsw = 233,
-    rv_op_c_nop = 234,
     rv_op_c_addi = 235,
     rv_op_c_jal = 236,
     rv_op_c_li = 237,
@@ -1896,10 +1895,9 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "c.sw", rv_codec_cs_sw, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw, rv_op_sw,
       rv_op_sw },
     { "c.fsw", rv_codec_cs_sw, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsw, 0, 0 },
-    { "c.nop", rv_codec_ci_none, rv_fmt_none, NULL, rv_op_addi, rv_op_addi,
-      rv_op_addi },
+    { },
     { "c.addi", rv_codec_ci, rv_fmt_rd_rs1_imm, NULL, rv_op_addi, rv_op_addi,
-      rv_op_addi, rvcd_imm_nz },
+      rv_op_addi },
     { "c.jal", rv_codec_cj_jal, rv_fmt_rd_offset, NULL, rv_op_jal, 0, 0 },
     { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, NULL, rv_op_addi, rv_op_addi,
       rv_op_addi },
@@ -3010,10 +3008,7 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
     case 1:
         switch ((inst >> 13) & 0b111) {
         case 0:
-            switch ((inst >> 2) & 0b11111111111) {
-            case 0: op = rv_op_c_nop; break;
-            default: op = rv_op_c_addi; break;
-            }
+            op = rv_op_c_addi; /* or unspecified HINT */
             break;
         case 1:
             if (isa == rv32) {
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 19/56
#42 lore raw

Re: [PATCH 19/56] disas/riscv: Simplify c.addi

Quoted 5 lines · Richard Henderson

While c.addi with imm == 0 and rd == 0 is c.nop, other c.addi with imm == 0 and rd != 0 are not illegal, but are reserved as HINTs.  Go ahead and disassemble as c.addi rather than falling back to invalid.

Quoted 7 lines

Further, there's no reason to differentiate c.nop, since we have c.addi -> addi -> nop
vs
  c.nop -> addi -> nop
via decompress and pseudo translation steps.

Alistair

Quoted 49 lines

---
 disas/riscv.c | 11 +++--------

 1 file changed, 3 insertions(+), 8 deletions(-)
disas/riscv.c +1 -3
index 8a957e6a1e..7978ffb378 100644
@@ -263,7 +263,6 @@ typedef enum {
      rv_op_c_fsd = 231,
      rv_op_c_sw = 232,
      rv_op_c_fsw = 233,
-    rv_op_c_nop = 234,
      rv_op_c_addi = 235,
      rv_op_c_jal = 236,
      rv_op_c_li = 237,
@@ -1896,10 +1895,9 @@ static const rv_opcode_data rvi_opcode_data[]
 = {
      { "c.sw", rv_codec_cs_sw, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw,
 rv_op_sw,
        rv_op_sw },
      { "c.fsw", rv_codec_cs_sw, rv_fmt_frs2_offset_rs1, NULL,
 rv_op_fsw, 0, 0 },
-    { "c.nop", rv_codec_ci_none, rv_fmt_none, NULL, rv_op_addi,
 rv_op_addi,
-      rv_op_addi },
+    { },
      { "c.addi", rv_codec_ci, rv_fmt_rd_rs1_imm, NULL, rv_op_addi,

rv_op_addi,
-      rv_op_addi, rvcd_imm_nz },
+      rv_op_addi },
     { "c.jal", rv_codec_cj_jal, rv_fmt_rd_offset, NULL, rv_op_jal, 0, 0 },
     { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, NULL, rv_op_addi, rv_op_addi,
       rv_op_addi },

disas/riscv.c +0 -0
@@ -3010,10 +3008,7 @@ static void decode_inst_opcode(rv_decode *dec,
 rv_isa isa)

     case 1:
         switch ((inst >> 13) & 0b111) {
         case 0:
-            switch ((inst >> 2) & 0b11111111111) { -            case 0: op = rv_op_c_nop; break;
-            default: op = rv_op_c_addi; break; -            }
+            op = rv_op_c_addi; /* or unspecified HINT */ break;
         case 1:
             if (isa == rv32) {

#43 lore raw

PATCH 20/56 disas/riscv: Handle c.lui imm != 0 during decode

In reply to Richard Henderson
---
 disas/riscv.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
disas/riscv.c +7 -5
index 7978ffb378..d6fbb3bca6 100644
@@ -1902,9 +1902,9 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, NULL, rv_op_addi, rv_op_addi,
       rv_op_addi },
     { "c.addi16sp", rv_codec_ci_16sp, rv_fmt_rd_rs1_imm, NULL, rv_op_addi,
-      rv_op_addi, rv_op_addi, rvcd_imm_nz },
+      rv_op_addi, rv_op_addi },
     { "c.lui", rv_codec_ci_lui, rv_fmt_rd_uimm, NULL, rv_op_lui, rv_op_lui,
-      rv_op_lui, rvcd_imm_nz },
+      rv_op_lui },
     { "c.srli", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_srli,
       rv_op_srli, rv_op_srli, rvcd_imm_nz },
     { "c.srai", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_srai,
@@ -3032,9 +3032,11 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
                     break;
                 }
             }
-            switch ((inst >> 7) & 0b11111) {
-            case 2: op = rv_op_c_addi16sp; break;
-            default: op = rv_op_c_lui; break;
+            if (inst & ((1 << 12) | (0x1f << 2))) {
+                switch ((inst >> 7) & 0b11111) {
+                case 2: op = rv_op_c_addi16sp; break;
+                default: op = rv_op_c_lui; break;
+                }
             }
             break;
         case 4:
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 20/56
#44 lore raw

Re: [PATCH 20/56] disas/riscv: Handle c.lui imm != 0 during decode

Quoted 1 line · Richard Henderson

Alistair

Quoted 42 lines

---
 disas/riscv.c | 12 +++++++-----

 1 file changed, 7 insertions(+), 5 deletions(-)
disas/riscv.c +2 -2
index 7978ffb378..d6fbb3bca6 100644
@@ -1902,9 +1902,9 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, NULL, rv_op_addi,
 rv_op_addi,
        rv_op_addi },
      { "c.addi16sp", rv_codec_ci_16sp, rv_fmt_rd_rs1_imm, NULL,
 rv_op_addi,
-      rv_op_addi, rv_op_addi, rvcd_imm_nz },
+      rv_op_addi, rv_op_addi },
      { "c.lui", rv_codec_ci_lui, rv_fmt_rd_uimm, NULL, rv_op_lui,
 rv_op_lui,
-      rv_op_lui, rvcd_imm_nz },
+      rv_op_lui },

     { "c.srli", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_srli,
       rv_op_srli, rv_op_srli, rvcd_imm_nz },
     { "c.srai", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_srai,

disas/riscv.c +5 -3
@@ -3032,9 +3032,11 @@ static void decode_inst_opcode(rv_decode *dec,
 rv_isa isa)
                      break;
                  }
              }
-            switch ((inst >> 7) & 0b11111) {
-            case 2: op = rv_op_c_addi16sp; break;
-            default: op = rv_op_c_lui; break;
+            if (inst & ((1 << 12) | (0x1f << 2))) {
+                switch ((inst >> 7) & 0b11111) {
+                case 2: op = rv_op_c_addi16sp; break;
+                default: op = rv_op_c_lui; break;
+                }
              }
              break;

         case 4:

#45 lore raw

PATCH 21/56 disas/riscv: Handle c.{srli,srai} imm during decode

In reply to Richard Henderson

Zero shift immediate to c.srli and c.srai are not illegal, but are reserved as HINTs. Go ahead and disassemble as shifts rather than falling back to invalid.

On the other hand, shift immediate >= 32 with RV32 is reserved for custom extensions, and we need to reject those early so that the extension disassemblers get a look in.

---
 disas/riscv.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
disas/riscv.c +10 -4
index d6fbb3bca6..a8fbefb9bd 100644
@@ -1906,9 +1906,9 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "c.lui", rv_codec_ci_lui, rv_fmt_rd_uimm, NULL, rv_op_lui, rv_op_lui,
       rv_op_lui },
     { "c.srli", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_srli,
-      rv_op_srli, rv_op_srli, rvcd_imm_nz },
+      rv_op_srli, rv_op_srli },
     { "c.srai", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_srai,
-      rv_op_srai, rv_op_srai, rvcd_imm_nz },
+      rv_op_srai, rv_op_srai },
     { "c.andi", rv_codec_cb_imm, rv_fmt_rd_rs1_imm, NULL, rv_op_andi,
       rv_op_andi, rv_op_andi },
     { "c.sub", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_sub, rv_op_sub,
@@ -3042,10 +3042,16 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
         case 4:
             switch ((inst >> 10) & 0b11) {
             case 0:
-                op = rv_op_c_srli;
+                /* For rv32, shamt[5]=1 is designated for custom extensions. */
+                if (isa != rv32 || (inst & 0x1000) == 0) {
+                    op = rv_op_c_srli; /* or unspecified HINT */
+                }
                 break;
             case 1:
-                op = rv_op_c_srai;
+                /* For rv32, shamt[5]=1 is designated for custom extensions. */
+                if (isa != rv32 || (inst & 0x1000) == 0) {
+                    op = rv_op_c_srai; /* or unspecified HINT */
+                }
                 break;
             case 2: op = rv_op_c_andi; break;
             case 3:
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 21/56
#46 lore raw

Re: [PATCH 21/56] disas/riscv: Handle c.{srli,srai} imm during decode

Quoted 9 lines · Richard Henderson

Zero shift immediate to c.srli and c.srai are not illegal, but are reserved as HINTs.  Go ahead and disassemble as shifts rather than falling back to invalid.

On the other hand, shift immediate >= 32 with RV32 is reserved for custom extensions, and we need to reject those early so that the extension disassemblers get a look in.

Alistair

Quoted 48 lines

---
 disas/riscv.c | 14 ++++++++++----

 1 file changed, 10 insertions(+), 4 deletions(-)
disas/riscv.c +2 -2
index d6fbb3bca6..a8fbefb9bd 100644
@@ -1906,9 +1906,9 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "c.lui", rv_codec_ci_lui, rv_fmt_rd_uimm, NULL, rv_op_lui,
 rv_op_lui,
        rv_op_lui },
      { "c.srli", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL,
 rv_op_srli,
-      rv_op_srli, rv_op_srli, rvcd_imm_nz },
+      rv_op_srli, rv_op_srli },
      { "c.srai", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL,
 rv_op_srai,
-      rv_op_srai, rv_op_srai, rvcd_imm_nz },
+      rv_op_srai, rv_op_srai },

     { "c.andi", rv_codec_cb_imm, rv_fmt_rd_rs1_imm, NULL, rv_op_andi,
       rv_op_andi, rv_op_andi },
     { "c.sub", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_sub, rv_op_sub,

disas/riscv.c +0 -0
@@ -3042,10 +3042,16 @@ static void decode_inst_opcode(rv_decode
 *dec, rv_isa isa)

         case 4:
             switch ((inst >> 10) & 0b11) {
             case 0:
-                op = rv_op_c_srli;
+                /* For rv32, shamt[5]=1 is designated for custom extensions. */
+                if (isa != rv32 || (inst & 0x1000) == 0) { +                    op = rv_op_c_srli; /* or unspecified HINT */ +                }
                 break;
             case 1:
-                op = rv_op_c_srai;
+                /* For rv32, shamt[5]=1 is designated for custom extensions. */
+                if (isa != rv32 || (inst & 0x1000) == 0) { +                    op = rv_op_c_srai; /* or unspecified HINT */ +                }
                 break;
             case 2: op = rv_op_c_andi; break;
             case 3:

#47 lore raw

PATCH 22/56 disas/riscv: Handle c.slli imm != 0 during decode

In reply to Richard Henderson
---
 disas/riscv.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
disas/riscv.c +4 -2
index a8fbefb9bd..77347b557d 100644
@@ -1930,7 +1930,7 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "c.bnez", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_bne, rv_op_bne,
       rv_op_bne },
     { "c.slli", rv_codec_ci_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_slli,
-      rv_op_slli, rv_op_slli, rvcd_imm_nz },
+      rv_op_slli, rv_op_slli },
     { "c.fldsp", rv_codec_ci_ldsp, rv_fmt_frd_offset_rs1, NULL, rv_op_fld,
       rv_op_fld, rv_op_fld },
     { "c.lwsp", rv_codec_ci_lwsp, rv_fmt_rd_offset_rs1, NULL, rv_op_lw,
@@ -3085,7 +3085,9 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
     case 2:
         switch ((inst >> 13) & 0b111) {
         case 0:
-            op = rv_op_c_slli;
+            if (isa != rv32 || (inst & 0x1000) == 0) {
+                op = rv_op_c_slli; /* or unspecified HINT */
+            }
             break;
         case 1:
             if (isa == rv128) {
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 22/56
#48 lore raw

Re: [PATCH 22/56] disas/riscv: Handle c.slli imm != 0 during decode

Quoted 1 line · Richard Henderson

Alistair

Quoted 34 lines

---
 disas/riscv.c | 6 ++++--

 1 file changed, 4 insertions(+), 2 deletions(-)
disas/riscv.c +1 -1
index a8fbefb9bd..77347b557d 100644
@@ -1930,7 +1930,7 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "c.bnez", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_bne,
 rv_op_bne,
        rv_op_bne },
      { "c.slli", rv_codec_ci_sh6, rv_fmt_rd_rs1_imm, NULL,
 rv_op_slli,
-      rv_op_slli, rv_op_slli, rvcd_imm_nz },
+      rv_op_slli, rv_op_slli },

     { "c.fldsp", rv_codec_ci_ldsp, rv_fmt_frd_offset_rs1, NULL, rv_op_fld,
       rv_op_fld, rv_op_fld },
     { "c.lwsp", rv_codec_ci_lwsp, rv_fmt_rd_offset_rs1, NULL, rv_op_lw,

disas/riscv.c +0 -0
@@ -3085,7 +3085,9 @@ static void decode_inst_opcode(rv_decode *dec,
 rv_isa isa)

     case 2:
         switch ((inst >> 13) & 0b111) {
         case 0:
-            op = rv_op_c_slli;
+            if (isa != rv32 || (inst & 0x1000) == 0) { +                op = rv_op_c_slli; /* or unspecified HINT */ +            }
             break;
         case 1:
             if (isa == rv128) {

#49 lore raw

PATCH 23/56 disas/riscv: Do not recognize c.{addw,subw} with rv32

In reply to Richard Henderson

These code points are reserved with RV32.

---
 disas/riscv.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
disas/riscv.c +10 -2
index 77347b557d..ddc2f73eae 100644
@@ -3060,8 +3060,16 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
                 case 1: op = rv_op_c_xor; break;
                 case 2: op = rv_op_c_or; break;
                 case 3: op = rv_op_c_and; break;
-                case 4: op = rv_op_c_subw; break;
-                case 5: op = rv_op_c_addw; break;
+                case 4:
+                    if (isa != rv32) {
+                        op = rv_op_c_subw;
+                    }
+                    break;
+                case 5:
+                    if (isa != rv32) {
+                        op = rv_op_c_addw;
+                    }
+                    break;
                 case 6: op = rv_op_c_mul; break;
                 case 7:
                     switch ((inst >> 2) & 0b111) {
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 23/56
#50 lore raw

Re: [PATCH 23/56] disas/riscv: Do not recognize c.{addw,subw} with rv32

Quoted 3 lines · Richard Henderson

These code points are reserved with RV32.

Alistair

Quoted 28 lines

---
 disas/riscv.c | 12 ++++++++++--

 1 file changed, 10 insertions(+), 2 deletions(-)
disas/riscv.c +10 -2
index 77347b557d..ddc2f73eae 100644
@@ -3060,8 +3060,16 @@ static void decode_inst_opcode(rv_decode *dec,
 rv_isa isa)
                  case 1: op = rv_op_c_xor; break;
                  case 2: op = rv_op_c_or; break;
                  case 3: op = rv_op_c_and; break;
-                case 4: op = rv_op_c_subw; break;
-                case 5: op = rv_op_c_addw; break;
+                case 4:
+                    if (isa != rv32) {
+                        op = rv_op_c_subw;
+                    }
+                    break;
+                case 5:
+                    if (isa != rv32) {
+                        op = rv_op_c_addw;
+                    }
+                    break;
                  case 6: op = rv_op_c_mul; break;

                 case 7:
                     switch ((inst >> 2) & 0b111) {

#51 lore raw

PATCH 24/56 disas/riscv: Remove rvcd_imm_nz

In reply to Richard Henderson

Remove rvcd_imm_nz and rv_opcode_data.decomp_data as unused.

---
 disas/riscv.h | 5 -----
 disas/riscv.c | 7 +------
 2 files changed, 1 insertion(+), 11 deletions(-)
disas/riscv.h +0 -5
index 31bb0db86c..3909d73dd0 100644
@@ -186,7 +186,6 @@ typedef struct {
     short decomp_rv32;
     short decomp_rv64;
     short decomp_rv128;
-    short decomp_data;
 } rv_opcode_data;
 
 typedef struct {
@@ -217,10 +216,6 @@ enum {
     rv_op_illegal = 0
 };
 
-enum {
-    rvcd_imm_nz = 0x1
-};
-
 /* instruction formats */
 
 #define rv_fmt_none                   "O\t"
disas/riscv.c +1 -6
index ddc2f73eae..95957506bd 100644
@@ -5417,12 +5417,7 @@ static const rv_opcode_data *decode_inst_decompress(rv_decode *dec, rv_isa isa,
     }
 
     if (decomp_op != rv_op_illegal) {
-        if ((op->decomp_data & rvcd_imm_nz) && dec->imm == 0) {
-            dec->opcode_data = rvi_opcode_data;
-            dec->op = rv_op_illegal;
-        } else {
-            dec->op = decomp_op;
-        }
+        dec->op = decomp_op;
         op = &dec->opcode_data[decomp_op];
     }
     return op;
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 24/56
#52 lore raw

Re: [PATCH 24/56] disas/riscv: Remove rvcd_imm_nz

Quoted 3 lines · Richard Henderson

Remove rvcd_imm_nz and rv_opcode_data.decomp_data as unused.

Alistair

Quoted 47 lines

---
 disas/riscv.h | 5 -----
 disas/riscv.c | 7 +------

 2 files changed, 1 insertion(+), 11 deletions(-)
disas/riscv.h +0 -1
index 31bb0db86c..3909d73dd0 100644
@@ -186,7 +186,6 @@ typedef struct {
      short decomp_rv32;
      short decomp_rv64;
      short decomp_rv128;
-    short decomp_data;
  } rv_opcode_data;


 typedef struct {

disas/riscv.h +0 -0
@@ -217,10 +216,6 @@ enum {

     rv_op_illegal = 0
 };

disas/riscv.h +0 -4
-enum {
-    rvcd_imm_nz = 0x1
-};
-

 /* instruction formats */

 #define rv_fmt_none                   "O\t"

disas/riscv.c +0 -0
index ddc2f73eae..95957506bd 100644
@@ -5417,12 +5417,7 @@ static const rv_opcode_data
 *decode_inst_decompress(rv_decode *dec, rv_isa isa,
      }


     if (decomp_op != rv_op_illegal) {
-        if ((op->decomp_data & rvcd_imm_nz) && dec->imm == 0) { -            dec->opcode_data = rvi_opcode_data;
-            dec->op = rv_op_illegal;
-        } else {
-            dec->op = decomp_op;
-        }
+        dec->op = decomp_op;
         op = &dec->opcode_data[decomp_op];
     }
     return op;

#53 lore raw

PATCH 25/56 disas/riscv: Unify decomp_rv{32,64,128}

In reply to Richard Henderson

We now distinguish compressed opcodes by isa during decode. Therefore we don't need 3 copies of decomp_*.

---
 disas/riscv.h |   4 +-
 disas/riscv.c | 155 ++++++++++++++++----------------------------------
 2 files changed, 51 insertions(+), 108 deletions(-)
disas/riscv.h +1 -3
index 3909d73dd0..900363c603 100644
@@ -183,9 +183,7 @@ typedef struct {
     rv_codec codec;
     const char *format;
     const rv_comp_data *pseudo;
-    short decomp_rv32;
-    short decomp_rv64;
-    short decomp_rv128;
+    rv_opcode decomp;
 } rv_opcode_data;
 
 typedef struct {
disas/riscv.c +50 -105

182 lines not on this page · raw message

Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 25/56
#54 lore raw

Re: [PATCH 25/56] disas/riscv: Unify decomp_rv{32,64,128}

Quoted 4 lines · Richard Henderson

We now distinguish compressed opcodes by isa during decode. Therefore we don't need 3 copies of decomp_*.

Alistair

Quoted 296 lines

---
 disas/riscv.h |   4 +-
 disas/riscv.c | 155 ++++++++++++++++-------------------------------- --

 2 files changed, 51 insertions(+), 108 deletions(-)
disas/riscv.h +1 -3
index 3909d73dd0..900363c603 100644
@@ -183,9 +183,7 @@ typedef struct {
      rv_codec codec;
      const char *format;
      const rv_comp_data *pseudo;
-    short decomp_rv32;
-    short decomp_rv64;
-    short decomp_rv128;
+    rv_opcode decomp;
  } rv_opcode_data;


 typedef struct {

disas/riscv.c +7 -52
index 95957506bd..2e891f509e 100644
@@ -1883,91 +1883,52 @@ static const rv_opcode_data rvi_opcode_data[]
 = {
      { "fcvt.q.lu", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
      { "fmv.x.q", rv_codec_r, rv_fmt_rd_frs1 },
      { "fmv.q.x", rv_codec_r, rv_fmt_frd_rs1 },
-    { "c.addi4spn", rv_codec_ciw_4spn, rv_fmt_rd_rs1_imm, NULL,
 rv_op_addi,
-      rv_op_addi, rv_op_addi },
-    { "c.fld", rv_codec_cl_ld, rv_fmt_frd_offset_rs1, NULL,
 rv_op_fld,
-      rv_op_fld, 0 },
-    { "c.lw", rv_codec_cl_lw, rv_fmt_rd_offset_rs1, NULL, rv_op_lw,
 rv_op_lw,
-      rv_op_lw },
-    { "c.flw", rv_codec_cl_lw, rv_fmt_frd_offset_rs1, NULL,
 rv_op_flw, 0, 0 },
-    { "c.fsd", rv_codec_cs_sd, rv_fmt_frs2_offset_rs1, NULL,
 rv_op_fsd,
-      rv_op_fsd, 0 },
-    { "c.sw", rv_codec_cs_sw, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw,
 rv_op_sw,
-      rv_op_sw },
-    { "c.fsw", rv_codec_cs_sw, rv_fmt_frs2_offset_rs1, NULL,
 rv_op_fsw, 0, 0 },
+    { "c.addi4spn", rv_codec_ciw_4spn, rv_fmt_rd_rs1_imm, NULL,
 rv_op_addi },
+    { "c.fld", rv_codec_cl_ld, rv_fmt_frd_offset_rs1, NULL,
 rv_op_fld },
+    { "c.lw", rv_codec_cl_lw, rv_fmt_rd_offset_rs1, NULL, rv_op_lw
 },
+    { "c.flw", rv_codec_cl_lw, rv_fmt_frd_offset_rs1, NULL,
 rv_op_flw },
+    { "c.fsd", rv_codec_cs_sd, rv_fmt_frs2_offset_rs1, NULL,
 rv_op_fsd },
+    { "c.sw", rv_codec_cs_sw, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw
 },
+    { "c.fsw", rv_codec_cs_sw, rv_fmt_frs2_offset_rs1, NULL,
 rv_op_fsw },
      { },
-    { "c.addi", rv_codec_ci, rv_fmt_rd_rs1_imm, NULL, rv_op_addi,
 rv_op_addi,
-      rv_op_addi },
-    { "c.jal", rv_codec_cj_jal, rv_fmt_rd_offset, NULL, rv_op_jal,
 0, 0 },
-    { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, NULL, rv_op_addi,
 rv_op_addi,
-      rv_op_addi },
-    { "c.addi16sp", rv_codec_ci_16sp, rv_fmt_rd_rs1_imm, NULL,
 rv_op_addi,
-      rv_op_addi, rv_op_addi },
-    { "c.lui", rv_codec_ci_lui, rv_fmt_rd_uimm, NULL, rv_op_lui,
 rv_op_lui,
-      rv_op_lui },
-    { "c.srli", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL,
 rv_op_srli,
-      rv_op_srli, rv_op_srli },
-    { "c.srai", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL,
 rv_op_srai,
-      rv_op_srai, rv_op_srai },
-    { "c.andi", rv_codec_cb_imm, rv_fmt_rd_rs1_imm, NULL,
 rv_op_andi,
-      rv_op_andi, rv_op_andi },
-    { "c.sub", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_sub,
 rv_op_sub,
-      rv_op_sub },
-    { "c.xor", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_xor,
 rv_op_xor,
-      rv_op_xor },
-    { "c.or", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_or,
 rv_op_or,
-      rv_op_or },
-    { "c.and", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_and,
 rv_op_and,
-      rv_op_and },
-    { "c.subw", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_subw,
 rv_op_subw,
-      rv_op_subw },
-    { "c.addw", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_addw,
 rv_op_addw,
-      rv_op_addw },
-    { "c.j", rv_codec_cj, rv_fmt_rd_offset, NULL, rv_op_jal,
 rv_op_jal,
-      rv_op_jal },
-    { "c.beqz", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_beq,
 rv_op_beq,
-      rv_op_beq },
-    { "c.bnez", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_bne,
 rv_op_bne,
-      rv_op_bne },
-    { "c.slli", rv_codec_ci_sh6, rv_fmt_rd_rs1_imm, NULL,
 rv_op_slli,
-      rv_op_slli, rv_op_slli },
-    { "c.fldsp", rv_codec_ci_ldsp, rv_fmt_frd_offset_rs1, NULL,
 rv_op_fld,
-      rv_op_fld, rv_op_fld },
-    { "c.lwsp", rv_codec_ci_lwsp, rv_fmt_rd_offset_rs1, NULL,
 rv_op_lw,
-      rv_op_lw, rv_op_lw },
-    { "c.flwsp", rv_codec_ci_lwsp, rv_fmt_frd_offset_rs1, NULL,

rv_op_flw, 0,
-      0 },
-    { "c.jr", rv_codec_cr_jr, rv_fmt_rd_rs1_offset, NULL, rv_op_jalr,
-      rv_op_jalr, rv_op_jalr },
-    { "c.mv", rv_codec_cr_mv, rv_fmt_rd_rs1_rs2, NULL, rv_op_addi, rv_op_addi,
-      rv_op_addi },
-    { "c.ebreak", rv_codec_ci_none, rv_fmt_none, NULL, rv_op_ebreak, -      rv_op_ebreak, rv_op_ebreak },
-    { "c.jalr", rv_codec_cr_jalr, rv_fmt_rd_rs1_offset, NULL, rv_op_jalr,
-      rv_op_jalr, rv_op_jalr },
-    { "c.add", rv_codec_cr, rv_fmt_rd_rs1_rs2, NULL, rv_op_add, rv_op_add,
-      rv_op_add },
-    { "c.fsdsp", rv_codec_css_sdsp, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsd,
-      rv_op_fsd, rv_op_fsd },
-    { "c.swsp", rv_codec_css_swsp, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw,
-      rv_op_sw, rv_op_sw },
-    { "c.fswsp", rv_codec_css_swsp, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsw, 0,
-      0 },
-    { "c.ld", rv_codec_cl_ld, rv_fmt_rd_offset_rs1, NULL, 0, rv_op_ld,
-      rv_op_ld },
-    { "c.sd", rv_codec_cs_sd, rv_fmt_rs2_offset_rs1, NULL, 0, rv_op_sd,
-      rv_op_sd },
-    { "c.addiw", rv_codec_ci, rv_fmt_rd_rs1_imm, NULL, 0, rv_op_addiw,
-      rv_op_addiw },
-    { "c.ldsp", rv_codec_ci_ldsp, rv_fmt_rd_offset_rs1, NULL, 0, rv_op_ld,
-      rv_op_ld },
-    { "c.sdsp", rv_codec_css_sdsp, rv_fmt_rs2_offset_rs1, NULL, 0, rv_op_sd,
-      rv_op_sd },
-    { "c.lq", rv_codec_cl_lq, rv_fmt_rd_offset_rs1, NULL, 0, 0, rv_op_lq },
-    { "c.sq", rv_codec_cs_sq, rv_fmt_rs2_offset_rs1, NULL, 0, 0, rv_op_sq },
-    { "c.lqsp", rv_codec_ci_lqsp, rv_fmt_rd_offset_rs1, NULL, 0, 0, rv_op_lq },
-    { "c.sqsp", rv_codec_css_sqsp, rv_fmt_rs2_offset_rs1, NULL, 0, 0,
-      rv_op_sq },
+    { "c.addi", rv_codec_ci, rv_fmt_rd_rs1_imm, NULL, rv_op_addi }, +    { "c.jal", rv_codec_cj_jal, rv_fmt_rd_offset, NULL, rv_op_jal }, +    { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, NULL, rv_op_addi }, +    { "c.addi16sp", rv_codec_ci_16sp, rv_fmt_rd_rs1_imm, NULL, rv_op_addi },
+    { "c.lui", rv_codec_ci_lui, rv_fmt_rd_uimm, NULL, rv_op_lui }, +    { "c.srli", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_srli },
+    { "c.srai", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_srai },
+    { "c.andi", rv_codec_cb_imm, rv_fmt_rd_rs1_imm, NULL, rv_op_andi },
+    { "c.sub", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_sub }, +    { "c.xor", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_xor }, +    { "c.or", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_or }, +    { "c.and", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_and }, +    { "c.subw", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_subw }, +    { "c.addw", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_addw }, +    { "c.j", rv_codec_cj, rv_fmt_rd_offset, NULL, rv_op_jal }, +    { "c.beqz", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_beq },
+    { "c.bnez", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_bne },
+    { "c.slli", rv_codec_ci_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_slli },
+    { "c.fldsp", rv_codec_ci_ldsp, rv_fmt_frd_offset_rs1, NULL, rv_op_fld },
+    { "c.lwsp", rv_codec_ci_lwsp, rv_fmt_rd_offset_rs1, NULL, rv_op_lw },
+    { "c.flwsp", rv_codec_ci_lwsp, rv_fmt_frd_offset_rs1, NULL, rv_op_flw },
+    { "c.jr", rv_codec_cr_jr, rv_fmt_rd_rs1_offset, NULL, rv_op_jalr },
+    { "c.mv", rv_codec_cr_mv, rv_fmt_rd_rs1_rs2, NULL, rv_op_addi }, +    { "c.ebreak", rv_codec_ci_none, rv_fmt_none, NULL, rv_op_ebreak },
+    { "c.jalr", rv_codec_cr_jalr, rv_fmt_rd_rs1_offset, NULL, rv_op_jalr },
+    { "c.add", rv_codec_cr, rv_fmt_rd_rs1_rs2, NULL, rv_op_add }, +    { "c.fsdsp", rv_codec_css_sdsp, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsd },
+    { "c.swsp", rv_codec_css_swsp, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw },
+    { "c.fswsp", rv_codec_css_swsp, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsw },
+    { "c.ld", rv_codec_cl_ld, rv_fmt_rd_offset_rs1, NULL, rv_op_ld },
+    { "c.sd", rv_codec_cs_sd, rv_fmt_rs2_offset_rs1, NULL,  rv_op_sd },
+    { "c.addiw", rv_codec_ci, rv_fmt_rd_rs1_imm, NULL, rv_op_addiw },
+    { "c.ldsp", rv_codec_ci_ldsp, rv_fmt_rd_offset_rs1, NULL, rv_op_ld },
+    { "c.sdsp", rv_codec_css_sdsp, rv_fmt_rs2_offset_rs1, NULL, rv_op_sd },
+    { "c.lq", rv_codec_cl_lq, rv_fmt_rd_offset_rs1, NULL, rv_op_lq },
+    { "c.sq", rv_codec_cs_sq, rv_fmt_rs2_offset_rs1, NULL, rv_op_sq },
+    { "c.lqsp", rv_codec_ci_lqsp, rv_fmt_rd_offset_rs1, NULL, rv_op_lq },
+    { "c.sqsp", rv_codec_css_sqsp, rv_fmt_rs2_offset_rs1, NULL, rv_op_sq },
     { "nop", rv_codec_i, rv_fmt_none },
     { "mv", rv_codec_i, rv_fmt_rd_rs1 },
     { "not", rv_codec_i, rv_fmt_rd_rs1 },

disas/riscv.c +2 -4
@@ -2649,10 +2610,8 @@ static const rv_opcode_data rvi_opcode_data[]
 = {
      { "ssrdp", rv_codec_r, rv_fmt_rd },
      { "ssamoswap.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 },
      { "ssamoswap.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 },
-    { "c.sspush", rv_codec_cmop_ss, rv_fmt_rs2, NULL, rv_op_sspush,
-      rv_op_sspush, 0 },
-    { "c.sspopchk", rv_codec_cmop_ss, rv_fmt_rs1, NULL,
 rv_op_sspopchk,
-      rv_op_sspopchk, 0 },
+    { "c.sspush", rv_codec_cmop_ss, rv_fmt_rs2, NULL, rv_op_sspush
 },
+    { "c.sspopchk", rv_codec_cmop_ss, rv_fmt_rs1, NULL,

rv_op_sspopchk },
    { "cbo.inval", rv_codec_r, rv_fmt_rs1 },
    { "cbo.clean", rv_codec_r, rv_fmt_rs1 },
    { "cbo.flush", rv_codec_r, rv_fmt_rs1 },

disas/riscv.c +0 -0
@@ -5397,24 +5356,10 @@ static const rv_opcode_data
 *decode_inst_lift_pseudo(rv_decode *dec,


 /* decompress instruction */

-static const rv_opcode_data *decode_inst_decompress(rv_decode *dec, rv_isa isa,
+static const rv_opcode_data *decode_inst_decompress(rv_decode *dec, const rv_opcode_data *op)
 {
-    int decomp_op;
-
-    switch (isa) {
-    case rv32:
-        decomp_op = op->decomp_rv32;
-        break;
-    case rv64:
-        decomp_op = op->decomp_rv64;
-        break;
-    case rv128:
-        decomp_op = op->decomp_rv128;
-        break;
-    default:
-        g_assert_not_reached();
-    }
+    int decomp_op = op->decomp;

     if (decomp_op != rv_op_illegal) {
         dec->op = decomp_op;

disas/riscv.c +0 -0
@@ -5473,7 +5418,7 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,


     op = &dec.opcode_data[dec.op];
     decode_inst_operands(&dec, isa, op);
-    op = decode_inst_decompress(&dec, isa, op);
+    op = decode_inst_decompress(&dec, op);
     op = decode_inst_lift_pseudo(&dec, op);
     return format_inst(24, &dec, op);
 }

#55 lore raw

PATCH 26/56 disas/riscv: Drop always true branch psudeos

In reply to Richard Henderson

The real insns are blt, bge, bltu, bgeu. Do not include psuedos that unconditionally swap operands. That's fine for an assembler but not a disassembler.

---
 disas/riscv.c | 32 ++++++--------------------------
 1 file changed, 6 insertions(+), 26 deletions(-)
disas/riscv.c +6 -26
index 2e891f509e..bde1cc6e62 100644
@@ -326,10 +326,6 @@ typedef enum {
     rv_op_bgez = 295,
     rv_op_bltz = 296,
     rv_op_bgtz = 297,
-    rv_op_ble = 298,
-    rv_op_bleu = 299,
-    rv_op_bgt = 300,
-    rv_op_bgtu = 301,
     rv_op_j = 302,
     rv_op_ret = 303,
     rv_op_jr = 304,
@@ -1062,10 +1058,6 @@ static const rvc_constraint rvcc_blez[] = { rvc_rs1_eq_x0, rvc_end };
 static const rvc_constraint rvcc_bgez[] = { rvc_rs2_eq_x0, rvc_end };
 static const rvc_constraint rvcc_bltz[] = { rvc_rs2_eq_x0, rvc_end };
 static const rvc_constraint rvcc_bgtz[] = { rvc_rs1_eq_x0, rvc_end };
-static const rvc_constraint rvcc_ble[] = { rvc_end };
-static const rvc_constraint rvcc_bleu[] = { rvc_end };
-static const rvc_constraint rvcc_bgt[] = { rvc_end };
-static const rvc_constraint rvcc_bgtu[] = { rvc_end };
 static const rvc_constraint rvcc_j[] = { rvc_rd_eq_x0, rvc_end };
 static const rvc_constraint rvcc_ret[] = { rvc_rd_eq_x0, rvc_rs1_eq_ra,
                                            rvc_end };
@@ -1123,24 +1115,12 @@ static const rv_comp_data rvcp_bne[] = {
 static const rv_comp_data rvcp_blt[] = {
     { rv_op_bltz, rvcc_bltz },
     { rv_op_bgtz, rvcc_bgtz },
-    { rv_op_bgt, rvcc_bgt },
     { rv_op_illegal, NULL }
 };
 
 static const rv_comp_data rvcp_bge[] = {
     { rv_op_blez, rvcc_blez },
     { rv_op_bgez, rvcc_bgez },
-    { rv_op_ble, rvcc_ble },
-    { rv_op_illegal, NULL }
-};
-
-static const rv_comp_data rvcp_bltu[] = {
-    { rv_op_bgtu, rvcc_bgtu },
-    { rv_op_illegal, NULL }
-};
-
-static const rv_comp_data rvcp_bgeu[] = {
-    { rv_op_bleu, rvcc_bleu },
     { rv_op_illegal, NULL }
 };
 
@@ -1665,8 +1645,8 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "bne", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bne },
     { "blt", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_blt },
     { "bge", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bge },
-    { "bltu", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bltu },
-    { "bgeu", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bgeu },
+    { "bltu", rv_codec_sb, rv_fmt_rs1_rs2_offset },
+    { "bgeu", rv_codec_sb, rv_fmt_rs1_rs2_offset },
     { "lb", rv_codec_i, rv_fmt_rd_offset_rs1 },
     { "lh", rv_codec_i, rv_fmt_rd_offset_rs1 },
     { "lw", rv_codec_i, rv_fmt_rd_offset_rs1 },
@@ -1954,10 +1934,10 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "bgez", rv_codec_sb, rv_fmt_rs1_offset },
     { "bltz", rv_codec_sb, rv_fmt_rs1_offset },
     { "bgtz", rv_codec_sb, rv_fmt_rs2_offset },
-    { "ble", rv_codec_sb, rv_fmt_rs2_rs1_offset },
-    { "bleu", rv_codec_sb, rv_fmt_rs2_rs1_offset },
-    { "bgt", rv_codec_sb, rv_fmt_rs2_rs1_offset },
-    { "bgtu", rv_codec_sb, rv_fmt_rs2_rs1_offset },
+    { },
+    { },
+    { },
+    { },
     { "j", rv_codec_uj, rv_fmt_offset },
     { "ret", rv_codec_i, rv_fmt_none },
     { "jr", rv_codec_i, rv_fmt_rs1 },
Signature · 1 line
2.43.0
Reviewed-by on v1 26/56
#56 lore raw

Re: [PATCH 26/56] disas/riscv: Drop always true branch psudeos

Quoted 2 lines · Richard Henderson

The real insns are blt, bge, bltu, bgeu. Do not include psuedos that unconditionally swap operands. That's fine

Typo "pseudos" (also in $subject), otherwise:

Quoted 6 lines

for an assembler but not a disassembler.

---
  disas/riscv.c | 32 ++++++--------------------------
  1 file changed, 6 insertions(+), 26 deletions(-)
Reviewed-by Alistair Francis on v1 26/56
#57 lore raw

Re: [PATCH 26/56] disas/riscv: Drop always true branch psudeos

In reply to Richard Henderson
Quoted 5 lines · Richard Henderson

The real insns are blt, bge, bltu, bgeu.  Do not include psuedos that unconditionally swap operands.  That's fine for an assembler but not a disassembler.

Alistair

Quoted 88 lines

---
 disas/riscv.c | 32 ++++++--------------------------

 1 file changed, 6 insertions(+), 26 deletions(-)
disas/riscv.c +0 -4
index 2e891f509e..bde1cc6e62 100644
@@ -326,10 +326,6 @@ typedef enum {
      rv_op_bgez = 295,
      rv_op_bltz = 296,
      rv_op_bgtz = 297,
-    rv_op_ble = 298,
-    rv_op_bleu = 299,
-    rv_op_bgt = 300,
-    rv_op_bgtu = 301,
      rv_op_j = 302,
      rv_op_ret = 303,
      rv_op_jr = 304,
@@ -1062,10 +1058,6 @@ static const rvc_constraint rvcc_blez[] = {
 rvc_rs1_eq_x0, rvc_end };

 static const rvc_constraint rvcc_bgez[] = { rvc_rs2_eq_x0, rvc_end };
 static const rvc_constraint rvcc_bltz[] = { rvc_rs2_eq_x0, rvc_end };
 static const rvc_constraint rvcc_bgtz[] = { rvc_rs1_eq_x0, rvc_end };

disas/riscv.c +0 -4
-static const rvc_constraint rvcc_ble[] = { rvc_end };
-static const rvc_constraint rvcc_bleu[] = { rvc_end };
-static const rvc_constraint rvcc_bgt[] = { rvc_end };
-static const rvc_constraint rvcc_bgtu[] = { rvc_end };

 static const rvc_constraint rvcc_j[] = { rvc_rd_eq_x0, rvc_end }; static const rvc_constraint rvcc_ret[] = { rvc_rd_eq_x0, rvc_rs1_eq_ra,
                                            rvc_end };

disas/riscv.c +0 -1
@@ -1123,24 +1115,12 @@ static const rv_comp_data rvcp_bne[] = {
  static const rv_comp_data rvcp_blt[] = {
      { rv_op_bltz, rvcc_bltz },
      { rv_op_bgtz, rvcc_bgtz },
-    { rv_op_bgt, rvcc_bgt },
      { rv_op_illegal, NULL }
  };


 static const rv_comp_data rvcp_bge[] = {
     { rv_op_blez, rvcc_blez },
     { rv_op_bgez, rvcc_bgez },
-    { rv_op_ble, rvcc_ble },
-    { rv_op_illegal, NULL }

disas/riscv.c +0 -9
-};
-
-static const rv_comp_data rvcp_bltu[] = {
-    { rv_op_bgtu, rvcc_bgtu },
-    { rv_op_illegal, NULL }
-};
-
-static const rv_comp_data rvcp_bgeu[] = {
-    { rv_op_bleu, rvcc_bleu },

     { rv_op_illegal, NULL }
 };

disas/riscv.c +2 -2
@@ -1665,8 +1645,8 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "bne", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bne },
      { "blt", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_blt },
      { "bge", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bge },
-    { "bltu", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bltu },
-    { "bgeu", rv_codec_sb, rv_fmt_rs1_rs2_offset, rvcp_bgeu },
+    { "bltu", rv_codec_sb, rv_fmt_rs1_rs2_offset },
+    { "bgeu", rv_codec_sb, rv_fmt_rs1_rs2_offset },
      { "lb", rv_codec_i, rv_fmt_rd_offset_rs1 },
      { "lh", rv_codec_i, rv_fmt_rd_offset_rs1 },

     { "lw", rv_codec_i, rv_fmt_rd_offset_rs1 },

disas/riscv.c +4 -4
@@ -1954,10 +1934,10 @@ static const rv_opcode_data rvi_opcode_data[]
 = {
      { "bgez", rv_codec_sb, rv_fmt_rs1_offset },
      { "bltz", rv_codec_sb, rv_fmt_rs1_offset },
      { "bgtz", rv_codec_sb, rv_fmt_rs2_offset },
-    { "ble", rv_codec_sb, rv_fmt_rs2_rs1_offset },
-    { "bleu", rv_codec_sb, rv_fmt_rs2_rs1_offset },
-    { "bgt", rv_codec_sb, rv_fmt_rs2_rs1_offset },
-    { "bgtu", rv_codec_sb, rv_fmt_rs2_rs1_offset },
+    { },
+    { },
+    { },
+    { },
      { "j", rv_codec_uj, rv_fmt_offset },
      { "ret", rv_codec_i, rv_fmt_none },

     { "jr", rv_codec_i, rv_fmt_rs1 },

#58 lore raw

PATCH 27/56 disas/riscv: Handle aliases of csrrw during decode

In reply to Richard Henderson
---
 disas/riscv.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)
disas/riscv.c +9 -13
index bde1cc6e62..e464b8b075 100644
@@ -1081,9 +1081,6 @@ static const rvc_constraint rvcc_frrm[] = { rvc_rs1_eq_x0, rvc_csr_eq_0x002,
                                             rvc_end };
 static const rvc_constraint rvcc_frflags[] = { rvc_rs1_eq_x0, rvc_csr_eq_0x001,
                                                rvc_end };
-static const rvc_constraint rvcc_fscsr[] = { rvc_csr_eq_0x003, rvc_end };
-static const rvc_constraint rvcc_fsrm[] = { rvc_csr_eq_0x002, rvc_end };
-static const rvc_constraint rvcc_fsflags[] = { rvc_csr_eq_0x001, rvc_end };
 static const rvc_constraint rvcc_fsrmi[] = { rvc_csr_eq_0x002, rvc_end };
 static const rvc_constraint rvcc_fsflagsi[] = { rvc_csr_eq_0x001, rvc_end };
 
@@ -1166,14 +1163,6 @@ static const rv_comp_data rvcp_subw[] = {
     { rv_op_illegal, NULL }
 };
 
-static const rv_comp_data rvcp_csrrw[] = {
-    { rv_op_fscsr, rvcc_fscsr },
-    { rv_op_fsrm, rvcc_fsrm },
-    { rv_op_fsflags, rvcc_fsflags },
-    { rv_op_illegal, NULL }
-};
-
-
 static const rv_comp_data rvcp_csrrs[] = {
     { rv_op_rdcycle, rvcc_rdcycle },
     { rv_op_rdtime, rvcc_rdtime },
@@ -1761,7 +1750,7 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "sfence.vm", rv_codec_r, rv_fmt_rs1 },
     { "sfence.vma", rv_codec_r, rv_fmt_rs1_rs2 },
     { "wfi", rv_codec_none, rv_fmt_none },
-    { "csrrw", rv_codec_i_csr, rv_fmt_rd_csr_rs1, rvcp_csrrw },
+    { "csrrw", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
     { "csrrs", rv_codec_i_csr, rv_fmt_rd_csr_rs1, rvcp_csrrs },
     { "csrrc", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
     { "csrrwi", rv_codec_i_csr, rv_fmt_rd_csr_zimm, rvcp_csrrwi },
@@ -4443,7 +4432,14 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
                     break;
                 }
                 break;
-            case 1: op = rv_op_csrrw; break;
+            case 1:
+                switch (operand_csr12(inst)) {
+                case 1: op = rv_op_fsflags; break;
+                case 2: op = rv_op_fsrm; break;
+                case 3: op = rv_op_fscsr; break;
+                default: op = rv_op_csrrw; break;
+                }
+                break;
             case 2: op = rv_op_csrrs; break;
             case 3: op = rv_op_csrrc; break;
             case 4:
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 27/56
#59 lore raw

Re: [PATCH 27/56] disas/riscv: Handle aliases of csrrw during decode

Quoted 1 line · Richard Henderson

Alistair

Quoted 67 lines

---
 disas/riscv.c | 22 +++++++++-------------

 1 file changed, 9 insertions(+), 13 deletions(-)
disas/riscv.c +0 -2
index bde1cc6e62..e464b8b075 100644
@@ -1081,9 +1081,6 @@ static const rvc_constraint rvcc_frrm[] = {
 rvc_rs1_eq_x0, rvc_csr_eq_0x002,
                                              rvc_end };
  static const rvc_constraint rvcc_frflags[] = { rvc_rs1_eq_x0,
 rvc_csr_eq_0x001,
                                                 rvc_end };
-static const rvc_constraint rvcc_fscsr[] = { rvc_csr_eq_0x003,
 rvc_end };
-static const rvc_constraint rvcc_fsrm[] = { rvc_csr_eq_0x002,

rvc_end };
-static const rvc_constraint rvcc_fsflags[] = { rvc_csr_eq_0x001, rvc_end };
 static const rvc_constraint rvcc_fsrmi[] = { rvc_csr_eq_0x002, rvc_end };
 static const rvc_constraint rvcc_fsflagsi[] = { rvc_csr_eq_0x001, rvc_end };

disas/riscv.c +0 -0
@@ -1166,14 +1163,6 @@ static const rv_comp_data rvcp_subw[] = {
      { rv_op_illegal, NULL }
  };

disas/riscv.c +0 -8
-static const rv_comp_data rvcp_csrrw[] = {
-    { rv_op_fscsr, rvcc_fscsr },
-    { rv_op_fsrm, rvcc_fsrm },
-    { rv_op_fsflags, rvcc_fsflags },
-    { rv_op_illegal, NULL }
-};
-
-

 static const rv_comp_data rvcp_csrrs[] = {
     { rv_op_rdcycle, rvcc_rdcycle },
     { rv_op_rdtime, rvcc_rdtime },

disas/riscv.c +1 -1
@@ -1761,7 +1750,7 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "sfence.vm", rv_codec_r, rv_fmt_rs1 },
      { "sfence.vma", rv_codec_r, rv_fmt_rs1_rs2 },
      { "wfi", rv_codec_none, rv_fmt_none },
-    { "csrrw", rv_codec_i_csr, rv_fmt_rd_csr_rs1, rvcp_csrrw },
+    { "csrrw", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
      { "csrrs", rv_codec_i_csr, rv_fmt_rd_csr_rs1, rvcp_csrrs },
      { "csrrc", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },

     { "csrrwi", rv_codec_i_csr, rv_fmt_rd_csr_zimm, rvcp_csrrwi },

disas/riscv.c +8 -1
@@ -4443,7 +4432,14 @@ static void decode_inst_opcode(rv_decode *dec,
 rv_isa isa)
                      break;
                  }
                  break;
-            case 1: op = rv_op_csrrw; break;
+            case 1:
+                switch (operand_csr12(inst)) {
+                case 1: op = rv_op_fsflags; break;
+                case 2: op = rv_op_fsrm; break;
+                case 3: op = rv_op_fscsr; break;
+                default: op = rv_op_csrrw; break;
+                }
+                break;
              case 2: op = rv_op_csrrs; break;
              case 3: op = rv_op_csrrc; break;

             case 4:

#60 lore raw

PATCH 28/56 disas/riscv: Handle aliases of csrrs during decode

In reply to Richard Henderson
---
 disas/riscv.h |  7 -----
 disas/riscv.c | 85 +++++++++++----------------------------------------
 2 files changed, 17 insertions(+), 75 deletions(-)
disas/riscv.h +0 -7
index 900363c603..d8c5acd969 100644
@@ -86,13 +86,6 @@ typedef enum {
     rvc_imm_eq_p1,
     rvc_csr_eq_0x001,
     rvc_csr_eq_0x002,
-    rvc_csr_eq_0x003,
-    rvc_csr_eq_0xc00,
-    rvc_csr_eq_0xc01,
-    rvc_csr_eq_0xc02,
-    rvc_csr_eq_0xc80,
-    rvc_csr_eq_0xc81,
-    rvc_csr_eq_0xc82,
 } rvc_constraint;
 
 typedef enum {
disas/riscv.c +17 -68

115 lines not on this page · raw message

Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 28/56
#61 lore raw

Re: [PATCH 28/56] disas/riscv: Handle aliases of csrrs during decode

Quoted 1 line · Richard Henderson

Alistair

Quoted 164 lines

---
 disas/riscv.h |  7 -----
 disas/riscv.c | 85 +++++++++++-------------------------------------- --

 2 files changed, 17 insertions(+), 75 deletions(-)
disas/riscv.h +0 -7
index 900363c603..d8c5acd969 100644
@@ -86,13 +86,6 @@ typedef enum {
      rvc_imm_eq_p1,
      rvc_csr_eq_0x001,
      rvc_csr_eq_0x002,
-    rvc_csr_eq_0x003,
-    rvc_csr_eq_0xc00,
-    rvc_csr_eq_0xc01,
-    rvc_csr_eq_0xc02,
-    rvc_csr_eq_0xc80,
-    rvc_csr_eq_0xc81,
-    rvc_csr_eq_0xc82,
  } rvc_constraint;


 typedef enum {

disas/riscv.c +0 -3
index e464b8b075..9ec79baf4d 100644
@@ -1063,24 +1063,6 @@ static const rvc_constraint rvcc_ret[] = {
 rvc_rd_eq_x0, rvc_rs1_eq_ra,
                                             rvc_end };
  static const rvc_constraint rvcc_jr[] = { rvc_rd_eq_x0,
 rvc_imm_eq_zero,
                                            rvc_end };
-static const rvc_constraint rvcc_rdcycle[] = { rvc_rs1_eq_x0,
 rvc_csr_eq_0xc00,
-                                               rvc_end };
-static const rvc_constraint rvcc_rdtime[] = { rvc_rs1_eq_x0,

rvc_csr_eq_0xc01,
-                                              rvc_end }; -static const rvc_constraint rvcc_rdinstret[] = { rvc_rs1_eq_x0, -                                                 rvc_csr_eq_0xc02, rvc_end };
-static const rvc_constraint rvcc_rdcycleh[] = { rvc_rs1_eq_x0, -                                                rvc_csr_eq_0xc80, rvc_end };
-static const rvc_constraint rvcc_rdtimeh[] = { rvc_rs1_eq_x0, rvc_csr_eq_0xc81,
-                                               rvc_end }; -static const rvc_constraint rvcc_rdinstreth[] = { rvc_rs1_eq_x0, -                                                  rvc_csr_eq_0xc82, rvc_end };
-static const rvc_constraint rvcc_frcsr[] = { rvc_rs1_eq_x0, rvc_csr_eq_0x003,
-                                             rvc_end }; -static const rvc_constraint rvcc_frrm[] = { rvc_rs1_eq_x0, rvc_csr_eq_0x002,
-                                            rvc_end }; -static const rvc_constraint rvcc_frflags[] = { rvc_rs1_eq_x0, rvc_csr_eq_0x001,
-                                               rvc_end }; static const rvc_constraint rvcc_fsrmi[] = { rvc_csr_eq_0x002, rvc_end };
 static const rvc_constraint rvcc_fsflagsi[] = { rvc_csr_eq_0x001, rvc_end };

disas/riscv.c +0 -0
@@ -1163,19 +1145,6 @@ static const rv_comp_data rvcp_subw[] = {
      { rv_op_illegal, NULL }
  };

disas/riscv.c +0 -13
-static const rv_comp_data rvcp_csrrs[] = {
-    { rv_op_rdcycle, rvcc_rdcycle },
-    { rv_op_rdtime, rvcc_rdtime },
-    { rv_op_rdinstret, rvcc_rdinstret },
-    { rv_op_rdcycleh, rvcc_rdcycleh },
-    { rv_op_rdtimeh, rvcc_rdtimeh },
-    { rv_op_rdinstreth, rvcc_rdinstreth },
-    { rv_op_frcsr, rvcc_frcsr },
-    { rv_op_frrm, rvcc_frrm },
-    { rv_op_frflags, rvcc_frflags },
-    { rv_op_illegal, NULL }
-};
-

 static const rv_comp_data rvcp_csrrwi[] = {
     { rv_op_fsrmi, rvcc_fsrmi },
     { rv_op_fsflagsi, rvcc_fsflagsi },

disas/riscv.c +1 -1
@@ -1751,7 +1720,7 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "sfence.vma", rv_codec_r, rv_fmt_rs1_rs2 },
      { "wfi", rv_codec_none, rv_fmt_none },
      { "csrrw", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
-    { "csrrs", rv_codec_i_csr, rv_fmt_rd_csr_rs1, rvcp_csrrs },
+    { "csrrs", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
      { "csrrc", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
      { "csrrwi", rv_codec_i_csr, rv_fmt_rd_csr_zimm, rvcp_csrrwi },

     { "csrrsi", rv_codec_i_csr, rv_fmt_rd_csr_zimm },

disas/riscv.c +16 -1
@@ -4440,7 +4409,22 @@ static void decode_inst_opcode(rv_decode *dec,
 rv_isa isa)
                  default: op = rv_op_csrrw; break;
                  }
                  break;
-            case 2: op = rv_op_csrrs; break;
+            case 2:
+                op = rv_op_csrrs;
+                if (operand_rs1(inst) == 0) {
+                    switch (operand_csr12(inst)) {
+                    case 0x001: op = rv_op_frflags; break;
+                    case 0x002: op = rv_op_frrm; break;
+                    case 0x003: op = rv_op_frcsr; break;
+                    case 0xc00: op = rv_op_rdcycle; break;
+                    case 0xc01: op = rv_op_rdtime; break;
+                    case 0xc02: op = rv_op_rdinstret; break;
+                    case 0xc80: op = rv_op_rdcycleh; break;
+                    case 0xc81: op = rv_op_rdtimeh; break;
+                    case 0xc82: op = rv_op_rdinstreth; break;
+                    }
+                }
+                break;
              case 3: op = rv_op_csrrc; break;

             case 4:
                 if (dec->cfg && dec->cfg->ext_zimop) {

disas/riscv.c +0 -35
@@ -5017,41 +5001,6 @@ static bool check_constraints(rv_decode *dec,
 const rvc_constraint *c)
                  return false;
              }
              break;
-        case rvc_csr_eq_0x003:
-            if (!(imm == 0x003)) {
-                return false;
-            }
-            break;
-        case rvc_csr_eq_0xc00:
-            if (!(imm == 0xc00)) {
-                return false;
-            }
-            break;
-        case rvc_csr_eq_0xc01:
-            if (!(imm == 0xc01)) {
-                return false;
-            }
-            break;
-        case rvc_csr_eq_0xc02:
-            if (!(imm == 0xc02)) {
-                return false;
-            }
-            break;
-        case rvc_csr_eq_0xc80:
-            if (!(imm == 0xc80)) {
-                return false;
-            }
-            break;
-        case rvc_csr_eq_0xc81:
-            if (!(imm == 0xc81)) {
-                return false;
-            }
-            break;
-        case rvc_csr_eq_0xc82:
-            if (!(imm == 0xc82)) {
-                return false;
-            }
-            break;
          default: break;
          }

         c++;

#62 lore raw

PATCH 29/56 disas/riscv: Handle aliases of csrrwi during decode

In reply to Richard Henderson
---
 disas/riscv.h |  2 --
 disas/riscv.c | 28 ++++++++--------------------
 2 files changed, 8 insertions(+), 22 deletions(-)
disas/riscv.h +0 -2
index d8c5acd969..3bbcbf10fb 100644
@@ -84,8 +84,6 @@ typedef enum {
     rvc_imm_eq_zero,
     rvc_imm_eq_n1,
     rvc_imm_eq_p1,
-    rvc_csr_eq_0x001,
-    rvc_csr_eq_0x002,
 } rvc_constraint;
 
 typedef enum {
disas/riscv.c +8 -20
index 9ec79baf4d..d3cbfb86ac 100644
@@ -1063,8 +1063,6 @@ static const rvc_constraint rvcc_ret[] = { rvc_rd_eq_x0, rvc_rs1_eq_ra,
                                            rvc_end };
 static const rvc_constraint rvcc_jr[] = { rvc_rd_eq_x0, rvc_imm_eq_zero,
                                           rvc_end };
-static const rvc_constraint rvcc_fsrmi[] = { rvc_csr_eq_0x002, rvc_end };
-static const rvc_constraint rvcc_fsflagsi[] = { rvc_csr_eq_0x001, rvc_end };
 
 /* pseudo-instruction metadata */
 
@@ -1145,12 +1143,6 @@ static const rv_comp_data rvcp_subw[] = {
     { rv_op_illegal, NULL }
 };
 
-static const rv_comp_data rvcp_csrrwi[] = {
-    { rv_op_fsrmi, rvcc_fsrmi },
-    { rv_op_fsflagsi, rvcc_fsflagsi },
-    { rv_op_illegal, NULL }
-};
-
 static const rv_comp_data rvcp_fsgnj_s[] = {
     { rv_op_fmv_s, rvcc_fmv_s },
     { rv_op_illegal, NULL }
@@ -1722,7 +1714,7 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "csrrw", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
     { "csrrs", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
     { "csrrc", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
-    { "csrrwi", rv_codec_i_csr, rv_fmt_rd_csr_zimm, rvcp_csrrwi },
+    { "csrrwi", rv_codec_i_csr, rv_fmt_rd_csr_zimm },
     { "csrrsi", rv_codec_i_csr, rv_fmt_rd_csr_zimm },
     { "csrrci", rv_codec_i_csr, rv_fmt_rd_csr_zimm },
     { "flw", rv_codec_i, rv_fmt_frd_offset_rs1 },
@@ -4469,7 +4461,13 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
                     }
                 }
                 break;
-            case 5: op = rv_op_csrrwi; break;
+            case 5:
+                switch (operand_csr12(inst)) {
+                case 1: op = rv_op_fsflagsi; break;
+                case 2: op = rv_op_fsrmi; break;
+                default: op = rv_op_csrrwi; break;
+                }
+                break;
             case 6: op = rv_op_csrrsi; break;
             case 7: op = rv_op_csrrci; break;
             }
@@ -4991,16 +4989,6 @@ static bool check_constraints(rv_decode *dec, const rvc_constraint *c)
                 return false;
             }
             break;
-        case rvc_csr_eq_0x001:
-            if (!(imm == 0x001)) {
-                return false;
-            }
-            break;
-        case rvc_csr_eq_0x002:
-            if (!(imm == 0x002)) {
-                return false;
-            }
-            break;
         default: break;
         }
         c++;
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 29/56
#63 lore raw

Re: [PATCH 29/56] disas/riscv: Handle aliases of csrrwi during decode

Quoted 1 line · Richard Henderson

Alistair

Quoted 92 lines

---
 disas/riscv.h |  2 --
 disas/riscv.c | 28 ++++++++--------------------

 2 files changed, 8 insertions(+), 22 deletions(-)
disas/riscv.h +0 -2
index d8c5acd969..3bbcbf10fb 100644
@@ -84,8 +84,6 @@ typedef enum {
      rvc_imm_eq_zero,
      rvc_imm_eq_n1,
      rvc_imm_eq_p1,
-    rvc_csr_eq_0x001,
-    rvc_csr_eq_0x002,
  } rvc_constraint;


 typedef enum {

disas/riscv.c +0 -2
index 9ec79baf4d..d3cbfb86ac 100644
@@ -1063,8 +1063,6 @@ static const rvc_constraint rvcc_ret[] = {
 rvc_rd_eq_x0, rvc_rs1_eq_ra,
                                             rvc_end };
  static const rvc_constraint rvcc_jr[] = { rvc_rd_eq_x0,
 rvc_imm_eq_zero,
                                            rvc_end };
-static const rvc_constraint rvcc_fsrmi[] = { rvc_csr_eq_0x002,
 rvc_end };
-static const rvc_constraint rvcc_fsflagsi[] = { rvc_csr_eq_0x001,

rvc_end };

 /* pseudo-instruction metadata */

disas/riscv.c +0 -0
@@ -1145,12 +1143,6 @@ static const rv_comp_data rvcp_subw[] = {
      { rv_op_illegal, NULL }
  };

disas/riscv.c +0 -6
-static const rv_comp_data rvcp_csrrwi[] = {
-    { rv_op_fsrmi, rvcc_fsrmi },
-    { rv_op_fsflagsi, rvcc_fsflagsi },
-    { rv_op_illegal, NULL }
-};
-

 static const rv_comp_data rvcp_fsgnj_s[] = {
     { rv_op_fmv_s, rvcc_fmv_s },
     { rv_op_illegal, NULL }

disas/riscv.c +1 -1
@@ -1722,7 +1714,7 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "csrrw", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
      { "csrrs", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
      { "csrrc", rv_codec_i_csr, rv_fmt_rd_csr_rs1 },
-    { "csrrwi", rv_codec_i_csr, rv_fmt_rd_csr_zimm, rvcp_csrrwi },
+    { "csrrwi", rv_codec_i_csr, rv_fmt_rd_csr_zimm },
      { "csrrsi", rv_codec_i_csr, rv_fmt_rd_csr_zimm },
      { "csrrci", rv_codec_i_csr, rv_fmt_rd_csr_zimm },

     { "flw", rv_codec_i, rv_fmt_frd_offset_rs1 },

disas/riscv.c +7 -1
@@ -4469,7 +4461,13 @@ static void decode_inst_opcode(rv_decode *dec,
 rv_isa isa)
                      }
                  }
                  break;
-            case 5: op = rv_op_csrrwi; break;
+            case 5:
+                switch (operand_csr12(inst)) {
+                case 1: op = rv_op_fsflagsi; break;
+                case 2: op = rv_op_fsrmi; break;
+                default: op = rv_op_csrrwi; break;
+                }
+                break;
              case 6: op = rv_op_csrrsi; break;
              case 7: op = rv_op_csrrci; break;

             }

disas/riscv.c +0 -10
@@ -4991,16 +4989,6 @@ static bool check_constraints(rv_decode *dec,
 const rvc_constraint *c)
                  return false;
              }
              break;
-        case rvc_csr_eq_0x001:
-            if (!(imm == 0x001)) {
-                return false;
-            }
-            break;
-        case rvc_csr_eq_0x002:
-            if (!(imm == 0x002)) {
-                return false;
-            }
-            break;
          default: break;
          }

         c++;

#64 lore raw

PATCH 30/56 disas/riscv: Break pseudo loop for jal and jalr

In reply to Richard Henderson

These were clearly intending to simplify
jal ra, foo
to
jal foo
and similarly for jalr, but the pseudo expansion looped back to the original jal/jalr with the full format.

Add new opcode expansions dropping the implied ra.

---
 disas/riscv.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
disas/riscv.c +9 -7
index d3cbfb86ac..fe503b6cae 100644
@@ -326,6 +326,8 @@ typedef enum {
     rv_op_bgez = 295,
     rv_op_bltz = 296,
     rv_op_bgtz = 297,
+    rv_op_jal_ra = 298,
+    rv_op_jalr_ra = 299,
     rv_op_j = 302,
     rv_op_ret = 303,
     rv_op_jr = 304,
@@ -1029,9 +1031,9 @@ static const char rv_fli_name_const[32][9] =
 
 /* pseudo-instruction constraints */
 
-static const rvc_constraint rvcc_jal[] = { rvc_rd_eq_ra, rvc_end };
-static const rvc_constraint rvcc_jalr[] = { rvc_rd_eq_ra, rvc_imm_eq_zero,
-                                            rvc_end };
+static const rvc_constraint rvcc_jal_ra[] = { rvc_rd_eq_ra, rvc_end };
+static const rvc_constraint rvcc_jalr_ra[] = { rvc_rd_eq_ra, rvc_imm_eq_zero,
+                                               rvc_end };
 static const rvc_constraint rvcc_nop[] = { rvc_rd_eq_x0, rvc_rs1_eq_x0,
                                            rvc_imm_eq_zero, rvc_end };
 static const rvc_constraint rvcc_mv[] = { rvc_imm_eq_zero, rvc_end };
@@ -1068,14 +1070,14 @@ static const rvc_constraint rvcc_jr[] = { rvc_rd_eq_x0, rvc_imm_eq_zero,
 
 static const rv_comp_data rvcp_jal[] = {
     { rv_op_j, rvcc_j },
-    { rv_op_jal, rvcc_jal },
+    { rv_op_jal_ra, rvcc_jal_ra },
     { rv_op_illegal, NULL }
 };
 
 static const rv_comp_data rvcp_jalr[] = {
     { rv_op_ret, rvcc_ret },
     { rv_op_jr, rvcc_jr },
-    { rv_op_jalr, rvcc_jalr },
+    { rv_op_jalr_ra, rvcc_jalr_ra },
     { rv_op_illegal, NULL }
 };
 
@@ -1884,8 +1886,8 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "bgez", rv_codec_sb, rv_fmt_rs1_offset },
     { "bltz", rv_codec_sb, rv_fmt_rs1_offset },
     { "bgtz", rv_codec_sb, rv_fmt_rs2_offset },
-    { },
-    { },
+    { "jal", rv_codec_none, rv_fmt_offset }, /* rv_op_jal_ra */
+    { "jalr", rv_codec_none, rv_fmt_rs1 }, /* rv_op_jalr_ra */
     { },
     { },
     { "j", rv_codec_uj, rv_fmt_offset },
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 30/56
#65 lore raw

Re: [PATCH 30/56] disas/riscv: Break pseudo loop for jal and jalr

Quoted 10 lines · Richard Henderson

These were clearly intending to simplify
jal ra, foo
to
jal foo
and similarly for jalr, but the pseudo expansion looped back to the original jal/jalr with the full format.

Add new opcode expansions dropping the implied ra.

Alistair

Quoted 66 lines

---
 disas/riscv.c | 16 +++++++++-------

 1 file changed, 9 insertions(+), 7 deletions(-)
disas/riscv.c +2 -0
index d3cbfb86ac..fe503b6cae 100644
@@ -326,6 +326,8 @@ typedef enum {
      rv_op_bgez = 295,
      rv_op_bltz = 296,
      rv_op_bgtz = 297,
+    rv_op_jal_ra = 298,
+    rv_op_jalr_ra = 299,
      rv_op_j = 302,
      rv_op_ret = 303,
      rv_op_jr = 304,
@@ -1029,9 +1031,9 @@ static const char rv_fli_name_const[32][9] =


 /* pseudo-instruction constraints */

disas/riscv.c +0 -2
-static const rvc_constraint rvcc_jal[] = { rvc_rd_eq_ra, rvc_end };
-static const rvc_constraint rvcc_jalr[] = { rvc_rd_eq_ra,

rvc_imm_eq_zero,
-                                            rvc_end }; +static const rvc_constraint rvcc_jal_ra[] = { rvc_rd_eq_ra, rvc_end };
+static const rvc_constraint rvcc_jalr_ra[] = { rvc_rd_eq_ra, rvc_imm_eq_zero,
+                                               rvc_end }; static const rvc_constraint rvcc_nop[] = { rvc_rd_eq_x0, rvc_rs1_eq_x0,
                                            rvc_imm_eq_zero, rvc_end };
 static const rvc_constraint rvcc_mv[] = { rvc_imm_eq_zero, rvc_end };

disas/riscv.c +0 -0
@@ -1068,14 +1070,14 @@ static const rvc_constraint rvcc_jr[] = {
 rvc_rd_eq_x0, rvc_imm_eq_zero,


 static const rv_comp_data rvcp_jal[] = {
     { rv_op_j, rvcc_j },
-    { rv_op_jal, rvcc_jal },
+    { rv_op_jal_ra, rvcc_jal_ra },
     { rv_op_illegal, NULL }
 };

 static const rv_comp_data rvcp_jalr[] = {
     { rv_op_ret, rvcc_ret },
     { rv_op_jr, rvcc_jr },
-    { rv_op_jalr, rvcc_jalr },
+    { rv_op_jalr_ra, rvcc_jalr_ra },
     { rv_op_illegal, NULL }
 };

disas/riscv.c +2 -2
@@ -1884,8 +1886,8 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "bgez", rv_codec_sb, rv_fmt_rs1_offset },
      { "bltz", rv_codec_sb, rv_fmt_rs1_offset },
      { "bgtz", rv_codec_sb, rv_fmt_rs2_offset },
-    { },
-    { },
+    { "jal", rv_codec_none, rv_fmt_offset }, /* rv_op_jal_ra */
+    { "jalr", rv_codec_none, rv_fmt_rs1 }, /* rv_op_jalr_ra */
      { },
      { },

     { "j", rv_codec_uj, rv_fmt_offset },

#66 lore raw

PATCH 31/56 disas/riscv: Allow decode_inst_lift_pseudo to loop

In reply to Richard Henderson

Allow pseudo expansion to proceed in multiple steps. Assert that we don't have simple loops.

---
 disas/riscv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
disas/riscv.c +3 -3
index fe503b6cae..b8e5b124a5 100644
@@ -5259,9 +5259,9 @@ static const rv_opcode_data *decode_inst_lift_pseudo(rv_decode *dec,
     if (comp_data) {
         while (comp_data->constraints) {
             if (check_constraints(dec, comp_data->constraints)) {
-                dec->op = comp_data->op;
-                op = &dec->opcode_data[dec->op];
-                break;
+                const rv_opcode_data *new_op = &dec->opcode_data[comp_data->op];
+                assert(new_op != op);
+                return decode_inst_lift_pseudo(dec, new_op);
             }
             comp_data++;
         }
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 31/56
#67 lore raw

Re: [PATCH 31/56] disas/riscv: Allow decode_inst_lift_pseudo to loop

Quoted 4 lines · Richard Henderson

Allow pseudo expansion to proceed in multiple steps. Assert that we don't have simple loops.

Alistair

Quoted 23 lines

---
 disas/riscv.c | 6 +++---

 1 file changed, 3 insertions(+), 3 deletions(-)
disas/riscv.c +3 -3
index fe503b6cae..b8e5b124a5 100644
@@ -5259,9 +5259,9 @@ static const rv_opcode_data
 *decode_inst_lift_pseudo(rv_decode *dec,
      if (comp_data) {
          while (comp_data->constraints) {
              if (check_constraints(dec, comp_data->constraints)) {
-                dec->op = comp_data->op;
-                op = &dec->opcode_data[dec->op];
-                break;
+                const rv_opcode_data *new_op = &dec-
 >opcode_data[comp_data->op];
+                assert(new_op != op);
+                return decode_inst_lift_pseudo(dec, new_op);
              }

             comp_data++;
         }

#68 lore raw

PATCH 32/56 disas/riscv: Handle decompression via decode_inst_lift_pseudo

In reply to Richard Henderson

Introduce a DECOMP macro that expands an rv_comp_data that always succeeds.

---
 disas/riscv.h |   1 -
 disas/riscv.c | 113 +++++++++++++++++++++++---------------------------
 2 files changed, 51 insertions(+), 63 deletions(-)
disas/riscv.h +0 -1
index 3bbcbf10fb..ea7141d3b5 100644
@@ -174,7 +174,6 @@ typedef struct {
     rv_codec codec;
     const char *format;
     const rv_comp_data *pseudo;
-    rv_opcode decomp;
 } rv_opcode_data;
 
 typedef struct {
disas/riscv.c +51 -62

150 lines not on this page · raw message

Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 32/56
#69 lore raw

Re: [PATCH 32/56] disas/riscv: Handle decompression via decode_inst_lift_pseudo

Quoted 4 lines · Richard Henderson

Introduce a DECOMP macro that expands an rv_comp_data that always succeeds.

Alistair

Quoted 260 lines

---
 disas/riscv.h |   1 -
 disas/riscv.c | 113 +++++++++++++++++++++++------------------------- --

 2 files changed, 51 insertions(+), 63 deletions(-)
disas/riscv.h +0 -1
index 3bbcbf10fb..ea7141d3b5 100644
@@ -174,7 +174,6 @@ typedef struct {
      rv_codec codec;
      const char *format;
      const rv_comp_data *pseudo;
-    rv_opcode decomp;
  } rv_opcode_data;


 typedef struct {

disas/riscv.c +1 -0
index b8e5b124a5..129e545c6e 100644
@@ -1065,6 +1065,7 @@ static const rvc_constraint rvcc_ret[] = {
 rvc_rd_eq_x0, rvc_rs1_eq_ra,
                                             rvc_end };
  static const rvc_constraint rvcc_jr[] = { rvc_rd_eq_x0,
 rvc_imm_eq_zero,
                                            rvc_end };
+static const rvc_constraint rvcc_true[] = { rvc_end };


 /* pseudo-instruction metadata */

disas/riscv.c +0 -0
@@ -1190,6 +1191,9 @@ static const rv_comp_data rvcp_fsgnjx_q[] = {
      { rv_op_illegal, NULL }
  };


+/* Convert compressed insns into normal insns via pseudo expansion. */

disas/riscv.c +2 -0
+#define DECOMP(X) (static const rv_comp_data[1]){ { X, rvcc_true } }
+

 /* operand extractors */

 static uint32_t operand_rd(rv_inst inst)

disas/riscv.c +7 -26
@@ -1815,52 +1819,52 @@ static const rv_opcode_data rvi_opcode_data[]
 = {
      { "fcvt.q.lu", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
      { "fmv.x.q", rv_codec_r, rv_fmt_rd_frs1 },
      { "fmv.q.x", rv_codec_r, rv_fmt_frd_rs1 },
-    { "c.addi4spn", rv_codec_ciw_4spn, rv_fmt_rd_rs1_imm, NULL,
 rv_op_addi },
-    { "c.fld", rv_codec_cl_ld, rv_fmt_frd_offset_rs1, NULL,
 rv_op_fld },
-    { "c.lw", rv_codec_cl_lw, rv_fmt_rd_offset_rs1, NULL, rv_op_lw
 },
-    { "c.flw", rv_codec_cl_lw, rv_fmt_frd_offset_rs1, NULL,
 rv_op_flw },
-    { "c.fsd", rv_codec_cs_sd, rv_fmt_frs2_offset_rs1, NULL,
 rv_op_fsd },
-    { "c.sw", rv_codec_cs_sw, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw
 },
-    { "c.fsw", rv_codec_cs_sw, rv_fmt_frs2_offset_rs1, NULL,
 rv_op_fsw },
+    { "c.addi4spn", rv_codec_ciw_4spn, rv_fmt_rd_rs1_imm,
 DECOMP(rv_op_addi) },
+    { "c.fld", rv_codec_cl_ld, rv_fmt_frd_offset_rs1,
 DECOMP(rv_op_fld) },
+    { "c.lw", rv_codec_cl_lw, rv_fmt_rd_offset_rs1, DECOMP(rv_op_lw)
 },
+    { "c.flw", rv_codec_cl_lw, rv_fmt_frd_offset_rs1,
 DECOMP(rv_op_flw) },
+    { "c.fsd", rv_codec_cs_sd, rv_fmt_frs2_offset_rs1,
 DECOMP(rv_op_fsd) },
+    { "c.sw", rv_codec_cs_sw, rv_fmt_rs2_offset_rs1,
 DECOMP(rv_op_sw) },
+    { "c.fsw", rv_codec_cs_sw, rv_fmt_frs2_offset_rs1,
 DECOMP(rv_op_fsw) },
      { },
-    { "c.addi", rv_codec_ci, rv_fmt_rd_rs1_imm, NULL, rv_op_addi },
-    { "c.jal", rv_codec_cj_jal, rv_fmt_rd_offset, NULL, rv_op_jal },
-    { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, NULL, rv_op_addi },
-    { "c.addi16sp", rv_codec_ci_16sp, rv_fmt_rd_rs1_imm, NULL,
 rv_op_addi },
-    { "c.lui", rv_codec_ci_lui, rv_fmt_rd_uimm, NULL, rv_op_lui },
-    { "c.srli", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_srli
 },
-    { "c.srai", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_srai
 },
-    { "c.andi", rv_codec_cb_imm, rv_fmt_rd_rs1_imm, NULL, rv_op_andi
 },
-    { "c.sub", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_sub },
-    { "c.xor", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_xor },
-    { "c.or", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_or },
-    { "c.and", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_and },
-    { "c.subw", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_subw },
-    { "c.addw", rv_codec_cs, rv_fmt_rd_rs1_rs2, NULL, rv_op_addw },
-    { "c.j", rv_codec_cj, rv_fmt_rd_offset, NULL, rv_op_jal },
-    { "c.beqz", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_beq
 },
-    { "c.bnez", rv_codec_cb, rv_fmt_rs1_rs2_offset, NULL, rv_op_bne
 },
-    { "c.slli", rv_codec_ci_sh6, rv_fmt_rd_rs1_imm, NULL, rv_op_slli
 },
-    { "c.fldsp", rv_codec_ci_ldsp, rv_fmt_frd_offset_rs1, NULL,

rv_op_fld },
-    { "c.lwsp", rv_codec_ci_lwsp, rv_fmt_rd_offset_rs1, NULL, rv_op_lw },
-    { "c.flwsp", rv_codec_ci_lwsp, rv_fmt_frd_offset_rs1, NULL, rv_op_flw },
-    { "c.jr", rv_codec_cr_jr, rv_fmt_rd_rs1_offset, NULL, rv_op_jalr },
-    { "c.mv", rv_codec_cr_mv, rv_fmt_rd_rs1_rs2, NULL, rv_op_addi }, -    { "c.ebreak", rv_codec_ci_none, rv_fmt_none, NULL, rv_op_ebreak },
-    { "c.jalr", rv_codec_cr_jalr, rv_fmt_rd_rs1_offset, NULL, rv_op_jalr },
-    { "c.add", rv_codec_cr, rv_fmt_rd_rs1_rs2, NULL, rv_op_add }, -    { "c.fsdsp", rv_codec_css_sdsp, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsd },
-    { "c.swsp", rv_codec_css_swsp, rv_fmt_rs2_offset_rs1, NULL, rv_op_sw },
-    { "c.fswsp", rv_codec_css_swsp, rv_fmt_frs2_offset_rs1, NULL, rv_op_fsw },
-    { "c.ld", rv_codec_cl_ld, rv_fmt_rd_offset_rs1, NULL, rv_op_ld },
-    { "c.sd", rv_codec_cs_sd, rv_fmt_rs2_offset_rs1, NULL,  rv_op_sd },
-    { "c.addiw", rv_codec_ci, rv_fmt_rd_rs1_imm, NULL, rv_op_addiw },
-    { "c.ldsp", rv_codec_ci_ldsp, rv_fmt_rd_offset_rs1, NULL, rv_op_ld },
-    { "c.sdsp", rv_codec_css_sdsp, rv_fmt_rs2_offset_rs1, NULL, rv_op_sd },
-    { "c.lq", rv_codec_cl_lq, rv_fmt_rd_offset_rs1, NULL, rv_op_lq },
-    { "c.sq", rv_codec_cs_sq, rv_fmt_rs2_offset_rs1, NULL, rv_op_sq },
-    { "c.lqsp", rv_codec_ci_lqsp, rv_fmt_rd_offset_rs1, NULL, rv_op_lq },
-    { "c.sqsp", rv_codec_css_sqsp, rv_fmt_rs2_offset_rs1, NULL, rv_op_sq },
+    { "c.addi", rv_codec_ci, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addi) },
+    { "c.jal", rv_codec_cj_jal, rv_fmt_rd_offset, DECOMP(rv_op_jal) },
+    { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addi) },
+    { "c.addi16sp", rv_codec_ci_16sp, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addi) },
+    { "c.lui", rv_codec_ci_lui, rv_fmt_rd_uimm, DECOMP(rv_op_lui) }, +    { "c.srli", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, DECOMP(rv_op_srli) },
+    { "c.srai", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, DECOMP(rv_op_srai) },
+    { "c.andi", rv_codec_cb_imm, rv_fmt_rd_rs1_imm, DECOMP(rv_op_andi) },
+    { "c.sub", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_sub) }, +    { "c.xor", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_xor) }, +    { "c.or", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_or) }, +    { "c.and", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_and) }, +    { "c.subw", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_subw) },
+    { "c.addw", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_addw) },
+    { "c.j", rv_codec_cj, rv_fmt_rd_offset, DECOMP(rv_op_jal) }, +    { "c.beqz", rv_codec_cb, rv_fmt_rs1_rs2_offset, DECOMP(rv_op_beq) },
+    { "c.bnez", rv_codec_cb, rv_fmt_rs1_rs2_offset, DECOMP(rv_op_bne) },
+    { "c.slli", rv_codec_ci_sh6, rv_fmt_rd_rs1_imm, DECOMP(rv_op_slli) },
+    { "c.fldsp", rv_codec_ci_ldsp, rv_fmt_frd_offset_rs1, DECOMP(rv_op_fld) },
+    { "c.lwsp", rv_codec_ci_lwsp, rv_fmt_rd_offset_rs1, DECOMP(rv_op_lw) },
+    { "c.flwsp", rv_codec_ci_lwsp, rv_fmt_frd_offset_rs1, DECOMP(rv_op_flw) },
+    { "c.jr", rv_codec_cr_jr, rv_fmt_rd_rs1_offset, DECOMP(rv_op_jalr) },
+    { "c.mv", rv_codec_cr_mv, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_addi) },
+    { "c.ebreak", rv_codec_ci_none, rv_fmt_none, DECOMP(rv_op_ebreak) },
+    { "c.jalr", rv_codec_cr_jalr, rv_fmt_rd_rs1_offset, DECOMP(rv_op_jalr) },
+    { "c.add", rv_codec_cr, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_add) }, +    { "c.fsdsp", rv_codec_css_sdsp, rv_fmt_frs2_offset_rs1, DECOMP(rv_op_fsd) },
+    { "c.swsp", rv_codec_css_swsp, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sw) },
+    { "c.fswsp", rv_codec_css_swsp, rv_fmt_frs2_offset_rs1, DECOMP(rv_op_fsw) },
+    { "c.ld", rv_codec_cl_ld, rv_fmt_rd_offset_rs1, DECOMP(rv_op_ld) },
+    { "c.sd", rv_codec_cs_sd, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sd) },
+    { "c.addiw", rv_codec_ci, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addiw) },
+    { "c.ldsp", rv_codec_ci_ldsp, rv_fmt_rd_offset_rs1, DECOMP(rv_op_ld) },
+    { "c.sdsp", rv_codec_css_sdsp, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sd) },
+    { "c.lq", rv_codec_cl_lq, rv_fmt_rd_offset_rs1, DECOMP(rv_op_lq) },
+    { "c.sq", rv_codec_cs_sq, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sq) },
+    { "c.lqsp", rv_codec_ci_lqsp, rv_fmt_rd_offset_rs1, DECOMP(rv_op_lq) },
+    { "c.sqsp", rv_codec_css_sqsp, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sq) },
     { "nop", rv_codec_i, rv_fmt_none },
     { "mv", rv_codec_i, rv_fmt_rd_rs1 },
     { "not", rv_codec_i, rv_fmt_rd_rs1 },

disas/riscv.c +1 -2
@@ -2542,8 +2546,8 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "ssrdp", rv_codec_r, rv_fmt_rd },
      { "ssamoswap.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 },
      { "ssamoswap.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 },
-    { "c.sspush", rv_codec_cmop_ss, rv_fmt_rs2, NULL, rv_op_sspush
 },
-    { "c.sspopchk", rv_codec_cmop_ss, rv_fmt_rs1, NULL,
 rv_op_sspopchk },
+    { "c.sspush", rv_codec_cmop_ss, rv_fmt_rs2, DECOMP(rv_op_sspush)

},
+    { "c.sspopchk", rv_codec_cmop_ss, rv_fmt_rs1, DECOMP(rv_op_sspopchk) },
    { "cbo.inval", rv_codec_r, rv_fmt_rs1 }, { "cbo.clean", rv_codec_r, rv_fmt_rs1 }, { "cbo.flush", rv_codec_r, rv_fmt_rs1 },

disas/riscv.c +0 -0
@@ -5269,20 +5273,6 @@ static const rv_opcode_data
 *decode_inst_lift_pseudo(rv_decode *dec,
      return op;
  }

disas/riscv.c +0 -4
-/* decompress instruction */
-
-static const rv_opcode_data *decode_inst_decompress(rv_decode *dec,
-                                                    const

rv_opcode_data *op)

disas/riscv.c +0 -10
-{
-    int decomp_op = op->decomp;
-
-    if (decomp_op != rv_op_illegal) {
-        dec->op = decomp_op;
-        op = &dec->opcode_data[decomp_op];
-    }
-    return op;
-}
-

 /* disassemble instruction */

 static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,

disas/riscv.c +0 -0
@@ -5333,7 +5323,6 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,


     op = &dec.opcode_data[dec.op];
     decode_inst_operands(&dec, isa, op);
-    op = decode_inst_decompress(&dec, op);
     op = decode_inst_lift_pseudo(&dec, op);
     return format_inst(24, &dec, op);
 }

#70 lore raw

PATCH 33/56 disas/riscv: Drop format from DECOMP insns

In reply to Richard Henderson

The format for these will never be used -- we will use the format from the decompressed insn.

---
 disas/riscv.c | 94 +++++++++++++++++++++++++--------------------------
 1 file changed, 47 insertions(+), 47 deletions(-)
disas/riscv.c +47 -47
index 129e545c6e..9904b4db03 100644
@@ -1819,52 +1819,52 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "fcvt.q.lu", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
     { "fmv.x.q", rv_codec_r, rv_fmt_rd_frs1 },
     { "fmv.q.x", rv_codec_r, rv_fmt_frd_rs1 },
-    { "c.addi4spn", rv_codec_ciw_4spn, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addi) },
-    { "c.fld", rv_codec_cl_ld, rv_fmt_frd_offset_rs1, DECOMP(rv_op_fld) },
-    { "c.lw", rv_codec_cl_lw, rv_fmt_rd_offset_rs1, DECOMP(rv_op_lw) },
-    { "c.flw", rv_codec_cl_lw, rv_fmt_frd_offset_rs1, DECOMP(rv_op_flw) },
-    { "c.fsd", rv_codec_cs_sd, rv_fmt_frs2_offset_rs1, DECOMP(rv_op_fsd) },
-    { "c.sw", rv_codec_cs_sw, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sw) },
-    { "c.fsw", rv_codec_cs_sw, rv_fmt_frs2_offset_rs1, DECOMP(rv_op_fsw) },
+    { "c.addi4spn", rv_codec_ciw_4spn, NULL, DECOMP(rv_op_addi) },
+    { "c.fld", rv_codec_cl_ld, NULL, DECOMP(rv_op_fld) },
+    { "c.lw", rv_codec_cl_lw, NULL, DECOMP(rv_op_lw) },
+    { "c.flw", rv_codec_cl_lw, NULL, DECOMP(rv_op_flw) },
+    { "c.fsd", rv_codec_cs_sd, NULL, DECOMP(rv_op_fsd) },
+    { "c.sw", rv_codec_cs_sw, NULL, DECOMP(rv_op_sw) },
+    { "c.fsw", rv_codec_cs_sw, NULL, DECOMP(rv_op_fsw) },
     { },
-    { "c.addi", rv_codec_ci, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addi) },
-    { "c.jal", rv_codec_cj_jal, rv_fmt_rd_offset, DECOMP(rv_op_jal) },
-    { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addi) },
-    { "c.addi16sp", rv_codec_ci_16sp, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addi) },
-    { "c.lui", rv_codec_ci_lui, rv_fmt_rd_uimm, DECOMP(rv_op_lui) },
-    { "c.srli", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, DECOMP(rv_op_srli) },
-    { "c.srai", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm, DECOMP(rv_op_srai) },
-    { "c.andi", rv_codec_cb_imm, rv_fmt_rd_rs1_imm, DECOMP(rv_op_andi) },
-    { "c.sub", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_sub) },
-    { "c.xor", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_xor) },
-    { "c.or", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_or) },
-    { "c.and", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_and) },
-    { "c.subw", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_subw) },
-    { "c.addw", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_addw) },
-    { "c.j", rv_codec_cj, rv_fmt_rd_offset, DECOMP(rv_op_jal) },
-    { "c.beqz", rv_codec_cb, rv_fmt_rs1_rs2_offset, DECOMP(rv_op_beq) },
-    { "c.bnez", rv_codec_cb, rv_fmt_rs1_rs2_offset, DECOMP(rv_op_bne) },
-    { "c.slli", rv_codec_ci_sh6, rv_fmt_rd_rs1_imm, DECOMP(rv_op_slli) },
-    { "c.fldsp", rv_codec_ci_ldsp, rv_fmt_frd_offset_rs1, DECOMP(rv_op_fld) },
-    { "c.lwsp", rv_codec_ci_lwsp, rv_fmt_rd_offset_rs1, DECOMP(rv_op_lw) },
-    { "c.flwsp", rv_codec_ci_lwsp, rv_fmt_frd_offset_rs1, DECOMP(rv_op_flw) },
-    { "c.jr", rv_codec_cr_jr, rv_fmt_rd_rs1_offset, DECOMP(rv_op_jalr) },
-    { "c.mv", rv_codec_cr_mv, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_addi) },
-    { "c.ebreak", rv_codec_ci_none, rv_fmt_none, DECOMP(rv_op_ebreak) },
-    { "c.jalr", rv_codec_cr_jalr, rv_fmt_rd_rs1_offset, DECOMP(rv_op_jalr) },
-    { "c.add", rv_codec_cr, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_add) },
-    { "c.fsdsp", rv_codec_css_sdsp, rv_fmt_frs2_offset_rs1, DECOMP(rv_op_fsd) },
-    { "c.swsp", rv_codec_css_swsp, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sw) },
-    { "c.fswsp", rv_codec_css_swsp, rv_fmt_frs2_offset_rs1, DECOMP(rv_op_fsw) },
-    { "c.ld", rv_codec_cl_ld, rv_fmt_rd_offset_rs1, DECOMP(rv_op_ld) },
-    { "c.sd", rv_codec_cs_sd, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sd) },
-    { "c.addiw", rv_codec_ci, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addiw) },
-    { "c.ldsp", rv_codec_ci_ldsp, rv_fmt_rd_offset_rs1, DECOMP(rv_op_ld) },
-    { "c.sdsp", rv_codec_css_sdsp, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sd) },
-    { "c.lq", rv_codec_cl_lq, rv_fmt_rd_offset_rs1, DECOMP(rv_op_lq) },
-    { "c.sq", rv_codec_cs_sq, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sq) },
-    { "c.lqsp", rv_codec_ci_lqsp, rv_fmt_rd_offset_rs1, DECOMP(rv_op_lq) },
-    { "c.sqsp", rv_codec_css_sqsp, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sq) },
+    { "c.addi", rv_codec_ci, NULL, DECOMP(rv_op_addi) },
+    { "c.jal", rv_codec_cj_jal, NULL, DECOMP(rv_op_jal) },
+    { "c.li", rv_codec_ci_li, NULL, DECOMP(rv_op_addi) },
+    { "c.addi16sp", rv_codec_ci_16sp, NULL, DECOMP(rv_op_addi) },
+    { "c.lui", rv_codec_ci_lui, NULL, DECOMP(rv_op_lui) },
+    { "c.srli", rv_codec_cb_sh6, NULL, DECOMP(rv_op_srli) },
+    { "c.srai", rv_codec_cb_sh6, NULL, DECOMP(rv_op_srai) },
+    { "c.andi", rv_codec_cb_imm, NULL, DECOMP(rv_op_andi) },
+    { "c.sub", rv_codec_cs, NULL, DECOMP(rv_op_sub) },
+    { "c.xor", rv_codec_cs, NULL, DECOMP(rv_op_xor) },
+    { "c.or", rv_codec_cs, NULL, DECOMP(rv_op_or) },
+    { "c.and", rv_codec_cs, NULL, DECOMP(rv_op_and) },
+    { "c.subw", rv_codec_cs, NULL, DECOMP(rv_op_subw) },
+    { "c.addw", rv_codec_cs, NULL, DECOMP(rv_op_addw) },
+    { "c.j", rv_codec_cj, NULL, DECOMP(rv_op_jal) },
+    { "c.beqz", rv_codec_cb, NULL, DECOMP(rv_op_beq) },
+    { "c.bnez", rv_codec_cb, NULL, DECOMP(rv_op_bne) },
+    { "c.slli", rv_codec_ci_sh6, NULL, DECOMP(rv_op_slli) },
+    { "c.fldsp", rv_codec_ci_ldsp, NULL, DECOMP(rv_op_fld) },
+    { "c.lwsp", rv_codec_ci_lwsp, NULL, DECOMP(rv_op_lw) },
+    { "c.flwsp", rv_codec_ci_lwsp, NULL, DECOMP(rv_op_flw) },
+    { "c.jr", rv_codec_cr_jr, NULL, DECOMP(rv_op_jalr) },
+    { "c.mv", rv_codec_cr_mv, NULL, DECOMP(rv_op_addi) },
+    { "c.ebreak", rv_codec_ci_none, NULL, DECOMP(rv_op_ebreak) },
+    { "c.jalr", rv_codec_cr_jalr, NULL, DECOMP(rv_op_jalr) },
+    { "c.add", rv_codec_cr, NULL, DECOMP(rv_op_add) },
+    { "c.fsdsp", rv_codec_css_sdsp, NULL, DECOMP(rv_op_fsd) },
+    { "c.swsp", rv_codec_css_swsp, NULL, DECOMP(rv_op_sw) },
+    { "c.fswsp", rv_codec_css_swsp, NULL, DECOMP(rv_op_fsw) },
+    { "c.ld", rv_codec_cl_ld, NULL, DECOMP(rv_op_ld) },
+    { "c.sd", rv_codec_cs_sd, NULL, DECOMP(rv_op_sd) },
+    { "c.addiw", rv_codec_ci, NULL, DECOMP(rv_op_addiw) },
+    { "c.ldsp", rv_codec_ci_ldsp, NULL, DECOMP(rv_op_ld) },
+    { "c.sdsp", rv_codec_css_sdsp, NULL, DECOMP(rv_op_sd) },
+    { "c.lq", rv_codec_cl_lq, NULL, DECOMP(rv_op_lq) },
+    { "c.sq", rv_codec_cs_sq, NULL, DECOMP(rv_op_sq) },
+    { "c.lqsp", rv_codec_ci_lqsp, NULL, DECOMP(rv_op_lq) },
+    { "c.sqsp", rv_codec_css_sqsp, NULL, DECOMP(rv_op_sq) },
     { "nop", rv_codec_i, rv_fmt_none },
     { "mv", rv_codec_i, rv_fmt_rd_rs1 },
     { "not", rv_codec_i, rv_fmt_rd_rs1 },
@@ -2546,8 +2546,8 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "ssrdp", rv_codec_r, rv_fmt_rd },
     { "ssamoswap.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 },
     { "ssamoswap.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 },
-    { "c.sspush", rv_codec_cmop_ss, rv_fmt_rs2, DECOMP(rv_op_sspush) },
-    { "c.sspopchk", rv_codec_cmop_ss, rv_fmt_rs1, DECOMP(rv_op_sspopchk) },
+    { "c.sspush", rv_codec_cmop_ss, NULL, DECOMP(rv_op_sspush) },
+    { "c.sspopchk", rv_codec_cmop_ss, NULL, DECOMP(rv_op_sspopchk) },
    { "cbo.inval", rv_codec_r, rv_fmt_rs1 },
    { "cbo.clean", rv_codec_r, rv_fmt_rs1 },
    { "cbo.flush", rv_codec_r, rv_fmt_rs1 },
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 33/56
#71 lore raw

Re: [PATCH 33/56] disas/riscv: Drop format from DECOMP insns

Quoted 4 lines · Richard Henderson

The format for these will never be used -- we will use the format from the decompressed insn.

Alistair

Quoted 161 lines

---
 disas/riscv.c | 94 +++++++++++++++++++++++++------------------------ --

 1 file changed, 47 insertions(+), 47 deletions(-)
disas/riscv.c +7 -27
index 129e545c6e..9904b4db03 100644
@@ -1819,52 +1819,52 @@ static const rv_opcode_data rvi_opcode_data[]
 = {
      { "fcvt.q.lu", rv_codec_r_m, rv_fmt_rm_frd_rs1 },
      { "fmv.x.q", rv_codec_r, rv_fmt_rd_frs1 },
      { "fmv.q.x", rv_codec_r, rv_fmt_frd_rs1 },
-    { "c.addi4spn", rv_codec_ciw_4spn, rv_fmt_rd_rs1_imm,
 DECOMP(rv_op_addi) },
-    { "c.fld", rv_codec_cl_ld, rv_fmt_frd_offset_rs1,
 DECOMP(rv_op_fld) },
-    { "c.lw", rv_codec_cl_lw, rv_fmt_rd_offset_rs1, DECOMP(rv_op_lw)
 },
-    { "c.flw", rv_codec_cl_lw, rv_fmt_frd_offset_rs1,
 DECOMP(rv_op_flw) },
-    { "c.fsd", rv_codec_cs_sd, rv_fmt_frs2_offset_rs1,
 DECOMP(rv_op_fsd) },
-    { "c.sw", rv_codec_cs_sw, rv_fmt_rs2_offset_rs1,
 DECOMP(rv_op_sw) },
-    { "c.fsw", rv_codec_cs_sw, rv_fmt_frs2_offset_rs1,
 DECOMP(rv_op_fsw) },
+    { "c.addi4spn", rv_codec_ciw_4spn, NULL, DECOMP(rv_op_addi) },
+    { "c.fld", rv_codec_cl_ld, NULL, DECOMP(rv_op_fld) },
+    { "c.lw", rv_codec_cl_lw, NULL, DECOMP(rv_op_lw) },
+    { "c.flw", rv_codec_cl_lw, NULL, DECOMP(rv_op_flw) },
+    { "c.fsd", rv_codec_cs_sd, NULL, DECOMP(rv_op_fsd) },
+    { "c.sw", rv_codec_cs_sw, NULL, DECOMP(rv_op_sw) },
+    { "c.fsw", rv_codec_cs_sw, NULL, DECOMP(rv_op_fsw) },
      { },
-    { "c.addi", rv_codec_ci, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addi)
 },
-    { "c.jal", rv_codec_cj_jal, rv_fmt_rd_offset, DECOMP(rv_op_jal)
 },
-    { "c.li", rv_codec_ci_li, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addi)
 },
-    { "c.addi16sp", rv_codec_ci_16sp, rv_fmt_rd_rs1_imm,
 DECOMP(rv_op_addi) },
-    { "c.lui", rv_codec_ci_lui, rv_fmt_rd_uimm, DECOMP(rv_op_lui) },
-    { "c.srli", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm,
 DECOMP(rv_op_srli) },
-    { "c.srai", rv_codec_cb_sh6, rv_fmt_rd_rs1_imm,
 DECOMP(rv_op_srai) },
-    { "c.andi", rv_codec_cb_imm, rv_fmt_rd_rs1_imm,
 DECOMP(rv_op_andi) },
-    { "c.sub", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_sub) },
-    { "c.xor", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_xor) },
-    { "c.or", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_or) },
-    { "c.and", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_and) },
-    { "c.subw", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_subw)
 },
-    { "c.addw", rv_codec_cs, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_addw)
 },
-    { "c.j", rv_codec_cj, rv_fmt_rd_offset, DECOMP(rv_op_jal) },
-    { "c.beqz", rv_codec_cb, rv_fmt_rs1_rs2_offset,
 DECOMP(rv_op_beq) },
-    { "c.bnez", rv_codec_cb, rv_fmt_rs1_rs2_offset,
 DECOMP(rv_op_bne) },
-    { "c.slli", rv_codec_ci_sh6, rv_fmt_rd_rs1_imm,
 DECOMP(rv_op_slli) },
-    { "c.fldsp", rv_codec_ci_ldsp, rv_fmt_frd_offset_rs1,
 DECOMP(rv_op_fld) },
-    { "c.lwsp", rv_codec_ci_lwsp, rv_fmt_rd_offset_rs1,

DECOMP(rv_op_lw) },
-    { "c.flwsp", rv_codec_ci_lwsp, rv_fmt_frd_offset_rs1, DECOMP(rv_op_flw) },
-    { "c.jr", rv_codec_cr_jr, rv_fmt_rd_rs1_offset, DECOMP(rv_op_jalr) },
-    { "c.mv", rv_codec_cr_mv, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_addi) },
-    { "c.ebreak", rv_codec_ci_none, rv_fmt_none, DECOMP(rv_op_ebreak) },
-    { "c.jalr", rv_codec_cr_jalr, rv_fmt_rd_rs1_offset, DECOMP(rv_op_jalr) },
-    { "c.add", rv_codec_cr, rv_fmt_rd_rs1_rs2, DECOMP(rv_op_add) }, -    { "c.fsdsp", rv_codec_css_sdsp, rv_fmt_frs2_offset_rs1, DECOMP(rv_op_fsd) },
-    { "c.swsp", rv_codec_css_swsp, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sw) },
-    { "c.fswsp", rv_codec_css_swsp, rv_fmt_frs2_offset_rs1, DECOMP(rv_op_fsw) },
-    { "c.ld", rv_codec_cl_ld, rv_fmt_rd_offset_rs1, DECOMP(rv_op_ld) },
-    { "c.sd", rv_codec_cs_sd, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sd) },
-    { "c.addiw", rv_codec_ci, rv_fmt_rd_rs1_imm, DECOMP(rv_op_addiw) },
-    { "c.ldsp", rv_codec_ci_ldsp, rv_fmt_rd_offset_rs1, DECOMP(rv_op_ld) },
-    { "c.sdsp", rv_codec_css_sdsp, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sd) },
-    { "c.lq", rv_codec_cl_lq, rv_fmt_rd_offset_rs1, DECOMP(rv_op_lq) },
-    { "c.sq", rv_codec_cs_sq, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sq) },
-    { "c.lqsp", rv_codec_ci_lqsp, rv_fmt_rd_offset_rs1, DECOMP(rv_op_lq) },
-    { "c.sqsp", rv_codec_css_sqsp, rv_fmt_rs2_offset_rs1, DECOMP(rv_op_sq) },
+    { "c.addi", rv_codec_ci, NULL, DECOMP(rv_op_addi) }, +    { "c.jal", rv_codec_cj_jal, NULL, DECOMP(rv_op_jal) }, +    { "c.li", rv_codec_ci_li, NULL, DECOMP(rv_op_addi) }, +    { "c.addi16sp", rv_codec_ci_16sp, NULL, DECOMP(rv_op_addi) }, +    { "c.lui", rv_codec_ci_lui, NULL, DECOMP(rv_op_lui) }, +    { "c.srli", rv_codec_cb_sh6, NULL, DECOMP(rv_op_srli) }, +    { "c.srai", rv_codec_cb_sh6, NULL, DECOMP(rv_op_srai) }, +    { "c.andi", rv_codec_cb_imm, NULL, DECOMP(rv_op_andi) }, +    { "c.sub", rv_codec_cs, NULL, DECOMP(rv_op_sub) },
+    { "c.xor", rv_codec_cs, NULL, DECOMP(rv_op_xor) },
+    { "c.or", rv_codec_cs, NULL, DECOMP(rv_op_or) },
+    { "c.and", rv_codec_cs, NULL, DECOMP(rv_op_and) },
+    { "c.subw", rv_codec_cs, NULL, DECOMP(rv_op_subw) }, +    { "c.addw", rv_codec_cs, NULL, DECOMP(rv_op_addw) }, +    { "c.j", rv_codec_cj, NULL, DECOMP(rv_op_jal) },
+    { "c.beqz", rv_codec_cb, NULL, DECOMP(rv_op_beq) },
+    { "c.bnez", rv_codec_cb, NULL, DECOMP(rv_op_bne) },
+    { "c.slli", rv_codec_ci_sh6, NULL, DECOMP(rv_op_slli) }, +    { "c.fldsp", rv_codec_ci_ldsp, NULL, DECOMP(rv_op_fld) }, +    { "c.lwsp", rv_codec_ci_lwsp, NULL, DECOMP(rv_op_lw) }, +    { "c.flwsp", rv_codec_ci_lwsp, NULL, DECOMP(rv_op_flw) }, +    { "c.jr", rv_codec_cr_jr, NULL, DECOMP(rv_op_jalr) }, +    { "c.mv", rv_codec_cr_mv, NULL, DECOMP(rv_op_addi) }, +    { "c.ebreak", rv_codec_ci_none, NULL, DECOMP(rv_op_ebreak) }, +    { "c.jalr", rv_codec_cr_jalr, NULL, DECOMP(rv_op_jalr) }, +    { "c.add", rv_codec_cr, NULL, DECOMP(rv_op_add) },
+    { "c.fsdsp", rv_codec_css_sdsp, NULL, DECOMP(rv_op_fsd) }, +    { "c.swsp", rv_codec_css_swsp, NULL, DECOMP(rv_op_sw) }, +    { "c.fswsp", rv_codec_css_swsp, NULL, DECOMP(rv_op_fsw) }, +    { "c.ld", rv_codec_cl_ld, NULL, DECOMP(rv_op_ld) },
+    { "c.sd", rv_codec_cs_sd, NULL, DECOMP(rv_op_sd) },
+    { "c.addiw", rv_codec_ci, NULL, DECOMP(rv_op_addiw) }, +    { "c.ldsp", rv_codec_ci_ldsp, NULL, DECOMP(rv_op_ld) }, +    { "c.sdsp", rv_codec_css_sdsp, NULL, DECOMP(rv_op_sd) }, +    { "c.lq", rv_codec_cl_lq, NULL, DECOMP(rv_op_lq) },
+    { "c.sq", rv_codec_cs_sq, NULL, DECOMP(rv_op_sq) },
+    { "c.lqsp", rv_codec_ci_lqsp, NULL, DECOMP(rv_op_lq) }, +    { "c.sqsp", rv_codec_css_sqsp, NULL, DECOMP(rv_op_sq) }, { "nop", rv_codec_i, rv_fmt_none },
     { "mv", rv_codec_i, rv_fmt_rd_rs1 },
     { "not", rv_codec_i, rv_fmt_rd_rs1 },

disas/riscv.c +2 -2
@@ -2546,8 +2546,8 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "ssrdp", rv_codec_r, rv_fmt_rd },
      { "ssamoswap.w", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 },
      { "ssamoswap.d", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1 },
-    { "c.sspush", rv_codec_cmop_ss, rv_fmt_rs2, DECOMP(rv_op_sspush)
 },
-    { "c.sspopchk", rv_codec_cmop_ss, rv_fmt_rs1,
 DECOMP(rv_op_sspopchk) },
+    { "c.sspush", rv_codec_cmop_ss, NULL, DECOMP(rv_op_sspush) },
+    { "c.sspopchk", rv_codec_cmop_ss, NULL, DECOMP(rv_op_sspopchk)

},
    { "cbo.inval", rv_codec_r, rv_fmt_rs1 },
    { "cbo.clean", rv_codec_r, rv_fmt_rs1 },
    { "cbo.flush", rv_codec_r, rv_fmt_rs1 },

#72 lore raw

PATCH 34/56 disas/riscv: Tidy rv_comp_data terminators

In reply to Richard Henderson

Use { } instead of two zeros.

---
 disas/riscv.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
disas/riscv.c +23 -23
index 9904b4db03..bb4779614b 100644
@@ -1072,123 +1072,123 @@ static const rvc_constraint rvcc_true[] = { rvc_end };
 static const rv_comp_data rvcp_jal[] = {
     { rv_op_j, rvcc_j },
     { rv_op_jal_ra, rvcc_jal_ra },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_jalr[] = {
     { rv_op_ret, rvcc_ret },
     { rv_op_jr, rvcc_jr },
     { rv_op_jalr_ra, rvcc_jalr_ra },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_beq[] = {
     { rv_op_beqz, rvcc_beqz },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_bne[] = {
     { rv_op_bnez, rvcc_bnez },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_blt[] = {
     { rv_op_bltz, rvcc_bltz },
     { rv_op_bgtz, rvcc_bgtz },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_bge[] = {
     { rv_op_blez, rvcc_blez },
     { rv_op_bgez, rvcc_bgez },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_addi[] = {
     { rv_op_nop, rvcc_nop },
     { rv_op_mv, rvcc_mv },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_sltiu[] = {
     { rv_op_seqz, rvcc_seqz },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_xori[] = {
     { rv_op_not, rvcc_not },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_sub[] = {
     { rv_op_neg, rvcc_neg },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_slt[] = {
     { rv_op_sltz, rvcc_sltz },
     { rv_op_sgtz, rvcc_sgtz },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_sltu[] = {
     { rv_op_snez, rvcc_snez },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_addiw[] = {
     { rv_op_sext_w, rvcc_sext_w },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_subw[] = {
     { rv_op_negw, rvcc_negw },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_fsgnj_s[] = {
     { rv_op_fmv_s, rvcc_fmv_s },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_fsgnjn_s[] = {
     { rv_op_fneg_s, rvcc_fneg_s },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_fsgnjx_s[] = {
     { rv_op_fabs_s, rvcc_fabs_s },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_fsgnj_d[] = {
     { rv_op_fmv_d, rvcc_fmv_d },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_fsgnjn_d[] = {
     { rv_op_fneg_d, rvcc_fneg_d },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_fsgnjx_d[] = {
     { rv_op_fabs_d, rvcc_fabs_d },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_fsgnj_q[] = {
     { rv_op_fmv_q, rvcc_fmv_q },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_fsgnjn_q[] = {
     { rv_op_fneg_q, rvcc_fneg_q },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 static const rv_comp_data rvcp_fsgnjx_q[] = {
     { rv_op_fabs_q, rvcc_fabs_q },
-    { rv_op_illegal, NULL }
+    { },
 };
 
 /* Convert compressed insns into normal insns via pseudo expansion. */
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 34/56
#73 lore raw

Re: [PATCH 34/56] disas/riscv: Tidy rv_comp_data terminators

Quoted 3 lines · Richard Henderson

Use { } instead of two zeros.

Alistair

Quoted 157 lines

---
 disas/riscv.c | 46 +++++++++++++++++++++++-----------------------

 1 file changed, 23 insertions(+), 23 deletions(-)
disas/riscv.c +1 -1
index 9904b4db03..bb4779614b 100644
@@ -1072,123 +1072,123 @@ static const rvc_constraint rvcc_true[] = {
 rvc_end };
  static const rv_comp_data rvcp_jal[] = {
      { rv_op_j, rvcc_j },
      { rv_op_jal_ra, rvcc_jal_ra },
-    { rv_op_illegal, NULL }
+    { },
  };


 static const rv_comp_data rvcp_jalr[] = {
     { rv_op_ret, rvcc_ret },
     { rv_op_jr, rvcc_jr },
     { rv_op_jalr_ra, rvcc_jalr_ra },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_beq[] = {
     { rv_op_beqz, rvcc_beqz },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_bne[] = {
     { rv_op_bnez, rvcc_bnez },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_blt[] = {
     { rv_op_bltz, rvcc_bltz },
     { rv_op_bgtz, rvcc_bgtz },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_bge[] = {
     { rv_op_blez, rvcc_blez },
     { rv_op_bgez, rvcc_bgez },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_addi[] = {
     { rv_op_nop, rvcc_nop },
     { rv_op_mv, rvcc_mv },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_sltiu[] = {
     { rv_op_seqz, rvcc_seqz },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_xori[] = {
     { rv_op_not, rvcc_not },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_sub[] = {
     { rv_op_neg, rvcc_neg },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_slt[] = {
     { rv_op_sltz, rvcc_sltz },
     { rv_op_sgtz, rvcc_sgtz },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_sltu[] = {
     { rv_op_snez, rvcc_snez },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_addiw[] = {
     { rv_op_sext_w, rvcc_sext_w },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_subw[] = {
     { rv_op_negw, rvcc_negw },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_fsgnj_s[] = {
     { rv_op_fmv_s, rvcc_fmv_s },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_fsgnjn_s[] = {
     { rv_op_fneg_s, rvcc_fneg_s },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_fsgnjx_s[] = {
     { rv_op_fabs_s, rvcc_fabs_s },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_fsgnj_d[] = {
     { rv_op_fmv_d, rvcc_fmv_d },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_fsgnjn_d[] = {
     { rv_op_fneg_d, rvcc_fneg_d },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_fsgnjx_d[] = {
     { rv_op_fabs_d, rvcc_fabs_d },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_fsgnj_q[] = {
     { rv_op_fmv_q, rvcc_fmv_q },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_fsgnjn_q[] = {
     { rv_op_fneg_q, rvcc_fneg_q },
-    { rv_op_illegal, NULL }
+    { },
 };

 static const rv_comp_data rvcp_fsgnjx_q[] = {
     { rv_op_fabs_q, rvcc_fabs_q },
-    { rv_op_illegal, NULL }
+    { },
 };

 /* Convert compressed insns into normal insns via pseudo expansion. */

#74 lore raw

PATCH 35/56 disas/riscv: Chain "ret" pseudo off "jr" pseudo

In reply to Richard Henderson

"jr" has already checked two conditions that apply to "ret".

---
 disas/riscv.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
disas/riscv.c +7 -4
index bb4779614b..2fec135b5f 100644
@@ -1061,8 +1061,7 @@ static const rvc_constraint rvcc_bgez[] = { rvc_rs2_eq_x0, rvc_end };
 static const rvc_constraint rvcc_bltz[] = { rvc_rs2_eq_x0, rvc_end };
 static const rvc_constraint rvcc_bgtz[] = { rvc_rs1_eq_x0, rvc_end };
 static const rvc_constraint rvcc_j[] = { rvc_rd_eq_x0, rvc_end };
-static const rvc_constraint rvcc_ret[] = { rvc_rd_eq_x0, rvc_rs1_eq_ra,
-                                           rvc_end };
+static const rvc_constraint rvcc_ret[] = { rvc_rs1_eq_ra, rvc_end };
 static const rvc_constraint rvcc_jr[] = { rvc_rd_eq_x0, rvc_imm_eq_zero,
                                           rvc_end };
 static const rvc_constraint rvcc_true[] = { rvc_end };
@@ -1076,12 +1075,16 @@ static const rv_comp_data rvcp_jal[] = {
 };
 
 static const rv_comp_data rvcp_jalr[] = {
-    { rv_op_ret, rvcc_ret },
     { rv_op_jr, rvcc_jr },
     { rv_op_jalr_ra, rvcc_jalr_ra },
     { },
 };
 
+static const rv_comp_data rvcp_jr[] = {
+    { rv_op_ret, rvcc_ret },
+    { },
+};
+
 static const rv_comp_data rvcp_beq[] = {
     { rv_op_beqz, rvcc_beqz },
     { },
@@ -1896,7 +1899,7 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { },
     { "j", rv_codec_uj, rv_fmt_offset },
     { "ret", rv_codec_i, rv_fmt_none },
-    { "jr", rv_codec_i, rv_fmt_rs1 },
+    { "jr", rv_codec_i, rv_fmt_rs1, rvcp_jr },
     { "rdcycle", rv_codec_i_csr, rv_fmt_rd },
     { "rdtime", rv_codec_i_csr, rv_fmt_rd },
     { "rdinstret", rv_codec_i_csr, rv_fmt_rd },
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 35/56
#75 lore raw

Re: [PATCH 35/56] disas/riscv: Chain "ret" pseudo off "jr" pseudo

Quoted 3 lines · Richard Henderson

"jr" has already checked two conditions that apply to "ret".

Alistair

Quoted 51 lines

---
 disas/riscv.c | 11 +++++++----

 1 file changed, 7 insertions(+), 4 deletions(-)
disas/riscv.c +0 -0
index bb4779614b..2fec135b5f 100644
@@ -1061,8 +1061,7 @@ static const rvc_constraint rvcc_bgez[] = {
 rvc_rs2_eq_x0, rvc_end };

 static const rvc_constraint rvcc_bltz[] = { rvc_rs2_eq_x0, rvc_end };
 static const rvc_constraint rvcc_bgtz[] = { rvc_rs1_eq_x0, rvc_end };
 static const rvc_constraint rvcc_j[] = { rvc_rd_eq_x0, rvc_end }; -static const rvc_constraint rvcc_ret[] = { rvc_rd_eq_x0, rvc_rs1_eq_ra,
-                                           rvc_end }; +static const rvc_constraint rvcc_ret[] = { rvc_rs1_eq_ra, rvc_end }; static const rvc_constraint rvcc_jr[] = { rvc_rd_eq_x0, rvc_imm_eq_zero,
                                           rvc_end }; static const rvc_constraint rvcc_true[] = { rvc_end };

disas/riscv.c +0 -0
@@ -1076,12 +1075,16 @@ static const rv_comp_data rvcp_jal[] = {
  };


 static const rv_comp_data rvcp_jalr[] = {
-    { rv_op_ret, rvcc_ret },
     { rv_op_jr, rvcc_jr },
     { rv_op_jalr_ra, rvcc_jalr_ra },
     { },
 };

disas/riscv.c +5 -0
+static const rv_comp_data rvcp_jr[] = {
+    { rv_op_ret, rvcc_ret },
+    { },
+};
+

 static const rv_comp_data rvcp_beq[] = {
     { rv_op_beqz, rvcc_beqz },
     { },

disas/riscv.c +1 -1
@@ -1896,7 +1899,7 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { },
      { "j", rv_codec_uj, rv_fmt_offset },
      { "ret", rv_codec_i, rv_fmt_none },
-    { "jr", rv_codec_i, rv_fmt_rs1 },
+    { "jr", rv_codec_i, rv_fmt_rs1, rvcp_jr },
      { "rdcycle", rv_codec_i_csr, rv_fmt_rd },
      { "rdtime", rv_codec_i_csr, rv_fmt_rd },

     { "rdinstret", rv_codec_i_csr, rv_fmt_rd },

#76 lore raw

PATCH 36/56 disas/riscv: Chain "nop" pseudo off "mv" pseudo

In reply to Richard Henderson

"mv" has already checked a condition that applies to "nop".

---
 disas/riscv.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
disas/riscv.c +7 -3
index 2fec135b5f..37f6440831 100644
@@ -1035,7 +1035,7 @@ static const rvc_constraint rvcc_jal_ra[] = { rvc_rd_eq_ra, rvc_end };
 static const rvc_constraint rvcc_jalr_ra[] = { rvc_rd_eq_ra, rvc_imm_eq_zero,
                                                rvc_end };
 static const rvc_constraint rvcc_nop[] = { rvc_rd_eq_x0, rvc_rs1_eq_x0,
-                                           rvc_imm_eq_zero, rvc_end };
+                                           rvc_end };
 static const rvc_constraint rvcc_mv[] = { rvc_imm_eq_zero, rvc_end };
 static const rvc_constraint rvcc_not[] = { rvc_imm_eq_n1, rvc_end };
 static const rvc_constraint rvcc_neg[] = { rvc_rs1_eq_x0, rvc_end };
@@ -1108,11 +1108,15 @@ static const rv_comp_data rvcp_bge[] = {
 };
 
 static const rv_comp_data rvcp_addi[] = {
-    { rv_op_nop, rvcc_nop },
     { rv_op_mv, rvcc_mv },
     { },
 };
 
+static const rv_comp_data rvcp_mv[] = {
+    { rv_op_nop, rvcc_nop },
+    { },
+};
+
 static const rv_comp_data rvcp_sltiu[] = {
     { rv_op_seqz, rvcc_seqz },
     { },
@@ -1869,7 +1873,7 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "c.lqsp", rv_codec_ci_lqsp, NULL, DECOMP(rv_op_lq) },
     { "c.sqsp", rv_codec_css_sqsp, NULL, DECOMP(rv_op_sq) },
     { "nop", rv_codec_i, rv_fmt_none },
-    { "mv", rv_codec_i, rv_fmt_rd_rs1 },
+    { "mv", rv_codec_i, rv_fmt_rd_rs1, rvcp_mv },
     { "not", rv_codec_i, rv_fmt_rd_rs1 },
     { "neg", rv_codec_r, rv_fmt_rd_rs2 },
     { "negw", rv_codec_r, rv_fmt_rd_rs2 },
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 36/56
#77 lore raw

Re: [PATCH 36/56] disas/riscv: Chain "nop" pseudo off "mv" pseudo

Quoted 3 lines · Richard Henderson

"mv" has already checked a condition that applies to "nop".

Alistair

Quoted 49 lines

---
 disas/riscv.c | 10 +++++++---

 1 file changed, 7 insertions(+), 3 deletions(-)
disas/riscv.c +0 -1
index 2fec135b5f..37f6440831 100644
@@ -1035,7 +1035,7 @@ static const rvc_constraint rvcc_jal_ra[] = {
 rvc_rd_eq_ra, rvc_end };
  static const rvc_constraint rvcc_jalr_ra[] = { rvc_rd_eq_ra,
 rvc_imm_eq_zero,
                                                 rvc_end };
  static const rvc_constraint rvcc_nop[] = { rvc_rd_eq_x0,
 rvc_rs1_eq_x0,
-                                           rvc_imm_eq_zero, rvc_end

};
+                                           rvc_end }; static const rvc_constraint rvcc_mv[] = { rvc_imm_eq_zero, rvc_end };
 static const rvc_constraint rvcc_not[] = { rvc_imm_eq_n1, rvc_end }; static const rvc_constraint rvcc_neg[] = { rvc_rs1_eq_x0, rvc_end };

disas/riscv.c +0 -0
@@ -1108,11 +1108,15 @@ static const rv_comp_data rvcp_bge[] = {
  };


 static const rv_comp_data rvcp_addi[] = {
-    { rv_op_nop, rvcc_nop },
     { rv_op_mv, rvcc_mv },
     { },
 };

disas/riscv.c +5 -0
+static const rv_comp_data rvcp_mv[] = {
+    { rv_op_nop, rvcc_nop },
+    { },
+};
+

 static const rv_comp_data rvcp_sltiu[] = {
     { rv_op_seqz, rvcc_seqz },
     { },

disas/riscv.c +1 -1
@@ -1869,7 +1873,7 @@ static const rv_opcode_data rvi_opcode_data[] =
 {
      { "c.lqsp", rv_codec_ci_lqsp, NULL, DECOMP(rv_op_lq) },
      { "c.sqsp", rv_codec_css_sqsp, NULL, DECOMP(rv_op_sq) },
      { "nop", rv_codec_i, rv_fmt_none },
-    { "mv", rv_codec_i, rv_fmt_rd_rs1 },
+    { "mv", rv_codec_i, rv_fmt_rd_rs1, rvcp_mv },
      { "not", rv_codec_i, rv_fmt_rd_rs1 },
      { "neg", rv_codec_r, rv_fmt_rd_rs2 },

     { "negw", rv_codec_r, rv_fmt_rd_rs2 },

#78 lore raw

PATCH 37/56 disas/riscv: Use rv_codec_illegal for pseudos

In reply to Richard Henderson

The codec is never used, since we arrive into pseudos from a decoding of another opcode.
Assert that rv_codec_illegal is never decoded. Use rv_codec_none for rv_op_illegal.

---
 disas/riscv.c | 68 +++++++++++++++++++++++++--------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)
disas/riscv.c +34 -34
index 37f6440831..fc821355fe 100644
@@ -1599,7 +1599,7 @@ static uint32_t operand_lpl(rv_inst inst)
 /* instruction metadata */
 
 static const rv_opcode_data rvi_opcode_data[] = {
-    { "illegal", rv_codec_illegal, rv_fmt_none },
+    { "illegal", rv_codec_none, rv_fmt_none },
     { "lui", rv_codec_u, rv_fmt_rd_uimm },
     { "auipc", rv_codec_u, rv_fmt_rd_uoffset },
     { "jal", rv_codec_uj, rv_fmt_rd_offset, rvcp_jal },
@@ -1872,38 +1872,38 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "c.sq", rv_codec_cs_sq, NULL, DECOMP(rv_op_sq) },
     { "c.lqsp", rv_codec_ci_lqsp, NULL, DECOMP(rv_op_lq) },
     { "c.sqsp", rv_codec_css_sqsp, NULL, DECOMP(rv_op_sq) },
-    { "nop", rv_codec_i, rv_fmt_none },
-    { "mv", rv_codec_i, rv_fmt_rd_rs1, rvcp_mv },
-    { "not", rv_codec_i, rv_fmt_rd_rs1 },
-    { "neg", rv_codec_r, rv_fmt_rd_rs2 },
-    { "negw", rv_codec_r, rv_fmt_rd_rs2 },
-    { "sext.w", rv_codec_i, rv_fmt_rd_rs1 },
-    { "seqz", rv_codec_i, rv_fmt_rd_rs1 },
-    { "snez", rv_codec_r, rv_fmt_rd_rs2 },
-    { "sltz", rv_codec_r, rv_fmt_rd_rs1 },
-    { "sgtz", rv_codec_r, rv_fmt_rd_rs2 },
-    { "fmv.s", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fabs.s", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fneg.s", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fmv.d", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fabs.d", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fneg.d", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fmv.q", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fabs.q", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fneg.q", rv_codec_r, rv_fmt_frd_frs1 },
-    { "beqz", rv_codec_sb, rv_fmt_rs1_offset },
-    { "bnez", rv_codec_sb, rv_fmt_rs1_offset },
-    { "blez", rv_codec_sb, rv_fmt_rs2_offset },
-    { "bgez", rv_codec_sb, rv_fmt_rs1_offset },
-    { "bltz", rv_codec_sb, rv_fmt_rs1_offset },
-    { "bgtz", rv_codec_sb, rv_fmt_rs2_offset },
-    { "jal", rv_codec_none, rv_fmt_offset }, /* rv_op_jal_ra */
-    { "jalr", rv_codec_none, rv_fmt_rs1 }, /* rv_op_jalr_ra */
+    { "nop", rv_codec_illegal, rv_fmt_none },
+    { "mv", rv_codec_illegal, rv_fmt_rd_rs1, rvcp_mv },
+    { "not", rv_codec_illegal, rv_fmt_rd_rs1 },
+    { "neg", rv_codec_illegal, rv_fmt_rd_rs2 },
+    { "negw", rv_codec_illegal, rv_fmt_rd_rs2 },
+    { "sext.w", rv_codec_illegal, rv_fmt_rd_rs1 },
+    { "seqz", rv_codec_illegal, rv_fmt_rd_rs1 },
+    { "snez", rv_codec_illegal, rv_fmt_rd_rs2 },
+    { "sltz", rv_codec_illegal, rv_fmt_rd_rs1 },
+    { "sgtz", rv_codec_illegal, rv_fmt_rd_rs2 },
+    { "fmv.s", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fabs.s", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fneg.s", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fmv.d", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fabs.d", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fneg.d", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fmv.q", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fabs.q", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fneg.q", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "beqz", rv_codec_illegal, rv_fmt_rs1_offset },
+    { "bnez", rv_codec_illegal, rv_fmt_rs1_offset },
+    { "blez", rv_codec_illegal, rv_fmt_rs2_offset },
+    { "bgez", rv_codec_illegal, rv_fmt_rs1_offset },
+    { "bltz", rv_codec_illegal, rv_fmt_rs1_offset },
+    { "bgtz", rv_codec_illegal, rv_fmt_rs2_offset },
+    { "jal", rv_codec_illegal, rv_fmt_offset }, /* rv_op_jal_ra */
+    { "jalr", rv_codec_illegal, rv_fmt_rs1 }, /* rv_op_jalr_ra */
     { },
     { },
-    { "j", rv_codec_uj, rv_fmt_offset },
-    { "ret", rv_codec_i, rv_fmt_none },
-    { "jr", rv_codec_i, rv_fmt_rs1, rvcp_jr },
+    { "j", rv_codec_illegal, rv_fmt_offset },
+    { "ret", rv_codec_illegal, rv_fmt_none },
+    { "jr", rv_codec_illegal, rv_fmt_rs1, rvcp_jr },
     { "rdcycle", rv_codec_i_csr, rv_fmt_rd },
     { "rdtime", rv_codec_i_csr, rv_fmt_rd },
     { "rdinstret", rv_codec_i_csr, rv_fmt_rd },
@@ -4551,8 +4551,6 @@ static void decode_inst_operands(rv_decode *dec, rv_isa isa,
     rv_inst inst = dec->inst;
 
     switch (op->codec) {
-    case rv_codec_illegal:
-        break;
     case rv_codec_none:
         dec->rd = dec->rs1 = dec->rs2 = rv_ireg_zero;
         dec->imm = 0;
@@ -4946,7 +4944,9 @@ static void decode_inst_operands(rv_decode *dec, rv_isa isa,
         dec->rs1 = dec->rs2 = operand_crs1(inst);
         dec->imm = 0;
         break;
-    };
+    default:
+        g_assert_not_reached();
+    }
 }
 
 /* check constraint */
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 37/56
#79 lore raw

Re: [PATCH 37/56] disas/riscv: Use rv_codec_illegal for pseudos

Quoted 6 lines · Richard Henderson

The codec is never used, since we arrive into pseudos from a decoding of another opcode.
Assert that rv_codec_illegal is never decoded. Use rv_codec_none for rv_op_illegal.

Alistair

Quoted 110 lines

---
 disas/riscv.c | 68 +++++++++++++++++++++++++------------------------ --

 1 file changed, 34 insertions(+), 34 deletions(-)
disas/riscv.c +0 -0
index 37f6440831..fc821355fe 100644
@@ -1599,7 +1599,7 @@ static uint32_t operand_lpl(rv_inst inst)
  /* instruction metadata */


 static const rv_opcode_data rvi_opcode_data[] = { -    { "illegal", rv_codec_illegal, rv_fmt_none }, +    { "illegal", rv_codec_none, rv_fmt_none }, { "lui", rv_codec_u, rv_fmt_rd_uimm },
     { "auipc", rv_codec_u, rv_fmt_rd_uoffset }, { "jal", rv_codec_uj, rv_fmt_rd_offset, rvcp_jal },

disas/riscv.c +30 -30
@@ -1872,38 +1872,38 @@ static const rv_opcode_data rvi_opcode_data[]
 = {
      { "c.sq", rv_codec_cs_sq, NULL, DECOMP(rv_op_sq) },
      { "c.lqsp", rv_codec_ci_lqsp, NULL, DECOMP(rv_op_lq) },
      { "c.sqsp", rv_codec_css_sqsp, NULL, DECOMP(rv_op_sq) },
-    { "nop", rv_codec_i, rv_fmt_none },
-    { "mv", rv_codec_i, rv_fmt_rd_rs1, rvcp_mv },
-    { "not", rv_codec_i, rv_fmt_rd_rs1 },
-    { "neg", rv_codec_r, rv_fmt_rd_rs2 },
-    { "negw", rv_codec_r, rv_fmt_rd_rs2 },
-    { "sext.w", rv_codec_i, rv_fmt_rd_rs1 },
-    { "seqz", rv_codec_i, rv_fmt_rd_rs1 },
-    { "snez", rv_codec_r, rv_fmt_rd_rs2 },
-    { "sltz", rv_codec_r, rv_fmt_rd_rs1 },
-    { "sgtz", rv_codec_r, rv_fmt_rd_rs2 },
-    { "fmv.s", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fabs.s", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fneg.s", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fmv.d", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fabs.d", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fneg.d", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fmv.q", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fabs.q", rv_codec_r, rv_fmt_frd_frs1 },
-    { "fneg.q", rv_codec_r, rv_fmt_frd_frs1 },
-    { "beqz", rv_codec_sb, rv_fmt_rs1_offset },
-    { "bnez", rv_codec_sb, rv_fmt_rs1_offset },
-    { "blez", rv_codec_sb, rv_fmt_rs2_offset },
-    { "bgez", rv_codec_sb, rv_fmt_rs1_offset },
-    { "bltz", rv_codec_sb, rv_fmt_rs1_offset },
-    { "bgtz", rv_codec_sb, rv_fmt_rs2_offset },
-    { "jal", rv_codec_none, rv_fmt_offset }, /* rv_op_jal_ra */
-    { "jalr", rv_codec_none, rv_fmt_rs1 }, /* rv_op_jalr_ra */
+    { "nop", rv_codec_illegal, rv_fmt_none },
+    { "mv", rv_codec_illegal, rv_fmt_rd_rs1, rvcp_mv },
+    { "not", rv_codec_illegal, rv_fmt_rd_rs1 },
+    { "neg", rv_codec_illegal, rv_fmt_rd_rs2 },
+    { "negw", rv_codec_illegal, rv_fmt_rd_rs2 },
+    { "sext.w", rv_codec_illegal, rv_fmt_rd_rs1 },
+    { "seqz", rv_codec_illegal, rv_fmt_rd_rs1 },
+    { "snez", rv_codec_illegal, rv_fmt_rd_rs2 },
+    { "sltz", rv_codec_illegal, rv_fmt_rd_rs1 },
+    { "sgtz", rv_codec_illegal, rv_fmt_rd_rs2 },
+    { "fmv.s", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fabs.s", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fneg.s", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fmv.d", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fabs.d", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fneg.d", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fmv.q", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fabs.q", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "fneg.q", rv_codec_illegal, rv_fmt_frd_frs1 },
+    { "beqz", rv_codec_illegal, rv_fmt_rs1_offset },
+    { "bnez", rv_codec_illegal, rv_fmt_rs1_offset },
+    { "blez", rv_codec_illegal, rv_fmt_rs2_offset },
+    { "bgez", rv_codec_illegal, rv_fmt_rs1_offset },
+    { "bltz", rv_codec_illegal, rv_fmt_rs1_offset },
+    { "bgtz", rv_codec_illegal, rv_fmt_rs2_offset },
+    { "jal", rv_codec_illegal, rv_fmt_offset }, /* rv_op_jal_ra */
+    { "jalr", rv_codec_illegal, rv_fmt_rs1 }, /* rv_op_jalr_ra */
      { },
      { },
-    { "j", rv_codec_uj, rv_fmt_offset },
-    { "ret", rv_codec_i, rv_fmt_none },
-    { "jr", rv_codec_i, rv_fmt_rs1, rvcp_jr },
+    { "j", rv_codec_illegal, rv_fmt_offset },
+    { "ret", rv_codec_illegal, rv_fmt_none },
+    { "jr", rv_codec_illegal, rv_fmt_rs1, rvcp_jr },
      { "rdcycle", rv_codec_i_csr, rv_fmt_rd },
      { "rdtime", rv_codec_i_csr, rv_fmt_rd },

     { "rdinstret", rv_codec_i_csr, rv_fmt_rd },

disas/riscv.c +0 -0
@@ -4551,8 +4551,6 @@ static void decode_inst_operands(rv_decode
 *dec, rv_isa isa,
      rv_inst inst = dec->inst;


     switch (op->codec) {
-    case rv_codec_illegal:
-        break;
     case rv_codec_none:
         dec->rd = dec->rs1 = dec->rs2 = rv_ireg_zero; dec->imm = 0;

disas/riscv.c +3 -1
@@ -4946,7 +4944,9 @@ static void decode_inst_operands(rv_decode
 *dec, rv_isa isa,
          dec->rs1 = dec->rs2 = operand_crs1(inst);
          dec->imm = 0;
          break;
-    };
+    default:
+        g_assert_not_reached();
+    }
  }


 /* check constraint */

#80 lore raw

PATCH 38/56 disas/riscv: Simplify some insn decompressions

In reply to Richard Henderson

Route "c.j" to "j" instead of "jal", etc.

---
 disas/riscv.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
disas/riscv.c +5 -5
index fc821355fe..9a528803e8 100644
@@ -1848,15 +1848,15 @@ static const rv_opcode_data rvi_opcode_data[] = {
     { "c.and", rv_codec_cs, NULL, DECOMP(rv_op_and) },
     { "c.subw", rv_codec_cs, NULL, DECOMP(rv_op_subw) },
     { "c.addw", rv_codec_cs, NULL, DECOMP(rv_op_addw) },
-    { "c.j", rv_codec_cj, NULL, DECOMP(rv_op_jal) },
-    { "c.beqz", rv_codec_cb, NULL, DECOMP(rv_op_beq) },
-    { "c.bnez", rv_codec_cb, NULL, DECOMP(rv_op_bne) },
+    { "c.j", rv_codec_cj, NULL, DECOMP(rv_op_j) },
+    { "c.beqz", rv_codec_cb, NULL, DECOMP(rv_op_beqz) },
+    { "c.bnez", rv_codec_cb, NULL, DECOMP(rv_op_bnez) },
     { "c.slli", rv_codec_ci_sh6, NULL, DECOMP(rv_op_slli) },
     { "c.fldsp", rv_codec_ci_ldsp, NULL, DECOMP(rv_op_fld) },
     { "c.lwsp", rv_codec_ci_lwsp, NULL, DECOMP(rv_op_lw) },
     { "c.flwsp", rv_codec_ci_lwsp, NULL, DECOMP(rv_op_flw) },
-    { "c.jr", rv_codec_cr_jr, NULL, DECOMP(rv_op_jalr) },
-    { "c.mv", rv_codec_cr_mv, NULL, DECOMP(rv_op_addi) },
+    { "c.jr", rv_codec_cr_jr, NULL, DECOMP(rv_op_jr) },
+    { "c.mv", rv_codec_cr_mv, NULL, DECOMP(rv_op_mv) },
     { "c.ebreak", rv_codec_ci_none, NULL, DECOMP(rv_op_ebreak) },
     { "c.jalr", rv_codec_cr_jalr, NULL, DECOMP(rv_op_jalr) },
     { "c.add", rv_codec_cr, NULL, DECOMP(rv_op_add) },
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 38/56
#81 lore raw

Re: [PATCH 38/56] disas/riscv: Simplify some insn decompressions

Quoted 3 lines · Richard Henderson

Route "c.j" to "j" instead of "jal", etc.

Alistair

Quoted 30 lines

---
 disas/riscv.c | 10 +++++-----

 1 file changed, 5 insertions(+), 5 deletions(-)
disas/riscv.c +5 -5
index fc821355fe..9a528803e8 100644
@@ -1848,15 +1848,15 @@ static const rv_opcode_data rvi_opcode_data[]
 = {
      { "c.and", rv_codec_cs, NULL, DECOMP(rv_op_and) },
      { "c.subw", rv_codec_cs, NULL, DECOMP(rv_op_subw) },
      { "c.addw", rv_codec_cs, NULL, DECOMP(rv_op_addw) },
-    { "c.j", rv_codec_cj, NULL, DECOMP(rv_op_jal) },
-    { "c.beqz", rv_codec_cb, NULL, DECOMP(rv_op_beq) },
-    { "c.bnez", rv_codec_cb, NULL, DECOMP(rv_op_bne) },
+    { "c.j", rv_codec_cj, NULL, DECOMP(rv_op_j) },
+    { "c.beqz", rv_codec_cb, NULL, DECOMP(rv_op_beqz) },
+    { "c.bnez", rv_codec_cb, NULL, DECOMP(rv_op_bnez) },
      { "c.slli", rv_codec_ci_sh6, NULL, DECOMP(rv_op_slli) },
      { "c.fldsp", rv_codec_ci_ldsp, NULL, DECOMP(rv_op_fld) },
      { "c.lwsp", rv_codec_ci_lwsp, NULL, DECOMP(rv_op_lw) },
      { "c.flwsp", rv_codec_ci_lwsp, NULL, DECOMP(rv_op_flw) },
-    { "c.jr", rv_codec_cr_jr, NULL, DECOMP(rv_op_jalr) },
-    { "c.mv", rv_codec_cr_mv, NULL, DECOMP(rv_op_addi) },
+    { "c.jr", rv_codec_cr_jr, NULL, DECOMP(rv_op_jr) },
+    { "c.mv", rv_codec_cr_mv, NULL, DECOMP(rv_op_mv) },
      { "c.ebreak", rv_codec_ci_none, NULL, DECOMP(rv_op_ebreak) },
      { "c.jalr", rv_codec_cr_jalr, NULL, DECOMP(rv_op_jalr) },

     { "c.add", rv_codec_cr, NULL, DECOMP(rv_op_add) },

#82 lore raw

PATCH 39/56 disas/riscv: Store op pointer in rv_comp_data

In reply to Richard Henderson

Store a pointer instead of an array index.

---
 disas/riscv.h |  8 +++---
 disas/riscv.c | 69 ++++++++++++++++++++++++++-------------------------
 2 files changed, 40 insertions(+), 37 deletions(-)
disas/riscv.h +5 -3
index ea7141d3b5..ab62c0db94 100644
@@ -164,17 +164,19 @@ typedef enum {
 
 /* structures */
 
+typedef struct rv_opcode_data rv_opcode_data;
+
 typedef struct {
-    int op;
+    const rv_opcode_data *op;
     const rvc_constraint *constraints;
 } rv_comp_data;
 
-typedef struct {
+struct rv_opcode_data {
     const char *name;
     rv_codec codec;
     const char *format;
     const rv_comp_data *pseudo;
-} rv_opcode_data;
+};
 
 typedef struct {
     const RISCVCPUConfig *cfg;
disas/riscv.c +35 -34

182 lines not on this page · raw message

Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 39/56
#83 lore raw

Re: [PATCH 39/56] disas/riscv: Store op pointer in rv_comp_data

Quoted 3 lines · Richard Henderson

Store a pointer instead of an array index.

Alistair

Quoted 226 lines

---
 disas/riscv.h |  8 +++---
 disas/riscv.c | 69 ++++++++++++++++++++++++++----------------------- --

 2 files changed, 40 insertions(+), 37 deletions(-)
disas/riscv.h +0 -0
index ea7141d3b5..ab62c0db94 100644
@@ -164,17 +164,19 @@ typedef enum {


 /* structures */

disas/riscv.h +2 -0
+typedef struct rv_opcode_data rv_opcode_data;
+

 typedef struct {
-    int op;
+    const rv_opcode_data *op;
     const rvc_constraint *constraints;
 } rv_comp_data;

disas/riscv.h +1 -1
-typedef struct {
+struct rv_opcode_data {

     const char *name;
     rv_codec codec;
     const char *format;
     const rv_comp_data *pseudo;

disas/riscv.h +1 -1
-} rv_opcode_data;
+};


 typedef struct {
     const RISCVCPUConfig *cfg;

disas/riscv.c +0 -0
index 9a528803e8..171c60238f 100644
@@ -1068,138 +1068,140 @@ static const rvc_constraint rvcc_true[] = {
 rvc_end };


 /* pseudo-instruction metadata */

disas/riscv.c +2 -0
+static const rv_opcode_data rvi_opcode_data[];
+

 static const rv_comp_data rvcp_jal[] = {
-    { rv_op_j, rvcc_j },
-    { rv_op_jal_ra, rvcc_jal_ra },
+    { &rvi_opcode_data[rv_op_j], rvcc_j },
+    { &rvi_opcode_data[rv_op_jal_ra], rvcc_jal_ra },
     { },
 };

 static const rv_comp_data rvcp_jalr[] = {
-    { rv_op_jr, rvcc_jr },
-    { rv_op_jalr_ra, rvcc_jalr_ra },
+    { &rvi_opcode_data[rv_op_jr], rvcc_jr },
+    { &rvi_opcode_data[rv_op_jalr_ra], rvcc_jalr_ra },
     { },
 };

 static const rv_comp_data rvcp_jr[] = {
-    { rv_op_ret, rvcc_ret },
+    { &rvi_opcode_data[rv_op_ret], rvcc_ret },
     { },
 };

 static const rv_comp_data rvcp_beq[] = {
-    { rv_op_beqz, rvcc_beqz },
+    { &rvi_opcode_data[rv_op_beqz], rvcc_beqz },
     { },
 };

 static const rv_comp_data rvcp_bne[] = {
-    { rv_op_bnez, rvcc_bnez },
+    { &rvi_opcode_data[rv_op_bnez], rvcc_bnez },
     { },
 };

 static const rv_comp_data rvcp_blt[] = {
-    { rv_op_bltz, rvcc_bltz },
-    { rv_op_bgtz, rvcc_bgtz },
+    { &rvi_opcode_data[rv_op_bltz], rvcc_bltz },
+    { &rvi_opcode_data[rv_op_bgtz], rvcc_bgtz },
     { },
 };

 static const rv_comp_data rvcp_bge[] = {
-    { rv_op_blez, rvcc_blez },
-    { rv_op_bgez, rvcc_bgez },
+    { &rvi_opcode_data[rv_op_blez], rvcc_blez },
+    { &rvi_opcode_data[rv_op_bgez], rvcc_bgez },
     { },
 };

 static const rv_comp_data rvcp_addi[] = {
-    { rv_op_mv, rvcc_mv },
+    { &rvi_opcode_data[rv_op_mv], rvcc_mv },
     { },
 };

 static const rv_comp_data rvcp_mv[] = {
-    { rv_op_nop, rvcc_nop },
+    { &rvi_opcode_data[rv_op_nop], rvcc_nop },
     { },
 };

 static const rv_comp_data rvcp_sltiu[] = {
-    { rv_op_seqz, rvcc_seqz },
+    { &rvi_opcode_data[rv_op_seqz], rvcc_seqz },
     { },
 };

 static const rv_comp_data rvcp_xori[] = {
-    { rv_op_not, rvcc_not },
+    { &rvi_opcode_data[rv_op_not], rvcc_not },
     { },
 };

 static const rv_comp_data rvcp_sub[] = {
-    { rv_op_neg, rvcc_neg },
+    { &rvi_opcode_data[rv_op_neg], rvcc_neg },
     { },
 };

 static const rv_comp_data rvcp_slt[] = {
-    { rv_op_sltz, rvcc_sltz },
-    { rv_op_sgtz, rvcc_sgtz },
+    { &rvi_opcode_data[rv_op_sltz], rvcc_sltz },
+    { &rvi_opcode_data[rv_op_sgtz], rvcc_sgtz },
     { },
 };

 static const rv_comp_data rvcp_sltu[] = {
-    { rv_op_snez, rvcc_snez },
+    { &rvi_opcode_data[rv_op_snez], rvcc_snez },
     { },
 };

 static const rv_comp_data rvcp_addiw[] = {
-    { rv_op_sext_w, rvcc_sext_w },
+    { &rvi_opcode_data[rv_op_sext_w], rvcc_sext_w },
     { },
 };

 static const rv_comp_data rvcp_subw[] = {
-    { rv_op_negw, rvcc_negw },
+    { &rvi_opcode_data[rv_op_negw], rvcc_negw },
     { },
 };

 static const rv_comp_data rvcp_fsgnj_s[] = {
-    { rv_op_fmv_s, rvcc_fmv_s },
+    { &rvi_opcode_data[rv_op_fmv_s], rvcc_fmv_s },
     { },
 };

 static const rv_comp_data rvcp_fsgnjn_s[] = {
-    { rv_op_fneg_s, rvcc_fneg_s },
+    { &rvi_opcode_data[rv_op_fneg_s], rvcc_fneg_s },
     { },
 };

 static const rv_comp_data rvcp_fsgnjx_s[] = {
-    { rv_op_fabs_s, rvcc_fabs_s },
+    { &rvi_opcode_data[rv_op_fabs_s], rvcc_fabs_s },
     { },
 };

 static const rv_comp_data rvcp_fsgnj_d[] = {
-    { rv_op_fmv_d, rvcc_fmv_d },
+    { &rvi_opcode_data[rv_op_fmv_d], rvcc_fmv_d },
     { },
 };

 static const rv_comp_data rvcp_fsgnjn_d[] = {
-    { rv_op_fneg_d, rvcc_fneg_d },
+    { &rvi_opcode_data[rv_op_fneg_d], rvcc_fneg_d },
     { },
 };

 static const rv_comp_data rvcp_fsgnjx_d[] = {
-    { rv_op_fabs_d, rvcc_fabs_d },
+    { &rvi_opcode_data[rv_op_fabs_d], rvcc_fabs_d },
     { },
 };

 static const rv_comp_data rvcp_fsgnj_q[] = {
-    { rv_op_fmv_q, rvcc_fmv_q },
+    { &rvi_opcode_data[rv_op_fmv_q], rvcc_fmv_q },
     { },
 };

 static const rv_comp_data rvcp_fsgnjn_q[] = {
-    { rv_op_fneg_q, rvcc_fneg_q },
+    { &rvi_opcode_data[rv_op_fneg_q], rvcc_fneg_q },
     { },
 };

 static const rv_comp_data rvcp_fsgnjx_q[] = {
-    { rv_op_fabs_q, rvcc_fabs_q },
+    { &rvi_opcode_data[rv_op_fabs_q], rvcc_fabs_q },
     { },
 };

 /* Convert compressed insns into normal insns via pseudo expansion. */

disas/riscv.c +1 -1
-#define DECOMP(X) (static const rv_comp_data[1]){ { X, rvcc_true } }
+#define DECOMP(X) (static const rv_comp_data[1]){ {

&rvi_opcode_data[X], rvcc_true } }

 /* operand extractors */

disas/riscv.c +2 -3
@@ -5270,9 +5272,8 @@ static const rv_opcode_data
 *decode_inst_lift_pseudo(rv_decode *dec,
      if (comp_data) {
          while (comp_data->constraints) {
              if (check_constraints(dec, comp_data->constraints)) {
-                const rv_opcode_data *new_op = &dec-
 >opcode_data[comp_data->op];
-                assert(new_op != op);
-                return decode_inst_lift_pseudo(dec, new_op);
+                assert(op != comp_data->op);
+                return decode_inst_lift_pseudo(dec, comp_data->op);
              }

             comp_data++;
         }

#84 lore raw

PATCH 40/56 disas/riscv: Return rv_opcode_data pointer from decoders

In reply to Richard Henderson

Rather than putting array + index into rv_decode,
return the pointer to the object directly.

---
 disas/riscv-xlrbr.h    |  2 +-
 disas/riscv-xthead.h   | 22 ++++++++---------
 disas/riscv-xventana.h |  2 +-
 disas/riscv.h          |  2 --
 disas/riscv-xlrbr.c    |  5 ++--
 disas/riscv-xthead.c   | 55 +++++++++++++++++-------------------------
 disas/riscv-xventana.c |  5 ++--
 disas/riscv.c          | 23 +++++++-----------
 8 files changed, 48 insertions(+), 68 deletions(-)
disas/riscv-xlrbr.h +1 -1
index ebf3d4c133..da14f1b340 100644
@@ -12,6 +12,6 @@
 
 #include "disas/riscv.h"
 
-void decode_xlrbr(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xlrbr(rv_decode *, rv_isa);
 
 #endif /* DISAS_RISCV_XLRBR_H */
disas/riscv-xthead.h +11 -11
index 0c65c8e0af..f2160be8a4 100644
@@ -11,16 +11,16 @@
 
 #include "disas/riscv.h"
 
-void decode_xtheadba(rv_decode *, rv_isa);
-void decode_xtheadbb(rv_decode *, rv_isa);
-void decode_xtheadbs(rv_decode *, rv_isa);
-void decode_xtheadcmo(rv_decode *, rv_isa);
-void decode_xtheadcondmov(rv_decode *, rv_isa);
-void decode_xtheadfmemidx(rv_decode *, rv_isa);
-void decode_xtheadfmv(rv_decode *, rv_isa);
-void decode_xtheadmac(rv_decode *, rv_isa);
-void decode_xtheadmemidx(rv_decode *, rv_isa);
-void decode_xtheadmempair(rv_decode *, rv_isa);
-void decode_xtheadsync(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadba(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadbb(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadbs(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadcmo(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadcondmov(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadfmemidx(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadfmv(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadmac(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadmemidx(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadmempair(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadsync(rv_decode *, rv_isa);
 
 #endif /* DISAS_RISCV_XTHEAD_H */
disas/riscv-xventana.h +1 -1
index 1006c3be00..d28e84c7e4 100644
@@ -11,6 +11,6 @@
 
 #include "disas/riscv.h"
 
-void decode_xventanacondops(rv_decode*, rv_isa);
+const rv_opcode_data *decode_xventanacondops(rv_decode*, rv_isa);
 
 #endif /* DISAS_RISCV_XVENTANA_H */
disas/riscv.h +0 -2
index ab62c0db94..241dd47d7f 100644
@@ -182,10 +182,8 @@ typedef struct {
     const RISCVCPUConfig *cfg;
     uint64_t  pc;
     uint64_t  inst;
-    const rv_opcode_data *opcode_data;
     int32_t   imm;
     int32_t   imm1;
-    uint16_t  op;
     uint8_t   rd;
     uint8_t   rs1;
     uint8_t   rs2;
disas/riscv-xlrbr.c +2 -3
index d0092e9edd..b12916c9da 100644
@@ -36,7 +36,7 @@ static const rv_opcode_data xlrbr_opcode_data[] = {
     { "crc32c.d", rv_codec_r, rv_fmt_rd_rs1 },
 };
 
-void decode_xlrbr(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xlrbr(rv_decode *dec, rv_isa isa)
 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;
@@ -76,6 +76,5 @@ void decode_xlrbr(rv_decode *dec, rv_isa isa)
         break;
     }
 
-    dec->opcode_data = xlrbr_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xlrbr_opcode_data[op];
 }
disas/riscv-xthead.c +22 -33

145 lines not on this page · raw message

disas/riscv-xventana.c +2 -3
index 4fb9a29d0b..a4e59312d0 100644
@@ -20,7 +20,7 @@ static const rv_opcode_data ventana_opcode_data[] = {
     { "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2 },
 };
 
-void decode_xventanacondops(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xventanacondops(rv_decode *dec, rv_isa isa)
 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;
@@ -38,6 +38,5 @@ void decode_xventanacondops(rv_decode *dec, rv_isa isa)
         break;
     }
 
-    dec->opcode_data = ventana_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &ventana_opcode_data[op];
 }
disas/riscv.c +9 -14
index 171c60238f..c4b8ee7d07 100644
@@ -2846,7 +2846,7 @@ static const char *csr_name(int csrno)
 
 /* decode opcode */
 
-static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
+static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;
@@ -4541,8 +4541,7 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
         break;
     }
 
-    dec->opcode_data = rvi_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &rvi_opcode_data[op];
 }
 
 /* decode operands */
@@ -5291,14 +5290,12 @@ static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
         .inst = inst,
         .cfg = cfg,
     };
-    const rv_opcode_data *op;
+    const rv_opcode_data *op = decode_inst_opcode(&dec, isa);
 
-    decode_inst_opcode(&dec, isa);
-
-    if (dec.op == rv_op_illegal && cfg) {
+    if (!op && cfg) {
         static const struct {
             bool (*guard_func)(const RISCVCPUConfig *);
-            void (*decode_func)(rv_decode *, rv_isa);
+            const rv_opcode_data *(*decode_func)(rv_decode *, rv_isa);
         } decoders[] = {
             { has_xtheadba_p, decode_xtheadba },
             { has_xtheadbb_p, decode_xtheadbb },
@@ -5317,19 +5314,17 @@ static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst,
 
         for (size_t i = 0; i < ARRAY_SIZE(decoders); i++) {
             if (decoders[i].guard_func(cfg)) {
-                decoders[i].decode_func(&dec, isa);
-                if (dec.op != rv_op_illegal) {
+                op = decoders[i].decode_func(&dec, isa);
+                if (op) {
                     break;
                 }
             }
         }
     }
-
-    if (dec.op == rv_op_illegal) {
-        dec.opcode_data = rvi_opcode_data;
+    if (!op) {
+        op = &rvi_opcode_data[rv_op_illegal];
     }
 
-    op = &dec.opcode_data[dec.op];
     decode_inst_operands(&dec, isa, op);
     op = decode_inst_lift_pseudo(&dec, op);
     return format_inst(24, &dec, op);
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 40/56
#85 lore raw

Re: [PATCH 40/56] disas/riscv: Return rv_opcode_data pointer from decoders

Quoted 4 lines · Richard Henderson

Rather than putting array + index into rv_decode,
return the pointer to the object directly.

Alistair

Quoted 375 lines

---
 disas/riscv-xlrbr.h    |  2 +-
 disas/riscv-xthead.h   | 22 ++++++++--------- disas/riscv-xventana.h |  2 +-
 disas/riscv.h          |  2 --
 disas/riscv-xlrbr.c    |  5 ++--
 disas/riscv-xthead.c   | 55 +++++++++++++++++----------------------- --
 disas/riscv-xventana.c |  5 ++--
 disas/riscv.c          | 23 +++++++-----------

 8 files changed, 48 insertions(+), 68 deletions(-)
disas/riscv-xlrbr.h +0 -0
index ebf3d4c133..da14f1b340 100644
@@ -12,6 +12,6 @@


 #include "disas/riscv.h"

disas/riscv-xlrbr.h +1 -1
-void decode_xlrbr(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xlrbr(rv_decode *, rv_isa);


 #endif /* DISAS_RISCV_XLRBR_H */

disas/riscv-xthead.h +0 -0
index 0c65c8e0af..f2160be8a4 100644
@@ -11,16 +11,16 @@


 #include "disas/riscv.h"

disas/riscv-xthead.h +11 -11
-void decode_xtheadba(rv_decode *, rv_isa);
-void decode_xtheadbb(rv_decode *, rv_isa);
-void decode_xtheadbs(rv_decode *, rv_isa);
-void decode_xtheadcmo(rv_decode *, rv_isa);
-void decode_xtheadcondmov(rv_decode *, rv_isa);
-void decode_xtheadfmemidx(rv_decode *, rv_isa);
-void decode_xtheadfmv(rv_decode *, rv_isa);
-void decode_xtheadmac(rv_decode *, rv_isa);
-void decode_xtheadmemidx(rv_decode *, rv_isa);
-void decode_xtheadmempair(rv_decode *, rv_isa);
-void decode_xtheadsync(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadba(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadbb(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadbs(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadcmo(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadcondmov(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadfmemidx(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadfmv(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadmac(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadmemidx(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadmempair(rv_decode *, rv_isa);
+const rv_opcode_data *decode_xtheadsync(rv_decode *, rv_isa);


 #endif /* DISAS_RISCV_XTHEAD_H */

disas/riscv-xventana.h +0 -0
index 1006c3be00..d28e84c7e4 100644
@@ -11,6 +11,6 @@


 #include "disas/riscv.h"

disas/riscv-xventana.h +1 -1
-void decode_xventanacondops(rv_decode*, rv_isa);
+const rv_opcode_data *decode_xventanacondops(rv_decode*, rv_isa);


 #endif /* DISAS_RISCV_XVENTANA_H */

disas/riscv.h +0 -2
index ab62c0db94..241dd47d7f 100644
@@ -182,10 +182,8 @@ typedef struct {
      const RISCVCPUConfig *cfg;
      uint64_t  pc;
      uint64_t  inst;
-    const rv_opcode_data *opcode_data;
      int32_t   imm;
      int32_t   imm1;
-    uint16_t  op;
      uint8_t   rd;
      uint8_t   rs1;
      uint8_t   rs2;
disas/riscv-xlrbr.c +0 -0
index d0092e9edd..b12916c9da 100644
@@ -36,7 +36,7 @@ static const rv_opcode_data xlrbr_opcode_data[] = {
      { "crc32c.d", rv_codec_r, rv_fmt_rd_rs1 },
  };

disas/riscv-xlrbr.c +1 -1
-void decode_xlrbr(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xlrbr(rv_decode *dec, rv_isa isa)

 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xlrbr.c +0 -0
@@ -76,6 +76,5 @@ void decode_xlrbr(rv_decode *dec, rv_isa isa)
          break;
      }


-    dec->opcode_data = xlrbr_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xlrbr_opcode_data[op]; }

disas/riscv-xthead.c +0 -0
index 757d6ff39f..428a6380e9 100644
@@ -246,7 +246,7 @@ static const rv_opcode_data xthead_opcode_data[]
 = {
      { "th.sync.s", rv_codec_none, rv_fmt_none },
  };

disas/riscv-xthead.c +1 -1
-void decode_xtheadba(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xtheadba(rv_decode *dec, rv_isa isa)

 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xthead.c +0 -0
@@ -272,11 +272,10 @@ void decode_xtheadba(rv_decode *dec, rv_isa
 isa)
          break;
      }


-    dec->opcode_data = xthead_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xthead_opcode_data[op]; }

disas/riscv-xthead.c +1 -1
-void decode_xtheadbb(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xtheadbb(rv_decode *dec, rv_isa isa)

 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xthead.c +0 -0
@@ -331,11 +330,10 @@ void decode_xtheadbb(rv_decode *dec, rv_isa
 isa)
          break;
      }


-    dec->opcode_data = xthead_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xthead_opcode_data[op]; }

disas/riscv-xthead.c +1 -1
-void decode_xtheadbs(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xtheadbs(rv_decode *dec, rv_isa isa)

 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xthead.c +0 -0
@@ -358,11 +356,10 @@ void decode_xtheadbs(rv_decode *dec, rv_isa
 isa)
          break;
      }


-    dec->opcode_data = xthead_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xthead_opcode_data[op]; }

disas/riscv-xthead.c +1 -1
-void decode_xtheadcmo(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xtheadcmo(rv_decode *dec, rv_isa isa)

 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xthead.c +0 -0
@@ -437,11 +434,10 @@ void decode_xtheadcmo(rv_decode *dec, rv_isa
 isa)
          break;
      }


-    dec->opcode_data = xthead_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xthead_opcode_data[op]; }

disas/riscv-xthead.c +1 -1
-void decode_xtheadcondmov(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xtheadcondmov(rv_decode *dec, rv_isa

isa)
 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xthead.c +0 -0
@@ -465,11 +461,10 @@ void decode_xtheadcondmov(rv_decode *dec,
 rv_isa isa)
          break;
      }


-    dec->opcode_data = xthead_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xthead_opcode_data[op]; }

disas/riscv-xthead.c +1 -1
-void decode_xtheadfmemidx(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xtheadfmemidx(rv_decode *dec, rv_isa

isa)
 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xthead.c +0 -0
@@ -503,11 +498,10 @@ void decode_xtheadfmemidx(rv_decode *dec,
 rv_isa isa)
          break;
      }


-    dec->opcode_data = xthead_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xthead_opcode_data[op]; }

disas/riscv-xthead.c +1 -1
-void decode_xtheadfmv(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xtheadfmv(rv_decode *dec, rv_isa isa)

 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xthead.c +0 -0
@@ -539,11 +533,10 @@ void decode_xtheadfmv(rv_decode *dec, rv_isa
 isa)
          break;
      }


-    dec->opcode_data = xthead_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xthead_opcode_data[op]; }

disas/riscv-xthead.c +1 -1
-void decode_xtheadmac(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xtheadmac(rv_decode *dec, rv_isa isa)

 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xthead.c +0 -0
@@ -571,11 +564,10 @@ void decode_xtheadmac(rv_decode *dec, rv_isa
 isa)
          break;
      }


-    dec->opcode_data = xthead_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xthead_opcode_data[op]; }

disas/riscv-xthead.c +1 -1
-void decode_xtheadmemidx(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xtheadmemidx(rv_decode *dec, rv_isa

isa)
 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xthead.c +0 -0
@@ -646,11 +638,10 @@ void decode_xtheadmemidx(rv_decode *dec, rv_isa
 isa)
          break;
      }


-    dec->opcode_data = xthead_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xthead_opcode_data[op]; }

disas/riscv-xthead.c +1 -1
-void decode_xtheadmempair(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xtheadmempair(rv_decode *dec, rv_isa

isa)
 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xthead.c +0 -0
@@ -681,11 +672,10 @@ void decode_xtheadmempair(rv_decode *dec,
 rv_isa isa)
          break;
      }


-    dec->opcode_data = xthead_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xthead_opcode_data[op]; }

disas/riscv-xthead.c +1 -1
-void decode_xtheadsync(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xtheadsync(rv_decode *dec, rv_isa isa)

 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xthead.c +0 -0
@@ -716,6 +706,5 @@ void decode_xtheadsync(rv_decode *dec, rv_isa
 isa)
          break;
      }


-    dec->opcode_data = xthead_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &xthead_opcode_data[op]; }

disas/riscv-xventana.c +0 -0
index 4fb9a29d0b..a4e59312d0 100644
@@ -20,7 +20,7 @@ static const rv_opcode_data ventana_opcode_data[] =
 {
      { "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2 },
  };

disas/riscv-xventana.c +1 -1
-void decode_xventanacondops(rv_decode *dec, rv_isa isa)
+const rv_opcode_data *decode_xventanacondops(rv_decode *dec, rv_isa

isa)
 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv-xventana.c +0 -0
@@ -38,6 +38,5 @@ void decode_xventanacondops(rv_decode *dec, rv_isa
 isa)
          break;
      }


-    dec->opcode_data = ventana_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &ventana_opcode_data[op]; }

disas/riscv.c +0 -0
index 171c60238f..c4b8ee7d07 100644
@@ -2846,7 +2846,7 @@ static const char *csr_name(int csrno)


 /* decode opcode */

disas/riscv.c +1 -1
-static void decode_inst_opcode(rv_decode *dec, rv_isa isa)
+static const rv_opcode_data *decode_inst_opcode(rv_decode *dec,

rv_isa isa)
 {
     rv_inst inst = dec->inst;
     rv_opcode op = rv_op_illegal;

disas/riscv.c +0 -0
@@ -4541,8 +4541,7 @@ static void decode_inst_opcode(rv_decode *dec,
 rv_isa isa)
          break;
      }


-    dec->opcode_data = rvi_opcode_data;
-    dec->op = op;
+    return op == rv_op_illegal ? NULL : &rvi_opcode_data[op]; }

 /* decode operands */

disas/riscv.c +1 -1
@@ -5291,14 +5290,12 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,
          .inst = inst,
          .cfg = cfg,
      };
-    const rv_opcode_data *op;
+    const rv_opcode_data *op = decode_inst_opcode(&dec, isa);


-    decode_inst_opcode(&dec, isa);
-
-    if (dec.op == rv_op_illegal && cfg) {
+    if (!op && cfg) {
         static const struct {
             bool (*guard_func)(const RISCVCPUConfig *); -            void (*decode_func)(rv_decode *, rv_isa); +            const rv_opcode_data *(*decode_func)(rv_decode *, rv_isa);
         } decoders[] = {
             { has_xtheadba_p, decode_xtheadba },
             { has_xtheadbb_p, decode_xtheadbb },

disas/riscv.c +0 -0
@@ -5317,19 +5314,17 @@ static GString *disasm_inst(rv_isa isa,
 uint64_t pc, rv_inst inst,


         for (size_t i = 0; i < ARRAY_SIZE(decoders); i++) { if (decoders[i].guard_func(cfg)) {
-                decoders[i].decode_func(&dec, isa); -                if (dec.op != rv_op_illegal) {
+                op = decoders[i].decode_func(&dec, isa); +                if (op) {
                     break;
                 }
             }
         }
     }
-
-    if (dec.op == rv_op_illegal) {
-        dec.opcode_data = rvi_opcode_data;
+    if (!op) {
+        op = &rvi_opcode_data[rv_op_illegal];
     }

-    op = &dec.opcode_data[dec.op]; decode_inst_operands(&dec, isa, op);
     op = decode_inst_lift_pseudo(&dec, op); return format_inst(24, &dec, op);

#86 lore raw

PATCH 41/56 disas/riscv: Reject all of OP-32 and OP-IMM-32 for RV32

In reply to Richard Henderson

These entire base opcodes are RV64. Reject them all at once rather than one at a time.

---
 disas/riscv.c | 8 ++++++++
 1 file changed, 8 insertions(+)
disas/riscv.c +8 -0
index c4b8ee7d07..f51d45674e 100644
@@ -3311,6 +3311,10 @@ static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
             }
             break;
         case 6:
+            /* OP-IMM-32 */
+            if (isa == rv32) {
+                break;
+            }
             switch ((inst >> 12) & 0b111) {
             case 0: op = rv_op_addiw; break;
             case 1:
@@ -3557,6 +3561,10 @@ static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
             break;
         case 13: op = rv_op_lui; break;
         case 14:
+            /* OP-32 */
+            if (isa == rv32) {
+                break;
+            }
             switch (((inst >> 22) & 0b1111111000) |
                     ((inst >> 12) & 0b0000000111)) {
             case 0: op = rv_op_addw; break;
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 41/56
#87 lore raw

Re: [PATCH 41/56] disas/riscv: Reject all of OP-32 and OP-IMM-32 for RV32

Quoted 4 lines · Richard Henderson

These entire base opcodes are RV64.  Reject them all at once rather than one at a time.

Alistair

Quoted 32 lines

---
 disas/riscv.c | 8 ++++++++

 1 file changed, 8 insertions(+)
disas/riscv.c +0 -0
index c4b8ee7d07..f51d45674e 100644
@@ -3311,6 +3311,10 @@ static const rv_opcode_data
 *decode_inst_opcode(rv_decode *dec, rv_isa isa)
              }
              break;

         case 6:
+            /* OP-IMM-32 */
+            if (isa == rv32) {
+                break;
+            }
             switch ((inst >> 12) & 0b111) {
             case 0: op = rv_op_addiw; break;
             case 1:

disas/riscv.c +0 -0
@@ -3557,6 +3561,10 @@ static const rv_opcode_data
 *decode_inst_opcode(rv_decode *dec, rv_isa isa)
              break;
          case 13: op = rv_op_lui; break;

         case 14:
+            /* OP-32 */
+            if (isa == rv32) {
+                break;
+            }
             switch (((inst >> 22) & 0b1111111000) | ((inst >> 12) & 0b0000000111)) { case 0: op = rv_op_addw; break;

#88 lore raw

PATCH 42/56 disas/riscv: Fix rv32 encoding of zext.h

In reply to Richard Henderson

For rv64, pack with rs2 = 0 does not encode zext.h.

Fixes 02c1b569a15 ("disas/riscv: Add Zb[abcs] instructions")
---
 disas/riscv.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
disas/riscv.c +4 -3
index f51d45674e..9442a6c115 100644
@@ -3506,9 +3506,10 @@ static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
             case 14: op = rv_op_rem; break;
             case 15: op = rv_op_remu; break;
             case 36:
-                switch ((inst >> 20) & 0b11111) {
-                case 0: op = rv_op_zext_h; break;
-                default: op = rv_op_pack; break;
+                if (isa == rv32 && !((inst >> 20) & 0b11111)) {
+                    op = rv_op_zext_h;
+                } else {
+                    op = rv_op_pack;
                 }
                 break;
             case 39: op = rv_op_packh; break;
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 42/56
#89 lore raw

Re: [PATCH 42/56] disas/riscv: Fix rv32 encoding of zext.h

Quoted 5 lines · Richard Henderson

For rv64, pack with rs2 = 0 does not encode zext.h.

Fixes 02c1b569a15 ("disas/riscv: Add Zb[abcs] instructions")

Alistair

Quoted 23 lines

---
 disas/riscv.c | 7 ++++---

 1 file changed, 4 insertions(+), 3 deletions(-)
disas/riscv.c +0 -0
index f51d45674e..9442a6c115 100644
@@ -3506,9 +3506,10 @@ static const rv_opcode_data
 *decode_inst_opcode(rv_decode *dec, rv_isa isa)
              case 14: op = rv_op_rem; break;
              case 15: op = rv_op_remu; break;

             case 36:
-                switch ((inst >> 20) & 0b11111) {
-                case 0: op = rv_op_zext_h; break;
-                default: op = rv_op_pack; break;
+                if (isa == rv32 && !((inst >> 20) & 0b11111)) { +                    op = rv_op_zext_h;
+                } else {
+                    op = rv_op_pack;
                 }
                 break;
             case 39: op = rv_op_packh; break;

#90 lore raw

PATCH 43/56 disas/riscv: Fix isa decoding of rev8

In reply to Richard Henderson

The encoding of rev8 is different for rv32 and rv64.

Fixes 02c1b569a15 ("disas/riscv: Add Zb[abcs] instructions")
---
 disas/riscv.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
disas/riscv.c +10 -2
index 9442a6c115..4141741d79 100644
@@ -3292,8 +3292,16 @@ static const rv_opcode_data *decode_inst_opcode(rv_decode *dec, rv_isa isa)
                 case 0b01100: op = rv_op_rori; break;
                 case 0b01101:
                     switch ((inst >> 20) & 0b1111111) {
-                    case 0b0011000: op = rv_op_rev8; break;
-                    case 0b0111000: op = rv_op_rev8; break;
+                    case 0b0011000:
+                        if (isa == rv32) {
+                            op = rv_op_rev8;
+                        }
+                        break;
+                    case 0b0111000:
+                        if (isa == rv64) {
+                            op = rv_op_rev8;
+                        }
+                        break;
                     case 0b0000111: op = rv_op_brev8; break;
                     }
                     break;
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 43/56
#91 lore raw

Re: [PATCH 43/56] disas/riscv: Fix isa decoding of rev8

Quoted 5 lines · Richard Henderson

The encoding of rev8 is different for rv32 and rv64.

Fixes 02c1b569a15 ("disas/riscv: Add Zb[abcs] instructions")

Alistair

Quoted 28 lines

---
 disas/riscv.c | 12 ++++++++++--

 1 file changed, 10 insertions(+), 2 deletions(-)
disas/riscv.c +0 -0
index 9442a6c115..4141741d79 100644
@@ -3292,8 +3292,16 @@ static const rv_opcode_data
 *decode_inst_opcode(rv_decode *dec, rv_isa isa)
                  case 0b01100: op = rv_op_rori; break;

                 case 0b01101:
                     switch ((inst >> 20) & 0b1111111) { -                    case 0b0011000: op = rv_op_rev8; break; -                    case 0b0111000: op = rv_op_rev8; break; +                    case 0b0011000:
+                        if (isa == rv32) {
+                            op = rv_op_rev8;
+                        }
+                        break;
+                    case 0b0111000:
+                        if (isa == rv64) {
+                            op = rv_op_rev8;
+                        }
+                        break;
                     case 0b0000111: op = rv_op_brev8; break; }
                     break;

#92 lore raw

PATCH 44/56 disas/riscv: Fix typo in th.lbib format

In reply to Richard Henderson

th.lbib should format the same as th.lbia, and the other increment insns, with the address register in parenthesis.

Fixes 318df7238b9 ("disas/riscv: Add support for XThead* instructions")
---
 disas/riscv-xthead.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
disas/riscv-xthead.c +1 -1
index 428a6380e9..fbc96631fd 100644
@@ -189,7 +189,7 @@ static const rv_opcode_data xthead_opcode_data[] = {
     { "th.mulsh", rv_codec_r, rv_fmt_rd_rs1_rs2 },
     /* XTheadMemIdx */
     { "th.lbia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
-    { "th.lbib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml },
+    { "th.lbib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
     { "th.lbuia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
     { "th.lbuib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
     { "th.lhia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 44/56
#93 lore raw

Re: [PATCH 44/56] disas/riscv: Fix typo in th.lbib format

Quoted 7 lines · Richard Henderson

th.lbib should format the same as th.lbia, and the other increment insns, with the address register in parenthesis.

Fixes 318df7238b9 ("disas/riscv: Add support for XThead*

instructions")

Alistair

Quoted 23 lines

---
 disas/riscv-xthead.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
disas/riscv-xthead.c +0 -0
index 428a6380e9..fbc96631fd 100644
@@ -189,7 +189,7 @@ static const rv_opcode_data xthead_opcode_data[]
 = {
      { "th.mulsh", rv_codec_r, rv_fmt_rd_rs1_rs2 },
      /* XTheadMemIdx */

     { "th.lbia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
-    { "th.lbib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml }, +    { "th.lbib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
     { "th.lbuia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
     { "th.lbuib", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },
     { "th.lhia", rv_codec_r2_imm2_imm5, rv_fmt_rd_rs1_immh_imml_addr },

#94 lore raw

PATCH 45/56 disas/riscv: Split ventana_opcode_data

In reply to Richard Henderson

Move the table to riscv-xventana-op.c.inc and massage the lines into OP() form. Drop vt.illegal as unused. Return pointers to objects directly.

---
 disas/riscv-xventana.c        | 21 ++++++---------------
 disas/riscv-xventana-op.c.inc |  2 ++
 2 files changed, 8 insertions(+), 15 deletions(-)
 create mode 100644 disas/riscv-xventana-op.c.inc
disas/riscv-xventana.c +6 -15
index a4e59312d0..5d2e07865f 100644
@@ -8,35 +8,26 @@
 #include "disas/riscv.h"
 #include "disas/riscv-xventana.h"
 
-typedef enum {
-    /* 0 is reserved for rv_op_illegal. */
-    ventana_op_vt_maskc = 1,
-    ventana_op_vt_maskcn = 2,
-} rv_ventana_op;
-
-static const rv_opcode_data ventana_opcode_data[] = {
-    { "vt.illegal", rv_codec_illegal, rv_fmt_none },
-    { "vt.maskc", rv_codec_r, rv_fmt_rd_rs1_rs2 },
-    { "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2 },
-};
+#define OP(N, ...) static const rv_opcode_data op_##N = { __VA_ARGS__ };
+#include "riscv-xventana-op.c.inc"
+#undef OP
 
 const rv_opcode_data *decode_xventanacondops(rv_decode *dec, rv_isa isa)
 {
     rv_inst inst = dec->inst;
-    rv_opcode op = rv_op_illegal;
 
     switch (((inst >> 0) & 0b11)) {
     case 3:
         switch (((inst >> 2) & 0b11111)) {
         case 30:
             switch (((inst >> 22) & 0b1111111000) | ((inst >> 12) & 0b0000000111)) {
-            case 6: op = ventana_op_vt_maskc; break;
-            case 7: op = ventana_op_vt_maskcn; break;
+            case 6: return &op_vt_maskc;
+            case 7: return &op_vt_maskcn;
             }
             break;
         }
         break;
     }
 
-    return op == rv_op_illegal ? NULL : &ventana_opcode_data[op];
+    return NULL;
 }
disas/riscv-xventana-op.c.inc new file +2 -0
new file mode 100644
index 0000000000..0fe4666aee
@@ -0,0 +1,2 @@
+OP(vt_maskc, "vt.maskc", rv_codec_r, rv_fmt_rd_rs1_rs2)
+OP(vt_maskcn, "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2)
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 45/56
#95 lore raw

Re: [PATCH 45/56] disas/riscv: Split ventana_opcode_data

Quoted 5 lines · Richard Henderson

Move the table to riscv-xventana-op.c.inc and massage the lines into OP() form.  Drop vt.illegal as unused. Return pointers to objects directly.

Alistair

Quoted 64 lines

---
 disas/riscv-xventana.c        | 21 ++++++--------------- disas/riscv-xventana-op.c.inc |  2 ++

 2 files changed, 8 insertions(+), 15 deletions(-)

 create mode 100644 disas/riscv-xventana-op.c.inc

disas/riscv-xventana.c +0 -0
index a4e59312d0..5d2e07865f 100644
@@ -8,35 +8,26 @@
  #include "disas/riscv.h"
  #include "disas/riscv-xventana.h"

disas/riscv-xventana.c +1 -11
-typedef enum {
-    /* 0 is reserved for rv_op_illegal. */
-    ventana_op_vt_maskc = 1,
-    ventana_op_vt_maskcn = 2,
-} rv_ventana_op;
-
-static const rv_opcode_data ventana_opcode_data[] = {
-    { "vt.illegal", rv_codec_illegal, rv_fmt_none },
-    { "vt.maskc", rv_codec_r, rv_fmt_rd_rs1_rs2 },
-    { "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2 },
-};
+#define OP(N, ...) static const rv_opcode_data op_##N = {

__VA_ARGS__ };

disas/riscv-xventana.c +2 -0
+#include "riscv-xventana-op.c.inc"
+#undef OP


 const rv_opcode_data *decode_xventanacondops(rv_decode *dec, rv_isa isa)
 {
     rv_inst inst = dec->inst;
-    rv_opcode op = rv_op_illegal;

     switch (((inst >> 0) & 0b11)) {
     case 3:
         switch (((inst >> 2) & 0b11111)) {
         case 30:
             switch (((inst >> 22) & 0b1111111000) | ((inst >> 12) & 0b0000000111)) {
-            case 6: op = ventana_op_vt_maskc; break;
-            case 7: op = ventana_op_vt_maskcn; break;
+            case 6: return &op_vt_maskc;
+            case 7: return &op_vt_maskcn;
             }
             break;
         }
         break;
     }

-    return op == rv_op_illegal ? NULL : &ventana_opcode_data[op]; +    return NULL;
 }

disas/riscv-xventana- renamed from disas/riscv-xventana-op.c.inc +0 -0

op.c.inc
new file mode 100644
index 0000000000..0fe4666aee

disas/riscv-xventana-op.c.inc new file +2 -0
@@ -0,0 +1,2 @@
+OP(vt_maskc, "vt.maskc", rv_codec_r, rv_fmt_rd_rs1_rs2)
+OP(vt_maskcn, "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2)
#96 lore raw

PATCH 46/56 disas/riscv: Split xlrbr_opcode_data

In reply to Richard Henderson

Move the table to riscv-xlrbr-op.c.inc and massage the lines into OP() form. Drop illegal as unused. Return pointers to objects directly.

---
 disas/riscv-xlrbr.c        | 54 +++++++++-----------------------------
 disas/riscv-xlrbr-op.c.inc |  8 ++++++
 2 files changed, 20 insertions(+), 42 deletions(-)
 create mode 100644 disas/riscv-xlrbr-op.c.inc
disas/riscv-xlrbr.c +12 -42
index b12916c9da..b4229e5c83 100644
@@ -8,38 +8,16 @@
  */
 
 #include "qemu/osdep.h"
-
 #include "disas/riscv.h"
 #include "disas/riscv-xlrbr.h"
 
-typedef enum {
-    /* 0 is reserved for rv_op_illegal. */
-    rv_op_crc32_b = 1,
-    rv_op_crc32_h = 2,
-    rv_op_crc32_w = 3,
-    rv_op_crc32_d = 4,
-    rv_op_crc32c_b = 5,
-    rv_op_crc32c_h = 6,
-    rv_op_crc32c_w = 7,
-    rv_op_crc32c_d = 8,
-} rv_xlrbr_op;
-
-static const rv_opcode_data xlrbr_opcode_data[] = {
-    { "illegal", rv_codec_illegal, rv_fmt_none },
-    { "crc32.b", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32.h", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32.w", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32.d", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32c.b", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32c.h", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32c.w", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32c.d", rv_codec_r, rv_fmt_rd_rs1 },
-};
+#define OP(N, ...) static const rv_opcode_data op_##N = { __VA_ARGS__ };
+#include "riscv-xlrbr-op.c.inc"
+#undef OP
 
 const rv_opcode_data *decode_xlrbr(rv_decode *dec, rv_isa isa)
 {
     rv_inst inst = dec->inst;
-    rv_opcode op = rv_op_illegal;
 
     switch ((inst >> 0) & 0b1111111) {
     case 0b0010011:
@@ -47,34 +25,26 @@ const rv_opcode_data *decode_xlrbr(rv_decode *dec, rv_isa isa)
         case 0b001:
             switch ((inst >> 20 & 0b111111111111)) {
             case 0b011000010000:
-                op = rv_op_crc32_b;
-                break;
+                return &op_crc32_b;
             case 0b011000010001:
-                op = rv_op_crc32_h;
-                break;
+                return &op_crc32_h;
             case 0b011000010010:
-                op = rv_op_crc32_w;
-                break;
+                return &op_crc32_w;
             case 0b011000010011:
-                op = rv_op_crc32_d;
-                break;
+                return &op_crc32_d;
             case 0b011000011000:
-                op = rv_op_crc32c_b;
-                break;
+                return &op_crc32c_b;
             case 0b011000011001:
-                op = rv_op_crc32c_h;
-                break;
+                return &op_crc32c_h;
             case 0b011000011010:
-                op = rv_op_crc32c_w;
-                break;
+                return &op_crc32c_w;
             case 0b011000011011:
-                op = rv_op_crc32c_d;
-                break;
+                return &op_crc32c_d;
             }
             break;
         }
         break;
     }
 
-    return op == rv_op_illegal ? NULL : &xlrbr_opcode_data[op];
+    return NULL;
 }
disas/riscv-xlrbr-op.c.inc new file +8 -0
new file mode 100644
index 0000000000..57add37c24
@@ -0,0 +1,8 @@
+OP(crc32_b, "crc32.b", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32_h, "crc32.h", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32_w, "crc32.w", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32_d, "crc32.d", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32c_b, "crc32c.b", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32c_h, "crc32c.h", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32c_w, "crc32c.w", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32c_d, "crc32c.d", rv_codec_r, rv_fmt_rd_rs1)
Signature · 1 line
2.43.0
Reviewed-by Alistair Francis on v1 46/56
#97 lore raw

Re: [PATCH 46/56] disas/riscv: Split xlrbr_opcode_data

Quoted 5 lines · Richard Henderson

Move the table to riscv-xlrbr-op.c.inc and massage the lines into OP() form.  Drop illegal as unused. Return pointers to objects directly.

Alistair

Quoted 113 lines

---
 disas/riscv-xlrbr.c        | 54 +++++++++--------------------------- --
 disas/riscv-xlrbr-op.c.inc |  8 ++++++

 2 files changed, 20 insertions(+), 42 deletions(-)

 create mode 100644 disas/riscv-xlrbr-op.c.inc

disas/riscv-xlrbr.c +0 -0
index b12916c9da..b4229e5c83 100644
@@ -8,38 +8,16 @@
   */


 #include "qemu/osdep.h"
-
 #include "disas/riscv.h"
 #include "disas/riscv-xlrbr.h"

disas/riscv-xlrbr.c +1 -23
-typedef enum {
-    /* 0 is reserved for rv_op_illegal. */
-    rv_op_crc32_b = 1,
-    rv_op_crc32_h = 2,
-    rv_op_crc32_w = 3,
-    rv_op_crc32_d = 4,
-    rv_op_crc32c_b = 5,
-    rv_op_crc32c_h = 6,
-    rv_op_crc32c_w = 7,
-    rv_op_crc32c_d = 8,
-} rv_xlrbr_op;
-
-static const rv_opcode_data xlrbr_opcode_data[] = {
-    { "illegal", rv_codec_illegal, rv_fmt_none },
-    { "crc32.b", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32.h", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32.w", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32.d", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32c.b", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32c.h", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32c.w", rv_codec_r, rv_fmt_rd_rs1 },
-    { "crc32c.d", rv_codec_r, rv_fmt_rd_rs1 },
-};
+#define OP(N, ...) static const rv_opcode_data op_##N = {

__VA_ARGS__ };

disas/riscv-xlrbr.c +2 -0
+#include "riscv-xlrbr-op.c.inc"
+#undef OP


 const rv_opcode_data *decode_xlrbr(rv_decode *dec, rv_isa isa) {
     rv_inst inst = dec->inst;
-    rv_opcode op = rv_op_illegal;

     switch ((inst >> 0) & 0b1111111) {
     case 0b0010011:

disas/riscv-xlrbr.c +0 -0
@@ -47,34 +25,26 @@ const rv_opcode_data *decode_xlrbr(rv_decode
 *dec, rv_isa isa)

         case 0b001:
             switch ((inst >> 20 & 0b111111111111)) { case 0b011000010000:
-                op = rv_op_crc32_b;
-                break;
+                return &op_crc32_b;
             case 0b011000010001:
-                op = rv_op_crc32_h;
-                break;
+                return &op_crc32_h;
             case 0b011000010010:
-                op = rv_op_crc32_w;
-                break;
+                return &op_crc32_w;
             case 0b011000010011:
-                op = rv_op_crc32_d;
-                break;
+                return &op_crc32_d;
             case 0b011000011000:
-                op = rv_op_crc32c_b;
-                break;
+                return &op_crc32c_b;
             case 0b011000011001:
-                op = rv_op_crc32c_h;
-                break;
+                return &op_crc32c_h;
             case 0b011000011010:
-                op = rv_op_crc32c_w;
-                break;
+                return &op_crc32c_w;
             case 0b011000011011:
-                op = rv_op_crc32c_d;
-                break;
+                return &op_crc32c_d;
             }
             break;
         }
         break;
     }

-    return op == rv_op_illegal ? NULL : &xlrbr_opcode_data[op]; +    return NULL;
 }

disas/riscv-xlrbr-op.c.inc new file +8 -0
new file mode 100644
index 0000000000..57add37c24
@@ -0,0 +1,8 @@
+OP(crc32_b, "crc32.b", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32_h, "crc32.h", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32_w, "crc32.w", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32_d, "crc32.d", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32c_b, "crc32c.b", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32c_h, "crc32c.h", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32c_w, "crc32c.w", rv_codec_r, rv_fmt_rd_rs1)
+OP(crc32c_d, "crc32c.d", rv_codec_r, rv_fmt_rd_rs1)