1
- //===-- llvm/MC/MCInst.h - MCInst class -------------------------*- C++ -*-===//
1
+ //===- llvm/MC/MCInst.h - MCInst class - -------------------------*- C++ -*-===//
2
2
//
3
3
// The LLVM Compiler Infrastructure
4
4
//
18
18
19
19
#include "llvm/ADT/SmallVector.h"
20
20
#include "llvm/ADT/StringRef.h"
21
- #include "llvm/Support/DataTypes.h"
22
21
#include "llvm/Support/SMLoc.h"
22
+ #include <cassert>
23
+ #include <cstddef>
24
+ #include <cstdint>
23
25
24
26
namespace llvm {
25
- class raw_ostream;
26
- class MCAsmInfo;
27
- class MCInstPrinter;
27
+
28
28
class MCExpr;
29
29
class MCInst;
30
+ class MCInstPrinter;
31
+ class raw_ostream;
30
32
31
33
/// \brief Instances of this class represent operands of the MCInst class.
32
34
/// This is a simple discriminated union.
@@ -39,7 +41,7 @@ class MCOperand {
39
41
kExpr, ///< Relocatable immediate operand.
40
42
kInst ///< Sub-instruction operand.
41
43
};
42
- MachineOperandType Kind;
44
+ MachineOperandType Kind = kInvalid ;
43
45
44
46
union {
45
47
unsigned RegVal;
@@ -50,7 +52,7 @@ class MCOperand {
50
52
};
51
53
52
54
public:
53
- MCOperand() : Kind(kInvalid), FPImmVal(0.0) {}
55
+ MCOperand() : FPImmVal(0.0) {}
54
56
55
57
bool isValid() const { return Kind != kInvalid; }
56
58
bool isReg() const { return Kind == kRegister; }
@@ -75,6 +77,7 @@ class MCOperand {
75
77
assert(isImm() && "This is not an immediate");
76
78
return ImmVal;
77
79
}
80
+
78
81
void setImm(int64_t Val) {
79
82
assert(isImm() && "This is not an immediate");
80
83
ImmVal = Val;
@@ -94,6 +97,7 @@ class MCOperand {
94
97
assert(isExpr() && "This is not an expression");
95
98
return ExprVal;
96
99
}
100
+
97
101
void setExpr(const MCExpr *Val) {
98
102
assert(isExpr() && "This is not an expression");
99
103
ExprVal = Val;
@@ -103,6 +107,7 @@ class MCOperand {
103
107
assert(isInst() && "This is not a sub-instruction");
104
108
return InstVal;
105
109
}
110
+
106
111
void setInst(const MCInst *Val) {
107
112
assert(isInst() && "This is not a sub-instruction");
108
113
InstVal = Val;
@@ -114,24 +119,28 @@ class MCOperand {
114
119
Op.RegVal = Reg;
115
120
return Op;
116
121
}
122
+
117
123
static MCOperand createImm(int64_t Val) {
118
124
MCOperand Op;
119
125
Op.Kind = kImmediate;
120
126
Op.ImmVal = Val;
121
127
return Op;
122
128
}
129
+
123
130
static MCOperand createFPImm(double Val) {
124
131
MCOperand Op;
125
132
Op.Kind = kFPImmediate;
126
133
Op.FPImmVal = Val;
127
134
return Op;
128
135
}
136
+
129
137
static MCOperand createExpr(const MCExpr *Val) {
130
138
MCOperand Op;
131
139
Op.Kind = kExpr;
132
140
Op.ExprVal = Val;
133
141
return Op;
134
142
}
143
+
135
144
static MCOperand createInst(const MCInst *Val) {
136
145
MCOperand Op;
137
146
Op.Kind = kInst;
@@ -148,12 +157,12 @@ template <> struct isPodLike<MCOperand> { static const bool value = true; };
148
157
/// \brief Instances of this class represent a single low-level machine
149
158
/// instruction.
150
159
class MCInst {
151
- unsigned Opcode;
160
+ unsigned Opcode = 0 ;
152
161
SMLoc Loc;
153
162
SmallVector<MCOperand, 8> Operands;
154
163
155
164
public:
156
- MCInst() : Opcode(0) {}
165
+ MCInst() = default;
157
166
158
167
void setOpcode(unsigned Op) { Opcode = Op; }
159
168
unsigned getOpcode() const { return Opcode; }
@@ -176,6 +185,7 @@ class MCInst {
176
185
const_iterator begin() const { return Operands.begin(); }
177
186
iterator end() { return Operands.end(); }
178
187
const_iterator end() const { return Operands.end(); }
188
+
179
189
iterator insert(iterator I, const MCOperand &Op) {
180
190
return Operands.insert(I, Op);
181
191
}
@@ -202,4 +212,4 @@ inline raw_ostream& operator<<(raw_ostream &OS, const MCInst &MI) {
202
212
203
213
} // end namespace llvm
204
214
205
- #endif
215
+ #endif // LLVM_MC_MCINST_H
0 commit comments