+ void addMachineBasicBlockOperand(MachineBasicBlock *MBB) {
+ assert(!OperandsComplete() &&
+ "Trying to add an operand to a machine instr that is already done!");
+ operands.push_back(MachineOperand(MBB));
+ }
+
+ /// addFrameIndexOperand - Add an abstract frame index to the instruction
+ ///
+ void addFrameIndexOperand(unsigned Idx) {
+ assert(!OperandsComplete() &&
+ "Trying to add an operand to a machine instr that is already done!");
+ operands.push_back(MachineOperand(Idx, MachineOperand::MO_FrameIndex));
+ }
+
+ /// addConstantPoolndexOperand - Add a constant pool object index to the
+ /// instruction.
+ ///
+ void addConstantPoolIndexOperand(unsigned I) {
+ assert(!OperandsComplete() &&
+ "Trying to add an operand to a machine instr that is already done!");
+ operands.push_back(MachineOperand(I, MachineOperand::MO_ConstantPoolIndex));
+ }
+
+ void addGlobalAddressOperand(GlobalValue *GV, bool isPCRelative) {
+ assert(!OperandsComplete() &&
+ "Trying to add an operand to a machine instr that is already done!");
+ operands.push_back(MachineOperand((Value*)GV,
+ MachineOperand::MO_GlobalAddress,
+ MOTy::Use, isPCRelative));
+ }
+
+ /// addExternalSymbolOperand - Add an external symbol operand to this instr
+ ///
+ void addExternalSymbolOperand(const std::string &SymName, bool isPCRelative) {
+ operands.push_back(MachineOperand(SymName, isPCRelative));
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Accessors used to modify instructions in place.
+ //
+ // FIXME: Move this stuff to MachineOperand itself!
+
+ /// replace - Support to rewrite a machine instruction in place: for now,
+ /// simply replace() and then set new operands with Set.*Operand methods
+ /// below.
+ ///
+ void replace(int Opcode, unsigned numOperands);
+
+ /// setOpcode - Replace the opcode of the current instruction with a new one.
+ ///
+ void setOpcode(unsigned Op) { opCode = Op; }
+
+ /// RemoveOperand - Erase an operand from an instruction, leaving it with one
+ /// fewer operand than it started with.
+ ///
+ void RemoveOperand(unsigned i) {
+ operands.erase(operands.begin()+i);
+ }
+
+ // Access to set the operands when building the machine instruction
+ //
+ void SetMachineOperandVal (unsigned i,
+ MachineOperand::MachineOperandType operandType,
+ Value* V);
+
+ void SetMachineOperandConst (unsigned i,
+ MachineOperand::MachineOperandType operandType,
+ int64_t intValue);
+
+ void SetMachineOperandReg(unsigned i, int regNum);
+