All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org
Subject: [RFC PATCH 00/56] disas/riscv: Reorganize the disassembler
Date: Sun,  9 Aug 2026 15:34:49 -0700	[thread overview]
Message-ID: <20260809223545.730664-1-richard.henderson@linaro.org> (raw)

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

-- 
2.43.0



             reply	other threads:[~2026-08-09 22:41 UTC|newest]

Thread overview: 119+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-09 22:34 Richard Henderson [this message]
2026-08-09 22:34 ` [PATCH 01/56] disas/riscv: Fix th.srri decoding Richard Henderson
2026-08-11 19:54   ` Alistair
2026-08-09 22:34 ` [PATCH 02/56] disas/riscv: Fix 6-bit immediate extraction Richard Henderson
2026-08-11 19:55   ` Alistair
2026-08-09 22:34 ` [PATCH 03/56] disas/riscv: Use signed type for vector immediates Richard Henderson
2026-08-10  2:53   ` Philippe Mathieu-Daudé
2026-08-11 19:56   ` Alistair
2026-08-09 22:34 ` [PATCH 04/56] disas/riscv: Decode unsigned vector immediates as unsigned Richard Henderson
2026-08-11 19:57   ` Alistair
2026-08-09 22:34 ` [PATCH 05/56] disas/riscv: Use extract helpers for operand fields Richard Henderson
2026-08-11 19:58   ` Alistair
2026-08-09 22:34 ` [PATCH 06/56] disas/riscv: Move operand extractors earlier in file Richard Henderson
2026-08-11 19:59   ` Alistair
2026-08-09 22:34 ` [PATCH 07/56] disas/riscv: Reduce rv_insn to uint32_t Richard Henderson
2026-08-10  2:54   ` Philippe Mathieu-Daudé
2026-08-11 19:59   ` Alistair
2026-08-09 22:34 ` [PATCH 08/56] disas/riscv: Tidy dec initialization in disasm_inst Richard Henderson
2026-08-10  2:54   ` Philippe Mathieu-Daudé
2026-08-11 20:00   ` Alistair
2026-08-09 22:34 ` [PATCH 09/56] disas/riscv: Pass rv_opcode_data pointer to decode_inst_operands Richard Henderson
2026-08-11 20:02   ` Alistair
2026-08-09 22:34 ` [PATCH 10/56] disas/riscv: Pass rv_opcode_data pointer to/from decode_inst_decompress Richard Henderson
2026-08-11 20:04   ` Alistair
2026-08-09 22:35 ` [PATCH 11/56] disas/riscv: Pass rv_opcode_data pointer to/from decode_inst_lift_pseudo Richard Henderson
2026-08-11 20:05   ` Alistair
2026-08-09 22:35 ` [PATCH 12/56] disas/riscv: Pass rv_opcode_data pointer to format_inst Richard Henderson
2026-08-11 20:06   ` Alistair
2026-08-09 22:35 ` [PATCH 13/56] disas/riscv: Tidy disasm_inst main loop Richard Henderson
2026-08-11 20:08   ` Alistair
2026-08-09 22:35 ` [PATCH 14/56] disas/riscv: Set dec->opcode_data in decode function Richard Henderson
2026-08-11 20:09   ` Alistair
2026-08-09 22:35 ` [PATCH 15/56] disas/riscv: Drop explicit zero of rv_opcode_data fields Richard Henderson
2026-08-11 20:10   ` Alistair
2026-08-09 22:35 ` [PATCH 16/56] disas/riscv: Drop useless const in structures Richard Henderson
2026-08-10  2:55   ` Philippe Mathieu-Daudé
2026-08-11 20:10   ` Alistair
2026-08-09 22:35 ` [PATCH 17/56] disas/riscv: Drop codec from rv_decode Richard Henderson
2026-08-11 20:11   ` Alistair
2026-08-09 22:35 ` [PATCH 18/56] disas/riscv: Handle c.addi4spn imm != 0 during decode Richard Henderson
2026-08-11 20:12   ` Alistair
2026-08-09 22:35 ` [PATCH 19/56] disas/riscv: Simplify c.addi Richard Henderson
2026-08-11 20:14   ` Alistair
2026-08-09 22:35 ` [PATCH 20/56] disas/riscv: Handle c.lui imm != 0 during decode Richard Henderson
2026-08-11 20:14   ` Alistair
2026-08-09 22:35 ` [PATCH 21/56] disas/riscv: Handle c.{srli,srai} imm " Richard Henderson
2026-08-11 20:16   ` Alistair
2026-08-09 22:35 ` [PATCH 22/56] disas/riscv: Handle c.slli imm != 0 " Richard Henderson
2026-08-11 20:16   ` Alistair
2026-08-09 22:35 ` [PATCH 23/56] disas/riscv: Do not recognize c.{addw,subw} with rv32 Richard Henderson
2026-08-11 20:17   ` Alistair
2026-08-09 22:35 ` [PATCH 24/56] disas/riscv: Remove rvcd_imm_nz Richard Henderson
2026-08-11 20:17   ` Alistair
2026-08-09 22:35 ` [PATCH 25/56] disas/riscv: Unify decomp_rv{32,64,128} Richard Henderson
2026-08-11 20:18   ` Alistair
2026-08-09 22:35 ` [PATCH 26/56] disas/riscv: Drop always true branch psudeos Richard Henderson
2026-08-10  2:58   ` Philippe Mathieu-Daudé
2026-08-11 20:19   ` Alistair
2026-08-09 22:35 ` [PATCH 27/56] disas/riscv: Handle aliases of csrrw during decode Richard Henderson
2026-08-11 20:20   ` Alistair
2026-08-09 22:35 ` [PATCH 28/56] disas/riscv: Handle aliases of csrrs " Richard Henderson
2026-08-11 20:21   ` Alistair
2026-08-09 22:35 ` [PATCH 29/56] disas/riscv: Handle aliases of csrrwi " Richard Henderson
2026-08-11 20:22   ` Alistair
2026-08-09 22:35 ` [PATCH 30/56] disas/riscv: Break pseudo loop for jal and jalr Richard Henderson
2026-08-11 20:23   ` Alistair
2026-08-09 22:35 ` [PATCH 31/56] disas/riscv: Allow decode_inst_lift_pseudo to loop Richard Henderson
2026-08-11 20:23   ` Alistair
2026-08-09 22:35 ` [PATCH 32/56] disas/riscv: Handle decompression via decode_inst_lift_pseudo Richard Henderson
2026-08-11 20:24   ` Alistair
2026-08-09 22:35 ` [PATCH 33/56] disas/riscv: Drop format from DECOMP insns Richard Henderson
2026-08-11 20:25   ` Alistair
2026-08-09 22:35 ` [PATCH 34/56] disas/riscv: Tidy rv_comp_data terminators Richard Henderson
2026-08-11 20:25   ` Alistair
2026-08-09 22:35 ` [PATCH 35/56] disas/riscv: Chain "ret" pseudo off "jr" pseudo Richard Henderson
2026-08-11 20:26   ` Alistair
2026-08-09 22:35 ` [PATCH 36/56] disas/riscv: Chain "nop" pseudo off "mv" pseudo Richard Henderson
2026-08-11 20:27   ` Alistair
2026-08-09 22:35 ` [PATCH 37/56] disas/riscv: Use rv_codec_illegal for pseudos Richard Henderson
2026-08-11 20:27   ` Alistair
2026-08-09 22:35 ` [PATCH 38/56] disas/riscv: Simplify some insn decompressions Richard Henderson
2026-08-11 20:29   ` Alistair
2026-08-09 22:35 ` [PATCH 39/56] disas/riscv: Store op pointer in rv_comp_data Richard Henderson
2026-08-12 12:47   ` Alistair
2026-08-09 22:35 ` [PATCH 40/56] disas/riscv: Return rv_opcode_data pointer from decoders Richard Henderson
2026-08-12 12:48   ` Alistair
2026-08-09 22:35 ` [PATCH 41/56] disas/riscv: Reject all of OP-32 and OP-IMM-32 for RV32 Richard Henderson
2026-08-12 12:49   ` Alistair
2026-08-09 22:35 ` [PATCH 42/56] disas/riscv: Fix rv32 encoding of zext.h Richard Henderson
2026-08-12 12:49   ` Alistair
2026-08-09 22:35 ` [PATCH 43/56] disas/riscv: Fix isa decoding of rev8 Richard Henderson
2026-08-12 12:50   ` Alistair
2026-08-09 22:35 ` [PATCH 44/56] disas/riscv: Fix typo in th.lbib format Richard Henderson
2026-08-12 12:50   ` Alistair
2026-08-09 22:35 ` [PATCH 45/56] disas/riscv: Split ventana_opcode_data Richard Henderson
2026-08-12 12:51   ` Alistair
2026-08-09 22:35 ` [PATCH 46/56] disas/riscv: Split xlrbr_opcode_data Richard Henderson
2026-08-12 12:52   ` Alistair
2026-08-09 22:35 ` [PATCH 47/56] disas/riscv: Split xthead_opcode_data Richard Henderson
2026-08-12 12:53   ` Alistair
2026-08-09 22:35 ` [PATCH 48/56] disas/riscv: Move rv_op_illegal to riscv.c Richard Henderson
2026-08-12 12:54   ` Alistair
2026-08-09 22:35 ` [PATCH 49/56] disas/riscv: Split out riscv-op.c.inc Richard Henderson
2026-08-12 12:55   ` Alistair
2026-08-09 22:35 ` [PATCH 50/56] disas/riscv: Merge all mop.r.n to one pattern Richard Henderson
2026-08-12 12:57   ` Alistair
2026-08-09 22:35 ` [PATCH 51/56] disas/riscv: Merge all mop.rr.n " Richard Henderson
2026-08-12 12:57   ` Alistair
2026-08-09 22:35 ` [PATCH 52/56] disas/riscv: Merge all c.mop.n " Richard Henderson
2026-08-12 12:58   ` Alistair
2026-08-09 22:35 ` [PATCH 53/56] disas/riscv: Tidy decode of c.mop.n Richard Henderson
2026-08-12 12:59   ` Alistair
2026-08-09 22:35 ` [PATCH 54/56] disas/riscv: Tidy decode of mop.r.n and mop.rr.n Richard Henderson
2026-08-12 13:00   ` Alistair
2026-08-09 22:35 ` [PATCH 55/56] disas/riscv: Split rvi_opcode_data Richard Henderson
2026-08-12 13:02   ` Alistair
2026-08-09 22:35 ` [PATCH 56/56] disas/riscv: Sort riscv-op.c.inc Richard Henderson
2026-08-10  2:59   ` Philippe Mathieu-Daudé
2026-08-12 13:03   ` Alistair

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260809223545.730664-1-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.