19 #ifndef LLVM_CODEGEN_MACHINEINSTRBUILDER_H
20 #define LLVM_CODEGEN_MACHINEINSTRBUILDER_H
82 unsigned SubReg = 0)
const {
83 assert((flags & 0x1) == 0 &&
84 "Passing in 'true' to addReg is forbidden! Use enums instead.");
100 unsigned SubReg = 0)
const {
107 unsigned SubReg = 0)
const {
109 "Misleading addUse defines register, use addReg instead.");
197 unsigned> MemOperandsRef)
const {
218 "first MDNode argument of a DBG_VALUE not a variable");
341 return BuildMI(BB, *I, DL, MCID, DestReg);
380 return BuildMI(BB, *I, DL, MCID);
402 MachineInstrBuilder
BuildMI(MachineFunction &MF,
const DebugLoc &
DL,
403 const MCInstrDesc &MCID,
bool IsIndirect,
405 const MDNode *Variable,
const MDNode *Expr);
410 MachineInstrBuilder
BuildMI(MachineBasicBlock &BB,
412 const MCInstrDesc &MCID,
bool IsIndirect,
414 const MDNode *Variable,
const MDNode *Expr);
469 : MBB(BB), Begin(Pos.getInstrIterator()), End(Begin) {}
474 : MBB(BB), Begin(B.getInstrIterator()), End(E.getInstrIterator()) {
475 assert(B != E &&
"No instructions to bundle");
495 bool empty()
const {
return Begin == End; }
540 #endif // LLVM_CODEGEN_MACHINEINSTRBUILDER_H
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
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & copyImplicitOps(const MachineInstr &OtherMI) const
Copy all the implicit operands from OtherMI onto this one.
MIBundleBuilder(MachineBasicBlock &BB, MachineBasicBlock::iterator Pos)
Create an MIBundleBuilder that inserts instructions into a new bundle in BB above the bundle or instr...
const GlobalValue * getGlobal() const
static MachineOperand CreateCImm(const ConstantInt *CI)
unsigned getRegState(const MachineOperand &RegOp)
Get all register state flags from machine operand RegOp.
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.
const MachineInstrBuilder & add(const MachineOperand &MO) const
MachineInstr * operator->() const
unsigned getInternalReadRegState(bool B)
const MachineInstrBuilder & addIntrinsicID(Intrinsic::ID ID) const
const MachineInstrBuilder & add(ArrayRef< MachineOperand > MOs) const
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL, bool NoImp=false)
CreateMachineInstr - Allocate a new MachineInstr.
const MachineInstrBuilder & addDef(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
const MachineInstrBuilder & setMemRefs(std::pair< MachineInstr::mmo_iterator, unsigned > MemOperandsRef) const
static MachineOperand CreateIntrinsicID(Intrinsic::ID ID)
MIBundleBuilder(MachineBasicBlock &BB, MachineBasicBlock::iterator B, MachineBasicBlock::iterator E)
Create a bundle from the sequence of instructions between B and E.
The address of a basic block.
A description of a memory reference used in the backend.
MachineInstr * buildDbgValueForSpill(MachineBasicBlock &BB, MachineBasicBlock::iterator I, const MachineInstr &Orig, int FrameIndex)
Clone a DBG_VALUE whose value has been spilled to FrameIndex.
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)
const MachineInstrBuilder & addDisp(const MachineOperand &Disp, int64_t off, unsigned char TargetFlags=0) const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
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
Add a new immediate operand.
void copyImplicitOps(MachineFunction &MF, const MachineInstr &MI)
Copy implicit register operands from specified instruction to this instruction.
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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void addMemOperand(MachineFunction &MF, MachineMemOperand *MO)
Add a MachineMemOperand to the machine instruction.
static MachineOperand CreatePredicate(unsigned Pred)
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)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Address of a global value.
unsigned getTargetFlags() const
MachineInstrBundleIterator< MachineInstr > iterator
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)
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
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
const MachineInstrBuilder & addPredicate(CmpInst::Predicate Pred) 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.
self_iterator getIterator()
MachineInstrBuilder()=default
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
llvm_unreachable("Unknown RegBank!")
static std::vector< std::string > Flags
Representation of each machine instruction.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
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)
Instructions::iterator instr_iterator
const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
const MachineInstrBuilder & addFPImm(const ConstantFP *Val) const
MIBundleBuilder & append(MachineInstr *MI)
Insert MI into MBB by appending it to the instructions in the bundle.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
static const Function * getParent(const Value *V)
Address of indexed Constant in Constant Pool.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
MachineBasicBlock::instr_iterator getBundleEnd(MachineBasicBlock::instr_iterator I)
Returns an iterator pointing beyond the bundle containing I.
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
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.
MachineInstrBuilder(MachineFunction &F, MachineBasicBlock::iterator I)
MIBundleBuilder(MachineInstr *MI)
Create an MIBundleBuilder representing an existing instruction or bundle that has MI as its head...
bool isInternalRead() const
Helper class for constructing bundles of MachineInstrs.
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly. ...