Move the code for printing a graph node label for an SUnit into

a virtual method of SelectionDAG.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59667 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2008-11-19 22:09:45 +00:00
parent 252ae9e8ae
commit 7d1cd3f21d
3 changed files with 25 additions and 24 deletions

View File

@ -396,6 +396,10 @@ namespace llvm {
///
virtual void Schedule() = 0;
/// getGraphpNodeLabel - Return a label for an SUnit node in a Graphviz or similar
/// graph visualization.
virtual std::string getGraphNodeLabel(const SUnit *SU) const;
private:
/// EmitSubregNode - Generate machine code for subreg nodes.
///

View File

@ -468,7 +468,7 @@ void SUnit::print(raw_ostream &O, const ScheduleDAG *G) const {
FlaggedNodes.push_back(N);
while (!FlaggedNodes.empty()) {
O << " ";
FlaggedNodes.back()->dump(G->DAG);
FlaggedNodes.back()->print(O, G->DAG);
O << "\n";
FlaggedNodes.pop_back();
}

View File

@ -444,31 +444,28 @@ namespace llvm {
std::string DOTGraphTraits<ScheduleDAG*>::getNodeLabel(const SUnit *SU,
const ScheduleDAG *G) {
std::string Op;
if (G->DAG) {
if (!SU->getNode())
Op = "<CROSS RC COPY>";
else {
SmallVector<SDNode *, 4> FlaggedNodes;
for (SDNode *N = SU->getNode(); N; N = N->getFlaggedNode())
FlaggedNodes.push_back(N);
while (!FlaggedNodes.empty()) {
Op += DOTGraphTraits<SelectionDAG*>::getNodeLabel(FlaggedNodes.back(),
G->DAG) + "\n";
FlaggedNodes.pop_back();
}
}
} else {
std::string s;
raw_string_ostream oss(s);
SU->getInstr()->print(oss);
Op += oss.str();
}
return Op;
return G->getGraphNodeLabel(SU);
}
std::string ScheduleDAG::getGraphNodeLabel(const SUnit *SU) const {
std::string s;
raw_string_ostream O(s);
O << "SU(" << SU->NodeNum << "): ";
if (SU->getNode()) {
SmallVector<SDNode *, 4> FlaggedNodes;
for (SDNode *N = SU->getNode(); N; N = N->getFlaggedNode())
FlaggedNodes.push_back(N);
while (!FlaggedNodes.empty()) {
O << DOTGraphTraits<SelectionDAG*>::getNodeLabel(FlaggedNodes.back(), DAG);
FlaggedNodes.pop_back();
if (!FlaggedNodes.empty())
O << "\n ";
}
} else {
O << "CROSS RC COPY";
}
return O.str();
}
/// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
/// rendered using 'dot'.