new helper method
authorChris Lattner <sabre@nondot.org>
Sun, 6 Mar 2005 20:55:34 +0000 (20:55 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 6 Mar 2005 20:55:34 +0000 (20:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20491 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/LoopInfo.h

index 0be3ddb3a0e1b2cf9c18ffb721ad0fc54d38fb07..402897c1fd9f64504aa6a248daf63c6db272c9ec 100644 (file)
@@ -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.