* [PATCH 0/1] RISC-V: Fix zip/unzip on disassembler @ 2022-06-03 12:04 Tsukasa OI 2022-06-03 12:04 ` [PATCH 1/1] RISC-V: Make zip/unzip on Zbkb non-aliases Tsukasa OI 0 siblings, 1 reply; 2+ messages in thread From: Tsukasa OI @ 2022-06-03 12:04 UTC (permalink / raw) To: Tsukasa OI, Kito Cheng, Palmer Dabbelt; +Cc: binutils Hello, I noticed another disassembler issue and this is a fix. 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 diassembler. With following assembler file with -march=rv32i_zbkb, _start: zip a0, a1 unzip a2, a3 The output with `objdump -d' is like this: 80000028 <_start>: 80000028: 08f59513 zip a0,a1 8000002c: 08f6d613 unzip a2,a3 However, output with `objdump -d -M no-aliases' looks like this: 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. When generalized shfli and unshfli instructions are ratified, the situation will be a bit different. As the same issue is already present on disassembling zext.h instruction on RV{32,64}_Zbb_Zbkb, this is to be fixed (but WITH ANOTHER PATCHSET I will submit later). Tsukasa OI (1): RISC-V: Make zip/unzip on Zbkb non-aliases opcodes/riscv-opc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) base-commit: 625b6eae091709b95471eae92d42dc6bc71e6553 -- 2.34.1 ^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/1] RISC-V: Make zip/unzip on Zbkb non-aliases 2022-06-03 12:04 [PATCH 0/1] RISC-V: Fix zip/unzip on disassembler Tsukasa OI @ 2022-06-03 12:04 ` Tsukasa OI 0 siblings, 0 replies; 2+ messages in thread From: Tsukasa OI @ 2022-06-03 12:04 UTC (permalink / raw) To: Tsukasa OI, Kito Cheng, Palmer Dabbelt; +Cc: binutils zip/unzip are specialized forms of shfli/unshfli instructions respectively. However, because both shfli and unshfli instructions are not ratified (in generalized forms), disassembling zip/unzip on RV32_Zbkb with `-M no-aliases' option makes disassembly dumps with .4byte (invalid instruction), not zip/unzip. This commit makes zip/unzip non-aliases until generalized forms of shfli and unshfli are ratified. opcodes/ChangeLog: * riscv-opc.c (riscv_opcodes): Make zip/unzip instructions on RV32_Zbkb non-aliases to fix a disassembler issue. --- opcodes/riscv-opc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c index 6355f8059f5..05079821fb7 100644 --- a/opcodes/riscv-opc.c +++ b/opcodes/riscv-opc.c @@ -942,8 +942,8 @@ const struct riscv_opcode riscv_opcodes[] = {"cpopw", 64, INSN_CLASS_ZBB, "d,s", MATCH_CPOPW, MASK_CPOPW, match_opcode, 0 }, {"brev8", 32, INSN_CLASS_ZBKB, "d,s", MATCH_GREVI | MATCH_SHAMT_BREV8, MASK_GREVI | MASK_SHAMT, match_opcode, 0 }, {"brev8", 64, INSN_CLASS_ZBKB, "d,s", MATCH_GREVI | MATCH_SHAMT_BREV8, MASK_GREVI | MASK_SHAMT, match_opcode, 0 }, -{"zip", 32, INSN_CLASS_ZBKB, "d,s", MATCH_SHFLI|MATCH_SHAMT_ZIP_32, MASK_SHFLI|MASK_SHAMT, match_opcode, INSN_ALIAS }, -{"unzip", 32, INSN_CLASS_ZBKB, "d,s", MATCH_UNSHFLI|MATCH_SHAMT_ZIP_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, INSN_ALIAS }, +{"zip", 32, INSN_CLASS_ZBKB, "d,s", MATCH_SHFLI|MATCH_SHAMT_ZIP_32, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 }, +{"unzip", 32, INSN_CLASS_ZBKB, "d,s", MATCH_UNSHFLI|MATCH_SHAMT_ZIP_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 }, {"pack", 0, INSN_CLASS_ZBKB, "d,s,t", MATCH_PACK, MASK_PACK, match_opcode, 0 }, {"packh", 0, INSN_CLASS_ZBKB, "d,s,t", MATCH_PACKH, MASK_PACKH, match_opcode, 0 }, {"packw", 64, INSN_CLASS_ZBKB, "d,s,t", MATCH_PACKW, MASK_PACKW, match_opcode, 0 }, -- 2.34.1 ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-03 12:04 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-06-03 12:04 [PATCH 0/1] RISC-V: Fix zip/unzip on disassembler Tsukasa OI 2022-06-03 12:04 ` [PATCH 1/1] RISC-V: Make zip/unzip on Zbkb non-aliases Tsukasa OI
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).