diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2010-07-27 04:17:13 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2010-07-27 04:17:13 +0000 |
commit | 082d587d35a41ee06985d7867b72fb2632962281 (patch) | |
tree | aa057955c7ba37f35f9b67830660639fbfe20911 /include/llvm/Analysis | |
parent | 81c7b19f0494b3995a564778f666025495033d86 (diff) | |
download | external_llvm-082d587d35a41ee06985d7867b72fb2632962281.zip external_llvm-082d587d35a41ee06985d7867b72fb2632962281.tar.gz external_llvm-082d587d35a41ee06985d7867b72fb2632962281.tar.bz2 |
Add function to query RegionInfo about loops.
* contains(Loop), * getOutermostLoop()
* Improve getNameStr() to return a sensible name, if basic blocks are not named.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109490 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis')
-rw-r--r-- | include/llvm/Analysis/RegionInfo.h | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/include/llvm/Analysis/RegionInfo.h b/include/llvm/Analysis/RegionInfo.h index c4ac1eb..a54509f 100644 --- a/include/llvm/Analysis/RegionInfo.h +++ b/include/llvm/Analysis/RegionInfo.h @@ -37,6 +37,8 @@ namespace llvm { class Region; class RegionInfo; class raw_ostream; +class Loop; +class LoopInfo; /// @brief Marker class to iterate over the elements of a Region in flat mode. /// @@ -287,16 +289,7 @@ public: /// @brief Returns the name of the Region. /// @return The Name of the Region. - std::string getNameStr() const { - std::string exitName; - - if (getExit()) - exitName = getExit()->getNameStr(); - else - exitName = "<Function Return>"; - - return getEntry()->getNameStr() + " => " + exitName; - } + std::string getNameStr() const; /// @brief Return the RegionInfo object, that belongs to this Region. RegionInfo *getRegionInfo() const { @@ -340,6 +333,36 @@ public: return contains(Inst->getParent()); } + /// @brief Check if the region contains a loop. + /// + /// @param L The loop that might be contained in this region. + /// @return True if the loop is contained in the region otherwise false. + /// In case a NULL pointer is passed to this function the result + /// is false, except for the region that describes the whole function. + /// In that case true is returned. + bool contains(const Loop *L) const; + + /// @brief Get the outermost loop in the region that contains a loop. + /// + /// Find for a Loop L the outermost loop OuterL that is a parent loop of L + /// and is itself contained in the region. + /// + /// @param L The loop the lookup is started. + /// @return The outermost loop in the region, NULL if such a loop does not + /// exist or if the region describes the whole function. + Loop *outermostLoopInRegion(Loop *L) const; + + /// @brief Get the outermost loop in the region that contains a basic block. + /// + /// Find for a basic block BB the outermost loop L that contains BB and is + /// itself contained in the region. + /// + /// @param LI A pointer to a LoopInfo analysis. + /// @param BB The basic block surrounded by the loop. + /// @return The outermost loop in the region, NULL if such a loop does not + /// exist or if the region describes the whole function. + Loop *outermostLoopInRegion(LoopInfo *LI, BasicBlock* BB) const; + /// @brief Get the subregion that starts at a BasicBlock /// /// @param BB The BasicBlock the subregion should start. |