mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-26 07:34:06 +00:00
Add single entry / single exit accessors.
Add methods for accessing the (single) entry / exit edge of a region. If no such edge exists, null is returned. Both accessors return the start block of the corresponding edge. The edge can finally be formed by utilizing Region::getEntry() or Region::getExit(); Contributed by: Andreas Simbuerger <simbuerg@fim.uni-passau.de> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123410 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0c9f250d54
commit
21d842c353
@ -305,6 +305,20 @@ public:
|
||||
/// NULL if such a basic block does not exist.
|
||||
Region *getExpandedRegion() const;
|
||||
|
||||
/// @brief Return the first block of this region's single entry edge,
|
||||
/// if existing.
|
||||
///
|
||||
/// @return The BasicBlock starting this region's single entry edge,
|
||||
/// else NULL.
|
||||
BasicBlock *getEnteringBlock() const;
|
||||
|
||||
/// @brief Return the first block of this region's single exit edge,
|
||||
/// if existing.
|
||||
///
|
||||
/// @return The BasicBlock starting this region's single exit edge,
|
||||
/// else NULL.
|
||||
BasicBlock *getExitingBlock() const;
|
||||
|
||||
/// @brief Is this a simple region?
|
||||
///
|
||||
/// A region is simple if it has exactly one exit and one entry edge.
|
||||
|
@ -134,40 +134,49 @@ Loop *Region::outermostLoopInRegion(LoopInfo *LI, BasicBlock* BB) const {
|
||||
return outermostLoopInRegion(L);
|
||||
}
|
||||
|
||||
bool Region::isSimple() const {
|
||||
bool isSimple = true;
|
||||
bool found = false;
|
||||
|
||||
BasicBlock *entry = getEntry(), *exit = getExit();
|
||||
|
||||
if (isTopLevelRegion())
|
||||
return false;
|
||||
BasicBlock *Region::getEnteringBlock() const {
|
||||
BasicBlock *entry = getEntry();
|
||||
BasicBlock *Pred;
|
||||
BasicBlock *enteringBlock = 0;
|
||||
|
||||
for (pred_iterator PI = pred_begin(entry), PE = pred_end(entry); PI != PE;
|
||||
++PI) {
|
||||
BasicBlock *Pred = *PI;
|
||||
Pred = *PI;
|
||||
if (DT->getNode(Pred) && !contains(Pred)) {
|
||||
if (found) {
|
||||
isSimple = false;
|
||||
break;
|
||||
}
|
||||
found = true;
|
||||
if (enteringBlock)
|
||||
return 0;
|
||||
|
||||
enteringBlock = Pred;
|
||||
}
|
||||
}
|
||||
|
||||
found = false;
|
||||
return enteringBlock;
|
||||
}
|
||||
|
||||
BasicBlock *Region::getExitingBlock() const {
|
||||
BasicBlock *exit = getExit();
|
||||
BasicBlock *Pred;
|
||||
BasicBlock *exitingBlock = 0;
|
||||
|
||||
if (!exit)
|
||||
return 0;
|
||||
|
||||
for (pred_iterator PI = pred_begin(exit), PE = pred_end(exit); PI != PE;
|
||||
++PI)
|
||||
if (contains(*PI)) {
|
||||
if (found) {
|
||||
isSimple = false;
|
||||
break;
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
++PI) {
|
||||
Pred = *PI;
|
||||
if (contains(Pred)) {
|
||||
if (exitingBlock)
|
||||
return 0;
|
||||
|
||||
return isSimple;
|
||||
exitingBlock = Pred;
|
||||
}
|
||||
}
|
||||
|
||||
return exitingBlock;
|
||||
}
|
||||
|
||||
bool Region::isSimple() const {
|
||||
return !isTopLevelRegion() && getEnteringBlock() && getExitingBlock();
|
||||
}
|
||||
|
||||
std::string Region::getNameStr() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user