riscv/disas: Fix disas output of upper immediates
authorChristoph Müllner <christoph.muellner@vrull.eu>
Tue, 11 Jul 2023 07:50:51 +0000 (09:50 +0200)
committerAlistair Francis <alistair.francis@wdc.com>
Wed, 19 Jul 2023 04:30:04 +0000 (14:30 +1000)
commit36df75a0a903c8ba3e2e28eb7162c43f8dd5d8f0
tree4e58974b0397360c4431bb7be6b81061f67b0c7f
parent542c8776cabd94c8afa0524e989bc26119b42d10
riscv/disas: Fix disas output of upper immediates

The GNU assembler produces the following output for instructions
with upper immediates:
    00002597                auipc   a1,0x2
    000024b7                lui     s1,0x2
    6409                    lui     s0,0x2 # c.lui

The immediate operands of upper immediates are not shifted.

However, the QEMU disassembler prints them shifted:
    00002597          auipc                   a1,8192
    000024b7          lui                     s1,8192
    6409              lui                     s0,8192 # c.lui

The current implementation extracts the immediate bits and shifts the by 12,
so the internal representation of the immediate is the actual immediate.
However, the immediates are later printed using rv_fmt_rd_imm or
rv_fmt_rd_offset, which don't undo the shift.

Let's fix this by using specific output formats for instructions
with upper immediates, that take care of the shift.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20230711075051.1531007-1-christoph.muellner@vrull.eu>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
disas/riscv.c
disas/riscv.h