#include "llvm/CodeGen/MachineInstr.h"
-struct MachineInstrBuilder {
+class MachineInstrBuilder {
MachineInstr *MI;
-
+public:
MachineInstrBuilder(MachineInstr *mi) : MI(mi) {}
/// Allow automatic conversion to the machine instruction we are working on.
return *this;
}
- /// addClobber - Assert that this MI is going to clobber a specific
- /// register. Useful for instructions that always clobber certain hard regs.
- /// (Same as addReg(RegNo, true) but shorter and more obvious).
+ /// addReg - Add an LLVM value that is to be used as a register...
///
- const MachineInstrBuilder &addClobber(int RegNo) const {
- MI->addRegOperand(RegNo, true);
+ const MachineInstrBuilder &addCCReg(Value *V,
+ MOTy::UseType Ty = MOTy::Use) const {
+ MI->addCCRegOperand(V, Ty);
return *this;
}
+ /// addRegDef - Add an LLVM value that is to be defined as a register... this
+ /// is the same as addReg(V, MOTy::Def).
+ ///
+ const MachineInstrBuilder &addRegDef(Value *V) const {
+ return addReg(V, MOTy::Def);
+ }
+
/// addPCDisp - Add an LLVM value to be treated as a PC relative
/// displacement...
///
MI->addZeroExtImmOperand(Val);
return *this;
}
+
+ const MachineInstrBuilder &addMBB(MachineBasicBlock *MBB) const {
+ MI->addMachineBasicBlockOperand(MBB);
+ return *this;
+ }
+
+ const MachineInstrBuilder &addFrameIndex(unsigned Idx) const {
+ MI->addFrameIndexOperand(Idx);
+ return *this;
+ }
+
+ const MachineInstrBuilder &addConstantPoolIndex(unsigned Idx) const {
+ MI->addConstantPoolIndexOperand(Idx);
+ return *this;
+ }
+
+ const MachineInstrBuilder &addGlobalAddress(GlobalValue *GV,
+ bool isPCRelative = false) const {
+ MI->addGlobalAddressOperand(GV, isPCRelative);
+ return *this;
+ }
+
+ const MachineInstrBuilder &addExternalSymbol(const std::string &Name,
+ bool isPCRelative = false) const{
+ MI->addExternalSymbolOperand(Name, isPCRelative);
+ return *this;
+ }
};
/// BuildMI - Builder interface. Specify how to create the initial instruction