diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp index 4a70642c4b5..f342f04abc9 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp @@ -15,6 +15,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/Function.h" #include "llvm/Support/GraphWriter.h" +#include "llvm/ADT/StringExtras.h" #include using namespace llvm; @@ -24,11 +25,13 @@ namespace llvm { static std::string getGraphName(const SelectionDAG *G) { return G->getMachineFunction().getFunction()->getName(); } - static std::string getNodeLabel(const SDNode *Node, - const SelectionDAG *Graph) { - return Node->getOperationName(); + + static bool renderGraphFromBottomUp() { + return true; } + static std::string getNodeLabel(const SDNode *Node, + const SelectionDAG *Graph); static std::string getNodeAttributes(const SDNode *N) { return "shape=Mrecord"; } @@ -41,6 +44,38 @@ namespace llvm { }; } +std::string DOTGraphTraits::getNodeLabel(const SDNode *Node, + const SelectionDAG *G) { + std::string Op = Node->getOperationName(); + if (const ConstantSDNode *CSDN = dyn_cast(Node)) { + Op += ": " + utostr(CSDN->getValue()); + } else if (const ConstantFPSDNode *CSDN = dyn_cast(Node)) { + Op += ": " + ftostr(CSDN->getValue()); + } else if (const GlobalAddressSDNode *GADN = + dyn_cast(Node)) { + Op += ": " + GADN->getGlobal()->getName(); + } else if (const FrameIndexSDNode *FIDN = + dyn_cast(Node)) { + Op += " " + itostr(FIDN->getIndex()); + } else if (const ConstantPoolSDNode *CP = dyn_cast(Node)){ + Op += "<" + utostr(CP->getIndex()) + ">"; + } else if (const BasicBlockSDNode *BBDN = + dyn_cast(Node)) { + Op = "BB: "; + const Value *LBB = (const Value*)BBDN->getBasicBlock()->getBasicBlock(); + if (LBB) + Op += LBB->getName(); + //Op += " " + (const void*)BBDN->getBasicBlock(); + } else if (const CopyRegSDNode *C2V = dyn_cast(Node)) { + Op += " #" + utostr(C2V->getReg()); + } else if (const ExternalSymbolSDNode *ES = + dyn_cast(Node)) { + Op += "'" + std::string(ES->getSymbol()) + "'"; + } + return Op; +} + + /// viewGraph - Pop up a ghostview window with the reachable parts of the DAG /// rendered using 'dot'. ///