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

Alistair <[email protected]>
Newsgroups org.nongnu.qemu-riscv,org.nongnu.qemu-devel
Message-ID <[email protected]>
On Sun, 2026-08-09 at 15:35 -0700, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <[email protected]>

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

Alistair

> ---
>  disas/riscv.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/disas/riscv.c b/disas/riscv.c
> index 7978ffb378..d6fbb3bca6 100644
> --- a/disas/riscv.c
> +++ b/disas/riscv.c
> @@ -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:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.