[CodeGen] Implement the SUnit::print() method
This method seems to have had a troubled life. This patch proposes that it
replaces the recently added helper function dumpSUIdentifier. This way, the
method can be used in other files using the SUnit class.
Differential revision: https://reviews.llvm.org/D28488
llvm-svn: 291520
diff --git a/llvm/lib/CodeGen/ScheduleDAG.cpp b/llvm/lib/CodeGen/ScheduleDAG.cpp
index 1f0c328..427d952 100644
--- a/llvm/lib/CodeGen/ScheduleDAG.cpp
+++ b/llvm/lib/CodeGen/ScheduleDAG.cpp
@@ -310,19 +310,19 @@
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-static void dumpSUIdentifier(const ScheduleDAG &DAG, const SUnit &SU) {
- if (&SU == &DAG.ExitSU)
- dbgs() << "ExitSU";
- else if (&SU == &DAG.EntrySU)
- dbgs() << "EntrySU";
+void SUnit::print(raw_ostream &OS, const ScheduleDAG *DAG) const {
+ if (this == &DAG->ExitSU)
+ OS << "ExitSU";
+ else if (this == &DAG->EntrySU)
+ OS << "EntrySU";
else
- dbgs() << "SU(" << SU.NodeNum << ")";
+ OS << "SU(" << NodeNum << ")";
}
/// 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 {
- dumpSUIdentifier(*G, *this);
+ print(dbgs(), G);
dbgs() << ": ";
G->dumpNode(this);
}
@@ -352,7 +352,7 @@
case SDep::Output: dbgs() << "out "; break;
case SDep::Order: dbgs() << "ord "; break;
}
- dumpSUIdentifier(*G, *I->getSUnit());
+ I->getSUnit()->print(dbgs(), G);
if (I->isArtificial())
dbgs() << " *";
dbgs() << ": Latency=" << I->getLatency();
@@ -372,7 +372,7 @@
case SDep::Output: dbgs() << "out "; break;
case SDep::Order: dbgs() << "ord "; break;
}
- dumpSUIdentifier(*G, *I->getSUnit());
+ I->getSUnit()->print(dbgs(), G);
if (I->isArtificial())
dbgs() << " *";
dbgs() << ": Latency=" << I->getLatency();