Go to the documentation of this file.
13 #ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H
14 #define LLVM_CODEGEN_MACHINEBASICBLOCK_H
34 class MachineFunction;
36 class ModuleSlotTracker;
43 class TargetRegisterClass;
44 class TargetRegisterInfo;
118 std::vector<MachineBasicBlock *> Predecessors;
119 std::vector<MachineBasicBlock *> Successors;
124 std::vector<BranchProbability> Probs;
125 using probability_iterator = std::vector<BranchProbability>::iterator;
126 using const_probability_iterator =
127 std::vector<BranchProbability>::const_iterator;
132 using LiveInVector = std::vector<RegisterMaskPair>;
133 LiveInVector LiveIns;
141 unsigned MaxBytesForAlignment = 0;
144 bool IsEHPad =
false;
148 bool AddressTaken =
false;
152 bool LabelMustBeEmitted =
false;
157 bool IsEHScopeEntry =
false;
160 bool IsEHCatchretTarget =
false;
163 bool IsEHFuncletEntry =
false;
166 bool IsCleanupFuncletEntry =
false;
172 bool IsBeginSection =
false;
175 bool IsEndSection =
false;
178 bool IsInlineAsmBrIndirectTarget =
false;
182 mutable MCSymbol *CachedMCSymbol =
nullptr;
185 mutable MCSymbol *CachedEHCatchretMCSymbol =
nullptr;
189 mutable MCSymbol *CachedEndMCSymbol =
nullptr;
192 MachineBasicBlock() =
default;
196 ~MachineBasicBlock();
248 unsigned size()
const {
return (
unsigned)Insts.size(); }
250 bool empty()
const {
return Insts.empty(); }
295 return &MachineBasicBlock::Insts;
319 std::vector<MachineBasicBlock *>::reverse_iterator;
321 std::vector<MachineBasicBlock *>::const_reverse_iterator;
323 std::vector<MachineBasicBlock *>::reverse_iterator;
325 std::vector<MachineBasicBlock *>::const_reverse_iterator;
331 {
return Predecessors.rbegin();}
333 {
return Predecessors.rbegin();}
335 {
return Predecessors.rend(); }
337 {
return Predecessors.rend(); }
339 return (
unsigned)Predecessors.size();
347 {
return Successors.rbegin(); }
349 {
return Successors.rbegin(); }
351 {
return Successors.rend(); }
353 {
return Successors.rend(); }
355 return (
unsigned)Successors.size();
382 LiveIns.push_back(RegMaskPair);
439 : ExceptionPointer(ExceptionPointer),
440 ExceptionSelector(ExceptionSelector), BlockI(
MBB.
succ_begin()),
444 else if (BlockI != BlockEnd) {
445 LiveRegI = (*BlockI)->livein_begin();
446 if (!advanceToValidPosition())
448 if (LiveRegI->PhysReg == ExceptionPointer ||
449 LiveRegI->PhysReg == ExceptionSelector)
457 if (!advanceToValidPosition())
459 }
while ((*BlockI)->isEHPad() &&
460 (LiveRegI->PhysReg == ExceptionPointer ||
461 LiveRegI->PhysReg == ExceptionSelector));
480 if (BlockI != BlockEnd)
481 return BlockI ==
RHS.BlockI && LiveRegI ==
RHS.LiveRegI;
482 return RHS.BlockI == BlockEnd;
486 return !(*
this ==
RHS);
489 bool advanceToValidPosition() {
490 if (LiveRegI != (*BlockI)->livein_end())
495 }
while (BlockI != BlockEnd && (*BlockI)->livein_empty());
496 if (BlockI == BlockEnd)
499 LiveRegI = (*BlockI)->livein_begin();
503 MCPhysReg ExceptionPointer, ExceptionSelector;
544 MaxBytesForAlignment = MaxBytes;
602 ((unsigned)SectionID.
Type) + SectionID.
Number;
618 return IsInlineAsmBrIndirectTarget;
623 IsInlineAsmBrIndirectTarget = V;
690 bool NormalizeSuccProbs =
false);
698 bool NormalizeSuccProbs =
false);
713 bool NormalizeSuccProbs =
false);
886 template<
typename IT>
889 "iterator points outside of basic block");
890 Insts.insert(
I.getInstrIterator(),
S,
E);
896 "iterator points outside of basic block");
897 assert(!
MI->isBundledWithPred() && !
MI->isBundledWithSucc() &&
898 "Cannot insert instruction with bundle flags");
899 return Insts.insert(
I.getInstrIterator(),
MI);
905 "iterator points outside of basic block");
906 assert(!
MI->isBundledWithPred() && !
MI->isBundledWithSucc() &&
907 "Cannot insert instruction with bundle flags");
908 return Insts.insertAfter(
I.getInstrIterator(),
MI);
915 "iterator points outside of basic block");
916 assert(!
MI->isBundledWithPred() && !
MI->isBundledWithSucc() &&
917 "Cannot insert instruction with bundle flags");
918 while (
I->isBundledWithSucc())
920 return Insts.insertAfter(
I,
MI);
939 return Insts.erase(
I.getInstrIterator(),
E.getInstrIterator());
963 assert(!
I->isBundled() &&
"Cannot remove bundled instructions");
1066 unsigned Neighborhood = 10)
const;
1071 bool IsStandalone =
true)
const;
1073 const SlotIndexes * =
nullptr,
bool IsStandalone =
true)
const;
1098 return IrrLoopHeaderWeight;
1102 IrrLoopHeaderWeight = Weight;
1113 const_probability_iterator
1149 return MBB->getNumber();
1225 return B ==
MBB.end() ?
MBB.begin() : std::next(
B);
1237 template <
typename IterT>
1239 bool SkipPseudoOp =
true) {
1241 (It->isDebugInstr() || (SkipPseudoOp && It->isPseudoProbe())))
1250 template <
class IterT>
1252 bool SkipPseudoOp =
true) {
1253 while (It != Begin &&
1254 (It->isDebugInstr() || (SkipPseudoOp && It->isPseudoProbe())))
1261 template <
typename IterT>
1262 inline IterT
next_nodbg(IterT It, IterT End,
bool SkipPseudoOp =
true) {
1268 template <
typename IterT>
1269 inline IterT
prev_nodbg(IterT It, IterT Begin,
bool SkipPseudoOp =
true) {
1275 template <
typename IterT>
1277 bool SkipPseudoOp =
true) {
1279 return !
MI.isDebugInstr() && !(SkipPseudoOp &&
MI.isPseudoProbe());
1285 #endif // LLVM_CODEGEN_MACHINEBASICBLOCK_H
IterT next_nodbg(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It, then continue incrementing it while it points to a debug instruction.
bool operator==(const MBBSectionID &Other) const
static ChildIteratorType child_end(NodeRef N)
static NodeRef getEntryNode(Inverse< const MachineBasicBlock * > G)
unsigned succ_size() const
iterator_range< const_iterator > terminators() const
pred_iterator pred_begin()
void setIrrLoopHeaderWeight(uint64_t Weight)
This is an optimization pass for GlobalISel generic memory operations.
const_reverse_iterator rend() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void splice(iterator Where, MachineBasicBlock *Other, iterator From, iterator To)
Take a block of instructions from MBB 'Other' in the range [From, To), and insert them into this MBB ...
print lazy value Lazy Value Info Printer Pass
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
void setIsCleanupFuncletEntry(bool V=true)
Indicates if this is the entry block of a cleanup funclet.
LivenessQueryResult
Possible outcome of a register liveness query to computeRegisterLiveness()
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
iterator erase(iterator I)
Remove an instruction or bundle from the instruction list and delete it.
void ReplaceUsesOfBlockWith(MachineBasicBlock *Old, MachineBasicBlock *New)
Given a machine basic block that branched to 'Old', change the code and CFG so that it branches to 'N...
MachineInstrSpan provides an interface to get an iteration range containing the instruction it was in...
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
bool isEHScopeReturn(QueryType Type=AnyInBundle) const
Return true if this is an instruction that marks the end of an EH scope, i.e., a catchpad or a cleanu...
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
iterator erase(iterator I, iterator E)
Remove a range of instructions from the instruction list and delete them.
const_instr_range instrs() const
instr_iterator insertAfterBundle(instr_iterator I, MachineInstr *MI)
If I is bundled then insert MI into the instruction list after the end of the bundle,...
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
void setIsEHCatchretTarget(bool V=true)
Indicates if this is a target block of a catchret.
An ilist node that can access its parent list.
bool sizeWithoutDebugLargerThan(unsigned Limit) const
Reg
All possible values of the reg field in the ModR/M byte.
bool isEntryBlock() const
Returns true if this is the entry block of the function.
void setSuccProbability(succ_iterator I, BranchProbability Prob)
Set successor probability of a given iterator.
MCSymbol * getEHCatchretSymbol() const
Return the EHCatchret Symbol for this basic block.
bool isReturnBlock() const
Convenience function that returns true if the block ends in a return instruction.
base_list_type::const_reverse_iterator const_reverse_iterator
std::vector< MachineBasicBlock * >::const_iterator const_pred_iterator
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
Callbacks do nothing by default in iplist and ilist.
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE and DBG_LABEL instructions.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LiveInVector::const_iterator livein_iterator
const_succ_reverse_iterator succ_rend() const
static NodeRef getEntryNode(const MachineBasicBlock *BB)
void moveBefore(MachineBasicBlock *NewAfter)
Move 'this' block before or after the specified block.
The instances of the Type class are immutable: once they are created, they are never changed.
iterator_range< livein_iterator > liveins() const
reference operator*() const
Optional< uint64_t > getIrrLoopHeaderWeight() const
static ChildIteratorType child_end(NodeRef N)
const MachineInstr & front() const
static ChildIteratorType child_begin(NodeRef N)
void addSuccessorWithoutProb(MachineBasicBlock *Succ)
Add Succ as a successor of this MachineBasicBlock.
iterator_range< const_succ_iterator > successors() const
iterator_range< iterator > terminators()
void clearBasicBlock()
Remove the reference to the underlying IR BasicBlock.
DebugLoc rfindPrevDebugLoc(reverse_iterator MBBI)
void copySuccessor(MachineBasicBlock *Orig, succ_iterator I)
Copy a successor (and any probability info) from original block to this block's.
iterator insert(iterator I, MachineInstr *MI)
Insert MI into the instruction list before I.
std::vector< MachineBasicBlock * >::reverse_iterator succ_reverse_iterator
Manage lifetime of a slot tracker for printing IR.
unsigned const TargetRegisterInfo * TRI
MachineBasicBlock::const_succ_iterator ChildIteratorType
static NodeRef getEntryNode(MachineBasicBlock *BB)
An intrusive list with ownership and callbacks specified/controlled by ilist_traits,...
succ_reverse_iterator succ_rbegin()
Instructions::const_iterator const_instr_iterator
LLVM Basic Block Representation.
iterator_range< const_instr_iterator > const_instr_range
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
bool isBeginSection() const
Returns true if this block begins any section.
const_succ_reverse_iterator succ_rbegin() const
void printName(raw_ostream &os, unsigned printNameFlags=PrintNameIr, ModuleSlotTracker *moduleSlotTracker=nullptr) const
Print the basic block's name as:
liveout_iterator & operator++()
void setSectionID(MBBSectionID V)
Sets the section ID for this basic block.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
MachineInstrBundleIterator< MachineInstr, true > reverse_iterator
const_instr_iterator instr_end() const
void push_back(MachineInstr *MI)
unsigned pred_size() const
iterator_range< liveout_iterator > liveouts() const
void setIsInlineAsmBrIndirectTarget(bool V=true)
Indicates if this is the indirect dest of an INLINEASM_BR.
instr_iterator getFirstInstrTerminator()
Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.
MachineBasicBlock * getSingleSuccessor()
iterator insertAfter(iterator I, MachineInstr *MI)
Insert MI into the instruction list after I.
MachineBasicBlock * removeFromParent()
This method unlinks 'this' from the containing function, and returns it, but does not delete it.
MachineInstr * remove(MachineInstr *I)
Remove the unbundled instruction from the instruction list without deleting it.
liveout_iterator operator++(int)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
friend class MachineFunction
unsigned getMaxBytesForAlignment() const
Return the maximum amount of padding allowed for aligning the basic block.
static ChildIteratorType child_end(NodeRef N)
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
void setMaxBytesForAlignment(unsigned MaxBytes)
Set the maximum amount of padding allowed for aligning the basic block.
const_pred_iterator pred_begin() const
into llvm powi allowing the code generator to produce balanced multiplication trees First
bool isLegalToHoistInto() const
Returns true if it is legal to hoist instructions into this block.
Pair of physical register and lane mask.
std::vector< MachineBasicBlock * >::const_reverse_iterator const_succ_reverse_iterator
pred_reverse_iterator pred_rbegin()
MachineBasicBlock * splitAt(MachineInstr &SplitInst, bool UpdateLiveIns=true, LiveIntervals *LIS=nullptr)
Split a basic block into 2 pieces at SplitPoint.
bool isEHCatchretTarget() const
Returns true if this is a target block of a catchret.
This class implements an extremely fast bulk output stream that can only output to a stream.
MachineInstr & instr_back()
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
MachineBasicBlock::iterator begin()
bool isCleanupFuncletEntry() const
Returns true if this is the entry block of a cleanup funclet.
This struct is a compact representation of a valid (non-zero power of two) alignment.
MachineBasicBlock::iterator end()
static BranchProbability getUnknown()
const_iterator getLastNonDebugInstr(bool SkipPseudoOp=true) const
base_list_type::reverse_iterator reverse_iterator
bool isEHScopeReturnBlock() const
Convenience function that returns true if the bock ends in a EH scope return instruction.
DebugLoc findPrevDebugLoc(instr_iterator MBBI)
Find the previous valid DebugLoc preceding MBBI, skipping and DBG_VALUE instructions.
static ChildIteratorType child_begin(NodeRef N)
MachineBasicBlock::pred_iterator ChildIteratorType
unsigned getSectionIDNum() const
Returns the unique section ID number of this basic block.
void setAlignment(Align A)
Set alignment of the basic block.
Template traits for intrusive list.
const MachineInstr & back() const
instr_iterator getInstrIterator() const
MachineBasicBlock::iterator getInitial()
std::vector< MachineBasicBlock * >::iterator succ_iterator
BranchProbability getSuccProbability(const_succ_iterator Succ) const
Return probability of the edge from this block to MBB.
static NodeRef getEntryNode(Inverse< MachineBasicBlock * > G)
bool hasSuccessorProbabilities() const
Return true if any of the successors have probabilities attached to them.
bool mayHaveInlineAsmBr() const
Returns true if this block may have an INLINEASM_BR (overestimate, by checking if any of the successo...
void printAsOperand(raw_ostream &OS, bool PrintType=true) const
const MachineInstr & instr_back() const
bool operator==(const liveout_iterator &RHS) const
void setAlignment(Align A, unsigned MaxBytes)
reverse_instr_iterator instr_rend()
Representation of each machine instruction.
bool hasAddressTaken() const
Test whether this block is potentially the target of an indirect branch.
void setIsEHPad(bool V=true)
Indicates the block is a landing pad.
const MachineBasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
base_list_type::iterator iterator
static MachineInstrBundleIterator getAtBundleBegin(instr_iterator MI)
Get the bundle iterator for the given instruction's bundle.
const_iterator end() const
iterator SkipPHIsAndLabels(iterator I)
Return the first instruction in MBB after I that is not a PHI or a label.
reverse_instr_iterator instr_rbegin()
@ LQR_Live
Register is known to be (at least partially) live.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
const_iterator getFirstTerminator() const
static ChildIteratorType child_begin(NodeRef N)
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
MachineBasicBlock::const_pred_iterator ChildIteratorType
liveout_iterator liveout_end() const
IterT prev_nodbg(IterT It, IterT Begin, bool SkipPseudoOp=true)
Decrement It, then continue decrementing it while it points to a debug instruction.
const_succ_iterator succ_end() const
iterator getLastNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the last non-debug instruction in the basic block, or end().
Align getAlignment() const
Return alignment of the basic block.
std::input_iterator_tag iterator_category
std::vector< MachineBasicBlock * >::iterator pred_iterator
void setIsEndSection(bool V=true)
const static MBBSectionID ExceptionSectionID
This class prints out the machine instructions using the MIR serialization format.
const MachineInstr & instr_front() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool canFallThrough()
Return true if the block can implicitly transfer control to the block after it by falling off the end...
succ_reverse_iterator succ_rend()
succ_iterator succ_begin()
void setHasAddressTaken()
Set this block to reflect that it potentially is the target of an indirect branch.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
bool operator!=(const liveout_iterator &RHS) const
@ BasicBlock
Various leaf nodes.
unsigned operator()(const MachineBasicBlock *MBB) const
const_reverse_instr_iterator instr_rend() const
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional ldr LCPI1_0 ldr ldr tst movne lsr ldr LCPI1_1 and r0 bx lr it saves an instruction and a register It might be profitable to cse MOVi16 if there are lots of bit immediates with the same bottom half Robert Muth started working on an alternate jump table implementation that does not put the tables in line in the text This is more like the llvm default jump table implementation This might be useful sometime Several revisions of patches are on the mailing beginning while CMP sets them like a subtract Therefore to be able to use CMN for comparisons other than the Z we ll need additional logic to reverse the conditionals associated with the comparison Perhaps a pseudo instruction for the with a post codegen pass to clean up and handle the condition codes See PR5694 for testcase Given the following on int B
livein_iterator livein_end() const
const_pred_reverse_iterator pred_rbegin() const
iterator_range< pred_iterator > predecessors()
Instructions::reverse_iterator reverse_instr_iterator
@ LQR_Dead
Register is known to be fully dead.
bool isReturn(QueryType Type=AnyInBundle) const
instr_iterator instr_begin()
static ChildIteratorType child_end(NodeRef N)
void setIsEHFuncletEntry(bool V=true)
Indicates if this is the entry block of an EH funclet.
instr_iterator instr_end()
void moveAfter(MachineBasicBlock *NewBefore)
@ PrintNameIr
Add IR name where available.
bool hasLabelMustBeEmitted() const
Test whether this block must have its label emitted.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
IterT skipDebugInstructionsForward(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It until it points to a non-debug instruction or to End and return the resulting iterator.
const uint32_t * getBeginClobberMask(const TargetRegisterInfo *TRI) const
Get the clobber mask for the start of this basic block.
iterator_range< iterator > phis()
Returns a range that iterates over the phis in the basic block.
MachineInstrBundleIterator< MachineInstr > iterator
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
bool isEHScopeEntry() const
Returns true if this is the entry block of an EH scope, i.e., the block that used to have a catchpad ...
@ PrintNameAttributes
Print attributes.
iterator getFirstNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the first non-debug instruction in the basic block, or end().
iterator_range< succ_iterator > successors()
bool isEHPad() const
Returns true if the block is a landing pad.
StringRef - Represent a constant reference to a string, i.e.
const_iterator getFirstNonDebugInstr(bool SkipPseudoOp=true) const
reverse_iterator rbegin()
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
bool hasEHPadSuccessor() const
MachineBasicBlock MachineBasicBlock::iterator MBBI
std::string getFullName() const
Return a formatted string to identify this block and its parent function.
iterator_range< livein_iterator > liveins_dbg() const
DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
void removeLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Remove the specified register from the live in set.
enum llvm::MBBSectionID::SectionType Type
DebugLoc rfindDebugLoc(reverse_instr_iterator MBBI)
Has exact same behavior as findDebugLoc (it also searches from the first to the last MI of this MBB) ...
void addNodeToList(NodeTy *)
When an MBB is added to an MF, we need to update the parent pointer of the MBB, the MBB numbering,...
livein_iterator livein_begin_dbg() const
Unlike livein_begin, this method does not check that the liveness information is accurate.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
MachineInstrSpan(MachineBasicBlock::iterator I, MachineBasicBlock *BB)
void splitSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New, bool NormalizeSuccProbs=false)
Split the old successor into old plus new and updates the probability info.
liveout_iterator liveout_begin() const
Iterator scanning successor basic blocks' liveins to determine the registers potentially live at the ...
void transferSuccessors(MachineBasicBlock *FromMBB)
Transfers all the successors from MBB to this machine basic block (i.e., copies all the successors Fr...
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
void setLabelMustBeEmitted()
Set this block to reflect that, regardless how we flow to it, we need its label be emitted.
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
const_pred_iterator pred_end() const
MachineInstr & instr_front()
void addLiveIn(const RegisterMaskPair &RegMaskPair)
void setIsEHScopeEntry(bool V=true)
Indicates if this is the entry block of an EH scope, i.e., the block that that used to have a catchpa...
RegisterMaskPair(MCPhysReg PhysReg, LaneBitmask LaneMask)
Wrapper class representing virtual and physical registers.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
bool isPredecessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a predecessor of this block.
iterator_range< const_iterator > phis() const
const_succ_iterator succ_begin() const
MCSymbol * getEndSymbol() const
Returns the MCSymbol marking the end of this basic block.
bool canSplitCriticalEdge(const MachineBasicBlock *Succ) const
Check if the edge between this block and the given successor Succ, can be split.
MachineInstrBundleIterator< const MachineInstr, true > const_reverse_iterator
void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New)
Replace successor OLD with NEW and update probability info.
void replacePhiUsesWith(MachineBasicBlock *Old, MachineBasicBlock *New)
Update all phi nodes in this basic block to refer to basic block New instead of basic block Old.
void sortUniqueLiveIns()
Sorts and uniques the LiveIns vector.
void removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs=false)
Remove successor from the successors list of this MachineBasicBlock.
bool isEndSection() const
Returns true if this block ends any section.
MachineBasicBlock::succ_iterator ChildIteratorType
iterator erase(MachineInstr *I)
Remove an instruction from the instruction list and delete it.
const static MBBSectionID ColdSectionID
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
Iterator for intrusive lists based on ilist_node.
LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI, MCRegister Reg, const_iterator Before, unsigned Neighborhood=10) const
Return whether (physical) register Reg has been defined and not killed as of just before Before.
bool operator!=(const MBBSectionID &Other) const
Instructions::iterator instr_iterator
void setIsBeginSection(bool V=true)
std::vector< MachineBasicBlock * >::reverse_iterator pred_reverse_iterator
void removeNodeFromList(NodeTy *)
pointer operator->() const
livein_iterator livein_begin() const
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
DebugLoc rfindPrevDebugLoc(reverse_instr_iterator MBBI)
Has exact same behavior as findPrevDebugLoc (it also searches from the last to the first MI of this M...
MachineFunction * getParent()
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
bool livein_empty() const
DebugLoc findPrevDebugLoc(iterator MBBI)
MachineBasicBlock * getFallThrough()
Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...
void validateSuccProbs() const
Validate successors' probabilities and check if the sum of them is approximate one.
const uint32_t * getEndClobberMask(const TargetRegisterInfo *TRI) const
Get the clobber mask for the end of the basic block.
const_instr_iterator instr_begin() const
Pass interface - Implemented by all 'passes'.
IterT skipDebugInstructionsBackward(IterT It, IterT Begin, bool SkipPseudoOp=true)
Decrement It until it points to a non-debug instruction or to Begin and return the resulting iterator...
static void normalizeProbabilities(ProbabilityIter Begin, ProbabilityIter End)
bool isInlineAsmBrIndirectTarget() const
Returns true if this is the indirect dest of an INLINEASM_BR.
static void deleteNode(NodeTy *V)
Simple wrapper around std::function<void(raw_ostream&)>.
base_list_type::const_iterator const_iterator
DebugLoc findDebugLoc(iterator MBBI)
A range adaptor for a pair of iterators.
std::vector< MachineBasicBlock * >::const_iterator const_succ_iterator
void clearLiveIns()
Clear live in list.
A simple intrusive list implementation.
const_iterator begin() const
static ChildIteratorType child_begin(NodeRef N)
instr_iterator erase_instr(MachineInstr *I)
Remove an instruction from the instruction list and delete it.
void insert(iterator I, IT S, IT E)
Insert a range of instructions into the instruction list before I.
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
pred_reverse_iterator pred_rend()
std::vector< MachineBasicBlock * >::const_reverse_iterator const_pred_reverse_iterator
@ LQR_Unknown
Register liveness not decidable from local neighborhood.
iterator SkipPHIsLabelsAndDebug(iterator I, bool SkipPseudoOp=true)
Return the first instruction in MBB after I that is not a PHI, label or debug.
BlockVerifier::State From
void print(raw_ostream &OS, const SlotIndexes *=nullptr, bool IsStandalone=true) const
void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator)
Callback before transferring nodes to this list.
const_reverse_iterator rbegin() const
void updateTerminator(MachineBasicBlock *PreviousLayoutSuccessor)
Update the terminator instructions in block to account for changes to block layout which may have bee...
iterator_range< instr_iterator > instr_range
DebugLoc rfindDebugLoc(reverse_iterator MBBI)
const_pred_reverse_iterator pred_rend() const
std::ptrdiff_t difference_type
static Instructions MachineBasicBlock::* getSublistAccess(MachineInstr *)
Support for MachineInstr::getNextNode().
liveout_iterator(const MachineBasicBlock &MBB, MCPhysReg ExceptionPointer, MCPhysReg ExceptionSelector, bool End)
MachineBasicBlock * SplitCriticalEdge(MachineBasicBlock *Succ, Pass &P, std::vector< SparseBitVector<>> *LiveInSets=nullptr)
Split the critical edge from this block to the given successor block, and return the newly created bl...
MachineInstr * remove_instr(MachineInstr *I)
Remove the possibly bundled instruction from the instruction list without deleting it.
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
static constexpr LaneBitmask getAll()
auto instructionsWithoutDebug(IterT It, IterT End, bool SkipPseudoOp=true)
Construct a range iterator which begins at It and moves forwards until End is reached,...
Optional< std::vector< StOtherPiece > > Other
Wrapper class representing physical registers. Should be passed by value.
bool sameSection(const MachineBasicBlock *MBB) const
Returns true if this and MBB belong to the same section.
iterator_range< const_pred_iterator > predecessors() const
const_reverse_instr_iterator instr_rbegin() const