aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-11 00:34:33 +0000
committerChris Lattner <sabre@nondot.org>2005-01-11 00:34:33 +0000
commite9c44cdf18b1235841a5d8bfeb07bee9f5699b9a (patch)
treec35e8e27b5adc031909ec3dd1561df034aa60389 /lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
parent89a1ed58399045d2b2c7b246571945b068f2e5e1 (diff)
Print SelectionDAGs bottom up, include extra info in the node labels
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19447 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp41
1 files changed, 38 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
index 4a70642c4b..f342f04abc 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 <fstream>
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<SelectionDAG*>::getNodeLabel(const SDNode *Node,
+ const SelectionDAG *G) {
+ std::string Op = Node->getOperationName();
+ if (const ConstantSDNode *CSDN = dyn_cast<ConstantSDNode>(Node)) {
+ Op += ": " + utostr(CSDN->getValue());
+ } else if (const ConstantFPSDNode *CSDN = dyn_cast<ConstantFPSDNode>(Node)) {
+ Op += ": " + ftostr(CSDN->getValue());
+ } else if (const GlobalAddressSDNode *GADN =
+ dyn_cast<GlobalAddressSDNode>(Node)) {
+ Op += ": " + GADN->getGlobal()->getName();
+ } else if (const FrameIndexSDNode *FIDN =
+ dyn_cast<FrameIndexSDNode>(Node)) {
+ Op += " " + itostr(FIDN->getIndex());
+ } else if (const ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(Node)){
+ Op += "<" + utostr(CP->getIndex()) + ">";
+ } else if (const BasicBlockSDNode *BBDN =
+ dyn_cast<BasicBlockSDNode>(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<CopyRegSDNode>(Node)) {
+ Op += " #" + utostr(C2V->getReg());
+ } else if (const ExternalSymbolSDNode *ES =
+ dyn_cast<ExternalSymbolSDNode>(Node)) {
+ Op += "'" + std::string(ES->getSymbol()) + "'";
+ }
+ return Op;
+}
+
+
/// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
/// rendered using 'dot'.
///