27 #ifndef LLVM_ANALYSIS_REGIONINFO_H
28 #define LLVM_ANALYSIS_REGIONINFO_H
51 template <
class GraphType>
126 inline raw_ostream &
operator<<(raw_ostream &OS,
const RegionNode &Node);
129 inline BasicBlock* RegionNode::getNodeAs<BasicBlock>()
const {
130 assert(!isSubRegion() &&
"This is not a BasicBlock RegionNode!");
135 inline Region* RegionNode::getNodeAs<Region>()
const {
136 assert(isSubRegion() &&
"This is not a subregion RegionNode!");
205 const
Region &operator=(const
Region &) LLVM_DELETED_FUNCTION;
215 typedef std::vector<
Region*> RegionSet;
223 mutable BBNodeMapT BBNodeMap;
227 void verifyBBInRegion(BasicBlock* BB) const;
232 void verifyWalk(BasicBlock* BB, std::set<BasicBlock*>* visitedBB) const;
236 void verifyRegionNest() const;
496 template <
bool IsConst>
500 BasicBlock>::type*> {
635 void releaseMemory();
638 void updateStatistics(
Region *R);
642 bool isSimple(
Region* R)
const;
713 return TopLevelRegion;
bool contains(const BasicBlock *BB) const
Check if the region contains a BasicBlock.
unsigned getDepth() const
Get the nesting level of this Region.
void print(raw_ostream &OS, bool printTree=true, unsigned level=0, enum PrintStyle Style=PrintNone) const
Print the region.
BasicBlock * operator*() const
std::string getNameStr() const
Returns the name of the Region.
The main container class for the LLVM Intermediate Representation.
Region * getExpandedRegion() const
Return a new (non canonical) region, that is obtained by joining this region with its predecessors...
const_iterator end() const
void clearNodeCache()
Clear the cache for BB RegionNodes.
pointer operator*() const
Region * getRegionFor(BasicBlock *BB) const
Get the smallest region that contains a BasicBlock.
block_iterator block_begin()
RegionSet::const_iterator const_iterator
element_iterator element_begin()
void replaceExitRecursive(BasicBlock *NewExit)
Recursively replace the exit basic block of the region.
Region * operator[](BasicBlock *BB) const
A shortcut for getRegionFor().
BasicBlock * getEntry() const
Get the entry BasicBlock of the Region.
Region * getCommonRegion(Region *A, Region *B) const
Find the smallest region that contains two regions.
A RegionNode represents a subregion or a BasicBlock that is part of a Region.
block_iterator_wrapper(super I)
bool isTopLevelRegion() const
Check if a Region is the TopLevel region.
LoopInfoBase< BlockT, LoopT > * LI
RegionInfo * getRegionInfo() const
Return the RegionInfo object, that belongs to this Region.
Region * getCommonRegion(BasicBlock *A, BasicBlock *B) const
Find the smallest region that contains two basic blocks.
void replaceExit(BasicBlock *BB)
Replace the exit basic block of the region with the new basic block.
bool contains(const Region *SubRegion) const
Check if the region contains another region.
virtual bool runOnFunction(Function &F)
block_iterator block_end()
RegionSet::iterator iterator
Region * getParent() const
Get the parent Region of this RegionNode.
BasicBlock * getEnteringBlock() const
Return the first block of this region's single entry edge, if existing.
block_iterator_wrapper< true > const_block_iterator
Loop * outermostLoopInRegion(Loop *L) const
Get the outermost loop in the region that contains a loop.
Region * getParent() const
Get the parent of the Region.
const_iterator begin() const
virtual void print(raw_ostream &OS, const Module *) const
void replaceEntry(BasicBlock *BB)
Replace the entry basic block of the region with the new basic block.
const_block_iterator block_end() const
BasicBlock * getEntry() const
Get the entry BasicBlock of this RegionNode.
LLVM Basic Block Representation.
void splitBlock(BasicBlock *NewBB, BasicBlock *OldBB)
Update RegionInfo after a basic block was split.
df_iterator< T > df_end(const T &G)
A single entry single exit Region.
Instr is a loop (backwards branch).
element_iterator element_end()
bool isSimple() const
Is this a simple region?
PrintStyle
PrintStyle - Print region in difference ways.
BasicBlock * getMaxRegionExit(BasicBlock *BB) const
Return the exit of the maximal refined region, that starts at a BasicBlock.
Region * removeSubRegion(Region *SubRegion)
Remove a subregion from this Region.
void transferChildrenTo(Region *To)
Move all direct child nodes of this Region to another Region.
BasicBlock * getExit() const
Get the exit BasicBlock of the Region.
RegionNode(Region *Parent, BasicBlock *Entry, bool isSubRegion=0)
Create a RegionNode.
void setRegionFor(BasicBlock *BB, Region *R)
Set the smallest region that surrounds a basic block.
virtual void verifyAnalysis() const
RegionNode * getNode() const
Get the RegionNode representing the current Region.
PointerTy getPointer() const
void dump() const
Print the region to stderr.
block_iterator_wrapper(pointer Entry, pointer Exit)
block_iterator_wrapper< false > block_iterator
Region * parent
The parent Region of this RegionNode.
RegionNode * getBBNode(BasicBlock *BB) const
Get the BasicBlock RegionNode for a BasicBlock.
Region * getSubRegionNode(BasicBlock *BB) const
Get the subregion that starts at a BasicBlock.
Region * getTopLevelRegion() const
const_block_iterator block_begin() const
virtual void getAnalysisUsage(AnalysisUsage &AU) const
#define LLVM_DELETED_FUNCTION
df_iterator< T > df_begin(const T &G)
PointerIntPair< BasicBlock *, 1, bool > entry
std::string getName(ID id, ArrayRef< Type * > Tys=None)
bool contains(const Instruction *Inst) const
Check if the region contains an Instruction.
bool isSubRegion() const
Is this RegionNode a subregion?
void clearNodeCache()
Clear the Node Cache for all Regions.
Marker class to iterate over the elements of a Region in flat mode.
df_iterator< const RegionNode *, SmallPtrSet< const RegionNode *, 8 >, false, GraphTraits< const RegionNode * > > const_element_iterator
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
void addSubRegion(Region *SubRegion, bool moveChildren=false)
Add a new subregion to this Region.
void verifyRegion() const
Verify if the region is a correct region.
df_iterator< RegionNode *, SmallPtrSet< RegionNode *, 8 >, false, GraphTraits< RegionNode * > > element_iterator
BasicBlock * getExitingBlock() const
Return the first block of this region's single exit edge, if existing.
T * getNodeAs() const
Get the content of this RegionNode.
block_iterator_wrapper< IsConst > Self
const BasicBlock * getParent() const
Analysis that detects all canonical Regions.
void replaceEntryRecursive(BasicBlock *NewEntry)
Recursively replace the entry basic block of the region.