RegAlloc superpass: includes phi elimination, coalescing, and scheduling.
[oota-llvm.git] / lib / CodeGen / MachineScheduler.cpp
index a14b3912236de6be3b1e8c91dbf7d1f4c42110cf..ba87f5a7ab3c58fc04dcaa5fafc5d9622997ff14 100644 (file)
@@ -43,6 +43,7 @@ public:
   const TargetInstrInfo *TII;
   const MachineLoopInfo *MLI;
   const MachineDominatorTree *MDT;
+  LiveIntervals *LIS;
 
   MachineScheduler();
 
@@ -68,8 +69,6 @@ INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
 INITIALIZE_PASS_DEPENDENCY(SlotIndexes)
 INITIALIZE_PASS_DEPENDENCY(LiveIntervals)
 INITIALIZE_PASS_DEPENDENCY(LiveDebugVariables)
-INITIALIZE_PASS_DEPENDENCY(StrongPHIElimination)
-INITIALIZE_PASS_DEPENDENCY(RegisterCoalescer)
 INITIALIZE_PASS_END(MachineScheduler, "misched",
                     "Machine Instruction Scheduler", false, false)
 
@@ -90,12 +89,6 @@ void MachineScheduler::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addPreserved<LiveIntervals>();
   AU.addRequired<LiveDebugVariables>();
   AU.addPreserved<LiveDebugVariables>();
-  if (StrongPHIElim) {
-    AU.addRequiredID(StrongPHIEliminationID);
-    AU.addPreservedID(StrongPHIEliminationID);
-  }
-  AU.addRequiredID(RegisterCoalescerPassID);
-  AU.addPreservedID(RegisterCoalescerPassID);
   MachineFunctionPass::getAnalysisUsage(AU);
 }
 
@@ -153,7 +146,7 @@ MachineSchedOpt("misched",
 //===----------------------------------------------------------------------===//
 
 namespace {
-/// MachineScheduler is an implementation of ScheduleDAGInstrs that schedules
+/// ScheduleTopDownLive is an implementation of ScheduleDAGInstrs that schedules
 /// machine instructions while updating LiveIntervals.
 class ScheduleTopDownLive : public ScheduleDAGInstrs {
 protected:
@@ -236,13 +229,11 @@ void ScheduleTopDownLive::Schedule() {
     if (&*InsertPos == MI)
       ++InsertPos;
     else {
-      BB->splice(InsertPos, BB, MI);
+      Pass->LIS->moveInstr(InsertPos, MI);
       if (Begin == InsertPos)
         Begin = MI;
     }
 
-    // TODO: Update live intervals.
-
     // Release dependent instructions for scheduling.
     releaseSuccessors(SU);
   }
@@ -253,6 +244,7 @@ bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) {
   MF = &mf;
   MLI = &getAnalysis<MachineLoopInfo>();
   MDT = &getAnalysis<MachineDominatorTree>();
+  LIS = &getAnalysis<LiveIntervals>();
   TII = MF->getTarget().getInstrInfo();
 
   // Select the scheduler, or set the default.
@@ -293,8 +285,10 @@ bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) {
         continue;
       }
       DEBUG(dbgs() << "MachineScheduling " << MF->getFunction()->getName()
-            << ":BB#" << MBB->getNumber() << "\n  From: " << *I << "    To: "
-            << *RegionEnd << " Remaining: " << RemainingCount << "\n");
+            << ":BB#" << MBB->getNumber() << "\n  From: " << *I << "    To: ";
+            if (RegionEnd != MBB->end()) dbgs() << *RegionEnd;
+            else dbgs() << "End";
+            dbgs() << " Remaining: " << RemainingCount << "\n");
 
       // Inform ScheduleDAGInstrs of the region being scheduled. It calls back
       // to our Schedule() method.