Skip to content

Commit

Permalink
[RISCV] Only disassemble fcvtmod.w.d if the rounding mode is rtz. (#1…
Browse files Browse the repository at this point in the history
…11308)

If we disassemble other rounding modes, we'll print something that can't
be parsed.
  • Loading branch information
topperc authored Oct 7, 2024
1 parent 8c15470 commit 35f1966
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,16 @@ static DecodeStatus decodeFRMArg(MCInst &Inst, uint32_t Imm, int64_t Address,
return MCDisassembler::Success;
}

static DecodeStatus decodeRTZArg(MCInst &Inst, uint32_t Imm, int64_t Address,
const MCDisassembler *Decoder) {
assert(isUInt<3>(Imm) && "Invalid immediate");
if (Imm != RISCVFPRndMode::RTZ)
return MCDisassembler::Fail;

Inst.addOperand(MCOperand::createImm(Imm));
return MCDisassembler::Success;
}

static DecodeStatus decodeRVCInstrRdRs1ImmZero(MCInst &Inst, uint32_t Insn,
uint64_t Address,
const MCDisassembler *Decoder);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def RTZArg : AsmOperandClass {
def rtzarg : Operand<XLenVT> {
let ParserMatchClass = RTZArg;
let PrintMethod = "printFRMArg";
let DecoderMethod = "decodeFRMArg";
let DecoderMethod = "decodeRTZArg";
}

//===----------------------------------------------------------------------===//
Expand Down

0 comments on commit 35f1966

Please sign in to comment.