File tree 3 files changed +60
-0
lines changed
3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 22
22
#include " llvm/Support/DebugLoc.h"
23
23
24
24
namespace llvm {
25
+ class raw_ostream ;
25
26
26
27
// / MCOperand - Instances of this class represent operands of the MCInst class.
27
28
// / This is a simple discriminated union.
@@ -119,6 +120,9 @@ class MCOperand {
119
120
Op.MCValueVal = Val;
120
121
return Op;
121
122
}
123
+
124
+ void print (raw_ostream &OS) const ;
125
+ void dump () const ;
122
126
};
123
127
124
128
@@ -142,6 +146,9 @@ class MCInst {
142
146
void addOperand (const MCOperand &Op) {
143
147
Operands.push_back (Op);
144
148
}
149
+
150
+ void print (raw_ostream &OS) const ;
151
+ void dump () const ;
145
152
};
146
153
147
154
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ add_llvm_library(LLVMMC
8
8
MCAssembler.cpp
9
9
MCCodeEmitter.cpp
10
10
MCContext.cpp
11
+ MCInst.cpp
11
12
MCMachOStreamer.cpp
12
13
MCNullStreamer.cpp
13
14
MCSection.cpp
Original file line number Diff line number Diff line change
1
+ // ===- lib/MC/MCInst.cpp - MCInst implementation --------------------------===//
2
+ //
3
+ // The LLVM Compiler Infrastructure
4
+ //
5
+ // This file is distributed under the University of Illinois Open Source
6
+ // License. See LICENSE.TXT for details.
7
+ //
8
+ // ===----------------------------------------------------------------------===//
9
+
10
+ #include " llvm/MC/MCInst.h"
11
+ #include " llvm/Support/raw_ostream.h"
12
+
13
+ using namespace llvm ;
14
+
15
+ void MCOperand::print (raw_ostream &OS) const {
16
+ OS << " <MCOperand " ;
17
+ if (!isValid ())
18
+ OS << " INVALID" ;
19
+ else if (isReg ())
20
+ OS << " Reg:" << getReg ();
21
+ else if (isImm ())
22
+ OS << " Imm:" << getImm ();
23
+ else if (isMBBLabel ())
24
+ OS << " MBB:(" << getMBBLabelFunction () << " ,"
25
+ << getMBBLabelBlock () << " )" ;
26
+ else if (isMCValue ()) {
27
+ OS << " Value:(" ;
28
+ getMCValue ().print (OS);
29
+ OS << " )" ;
30
+ } else
31
+ OS << " UNDEFINED" ;
32
+ OS << " >" ;
33
+ }
34
+
35
+ void MCOperand::dump () const {
36
+ print (errs ());
37
+ errs () << " \n " ;
38
+ }
39
+
40
+ void MCInst::print (raw_ostream &OS) const {
41
+ OS << " <MCInst " << getOpcode ();
42
+ for (unsigned i = 0 , e = getNumOperands (); i != e; ++i) {
43
+ OS << " " ;
44
+ getOperand (i).print (OS);
45
+ }
46
+ OS << " >" ;
47
+ }
48
+
49
+ void MCInst::dump () const {
50
+ print (errs ());
51
+ errs () << " \n " ;
52
+ }
You can’t perform that action at this time.
0 commit comments