From f4d95fdce9101b959c093f08d6df881886edcc07 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 19 Nov 2008 22:09:45 +0000 Subject: Move the code for printing a graph node label for an SUnit into a virtual method of SelectionDAG. llvm-svn: 59667 --- .../CodeGen/SelectionDAG/SelectionDAGPrinter.cpp | 39 ++++++++++------------ 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp index 758b8f263b3..d7481085dfd 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp @@ -444,32 +444,29 @@ namespace llvm { std::string DOTGraphTraits::getNodeLabel(const SUnit *SU, const ScheduleDAG *G) { - std::string Op; - - if (G->DAG) { - if (!SU->getNode()) - Op = ""; - else { - SmallVector FlaggedNodes; - for (SDNode *N = SU->getNode(); N; N = N->getFlaggedNode()) - FlaggedNodes.push_back(N); - while (!FlaggedNodes.empty()) { - Op += DOTGraphTraits::getNodeLabel(FlaggedNodes.back(), - G->DAG) + "\n"; - FlaggedNodes.pop_back(); - } + 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 FlaggedNodes; + for (SDNode *N = SU->getNode(); N; N = N->getFlaggedNode()) + FlaggedNodes.push_back(N); + while (!FlaggedNodes.empty()) { + O << DOTGraphTraits::getNodeLabel(FlaggedNodes.back(), DAG); + FlaggedNodes.pop_back(); + if (!FlaggedNodes.empty()) + O << "\n "; } } else { - std::string s; - raw_string_ostream oss(s); - SU->getInstr()->print(oss); - Op += oss.str(); + O << "CROSS RC COPY"; } - - return Op; + return O.str(); } - /// viewGraph - Pop up a ghostview window with the reachable parts of the DAG /// rendered using 'dot'. /// -- cgit v1.2.3