Skip to content

Commit 35f1966

Browse files
authored
[RISCV] Only disassemble fcvtmod.w.d if the rounding mode is rtz. (#111308)
If we disassemble other rounding modes, we'll print something that can't be parsed.
1 parent 8c15470 commit 35f1966

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,16 @@ static DecodeStatus decodeFRMArg(MCInst &Inst, uint32_t Imm, int64_t Address,
375375
return MCDisassembler::Success;
376376
}
377377

378+
static DecodeStatus decodeRTZArg(MCInst &Inst, uint32_t Imm, int64_t Address,
379+
const MCDisassembler *Decoder) {
380+
assert(isUInt<3>(Imm) && "Invalid immediate");
381+
if (Imm != RISCVFPRndMode::RTZ)
382+
return MCDisassembler::Fail;
383+
384+
Inst.addOperand(MCOperand::createImm(Imm));
385+
return MCDisassembler::Success;
386+
}
387+
378388
static DecodeStatus decodeRVCInstrRdRs1ImmZero(MCInst &Inst, uint32_t Insn,
379389
uint64_t Address,
380390
const MCDisassembler *Decoder);

llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def RTZArg : AsmOperandClass {
4747
def rtzarg : Operand<XLenVT> {
4848
let ParserMatchClass = RTZArg;
4949
let PrintMethod = "printFRMArg";
50-
let DecoderMethod = "decodeFRMArg";
50+
let DecoderMethod = "decodeRTZArg";
5151
}
5252

5353
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)