diff options
author | Sergei Barannikov <barannikov88@gmail.com> | 2025-09-22 20:50:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-22 20:50:17 +0300 |
commit | 6a43c669d17ca6f47beda6c5b2428eb34a24fa4f (patch) | |
tree | c175b0b65e73d998eb9a7086c50a4c746c151726 /llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp | |
parent | 19935ea2239bbda7a1c88f70e8bd365be8685328 (diff) | |
download | llvm-6a43c669d17ca6f47beda6c5b2428eb34a24fa4f.zip llvm-6a43c669d17ca6f47beda6c5b2428eb34a24fa4f.tar.gz llvm-6a43c669d17ca6f47beda6c5b2428eb34a24fa4f.tar.bz2 |
[TableGen][DecoderEmitter][RISCV] Always handle `bits<0>` (#159951)
Previously, `bits<0>` only had effect if `ignore-non-decodable-operands`
wasn't specified. Handle it even if the option was specified. This
should allow for a smoother transition to the option removed.
The change revealed a couple of inaccuracies in RISCV compressed
instruction definitions.
* `C_ADDI4SPN` has `bits<5> rs1` field, but `rs1` is not encoded. It
should be `bits<0>`.
* `C_ADDI16SP` has `bits<5> rd` in the base class, but it is unused
since `Inst{11-7}` is overwritten with constant bits.
We should instead set `rd = 2` and `Inst{11-7} = rd`. There are a couple
of alternative fixes, but this one is the shortest.
Diffstat (limited to 'llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp')
-rw-r--r-- | llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp index ff07122..9f070fb2 100644 --- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -206,6 +206,14 @@ static DecodeStatus DecodeSPRegisterClass(MCInst &Inst, return MCDisassembler::Success; } +static DecodeStatus DecodeSPRegisterClass(MCInst &Inst, uint64_t RegNo, + uint32_t Address, + const MCDisassembler *Decoder) { + assert(RegNo == 2); + Inst.addOperand(MCOperand::createReg(RISCV::X2)); + return MCDisassembler::Success; +} + static DecodeStatus DecodeGPRX5RegisterClass(MCInst &Inst, const MCDisassembler *Decoder) { Inst.addOperand(MCOperand::createReg(RISCV::X5)); |