[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Jan 10 16:34:49 PST 2005
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAGPrinter.cpp updated: 1.3 -> 1.4
---
Log message:
Print SelectionDAGs bottom up, include extra info in the node labels
---
Diffs of the changes: (+38 -3)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.3 llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.4
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.3 Mon Jan 10 17:52:04 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Mon Jan 10 18:34:33 2005
@@ -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 @@
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 @@
};
}
+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'.
///
More information about the llvm-commits
mailing list