14 #ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H
15 #define LLVM_CODEGEN_MACHINEBASICBLOCK_H
19 #include "llvm/Support/DataTypes.h"
26 class MachineFunction;
31 class MachineBranchProbabilityInfo;
71 std::vector<MachineBasicBlock *> Predecessors;
72 std::vector<MachineBasicBlock *> Successors;
77 std::vector<uint32_t> Weights;
78 typedef std::vector<uint32_t>::iterator weight_iterator;
79 typedef std::vector<uint32_t>::const_iterator const_weight_iterator;
83 std::vector<unsigned> LiveIns;
143 template<
typename Ty,
typename IterTy>
145 :
public std::iterator<std::bidirectional_iterator_tag, Ty, ptrdiff_t> {
152 assert(!mi.isBundledWithPred() &&
153 "It's not legal to initialize bundle_iterator with a bundled MI");
156 assert((!mi || !mi->isBundledWithPred()) &&
157 "It's not legal to initialize bundle_iterator with a bundled MI");
160 template<
class OtherTy,
class OtherIterTy>
168 operator Ty*()
const {
return MII; }
180 while (MII->isBundledWithPred());
184 while (MII->isBundledWithSucc())
219 unsigned size()
const {
return (
unsigned)Insts.
size(); }
253 typedef std::vector<MachineBasicBlock *>::const_reverse_iterator
257 typedef std::vector<MachineBasicBlock *>::const_reverse_iterator
265 {
return Predecessors.rbegin();}
267 {
return Predecessors.rbegin();}
269 {
return Predecessors.rend(); }
271 {
return Predecessors.rend(); }
273 return (
unsigned)Predecessors.size();
281 {
return Successors.rbegin(); }
283 {
return Successors.rbegin(); }
285 {
return Successors.rend(); }
287 {
return Successors.rend(); }
289 return (
unsigned)Successors.size();
461 template<
typename IT>
463 Insts.
insert(I.getInstrIterator(), S, E);
469 "Cannot insert instruction with bundle flags");
470 return Insts.
insert(I.getInstrIterator(),
MI);
476 "Cannot insert instruction with bundle flags");
496 return Insts.
erase(I.getInstrIterator(), E.getInstrIterator());
520 assert(!
I->isBundled() &&
"Cannot remove bundled instructions");
552 Insts.
splice(Where.getInstrIterator(), Other->Insts,
553 From.getInstrIterator(), To.getInstrIterator());
605 unsigned Neighborhood=10);
662 public std::unary_function<const MachineBasicBlock*, unsigned> {
static ChildIteratorType child_end(NodeType *N)
pred_reverse_iterator pred_rbegin()
unsigned succ_size() const
static void noteHead(MachineInstr *, MachineInstr *)
const MachineFunction * getParent() const
instr_iterator erase(instr_iterator I)
pred_reverse_iterator pred_rend()
const_instr_iterator instr_begin() const
instr_iterator instr_begin()
void transferNodesFromList(ilist_node_traits &, ilist_iterator< NodeTy >, ilist_iterator< NodeTy >)
void removeNodeFromList(NodeTy *)
instr_iterator instr_end()
bool operator==(const bundle_iterator &x) const
iplist< MachineInstr >::iterator iterator
static NodeTy * createNode(const NodeTy &V)
void setIsLandingPad(bool V=true)
Instructions::const_iterator const_instr_iterator
const_succ_iterator succ_begin() const
instr_iterator getFirstInstrTerminator()
MachineBasicBlock::pred_iterator ChildIteratorType
bundle_iterator(const bundle_iterator< OtherTy, OtherIterTy > &I)
std::vector< unsigned >::const_iterator livein_iterator
iterator getFirstTerminator()
MachineBasicBlock::succ_iterator ChildIteratorType
void removeLiveIn(unsigned Reg)
static NodeType * getEntryNode(MachineBasicBlock *BB)
void addLiveIn(unsigned Reg)
iterator insertAfter(iterator I, MachineInstr *MI)
Insert MI into the instruction list after I.
LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI, unsigned Reg, MachineInstr *MI, unsigned Neighborhood=10)
DebugLoc findDebugLoc(iterator MBBI)
void moveAfter(MachineBasicBlock *NewBefore)
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *fromMBB)
std::reverse_iterator< const_instr_iterator > const_reverse_instr_iterator
MachineInstr * createSentinel() const
Instructions::iterator instr_iterator
MachineInstrSpan(MachineBasicBlock::iterator I)
iterator insert(iterator I, MachineInstr *MI)
Insert MI into the instruction list before I.
MachineBasicBlock * removeFromParent()
void setAlignment(unsigned Align)
void splice(iterator Where, MachineBasicBlock *Other, iterator From, iterator To)
reverse_iterator rbegin()
void WriteAsOperand(raw_ostream &, const Value *, bool PrintTy=true, const Module *Context=0)
std::vector< MachineBasicBlock * >::const_reverse_iterator const_pred_reverse_iterator
livein_iterator livein_begin() const
void ReplaceUsesOfBlockWith(MachineBasicBlock *Old, MachineBasicBlock *New)
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::ZeroOrMore, cl::values(clEnumValN(DefaultIT,"arm-default-it","Generate IT block based on arch"), clEnumValN(RestrictedIT,"arm-restrict-it","Disallow deprecated IT based on ARMv8"), clEnumValN(NoRestrictedIT,"arm-no-restrict-it","Allow IT blocks based on ARMv7"), clEnumValEnd))
iterator erase(MachineInstr *I)
void insert(iterator I, IT S, IT E)
Insert a range of instructions into the instruction list before I.
std::vector< MachineBasicBlock * >::iterator succ_iterator
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P)
void print(raw_ostream &OS, SlotIndexes *=0) const
MachineInstr * remove_instr(MachineInstr *I)
void destroySentinel(MachineInstr *) const
MachineBasicBlock::iterator end()
static NodeType * getEntryNode(const MachineBasicBlock *BB)
bool isBundledWithSucc() const
void transferSuccessors(MachineBasicBlock *fromMBB)
std::reverse_iterator< instr_iterator > reverse_instr_iterator
const_succ_iterator succ_end() const
const MachineInstr & front() const
bool livein_empty() const
iterator getLastNonDebugInstr()
std::vector< MachineBasicBlock * >::iterator pred_iterator
succ_reverse_iterator succ_rend()
const_pred_iterator pred_end() const
reverse_iterator rbegin()
bundle_iterator operator--(int)
const BasicBlock * getBasicBlock() const
const MachineBasicBlock NodeType
static NodeType * getEntryNode(Inverse< MachineBasicBlock * > G)
const_reverse_instr_iterator instr_rend() const
bundle_iterator< MachineInstr, instr_iterator > iterator
IterTy getInstrIterator() const
static NodeType * getEntryNode(Inverse< const MachineBasicBlock * > G)
iterator SkipPHIsAndLabels(iterator I)
instr_iterator erase_instr(MachineInstr *I)
LLVM Basic Block Representation.
static ChildIteratorType child_end(NodeType *N)
succ_reverse_iterator succ_rbegin()
size_type LLVM_ATTRIBUTE_UNUSED_RESULT size() const
const_iterator begin() const
livein_iterator livein_end() const
iterator insertAfter(iterator where, NodeTy *New)
iterator insert(iterator where, const NodeTy &val)
Register is known to be dead.
ItTy next(ItTy it, Dist n)
std::reverse_iterator< const_iterator > const_reverse_iterator
const MachineBasicBlock * getLandingPadSuccessor() const
const_reverse_instr_iterator instr_rbegin() const
static ChildIteratorType child_begin(NodeType *N)
bool isBundledWithPred() const
LivenessQueryResult
Possible outcome of a register liveness query to computeRegisterLiveness()
Register is known to be live.
succ_iterator succ_begin()
void removeSuccessor(MachineBasicBlock *succ)
bool operator!=(const bundle_iterator &x) const
void moveBefore(MachineBasicBlock *NewAfter)
iterator erase(iterator I)
static ChildIteratorType child_begin(NodeType *N)
pred_iterator pred_begin()
MCSymbol * getSymbol() const
const MachineBasicBlock NodeType
iterator erase(iterator I, iterator E)
Remove a range of instructions from the instruction list and delete them.
iterator erase(iterator where)
std::vector< MachineBasicBlock * >::const_iterator const_pred_iterator
DebugLoc findDebugLoc(instr_iterator MBBI)
static ChildIteratorType child_end(NodeType *N)
std::string getFullName() const
Return a hopefully unique identifier for this block.
MachineInstr * ensureHead(MachineInstr *) const
const_iterator end() const
reverse_instr_iterator instr_rbegin()
const_succ_reverse_iterator succ_rbegin() const
std::vector< MachineBasicBlock * >::const_reverse_iterator const_succ_reverse_iterator
const_succ_reverse_iterator succ_rend() const
std::vector< MachineBasicBlock * >::reverse_iterator succ_reverse_iterator
bool isSuccessor(const MachineBasicBlock *MBB) const
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
MachineBasicBlock::iterator getInitial()
const_reverse_iterator rbegin() const
void splice(iterator where, iplist &L2)
reverse_instr_iterator instr_rend()
static void deleteNode(NodeTy *V)
StringRef getName() const
MachineBasicBlock::const_succ_iterator ChildIteratorType
void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New)
void setHasAddressTaken()
MachineFunction * getParent()
MachineInstr * provideInitialHead() const
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
bundle_iterator(IterTy mii)
bundle_iterator< const MachineInstr, const_instr_iterator > const_iterator
bundle_iterator operator++(int)
bool hasAddressTaken() const
const_pred_iterator pred_begin() const
bool isLandingPad() const
void addNodeToList(NodeTy *)
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
bool isLiveIn(unsigned Reg) const
MachineBasicBlock NodeType
std::reverse_iterator< const_iterator > reverse_iterator
const_reverse_iterator rend() const
void push_back(MachineInstr *MI)
const_pred_reverse_iterator pred_rbegin() const
bundle_iterator & operator--()
instr_iterator insert(instr_iterator I, MachineInstr *M)
iterator getFirstNonPHI()
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
static ChildIteratorType child_begin(NodeType *N)
MachineBasicBlock::const_pred_iterator ChildIteratorType
MachineBasicBlock NodeType
static NodeTy * createSentinel()
createSentinel - create the dynamic sentinel
static ChildIteratorType child_begin(NodeType *N)
std::vector< MachineBasicBlock * >::const_iterator const_succ_iterator
std::reverse_iterator< iterator > reverse_iterator
std::vector< MachineBasicBlock * >::reverse_iterator pred_reverse_iterator
static const Function * getParent(const Value *V)
ItTy prior(ItTy it, Dist n)
const_pred_reverse_iterator pred_rend() const
bool isPredecessor(const MachineBasicBlock *MBB) const
const MachineInstr & back() const
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
const_instr_iterator instr_end() const
NodeTy * remove(iterator &IT)
bundle_iterator & operator++()
void addSuccessor(MachineBasicBlock *succ, uint32_t weight=0)
unsigned pred_size() const
bool CorrectExtraCFGEdges(MachineBasicBlock *DestA, MachineBasicBlock *DestB, bool isCond)
static ChildIteratorType child_end(NodeType *N)
unsigned operator()(const MachineBasicBlock *MBB) const
void push_back(const NodeTy &val)
MachineBasicBlock::iterator begin()
unsigned getAlignment() const