8
8
9
9
#include " llvm/MC/MCInst.h"
10
10
#include " llvm/Config/llvm-config.h"
11
+ #include " llvm/MC/MCAsmInfo.h"
12
+ #include " llvm/MC/MCContext.h"
11
13
#include " llvm/MC/MCExpr.h"
12
14
#include " llvm/MC/MCInstPrinter.h"
13
15
#include " llvm/MC/MCRegisterInfo.h"
18
20
19
21
using namespace llvm ;
20
22
21
- void MCOperand::print (raw_ostream &OS, const MCRegisterInfo *RegInfo ) const {
23
+ void MCOperand::print (raw_ostream &OS, const MCContext *Ctx ) const {
22
24
OS << " <MCOperand " ;
23
25
if (!isValid ())
24
26
OS << " INVALID" ;
25
27
else if (isReg ()) {
26
28
OS << " Reg:" ;
27
- if (RegInfo )
28
- OS << RegInfo ->getName (getReg ());
29
+ if (Ctx && Ctx-> getRegisterInfo () )
30
+ OS << Ctx-> getRegisterInfo () ->getName (getReg ());
29
31
else
30
32
OS << getReg ();
31
33
} else if (isImm ())
@@ -36,11 +38,14 @@ void MCOperand::print(raw_ostream &OS, const MCRegisterInfo *RegInfo) const {
36
38
OS << " DFPImm:" << bit_cast<double >(getDFPImm ());
37
39
else if (isExpr ()) {
38
40
OS << " Expr:" ;
39
- getExpr ()->print (OS, nullptr );
41
+ if (Ctx)
42
+ Ctx->getAsmInfo ()->printExpr (OS, *getExpr ());
43
+ else
44
+ getExpr ()->print (OS, nullptr );
40
45
} else if (isInst ()) {
41
46
OS << " Inst:(" ;
42
47
if (const auto *Inst = getInst ())
43
- Inst->print (OS, RegInfo );
48
+ Inst->print (OS, Ctx );
44
49
else
45
50
OS << " NULL" ;
46
51
OS << " )" ;
@@ -73,24 +78,23 @@ LLVM_DUMP_METHOD void MCOperand::dump() const {
73
78
}
74
79
#endif
75
80
76
- void MCInst::print (raw_ostream &OS, const MCRegisterInfo *RegInfo ) const {
81
+ void MCInst::print (raw_ostream &OS, const MCContext *Ctx ) const {
77
82
OS << " <MCInst " << getOpcode ();
78
83
for (unsigned i = 0 , e = getNumOperands (); i != e; ++i) {
79
84
OS << " " ;
80
- getOperand (i).print (OS, RegInfo );
85
+ getOperand (i).print (OS, Ctx );
81
86
}
82
87
OS << " >" ;
83
88
}
84
89
85
90
void MCInst::dump_pretty (raw_ostream &OS, const MCInstPrinter *Printer,
86
- StringRef Separator,
87
- const MCRegisterInfo *RegInfo) const {
91
+ StringRef Separator, const MCContext *Ctx) const {
88
92
StringRef InstName = Printer ? Printer->getOpcodeName (getOpcode ()) : " " ;
89
- dump_pretty (OS, InstName, Separator, RegInfo );
93
+ dump_pretty (OS, InstName, Separator, Ctx );
90
94
}
91
95
92
96
void MCInst::dump_pretty (raw_ostream &OS, StringRef Name, StringRef Separator,
93
- const MCRegisterInfo *RegInfo ) const {
97
+ const MCContext *Ctx ) const {
94
98
OS << " <MCInst #" << getOpcode ();
95
99
96
100
// Show the instruction opcode name if we have it.
@@ -99,7 +103,7 @@ void MCInst::dump_pretty(raw_ostream &OS, StringRef Name, StringRef Separator,
99
103
100
104
for (unsigned i = 0 , e = getNumOperands (); i != e; ++i) {
101
105
OS << Separator;
102
- getOperand (i).print (OS, RegInfo );
106
+ getOperand (i).print (OS, Ctx );
103
107
}
104
108
OS << " >" ;
105
109
}
0 commit comments