Fill in some methods for the MCValue field of an MCOperand.

llvm-svn: 74572
This commit is contained in:
Daniel Dunbar 2009-06-30 23:37:44 +00:00
parent 3f34774b4a
commit cf67d9ed78

View File

@ -31,7 +31,7 @@ class MCOperand {
kRegister, ///< Register operand. kRegister, ///< Register operand.
kImmediate, ///< Immediate operand. kImmediate, ///< Immediate operand.
kMBBLabel, ///< Basic block label. kMBBLabel, ///< Basic block label.
kMCValue kMCValue ///< Relocatable immediate operand.
}; };
unsigned char Kind; unsigned char Kind;
@ -49,9 +49,11 @@ public:
MCOperand() : Kind(kInvalid) {} MCOperand() : Kind(kInvalid) {}
MCOperand(const MCOperand &RHS) { *this = RHS; } MCOperand(const MCOperand &RHS) { *this = RHS; }
bool isValid() const { return Kind != kInvalid; }
bool isReg() const { return Kind == kRegister; } bool isReg() const { return Kind == kRegister; }
bool isImm() const { return Kind == kImmediate; } bool isImm() const { return Kind == kImmediate; }
bool isMBBLabel() const { return Kind == kMBBLabel; } bool isMBBLabel() const { return Kind == kMBBLabel; }
bool isMCValue() const { return Kind == kMCValue; }
/// getReg - Returns the register number. /// getReg - Returns the register number.
unsigned getReg() const { unsigned getReg() const {
@ -82,6 +84,15 @@ public:
assert(isMBBLabel() && "Wrong accessor"); assert(isMBBLabel() && "Wrong accessor");
return MBBLabel.BlockNo; return MBBLabel.BlockNo;
} }
const MCValue &getMCValue() const {
assert(isMCValue() && "This is not an MCValue");
return MCValueVal;
}
void setMCValue(const MCValue &Val) {
assert(isMCValue() && "This is not an MCValue");
MCValueVal = Val;
}
void MakeReg(unsigned Reg) { void MakeReg(unsigned Reg) {
Kind = kRegister; Kind = kRegister;
@ -96,6 +107,10 @@ public:
MBBLabel.FunctionNo = Fn; MBBLabel.FunctionNo = Fn;
MBBLabel.BlockNo = MBB; MBBLabel.BlockNo = MBB;
} }
void MakeMCValue(const MCValue &Val) {
Kind = kMCValue;
MCValueVal = Val;
}
}; };
@ -119,7 +134,6 @@ public:
void addOperand(const MCOperand &Op) { void addOperand(const MCOperand &Op) {
Operands.push_back(Op); Operands.push_back(Op);
} }
}; };