88
99#include " llvm/MC/MCInst.h"
1010#include " llvm/Config/llvm-config.h"
11+ #include " llvm/MC/MCAsmInfo.h"
12+ #include " llvm/MC/MCContext.h"
1113#include " llvm/MC/MCExpr.h"
1214#include " llvm/MC/MCInstPrinter.h"
1315#include " llvm/MC/MCRegisterInfo.h"
1820
1921using namespace llvm ;
2022
21- void MCOperand::print (raw_ostream &OS, const MCRegisterInfo *RegInfo ) const {
23+ void MCOperand::print (raw_ostream &OS, const MCContext *Ctx ) const {
2224 OS << " <MCOperand " ;
2325 if (!isValid ())
2426 OS << " INVALID" ;
2527 else if (isReg ()) {
2628 OS << " Reg:" ;
27- if (RegInfo )
28- OS << RegInfo ->getName (getReg ());
29+ if (Ctx && Ctx-> getRegisterInfo () )
30+ OS << Ctx-> getRegisterInfo () ->getName (getReg ());
2931 else
3032 OS << getReg ();
3133 } else if (isImm ())
@@ -36,11 +38,14 @@ void MCOperand::print(raw_ostream &OS, const MCRegisterInfo *RegInfo) const {
3638 OS << " DFPImm:" << bit_cast<double >(getDFPImm ());
3739 else if (isExpr ()) {
3840 OS << " Expr:" ;
39- getExpr ()->print (OS, nullptr );
41+ if (Ctx)
42+ Ctx->getAsmInfo ()->printExpr (OS, *getExpr ());
43+ else
44+ getExpr ()->print (OS, nullptr );
4045 } else if (isInst ()) {
4146 OS << " Inst:(" ;
4247 if (const auto *Inst = getInst ())
43- Inst->print (OS, RegInfo );
48+ Inst->print (OS, Ctx );
4449 else
4550 OS << " NULL" ;
4651 OS << " )" ;
@@ -73,24 +78,23 @@ LLVM_DUMP_METHOD void MCOperand::dump() const {
7378}
7479#endif
7580
76- void MCInst::print (raw_ostream &OS, const MCRegisterInfo *RegInfo ) const {
81+ void MCInst::print (raw_ostream &OS, const MCContext *Ctx ) const {
7782 OS << " <MCInst " << getOpcode ();
7883 for (unsigned i = 0 , e = getNumOperands (); i != e; ++i) {
7984 OS << " " ;
80- getOperand (i).print (OS, RegInfo );
85+ getOperand (i).print (OS, Ctx );
8186 }
8287 OS << " >" ;
8388}
8489
8590void MCInst::dump_pretty (raw_ostream &OS, const MCInstPrinter *Printer,
86- StringRef Separator,
87- const MCRegisterInfo *RegInfo) const {
91+ StringRef Separator, const MCContext *Ctx) const {
8892 StringRef InstName = Printer ? Printer->getOpcodeName (getOpcode ()) : " " ;
89- dump_pretty (OS, InstName, Separator, RegInfo );
93+ dump_pretty (OS, InstName, Separator, Ctx );
9094}
9195
9296void MCInst::dump_pretty (raw_ostream &OS, StringRef Name, StringRef Separator,
93- const MCRegisterInfo *RegInfo ) const {
97+ const MCContext *Ctx ) const {
9498 OS << " <MCInst #" << getOpcode ();
9599
96100 // Show the instruction opcode name if we have it.
@@ -99,7 +103,7 @@ void MCInst::dump_pretty(raw_ostream &OS, StringRef Name, StringRef Separator,
99103
100104 for (unsigned i = 0 , e = getNumOperands (); i != e; ++i) {
101105 OS << Separator;
102- getOperand (i).print (OS, RegInfo );
106+ getOperand (i).print (OS, Ctx );
103107 }
104108 OS << " >" ;
105109}
0 commit comments