Rename BuildSchedUnits to BuildSchedGraph, and refactor the
authorDan Gohman <gohman@apple.com>
Tue, 23 Dec 2008 18:36:58 +0000 (18:36 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 23 Dec 2008 18:36:58 +0000 (18:36 +0000)
code in ScheduleDAGSDNodes' BuildSchedGraph into separate functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61376 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/ScheduleDAG.h
include/llvm/CodeGen/ScheduleDAGInstrs.h
include/llvm/CodeGen/ScheduleDAGSDNodes.h
lib/CodeGen/PostRASchedulerList.cpp
lib/CodeGen/ScheduleDAGInstrs.cpp
lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp
lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp
lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp

index b90e5254ffd8196c48b533cf903a399ced7d3944..03d11e2d8287dd6e278d465447cffe7d0b144802 100644 (file)
@@ -442,10 +442,10 @@ namespace llvm {
     ///
     void Run();
 
-    /// BuildSchedUnits - Build SUnits and set up their Preds and Succs
+    /// BuildSchedGraph - Build SUnits and set up their Preds and Succs
     /// to form the scheduling dependency graph.
     ///
-    virtual void BuildSchedUnits() = 0;
+    virtual void BuildSchedGraph() = 0;
 
     /// ComputeLatency - Compute node latency.
     ///
index cfea3e08895c9766af04d28461f1aba8bb44d4a9..96d3f0f212a1a9cdc991bce93904d12f9e73e972 100644 (file)
@@ -45,9 +45,9 @@ namespace llvm {
       return &SUnits.back();
     }
 
-    /// BuildSchedUnits - Build SUnits from the MachineBasicBlock that we are
+    /// BuildSchedGraph - Build SUnits from the MachineBasicBlock that we are
     /// input.
-    virtual void BuildSchedUnits();
+    virtual void BuildSchedGraph();
 
     /// ComputeLatency - Compute node latency.
     ///
index b3ec2807d776d97ae0ed6027fbdf454549ad6c9f..d7f0ea49d487de3f46d53a56c1d3b4fc98578646 100644 (file)
@@ -118,10 +118,11 @@ namespace llvm {
     
     virtual SelectionDAG *getDAG() { return DAG; }
 
-    /// BuildSchedUnits - Build SUnits from the selection dag that we are input.
-    /// This SUnit graph is similar to the SelectionDAG, but represents flagged
-    /// together nodes with a single SUnit.
-    virtual void BuildSchedUnits();
+    /// BuildSchedGraph - Build the SUnit graph from the selection dag that we
+    /// are input.  This SUnit graph is similar to the SelectionDAG, but
+    /// excludes nodes that aren't interesting to scheduling, and represents
+    /// flagged together nodes with a single SUnit.
+    virtual void BuildSchedGraph();
 
     /// ComputeLatency - Compute node latency.
     ///
@@ -189,6 +190,10 @@ namespace llvm {
     void CreateVirtualRegisters(SDNode *Node, MachineInstr *MI,
                                 const TargetInstrDesc &II,
                                 DenseMap<SDValue, unsigned> &VRBaseMap);
+
+    /// BuildSchedUnits, AddSchedEdges - Helper functions for BuildSchedGraph.
+    void BuildSchedUnits();
+    void AddSchedEdges();
   };
 }
 
index 18a073c44ec30c0f8207d2f39820b6b78371bf1f..dc11400094cc4ca1ef9e779bc5455901c7d3247d 100644 (file)
@@ -121,8 +121,8 @@ bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) {
 void SchedulePostRATDList::Schedule() {
   DOUT << "********** List Scheduling **********\n";
   
-  // Build scheduling units.
-  BuildSchedUnits();
+  // Build the scheduling graph.
+  BuildSchedGraph();
 
   if (EnableAntiDepBreaking) {
     if (BreakAntiDependencies()) {
@@ -133,7 +133,7 @@ void SchedulePostRATDList::Schedule() {
       // that register, and add new anti-dependence and output-dependence
       // edges based on the next live range of the register.
       SUnits.clear();
-      BuildSchedUnits();
+      BuildSchedGraph();
     }
   }
 
index c47dddaf18992cdc47bca9117568258636510094..8cff5b55585e96ef623b335fa22952d29cf06d32 100644 (file)
@@ -89,7 +89,7 @@ ScheduleDAGInstrs::ScheduleDAGInstrs(MachineBasicBlock *bb,
                                      const MachineDominatorTree &mdt)
   : ScheduleDAG(0, bb, tm), MLI(mli), MDT(mdt) {}
 
-void ScheduleDAGInstrs::BuildSchedUnits() {
+void ScheduleDAGInstrs::BuildSchedGraph() {
   SUnits.clear();
   SUnits.reserve(BB->size());
 
index d917386967cf639d1cbfac1feecf6d7606dea1c8..113dfb1751dcadb9bf585921f37d0326716e7173 100644 (file)
@@ -114,8 +114,8 @@ void ScheduleDAGFast::Schedule() {
   LiveRegDefs.resize(TRI->getNumRegs(), NULL);  
   LiveRegCycles.resize(TRI->getNumRegs(), 0);
 
-  // Build scheduling units.
-  BuildSchedUnits();
+  // Build the scheduling graph.
+  BuildSchedGraph();
 
   DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su)
           SUnits[su].dumpAll(this));
index d42c8d886735012d06618bf9abec6f5cc38efe2f..fea74ca3038d698f2707f61249668f38d5504479 100644 (file)
@@ -91,8 +91,8 @@ HazardRecognizer::~HazardRecognizer() {}
 void ScheduleDAGList::Schedule() {
   DOUT << "********** List Scheduling **********\n";
   
-  // Build scheduling units.
-  BuildSchedUnits();
+  // Build the scheduling graph.
+  BuildSchedGraph();
 
   AvailableQueue->initNodes(SUnits);
   
index c3b6137ae36ece4914e8dd7579b04b6c2aa162e7..aededf44440a5938c0cde17da253d574eda91c88 100644 (file)
@@ -170,8 +170,8 @@ void ScheduleDAGRRList::Schedule() {
   LiveRegDefs.resize(TRI->getNumRegs(), NULL);  
   LiveRegCycles.resize(TRI->getNumRegs(), 0);
 
-  // Build scheduling units.
-  BuildSchedUnits();
+  // Build the scheduling graph.
+  BuildSchedGraph();
 
   DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su)
           SUnits[su].dumpAll(this));
index 4a7920acedba4894f0eb0ec40784ff52372b9bae..347410ae7d690c795c1f5f092eb6530ed5ae4991 100644 (file)
@@ -64,9 +64,6 @@ static void CheckForPhysRegDependency(SDNode *Def, SDNode *User, unsigned Op,
   }
 }
 
-/// BuildSchedUnits - Build SUnits from the selection dag that we are input.
-/// This SUnit graph is similar to the SelectionDAG, but represents flagged
-/// together nodes with a single SUnit.
 void ScheduleDAGSDNodes::BuildSchedUnits() {
   // During scheduling, the NodeId field of SDNode is used to map SDNodes
   // to their associated SUnits by holding SUnits table indices. A value
@@ -146,7 +143,9 @@ void ScheduleDAGSDNodes::BuildSchedUnits() {
     else
       ComputeLatency(NodeSUnit);
   }
-  
+}
+
+void ScheduleDAGSDNodes::AddSchedEdges() {
   // Pass 2: add the preds, succs, etc.
   for (unsigned su = 0, e = SUnits.size(); su != e; ++su) {
     SUnit *SU = &SUnits[su];
@@ -196,6 +195,17 @@ void ScheduleDAGSDNodes::BuildSchedUnits() {
   }
 }
 
+/// BuildSchedGraph - Build the SUnit graph from the selection dag that we
+/// are input.  This SUnit graph is similar to the SelectionDAG, but
+/// excludes nodes that aren't interesting to scheduling, and represents
+/// flagged together nodes with a single SUnit.
+void ScheduleDAGSDNodes::BuildSchedGraph() {
+  // Populate the SUnits array.
+  BuildSchedUnits();
+  // Compute all the scheduling dependencies between nodes.
+  AddSchedEdges();
+}
+
 void ScheduleDAGSDNodes::ComputeLatency(SUnit *SU) {
   const InstrItineraryData &InstrItins = TM.getInstrItineraryData();