Convert SUnit's dump method into a print method and implement
dump in terms of it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59665 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
index da68cd5..b63c3c1 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetRegisterInfo.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
 ScheduleDAG::ScheduleDAG(SelectionDAG *dag, MachineBasicBlock *bb,
@@ -459,22 +460,25 @@
 
 /// SUnit - Scheduling unit. It's an wrapper around either a single SDNode or
 /// a group of nodes flagged together.
-void SUnit::dump(const ScheduleDAG *G) const {
-  cerr << "SU(" << NodeNum << "): ";
+void SUnit::print(raw_ostream &O, const ScheduleDAG *G) const {
+  O << "SU(" << NodeNum << "): ";
   if (getNode()) {
     SmallVector<SDNode *, 4> FlaggedNodes;
     for (SDNode *N = getNode(); N; N = N->getFlaggedNode())
       FlaggedNodes.push_back(N);
     while (!FlaggedNodes.empty()) {
-      cerr << "    ";
+      O << "    ";
       FlaggedNodes.back()->dump(G->DAG);
-      cerr << "\n";
+      O << "\n";
       FlaggedNodes.pop_back();
     }
   } else {
-    cerr << "CROSS RC COPY ";
+    O << "CROSS RC COPY\n";
   }
-  cerr << "\n";
+}
+
+void SUnit::dump(const ScheduleDAG *G) const {
+  print(errs(), G);
 }
 
 void SUnit::dumpAll(const ScheduleDAG *G) const {