diff options
author | Chris Lattner <sabre@nondot.org> | 2004-04-12 20:26:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-04-12 20:26:17 +0000 |
commit | 46758a894f5d9ca7adc8ec03dd6adeb36b7eadb3 (patch) | |
tree | 27fb6f31321831a71584bd595d498c43aaf4e389 /include | |
parent | 479f7e5e78acc18a0aa39f28c66165195db699b9 (diff) | |
download | external_llvm-46758a894f5d9ca7adc8ec03dd6adeb36b7eadb3.zip external_llvm-46758a894f5d9ca7adc8ec03dd6adeb36b7eadb3.tar.gz external_llvm-46758a894f5d9ca7adc8ec03dd6adeb36b7eadb3.tar.bz2 |
Add some methods that are useful for updating loop information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12871 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Analysis/LoopInfo.h | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index aba4454..d1d2944 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -9,7 +9,7 @@ // // This file defines the LoopInfo class that is used to identify natural loops // and determine the loop depth of various nodes of the CFG. Note that natural -// loops may actually be several loops that share the same header node... +// loops may actually be several loops that share the same header node. // // This analysis calculates the nesting structure of loops in a function. For // each natural loop identified, this analysis identifies natural loops @@ -48,6 +48,9 @@ class Loop { Loop(const Loop &); // DO NOT IMPLEMENT const Loop &operator=(const Loop &); // DO NOT IMPLEMENT public: + /// Loop ctor - This creates an empty loop. + Loop() : ParentLoop(0), LoopDepth(0) { + } unsigned getLoopDepth() const { return LoopDepth; } BasicBlock *getHeader() const { return Blocks.front(); } @@ -117,11 +120,45 @@ public: /// void changeExitBlock(BasicBlock *Old, BasicBlock *New); + /// replaceChildLoopWith - This is used when splitting loops up. It replaces + /// the OldChild entry in our children list with NewChild, and updates the + /// parent pointer of OldChild to be null and the NewChild to be this loop. + /// This updates the loop depth of the new child. + void replaceChildLoopWith(Loop *OldChild, Loop *NewChild); + + /// addChildLoop - Add the specified loop to be a child of this loop. This + /// updates the loop depth of the new child. + /// + void addChildLoop(Loop *NewChild); + + /// removeChildLoop - This removes the specified child from being a subloop of + /// this loop. The loop is not deleted, as it will presumably be inserted + /// into another loop. + Loop *removeChildLoop(iterator OldChild); + + /// addExitBlock - Add the specified exit block to the loop. + /// + void addExitBlock(BasicBlock *BB) { + ExitBlocks.push_back(BB); + } + + /// addBlockEntry - This adds a basic block directly to the basic block list. + /// This should only be used by transformations that create new loops. Other + /// transformations should use addBasicBlockToLoop. + void addBlockEntry(BasicBlock *BB) { + Blocks.push_back(BB); + } + + /// removeBlockFromLoop - This removes the specified basic block from the + /// current loop, updating the Blocks and ExitBlocks lists as appropriate. + /// This does not update the mapping in the LoopInfo class. + void removeBlockFromLoop(BasicBlock *BB); + void print(std::ostream &O, unsigned Depth = 0) const; void dump() const; private: friend class LoopInfo; - inline Loop(BasicBlock *BB) : ParentLoop(0) { + Loop(BasicBlock *BB) : ParentLoop(0) { Blocks.push_back(BB); LoopDepth = 0; } ~Loop() { @@ -194,6 +231,15 @@ public: /// virtual void getAnalysisUsage(AnalysisUsage &AU) const; + /// changeLoopFor - Change the top-level loop that contains BB to the + /// specified loop. This should be used by transformations that restructure + /// the loop hierarchy tree. + void changeLoopFor(BasicBlock *BB, Loop *L); + + /// changeTopLevelLoop - Replace the specified loop in the top-level loops + /// list with the indicated loop. + void changeTopLevelLoop(Loop *OldLoop, Loop *NewLoop); + static void stub(); // Noop private: void Calculate(const DominatorSet &DS); |