Cleanup in preparation for misched: Move DAG visualization logic.
authorAndrew Trick <atrick@apple.com>
Wed, 7 Mar 2012 00:18:22 +0000 (00:18 +0000)
committerAndrew Trick <atrick@apple.com>
Wed, 7 Mar 2012 00:18:22 +0000 (00:18 +0000)
Soon, ScheduleDAG will not refer to the BB.

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

include/llvm/CodeGen/ScheduleDAG.h
lib/CodeGen/ScheduleDAGInstrs.cpp
lib/CodeGen/ScheduleDAGInstrs.h
lib/CodeGen/ScheduleDAGPrinter.cpp
lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.h

index a6ad732c0bebfaf5364b7586f6eb71bfe592a998..fa34e82bff839e01a4d5eeac6bfeafa7b03216bc 100644 (file)
@@ -519,6 +519,7 @@ namespace llvm {
     /// viewGraph - Pop up a GraphViz/gv window with the ScheduleDAG rendered
     /// using 'dot'.
     ///
     /// viewGraph - Pop up a GraphViz/gv window with the ScheduleDAG rendered
     /// using 'dot'.
     ///
+    void viewGraph(const Twine &Name, const Twine &Title);
     void viewGraph();
 
     /// EmitSchedule - Insert MachineInstrs into the MachineBasicBlock
     void viewGraph();
 
     /// EmitSchedule - Insert MachineInstrs into the MachineBasicBlock
@@ -534,6 +535,9 @@ namespace llvm {
     /// of the ScheduleDAG.
     virtual std::string getGraphNodeLabel(const SUnit *SU) const = 0;
 
     /// of the ScheduleDAG.
     virtual std::string getGraphNodeLabel(const SUnit *SU) const = 0;
 
+    /// getDAGLabel - Return a label for the region of code covered by the DAG.
+    virtual std::string getDAGName() const = 0;
+
     /// addCustomGraphFeatures - Add custom features for a visualization of
     /// the ScheduleDAG.
     virtual void addCustomGraphFeatures(GraphWriter<ScheduleDAG*> &) const {}
     /// addCustomGraphFeatures - Add custom features for a visualization of
     /// the ScheduleDAG.
     virtual void addCustomGraphFeatures(GraphWriter<ScheduleDAG*> &) const {}
index c0ccdb33e84ff05aacb9d4924e151bab8dbe100a..bad6286b4dd480e435e085359e0939d79695ed96 100644 (file)
@@ -808,6 +808,12 @@ std::string ScheduleDAGInstrs::getGraphNodeLabel(const SUnit *SU) const {
   return oss.str();
 }
 
   return oss.str();
 }
 
+/// Return the basic block label. It is not necessarilly unique because a block
+/// contains multiple scheduling regions. But it is fine for visualization.
+std::string ScheduleDAGInstrs::getDAGName() const {
+  return "dag." + BB->getFullName();
+}
+
 // EmitSchedule - Emit the machine code in scheduled order.
 MachineBasicBlock *ScheduleDAGInstrs::EmitSchedule() {
   Begin = InsertPos;
 // EmitSchedule - Emit the machine code in scheduled order.
 MachineBasicBlock *ScheduleDAGInstrs::EmitSchedule() {
   Begin = InsertPos;
index 248c273a7284ece4bb51d1d1ad61d0dc721ff049..7d761044919a59e33eae695834c007a90e96b8ee 100644 (file)
@@ -285,6 +285,8 @@ namespace llvm {
 
     virtual std::string getGraphNodeLabel(const SUnit *SU) const;
 
 
     virtual std::string getGraphNodeLabel(const SUnit *SU) const;
 
+    virtual std::string getDAGName() const;
+
   protected:
     SUnit *getSUnit(MachineInstr *MI) const {
       DenseMap<MachineInstr*, SUnit*>::const_iterator I = MISUnitMap.find(MI);
   protected:
     SUnit *getSUnit(MachineInstr *MI) const {
       DenseMap<MachineInstr*, SUnit*>::const_iterator I = MISUnitMap.find(MI);
index f2c2f773f28db533a461e965373506bd09e4ba05..38feee95a58ef8671b70d80013bf3bcf249a62d9 100644 (file)
@@ -81,18 +81,17 @@ std::string DOTGraphTraits<ScheduleDAG*>::getNodeLabel(const SUnit *SU,
 /// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
 /// rendered using 'dot'.
 ///
 /// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
 /// rendered using 'dot'.
 ///
-void ScheduleDAG::viewGraph() {
-// This code is only for debugging!
+void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
+  // This code is only for debugging!
 #ifndef NDEBUG
 #ifndef NDEBUG
-  if (BB->getBasicBlock())
-    ViewGraph(this, "dag." + MF.getFunction()->getName(), false,
-              "Scheduling-Units Graph for " + MF.getFunction()->getName() +
-              ":" + BB->getBasicBlock()->getName());
-  else
-    ViewGraph(this, "dag." + MF.getFunction()->getName(), false,
-              "Scheduling-Units Graph for " + MF.getFunction()->getName());
+  ViewGraph(this, Name, false, Title);
 #else
   errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
          << "systems with Graphviz or gv!\n";
 #endif  // NDEBUG
 }
 #else
   errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
          << "systems with Graphviz or gv!\n";
 #endif  // NDEBUG
 }
+
+/// Out-of-line implementation with no arguments is handy for gdb.
+void ScheduleDAG::viewGraph() {
+  viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
+}
index 71f07d6fa47a7147428631d4042d7b325e746982..c5c5bcd5daa201ad54dd77ef0e180548887f9232 100644 (file)
@@ -800,3 +800,8 @@ MachineBasicBlock *ScheduleDAGSDNodes::EmitSchedule() {
   InsertPos = Emitter.getInsertPos();
   return BB;
 }
   InsertPos = Emitter.getInsertPos();
   return BB;
 }
+
+/// Return the basic block label.
+std::string ScheduleDAGSDNodes::getDAGName() const {
+  return "sunit-dag." + BB->getFullName();
+}
index d7e13d7b25c1fffdd302fa878fb1c02374bfdae0..9023f3b03fdc944bcea0ed445ab78886e0187e9f 100644 (file)
@@ -115,6 +115,8 @@ namespace llvm {
 
     virtual std::string getGraphNodeLabel(const SUnit *SU) const;
 
 
     virtual std::string getGraphNodeLabel(const SUnit *SU) const;
 
+    virtual std::string getDAGName() const;
+
     virtual void getCustomGraphFeatures(GraphWriter<ScheduleDAG*> &GW) const;
 
     /// RegDefIter - In place iteration over the values defined by an
     virtual void getCustomGraphFeatures(GraphWriter<ScheduleDAG*> &GW) const;
 
     /// RegDefIter - In place iteration over the values defined by an