Skip to content

Commit

Permalink
[RISCV] Improve RISCVOperand Printing (llvm#126179)
Browse files Browse the repository at this point in the history
We've gradually added more information to the RISCVOperand structure,
but the debug output has never caught up, which is quite confusing. This
adds printing for many of additional the fields in the structure, where
they are relevant.

In addition to this, we now have quite a lot of internal registers which
share names with each other - e.g. X0_H, X0_W, X0, X0_Pair all have the
same name - so also print the enum value to differentiate these.
  • Loading branch information
lenary authored Feb 7, 2025
1 parent f2a1103 commit 5566bfa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,18 +1116,21 @@ struct RISCVOperand final : public MCParsedAsmOperand {

switch (Kind) {
case KindTy::Immediate:
OS << *getImm();
OS << "<imm: " << *Imm.Val << " " << (Imm.IsRV64 ? "rv64" : "rv32")
<< ">";
break;
case KindTy::FPImmediate:
OS << "<fpimm: " << FPImm.Val << ">";
break;
case KindTy::Register:
OS << "<register " << RegName(getReg()) << ">";
OS << "<reg: " << RegName(Reg.RegNum) << " (" << Reg.RegNum
<< (Reg.IsGPRAsFPR ? ") GPRasFPR>" : ")>");
break;
case KindTy::Token:
OS << "'" << getToken() << "'";
break;
case KindTy::SystemRegister:
OS << "<sysreg: " << getSysReg() << '>';
OS << "<sysreg: " << getSysReg() << " (" << SysReg.Encoding << ")>";
break;
case KindTy::VType:
OS << "<vtype: ";
Expand Down

0 comments on commit 5566bfa

Please sign in to comment.