summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-10-28 20:48:39 +0000
committerChris Lattner <sabre@nondot.org>2002-10-28 20:48:39 +0000
commitca4a9d20b89af397e5c598071f84606c88c6fa86 (patch)
tree227522de3290bbb4e039f0515b113a62722d321f /llvm/lib/CodeGen/MachineInstr.cpp
parent3d736950ea89ac5b2af32a7250d341a8779c85c5 (diff)
downloadbcm5719-llvm-ca4a9d20b89af397e5c598071f84606c88c6fa86.tar.gz
bcm5719-llvm-ca4a9d20b89af397e5c598071f84606c88c6fa86.zip
* Make MachineOperand ctors private, so MachineOperand can only be created
by MachineInstr. * Add a bunch of new methods to allow incremental addition of operands to the machine instr instance. llvm-svn: 4356
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineInstr.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index c3c5ca8fead..2a1893cc3d0 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -11,41 +11,42 @@ using std::cerr;
// Constructor for instructions with fixed #operands (nearly all)
MachineInstr::MachineInstr(MachineOpCode _opCode,
OpCodeMask _opCodeMask)
- : opCode(_opCode),
- opCodeMask(_opCodeMask),
- operands(TargetInstrDescriptors[_opCode].numOperands)
-{
+ : opCode(_opCode), opCodeMask(_opCodeMask),
+ operands(TargetInstrDescriptors[_opCode].numOperands, MachineOperand()) {
assert(TargetInstrDescriptors[_opCode].numOperands >= 0);
}
// Constructor for instructions with variable #operands
-MachineInstr::MachineInstr(MachineOpCode _opCode,
- unsigned numOperands,
- OpCodeMask _opCodeMask)
- : opCode(_opCode),
- opCodeMask(_opCodeMask),
- operands(numOperands)
-{
+MachineInstr::MachineInstr(MachineOpCode OpCode, unsigned numOperands,
+ OpCodeMask OpCodeMask)
+ : opCode(OpCode), opCodeMask(OpCodeMask),
+ operands(numOperands, MachineOperand()) {
}
+// OperandComplete - Return true if it's illegal to add a new operand
+bool MachineInstr::OperandsComplete() const {
+ int NumOperands = TargetInstrDescriptors[opCode].numOperands;
+ if (NumOperands >= 0 && operands.size() >= (unsigned)NumOperands)
+ return true; // Broken!
+ return false;
+}
+
+
//
// Support for replacing opcode and operands of a MachineInstr in place.
// This only resets the size of the operand vector and initializes it.
// The new operands must be set explicitly later.
//
-void
-MachineInstr::replace(MachineOpCode _opCode,
- unsigned numOperands,
- OpCodeMask _opCodeMask)
-{
- opCode = _opCode;
- opCodeMask = _opCodeMask;
+void MachineInstr::replace(MachineOpCode Opcode, unsigned numOperands,
+ OpCodeMask Mask) {
+ opCode = Opcode;
+ opCodeMask = Mask;
operands.clear();
- operands.resize(numOperands);
+ operands.resize(numOperands, MachineOperand());
}
void
-MachineInstr::SetMachineOperandVal(unsigned int i,
+MachineInstr::SetMachineOperandVal(unsigned i,
MachineOperand::MachineOperandType opType,
Value* V,
bool isdef,
OpenPOWER on IntegriCloud