Skip to content

Commit 0e6520d

Browse files
lenaryIcohedron
authored andcommitted
[RISCV] Improve RISCVOperand Printing (llvm#126179)
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.
1 parent 903d76b commit 0e6520d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -1116,18 +1116,21 @@ struct RISCVOperand final : public MCParsedAsmOperand {
11161116

11171117
switch (Kind) {
11181118
case KindTy::Immediate:
1119-
OS << *getImm();
1119+
OS << "<imm: " << *Imm.Val << " " << (Imm.IsRV64 ? "rv64" : "rv32")
1120+
<< ">";
11201121
break;
11211122
case KindTy::FPImmediate:
1123+
OS << "<fpimm: " << FPImm.Val << ">";
11221124
break;
11231125
case KindTy::Register:
1124-
OS << "<register " << RegName(getReg()) << ">";
1126+
OS << "<reg: " << RegName(Reg.RegNum) << " (" << Reg.RegNum
1127+
<< (Reg.IsGPRAsFPR ? ") GPRasFPR>" : ")>");
11251128
break;
11261129
case KindTy::Token:
11271130
OS << "'" << getToken() << "'";
11281131
break;
11291132
case KindTy::SystemRegister:
1130-
OS << "<sysreg: " << getSysReg() << '>';
1133+
OS << "<sysreg: " << getSysReg() << " (" << SysReg.Encoding << ")>";
11311134
break;
11321135
case KindTy::VType:
11331136
OS << "<vtype: ";

0 commit comments

Comments
 (0)