17 #ifndef LLVM_CODEGEN_MACHINEINSTRBUILDER_H
18 #define LLVM_CODEGEN_MACHINEINSTRBUILDER_H
69 unsigned SubReg = 0)
const {
70 assert((flags & 0x1) == 0 &&
71 "Passing in 'true' to addReg is forbidden! Use enums instead.");
103 unsigned char TargetFlags = 0)
const {
115 unsigned char TargetFlags = 0)
const {
121 unsigned char TargetFlags = 0)
const {
128 unsigned char TargetFlags = 0)
const {
135 unsigned char TargetFlags = 0)
const {
141 unsigned char TargetFlags = 0)
const {
148 unsigned char TargetFlags = 0)
const {
179 "first MDNode argument of a DBG_VALUE not a variable");
189 unsigned char TargetFlags = 0)
const {
206 unsigned char TargetFlags = 0)
const {
286 return BuildMI(BB, MII, DL, MCID, DestReg);
290 return BuildMI(BB, MII, DL, MCID, DestReg);
323 return BuildMI(BB, MII, DL, MCID);
327 return BuildMI(BB, MII, DL, MCID);
348 return BuildMI(*BB, BB->
end(), DL, MCID, DestReg);
358 unsigned Reg,
unsigned Offset,
360 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
361 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
362 assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
363 "Expected inlined-at fields to agree");
371 assert(Offset == 0 &&
"A direct address cannot have an offset.");
387 unsigned Reg,
unsigned Offset,
389 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
390 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
393 BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, Variable, Expr);
437 : MBB(BB), Begin(Pos.getInstrIterator()), End(Begin) {}
443 : MBB(BB), Begin(B.getInstrIterator()), End(E.getInstrIterator()) {
444 assert(B != E &&
"No instructions to bundle");
463 bool empty()
const {
return Begin == End; }
bool isInsideBundle() const
Return true if MI is in a bundle (but not the first MI in a bundle).
MachineBasicBlock::instr_iterator begin() const
Return an iterator to the first bundled instruction.
void bundleWithPred()
Bundle this instruction with its predecessor.
const MachineInstrBuilder & addMetadata(const MDNode *MD) const
const MachineFunction * getParent() const
getParent - Return the MachineFunction containing this basic block.
MIBundleBuilder(MachineBasicBlock &BB, MachineBasicBlock::iterator Pos)
Create an MIBundleBuilder that inserts instructions into a new bundle in BB above the bundle or instr...
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, DebugLoc DL, bool NoImp=false)
CreateMachineInstr - Allocate a new MachineInstr.
MachineBasicBlock::instr_iterator getBundleEnd(MachineInstr *MI)
Return an iterator pointing beyond the bundle containing MI.
const GlobalValue * getGlobal() const
static MachineOperand CreateCImm(const ConstantInt *CI)
static MachineOperand CreateMCSymbol(MCSymbol *Sym, unsigned char TargetFlags=0)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
static MachineOperand CreateJTI(unsigned Idx, unsigned char TargetFlags=0)
Describe properties that are true of each instruction in the target description file.
MachineInstr * operator->() const
unsigned getInternalReadRegState(bool B)
Instructions::iterator instr_iterator
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
MIBundleBuilder(MachineBasicBlock &BB, MachineBasicBlock::iterator B, MachineBasicBlock::iterator E)
Create a bundle from the sequence of instructions between B and E.
BlockAddress - The address of a basic block.
MachineMemOperand - A description of a memory reference used in the backend.
MachineInstrBuilder(MachineFunction &F, MachineInstr *I)
Create a MachineInstrBuilder for manipulating an existing instruction.
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const MachineInstrBuilder & addDisp(const MachineOperand &Disp, int64_t off, unsigned char TargetFlags=0) const
Reg
All possible values of the reg field in the ModR/M byte.
void bundleWithSucc()
Bundle this instruction with its successor.
static MachineOperand CreateRegMask(const uint32_t *Mask)
CreateRegMask - Creates a register mask operand referencing Mask.
const MachineInstrBuilder & addImm(int64_t Val) const
addImm - Add a new immediate operand.
MIBundleBuilder & prepend(MachineInstr *MI)
Insert MI into MBB by prepending it to the instructions in the bundle.
MachineBasicBlock & getMBB() const
Return a reference to the basic block containing this bundle.
void addMemOperand(MachineFunction &MF, MachineMemOperand *MO)
Add a MachineMemOperand to the machine instruction.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
unsigned getUndefRegState(bool B)
MachineBasicBlock::instr_iterator end() const
Return an iterator beyond the last bundled instruction.
unsigned getKillRegState(bool B)
Flag
These should be considered private to the implementation of the MCInstrDesc class.
unsigned getDebugRegState(bool B)
bool isDebugValue() const
unsigned getDeadRegState(bool B)
unsigned getDefRegState(bool B)
bundle_iterator< MachineInstr, instr_iterator > iterator
Address of a global value.
unsigned getTargetFlags() const
const MachineInstrBuilder & setMemRefs(MachineInstr::mmo_iterator b, MachineInstr::mmo_iterator e) const
static MachineOperand CreateCPI(unsigned Idx, int Offset, unsigned char TargetFlags=0)
static MachineOperand CreateFPImm(const ConstantFP *CFP)
bundle_iterator - MachineBasicBlock iterator that automatically skips over MIs that are inside bundle...
ConstantFP - Floating Point Values [float, double].
bool empty() const
Return true if no instructions have been inserted in this bundle yet.
static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset, unsigned char TargetFlags=0)
void setFlag(MIFlag Flag)
Set a MI flag.
const MachineInstrBuilder & addTargetIndex(unsigned Idx, int64_t Offset=0, unsigned char TargetFlags=0) const
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset, unsigned char TargetFlags=0)
static MachineOperand CreateTargetIndex(unsigned Idx, int64_t Offset, unsigned char TargetFlags=0)
int64_t getOffset() const
Return the offset from the symbol in this operand.
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
BuildMI - Builder interface.
const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
static MachineOperand CreateMetadata(const MDNode *Meta)
This is the shared class of boolean and integer constants.
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
void setFlags(unsigned flags)
const MachineInstrBuilder & addJumpTableIndex(unsigned Idx, unsigned char TargetFlags=0) const
MachineOperand class - Representation of each machine instruction operand.
const MachineInstrBuilder & addCImm(const ConstantInt *Val) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
MIBundleBuilder & insert(MachineBasicBlock::instr_iterator I, MachineInstr *MI)
Insert MI into this bundle before I which must point to an instruction in the bundle, or end().
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
static MachineOperand CreateES(const char *SymName, unsigned char TargetFlags=0)
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned char TargetFlags=0) const
Representation of each machine instruction.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
void copyImplicitOps(MachineFunction &MF, const MachineInstr *MI)
Copy implicit register operands from specified instruction to this instruction.
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0)
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned char TargetFlags=0) const
static MachineOperand CreateCFIIndex(unsigned CFIIndex)
const MachineInstrBuilder & addConstantPoolIndex(unsigned Idx, int Offset=0, unsigned char TargetFlags=0) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
static MachineOperand CreateImm(int64_t Val)
unsigned getImplRegState(bool B)
const MachineInstrBuilder & copyImplicitOps(const MachineInstr *OtherMI)
Copy all the implicit operands from OtherMI onto this one.
const MachineInstrBuilder & addFPImm(const ConstantFP *Val) const
MIBundleBuilder & append(MachineInstr *MI)
Insert MI into MBB by appending it to the instructions in the bundle.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
static const Function * getParent(const Value *V)
const MachineInstrBuilder & addOperand(const MachineOperand &MO) const
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
const MachineInstrBuilder & addBlockAddress(const BlockAddress *BA, int64_t Offset=0, unsigned char TargetFlags=0) const
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
addReg - Add a new virtual register operand...
static MachineOperand CreateFI(int Idx)
void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd)
Assign this MachineInstr's memory reference descriptor list.
MIBundleBuilder(MachineInstr *MI)
Create an MIBundleBuilder representing an existing instruction or bundle that has MI as its head...
Helper class for constructing bundles of MachineInstrs.
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly. ...