On Sun, 2026-08-09 at 15:35 -0700, Richard Henderson wrote:
> 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.
> 
> Signed-off-by: Richard Henderson <[email protected]>

Reviewed-by: Alistair Francis <[email protected]>

Alistair

> ---
>  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
> 
> diff --git a/disas/riscv-xventana.c b/disas/riscv-xventana.c
> index a4e59312d0..5d2e07865f 100644
> --- a/disas/riscv-xventana.c
> +++ b/disas/riscv-xventana.c
> @@ -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;
>  }
> diff --git a/disas/riscv-xventana-op.c.inc b/disas/riscv-xventana-
> op.c.inc
> new file mode 100644
> index 0000000000..0fe4666aee
> --- /dev/null
> +++ b/disas/riscv-xventana-op.c.inc
> @@ -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)

Reply via email to