1- // ===-- llvm/MC/MCInst.h - MCInst class -------------------------*- C++ -*-===//
1+ // ===- llvm/MC/MCInst.h - MCInst class - -------------------------*- C++ -*-===//
22//
33// The LLVM Compiler Infrastructure
44//
1818
1919#include " llvm/ADT/SmallVector.h"
2020#include " llvm/ADT/StringRef.h"
21- #include " llvm/Support/DataTypes.h"
2221#include " llvm/Support/SMLoc.h"
22+ #include < cassert>
23+ #include < cstddef>
24+ #include < cstdint>
2325
2426namespace llvm {
25- class raw_ostream ;
26- class MCAsmInfo ;
27- class MCInstPrinter ;
27+
2828class MCExpr ;
2929class MCInst ;
30+ class MCInstPrinter ;
31+ class raw_ostream ;
3032
3133// / \brief Instances of this class represent operands of the MCInst class.
3234// / This is a simple discriminated union.
@@ -39,7 +41,7 @@ class MCOperand {
3941 kExpr , // /< Relocatable immediate operand.
4042 kInst // /< Sub-instruction operand.
4143 };
42- MachineOperandType Kind;
44+ MachineOperandType Kind = kInvalid ;
4345
4446 union {
4547 unsigned RegVal;
@@ -50,7 +52,7 @@ class MCOperand {
5052 };
5153
5254public:
53- MCOperand () : Kind( kInvalid ), FPImmVal(0.0 ) {}
55+ MCOperand () : FPImmVal(0.0 ) {}
5456
5557 bool isValid () const { return Kind != kInvalid ; }
5658 bool isReg () const { return Kind == kRegister ; }
@@ -75,6 +77,7 @@ class MCOperand {
7577 assert (isImm () && " This is not an immediate" );
7678 return ImmVal;
7779 }
80+
7881 void setImm (int64_t Val) {
7982 assert (isImm () && " This is not an immediate" );
8083 ImmVal = Val;
@@ -94,6 +97,7 @@ class MCOperand {
9497 assert (isExpr () && " This is not an expression" );
9598 return ExprVal;
9699 }
100+
97101 void setExpr (const MCExpr *Val) {
98102 assert (isExpr () && " This is not an expression" );
99103 ExprVal = Val;
@@ -103,6 +107,7 @@ class MCOperand {
103107 assert (isInst () && " This is not a sub-instruction" );
104108 return InstVal;
105109 }
110+
106111 void setInst (const MCInst *Val) {
107112 assert (isInst () && " This is not a sub-instruction" );
108113 InstVal = Val;
@@ -114,24 +119,28 @@ class MCOperand {
114119 Op.RegVal = Reg;
115120 return Op;
116121 }
122+
117123 static MCOperand createImm (int64_t Val) {
118124 MCOperand Op;
119125 Op.Kind = kImmediate ;
120126 Op.ImmVal = Val;
121127 return Op;
122128 }
129+
123130 static MCOperand createFPImm (double Val) {
124131 MCOperand Op;
125132 Op.Kind = kFPImmediate ;
126133 Op.FPImmVal = Val;
127134 return Op;
128135 }
136+
129137 static MCOperand createExpr (const MCExpr *Val) {
130138 MCOperand Op;
131139 Op.Kind = kExpr ;
132140 Op.ExprVal = Val;
133141 return Op;
134142 }
143+
135144 static MCOperand createInst (const MCInst *Val) {
136145 MCOperand Op;
137146 Op.Kind = kInst ;
@@ -148,12 +157,12 @@ template <> struct isPodLike<MCOperand> { static const bool value = true; };
148157// / \brief Instances of this class represent a single low-level machine
149158// / instruction.
150159class MCInst {
151- unsigned Opcode;
160+ unsigned Opcode = 0 ;
152161 SMLoc Loc;
153162 SmallVector<MCOperand, 8 > Operands;
154163
155164public:
156- MCInst () : Opcode( 0 ) {}
165+ MCInst () = default ;
157166
158167 void setOpcode (unsigned Op) { Opcode = Op; }
159168 unsigned getOpcode () const { return Opcode; }
@@ -176,6 +185,7 @@ class MCInst {
176185 const_iterator begin () const { return Operands.begin (); }
177186 iterator end () { return Operands.end (); }
178187 const_iterator end () const { return Operands.end (); }
188+
179189 iterator insert (iterator I, const MCOperand &Op) {
180190 return Operands.insert (I, Op);
181191 }
@@ -202,4 +212,4 @@ inline raw_ostream& operator<<(raw_ostream &OS, const MCInst &MI) {
202212
203213} // end namespace llvm
204214
205- #endif
215+ #endif // LLVM_MC_MCINST_H
0 commit comments