add moveBefore/moveAfter helper methods
authorChris Lattner <sabre@nondot.org>
Tue, 24 Oct 2006 00:02:26 +0000 (00:02 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 24 Oct 2006 00:02:26 +0000 (00:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31145 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineBasicBlock.cpp

index ebd492c7ac2291bd8c465f8fa549fd11eaea3d0c..fcc01299cd8a25b970599314d57331da4004da5d 100644 (file)
@@ -120,6 +120,18 @@ void MachineBasicBlock::print(std::ostream &OS) const {
   }
 }
 
+void MachineBasicBlock::moveBefore(MachineBasicBlock *NewAfter) {
+  MachineFunction::BasicBlockListType &BBList =getParent()->getBasicBlockList();
+  getParent()->getBasicBlockList().splice(NewAfter, BBList, this);
+}
+
+void MachineBasicBlock::moveAfter(MachineBasicBlock *NewBefore) {
+  MachineFunction::BasicBlockListType &BBList =getParent()->getBasicBlockList();
+  MachineFunction::iterator BBI = NewBefore;
+  getParent()->getBasicBlockList().splice(++BBI, BBList, this);
+}
+
+
 void MachineBasicBlock::addSuccessor(MachineBasicBlock *succ) {
   Successors.push_back(succ);
   succ->addPredecessor(this);