RISC-V disassembler correctly checks vector type extensions for altfmt disassembly
Fixes RISC-V disassembly to only show alternative format (altfmt) vector type names when supported extensions are advertised.
The RISC-V disassembler now correctly checks for supported vector type extensions before displaying alternative format (altfmt) names. This prevents the disassembler from showing altfmt encodings for instructions that are not supported by the target architecture’s extensions. The change ensures accurate disassembly output by only displaying these extended formats when the object file advertises the relevant extensions or when all extensions are explicitly enabled.
In Details
In opcodes/riscv-dis.c, the riscv_vtype_altfmt_supported function was added to print_insn_args to check if the RISC-V vector type alternative format (altfmt) should be printed. This function determines support by checking if the object file advertises the necessary extensions (like Zvlsseg, Zvlsmin, Zvlsmax, Zvf32 etc.) or if the disassembler is run with all extensions enabled. This ensures the disassembler output is consistent with the advertised capabilities of the code being disassembled.
- RISC-V
- A free and open Instruction Set Architecture (ISA) based on reduced instruction set computer principles. It is modular and extensible, with various standard and custom extensions.
- disassembler
- A tool that translates machine code (binary instructions) back into human-readable assembly language. In binutils, this functionality is primarily in the
objdumputility and within theopcodeslibrary. - altfmt
- Alternative format. In the context of RISC-V vector instructions, this refers to a specific way of encoding vector types or formats that may be part of certain extensions, providing different operand representations or capabilities.
- vector type extensions
- In RISC-V, these are optional extensions to the base integer ISA that add support for vector processing. Examples include
Zve64x,Zvlsseg,Zvf32, etc., which define specific instruction sets and data type handling for vector operations. - vtype
- Vector Type. In RISC-V vector processing, this specifies the data type and structure of the operands used in vector instructions.