summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-12-18 01:24:09 +0000
committerDan Gohman <gohman@apple.com>2009-12-18 01:24:09 +0000
commit18fa5686f6e06c60bcbfd20a6418c2e5bee8c856 (patch)
treeaece8390eca40bd85f9bbcfdf08589109e6271dc /llvm/include
parentfd7231f1fe2ceed126bee6593f940563158c690f (diff)
downloadbcm5719-llvm-18fa5686f6e06c60bcbfd20a6418c2e5bee8c856.tar.gz
bcm5719-llvm-18fa5686f6e06c60bcbfd20a6418c2e5bee8c856.zip
Add Loop contains utility methods for testing whether a loop
contains another loop, or an instruction. The loop form is substantially more efficient on large loops than the typical code it replaces. llvm-svn: 91654
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/Analysis/LoopInfo.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h
index 2294e5352cb..d513f2cb4e2 100644
--- a/llvm/include/llvm/Analysis/LoopInfo.h
+++ b/llvm/include/llvm/Analysis/LoopInfo.h
@@ -93,12 +93,28 @@ public:
BlockT *getHeader() const { return Blocks.front(); }
LoopT *getParentLoop() const { return ParentLoop; }
- /// contains - Return true if the specified basic block is in this loop
+ /// contains - Return true if the specified loop is contained within in
+ /// this loop.
+ ///
+ bool contains(const LoopT *L) const {
+ if (L == this) return true;
+ if (L == 0) return false;
+ return contains(L->getParentLoop());
+ }
+
+ /// contains - Return true if the specified basic block is in this loop.
///
bool contains(const BlockT *BB) const {
return std::find(block_begin(), block_end(), BB) != block_end();
}
+ /// contains - Return true if the specified instruction is in this loop.
+ ///
+ template<class InstT>
+ bool contains(const InstT *Inst) const {
+ return contains(Inst->getParent());
+ }
+
/// iterator/begin/end - Return the loops contained entirely within this loop.
///
const std::vector<LoopT *> &getSubLoops() const { return SubLoops; }
OpenPOWER on IntegriCloud