aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Analysis/LoopInfo.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-03-06 20:55:34 +0000
committerChris Lattner <sabre@nondot.org>2005-03-06 20:55:34 +0000
commit51a4ad475b095aed49caff176b98c0754e421af4 (patch)
treead953d4ec23d01b2afbf5df41a212b73556390df /include/llvm/Analysis/LoopInfo.h
parentbe876b6036d1e4bd16da3c992b67c548c66d3ee1 (diff)
downloadexternal_llvm-51a4ad475b095aed49caff176b98c0754e421af4.zip
external_llvm-51a4ad475b095aed49caff176b98c0754e421af4.tar.gz
external_llvm-51a4ad475b095aed49caff176b98c0754e421af4.tar.bz2
new helper method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20491 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis/LoopInfo.h')
-rw-r--r--include/llvm/Analysis/LoopInfo.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h
index 0be3ddb..402897c 100644
--- a/include/llvm/Analysis/LoopInfo.h
+++ b/include/llvm/Analysis/LoopInfo.h
@@ -175,6 +175,21 @@ public:
Blocks.push_back(BB);
}
+ /// moveToHeader - This method is used to move BB (which must be part of this
+ /// loop) to be the loop header of the loop (the block that dominates all
+ /// others).
+ void moveToHeader(BasicBlock *BB) {
+ if (Blocks[0] == BB) return;
+ for (unsigned i = 0; ; ++i) {
+ assert(i != Blocks.size() && "Loop does not contain BB!");
+ if (Blocks[i] == BB) {
+ Blocks[i] = Blocks[0];
+ Blocks[0] = BB;
+ return;
+ }
+ }
+ }
+
/// removeBlockFromLoop - This removes the specified basic block from the
/// current loop, updating the Blocks as appropriate. This does not update
/// the mapping in the LoopInfo class.