Skip to content

riscv_dis_rv32_zip

Tsukasa OI edited this page Oct 3, 2022 · 2 revisions

Fix zip / unzip on disassembler

Issue Solved

zip and unzip are instructions from Zbkb extension (RV32 only).

They are, in fact, specialized forms of shfli and unshfli instructions, respectively. The problem now is, since generalized shfli and unshfli are not ratified and zip/unzip are defined as aliases (with INSN_ALIAS), it causes a problem on the disassembler.

With following assembler file with -march=rv32i_zbkb,

_start:
    zip   a0, a1
    unzip a2, a3

The output with objdump -d will look like:

80000028 <_start>:
80000028:   08f59513      zip     a0,a1
8000002c:   08f6d613      unzip   a2,a3

However, output of objdump -d -M no-aliases will look like:

80000028 <_start>:
80000028:   08f59513      .4byte  0x8f59513
8000002c:   08f6d613      .4byte  0x8f6d613

You can see that -M no-aliases option causes disassembler to ignore zip/unzip instructions but cannot find right non-alias instructions.

Until generalized shfli and unshfli instructions are ratified, my simple patch (which makes zip/unzip non-aliases) does the trick.

Clone this wiki locally