Revamp the loop unroller, extending it to correctly update PHI nodes
[oota-llvm.git] / lib / CodeGen / MachineBasicBlock.cpp
index dc6a618d34c782fffa5e7d1781a908ab7e60ea5d..01aaba5282b1568dcebdceca00c190f8cf9b43ab 100644 (file)
@@ -166,6 +166,7 @@ void MachineBasicBlock::print(std::ostream &OS) const {
   if (LBB) OS << LBB->getName() << ": ";
   OS << (const void*)this
      << ", LLVM BB @" << (const void*) LBB << ", ID#" << getNumber();
+  if (Alignment) OS << ", Alignment " << Alignment;
   if (isLandingPad()) OS << ", EH LANDING PAD";
   OS << ":\n";
 
@@ -204,6 +205,11 @@ void MachineBasicBlock::removeLiveIn(unsigned Reg) {
   LiveIns.erase(I);
 }
 
+bool MachineBasicBlock::isLiveIn(unsigned Reg) const {
+  const_livein_iterator I = std::find(livein_begin(), livein_end(), Reg);
+  return I != livein_end();
+}
+
 void MachineBasicBlock::moveBefore(MachineBasicBlock *NewAfter) {
   MachineFunction::BasicBlockListType &BBList =getParent()->getBasicBlockList();
   getParent()->getBasicBlockList().splice(NewAfter, BBList, this);
@@ -246,6 +252,19 @@ void MachineBasicBlock::removePredecessor(MachineBasicBlock *pred) {
   Predecessors.erase(I);
 }
 
+void MachineBasicBlock::transferSuccessors(MachineBasicBlock *fromMBB)
+{
+  if (this == fromMBB)
+    return;
+  
+  for(MachineBasicBlock::succ_iterator iter = fromMBB->succ_begin(), 
+      end = fromMBB->succ_end(); iter != end; ++iter) {
+      addSuccessor(*iter);
+  }
+  while(!fromMBB->succ_empty())
+    fromMBB->removeSuccessor(fromMBB->succ_begin());
+}
+
 bool MachineBasicBlock::isSuccessor(MachineBasicBlock *MBB) const {
   std::vector<MachineBasicBlock *>::const_iterator I =
     std::find(Successors.begin(), Successors.end(), MBB);