[llvm-commits] [llvm] r90133 - in /llvm/trunk: include/llvm/Analysis/CFGPrinter.h include/llvm/Support/DOTGraphTraits.h include/llvm/Support/GraphWriter.h lib/Analysis/DomPrinter.cpp lib/CodeGen/MachineFunction.cpp lib/CodeGen/ScheduleDAGPrinter.cpp lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp tools/opt/GraphPrinters.cpp

Tobias Grosser grosser at fim.uni-passau.de
Mon Nov 30 04:38:13 PST 2009


Author: grosser
Date: Mon Nov 30 06:38:13 2009
New Revision: 90133

URL: http://llvm.org/viewvc/llvm-project?rev=90133&view=rev
Log:
Instantiate DefaultDOTGraphTraits

Modified:
    llvm/trunk/include/llvm/Analysis/CFGPrinter.h
    llvm/trunk/include/llvm/Support/DOTGraphTraits.h
    llvm/trunk/include/llvm/Support/GraphWriter.h
    llvm/trunk/lib/Analysis/DomPrinter.cpp
    llvm/trunk/lib/CodeGen/MachineFunction.cpp
    llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
    llvm/trunk/tools/opt/GraphPrinters.cpp

Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CFGPrinter.h?rev=90133&r1=90132&r2=90133&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/CFGPrinter.h (original)
+++ llvm/trunk/include/llvm/Analysis/CFGPrinter.h Mon Nov 30 06:38:13 2009
@@ -24,6 +24,9 @@
 namespace llvm {
 template<>
 struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
+
+  DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
+
   static std::string getGraphName(const Function *F) {
     return "CFG for '" + F->getNameStr() + "' function";
   }

Modified: llvm/trunk/include/llvm/Support/DOTGraphTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DOTGraphTraits.h?rev=90133&r1=90132&r2=90133&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/DOTGraphTraits.h (original)
+++ llvm/trunk/include/llvm/Support/DOTGraphTraits.h Mon Nov 30 06:38:13 2009
@@ -27,6 +27,17 @@
 /// implementations.
 ///
 struct DefaultDOTGraphTraits {
+private:
+  bool IsSimple;
+
+protected:
+  bool isSimple() {
+    return IsSimple;
+  }
+
+public:
+  DefaultDOTGraphTraits (bool simple=false) : IsSimple (simple) {}
+
   /// getGraphName - Return the label for the graph as a whole.  Printed at the
   /// top of the graph.
   ///
@@ -135,7 +146,9 @@
 /// from DefaultDOTGraphTraits if you don't need to override everything.
 ///
 template <typename Ty>
-struct DOTGraphTraits : public DefaultDOTGraphTraits {};
+struct DOTGraphTraits : public DefaultDOTGraphTraits {
+  DOTGraphTraits (bool simple=false) : DefaultDOTGraphTraits (simple) {}
+};
 
 } // End llvm namespace
 

Modified: llvm/trunk/include/llvm/Support/GraphWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=90133&r1=90132&r2=90133&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/GraphWriter.h (original)
+++ llvm/trunk/include/llvm/Support/GraphWriter.h Mon Nov 30 06:38:13 2009
@@ -59,6 +59,7 @@
   typedef typename GTraits::NodeType          NodeType;
   typedef typename GTraits::nodes_iterator    node_iterator;
   typedef typename GTraits::ChildIteratorType child_iterator;
+  DOTTraits DTraits;
 
   // Writes the edge labels of the node to O and returns true if there are any
   // edge labels not equal to the empty string "".
@@ -68,7 +69,7 @@
     bool hasEdgeSourceLabels = false;
 
     for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) {
-      std::string label = DOTTraits::getEdgeSourceLabel(Node, EI);
+      std::string label = DTraits.getEdgeSourceLabel(Node, EI);
 
       if (label == "")
         continue;
@@ -78,7 +79,7 @@
       if (i)
         O << "|";
 
-      O << "<s" << i << ">" << DOTTraits::getEdgeSourceLabel(Node, EI);
+      O << "<s" << i << ">" << DTraits.getEdgeSourceLabel(Node, EI);
     }
 
     if (EI != EE && hasEdgeSourceLabels)
@@ -89,10 +90,12 @@
 
 public:
   GraphWriter(raw_ostream &o, const GraphType &g, bool SN) :
-    O(o), G(g), ShortNames(SN) {}
+    O(o), G(g), ShortNames(SN) {
+  DTraits = DOTTraits(SN); 
+}
 
   void writeHeader(const std::string &Name) {
-    std::string GraphName = DOTTraits::getGraphName(G);
+    std::string GraphName = DTraits.getGraphName(G);
 
     if (!Name.empty())
       O << "digraph \"" << DOT::EscapeString(Name) << "\" {\n";
@@ -101,14 +104,14 @@
     else
       O << "digraph unnamed {\n";
 
-    if (DOTTraits::renderGraphFromBottomUp())
+    if (DTraits.renderGraphFromBottomUp())
       O << "\trankdir=\"BT\";\n";
 
     if (!Name.empty())
       O << "\tlabel=\"" << DOT::EscapeString(Name) << "\";\n";
     else if (!GraphName.empty())
       O << "\tlabel=\"" << DOT::EscapeString(GraphName) << "\";\n";
-    O << DOTTraits::getGraphProperties(G);
+    O << DTraits.getGraphProperties(G);
     O << "\n";
   }
 
@@ -133,17 +136,17 @@
   }
 
   void writeNode(NodeType *Node) {
-    std::string NodeAttributes = DOTTraits::getNodeAttributes(Node, G);
+    std::string NodeAttributes = DTraits.getNodeAttributes(Node, G);
 
     O << "\tNode" << static_cast<const void*>(Node) << " [shape=record,";
     if (!NodeAttributes.empty()) O << NodeAttributes << ",";
     O << "label=\"{";
 
-    if (!DOTTraits::renderGraphFromBottomUp()) {
-      O << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G, ShortNames));
+    if (!DTraits.renderGraphFromBottomUp()) {
+      O << DOT::EscapeString(DTraits.getNodeLabel(Node, G, ShortNames));
 
       // If we should include the address of the node in the label, do so now.
-      if (DOTTraits::hasNodeAddressLabel(Node, G))
+      if (DTraits.hasNodeAddressLabel(Node, G))
         O << "|" << (void*)Node;
     }
 
@@ -152,28 +155,28 @@
     bool hasEdgeSourceLabels = getEdgeSourceLabels(EdgeSourceLabels, Node);
 
     if (hasEdgeSourceLabels) {
-      if (!DOTTraits::renderGraphFromBottomUp()) O << "|";
+      if (!DTraits.renderGraphFromBottomUp()) O << "|";
 
       O << "{" << EdgeSourceLabels.str() << "}";
 
-      if (DOTTraits::renderGraphFromBottomUp()) O << "|";
+      if (DTraits.renderGraphFromBottomUp()) O << "|";
     }
 
-    if (DOTTraits::renderGraphFromBottomUp()) {
-      O << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G, ShortNames));
+    if (DTraits.renderGraphFromBottomUp()) {
+      O << DOT::EscapeString(DTraits.getNodeLabel(Node, G, ShortNames));
 
       // If we should include the address of the node in the label, do so now.
-      if (DOTTraits::hasNodeAddressLabel(Node, G))
+      if (DTraits.hasNodeAddressLabel(Node, G))
         O << "|" << (void*)Node;
     }
 
-    if (DOTTraits::hasEdgeDestLabels()) {
+    if (DTraits.hasEdgeDestLabels()) {
       O << "|{";
 
-      unsigned i = 0, e = DOTTraits::numEdgeDestLabels(Node);
+      unsigned i = 0, e = DTraits.numEdgeDestLabels(Node);
       for (; i != e && i != 64; ++i) {
         if (i) O << "|";
-        O << "<d" << i << ">" << DOTTraits::getEdgeDestLabel(Node, i);
+        O << "<d" << i << ">" << DTraits.getEdgeDestLabel(Node, i);
       }
 
       if (i != e)
@@ -195,8 +198,8 @@
   void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) {
     if (NodeType *TargetNode = *EI) {
       int DestPort = -1;
-      if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) {
-        child_iterator TargetIt = DOTTraits::getEdgeTarget(Node, EI);
+      if (DTraits.edgeTargetsEdgeSource(Node, EI)) {
+        child_iterator TargetIt = DTraits.getEdgeTarget(Node, EI);
 
         // Figure out which edge this targets...
         unsigned Offset =
@@ -204,12 +207,12 @@
         DestPort = static_cast<int>(Offset);
       }
 
-      if (DOTTraits::getEdgeSourceLabel(Node, EI) == "")
+      if (DTraits.getEdgeSourceLabel(Node, EI) == "")
         edgeidx = -1;
 
       emitEdge(static_cast<const void*>(Node), edgeidx,
                static_cast<const void*>(TargetNode), DestPort,
-               DOTTraits::getEdgeAttributes(Node, EI));
+               DTraits.getEdgeAttributes(Node, EI));
     }
   }
 
@@ -247,7 +250,7 @@
     if (SrcNodePort >= 0)
       O << ":s" << SrcNodePort;
     O << " -> Node" << DestNodeID;
-    if (DestNodePort >= 0 && DOTTraits::hasEdgeDestLabels())
+    if (DestNodePort >= 0 && DTraits.hasEdgeDestLabels())
       O << ":d" << DestNodePort;
 
     if (!Attrs.empty())

Modified: llvm/trunk/lib/Analysis/DomPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DomPrinter.cpp?rev=90133&r1=90132&r2=90133&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/DomPrinter.cpp (original)
+++ llvm/trunk/lib/Analysis/DomPrinter.cpp Mon Nov 30 06:38:13 2009
@@ -30,6 +30,9 @@
 namespace llvm {
 template<>
 struct DOTGraphTraits<DomTreeNode*> : public DefaultDOTGraphTraits {
+
+  DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
+
   static std::string getNodeLabel(DomTreeNode *Node, DomTreeNode *Graph,
                                   bool ShortNames) {
 
@@ -46,6 +49,9 @@
 template<>
 struct DOTGraphTraits<DominatorTree*> : public DOTGraphTraits<DomTreeNode*> {
 
+  DOTGraphTraits (bool isSimple=false)
+    : DOTGraphTraits<DomTreeNode*>(isSimple) {}
+
   static std::string getGraphName(DominatorTree *DT) {
     return "Dominator tree";
   }
@@ -61,6 +67,10 @@
 template<>
 struct DOTGraphTraits<PostDominatorTree*>
   : public DOTGraphTraits<DomTreeNode*> {
+
+  DOTGraphTraits (bool isSimple=false)
+    : DOTGraphTraits<DomTreeNode*>(isSimple) {}
+
   static std::string getGraphName(PostDominatorTree *DT) {
     return "Post dominator tree";
   }

Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=90133&r1=90132&r2=90133&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Mon Nov 30 06:38:13 2009
@@ -359,6 +359,9 @@
 namespace llvm {
   template<>
   struct DOTGraphTraits<const MachineFunction*> : public DefaultDOTGraphTraits {
+
+  DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
+
     static std::string getGraphName(const MachineFunction *F) {
       return "CFG for '" + F->getFunction()->getNameStr() + "' function";
     }

Modified: llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp?rev=90133&r1=90132&r2=90133&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp Mon Nov 30 06:38:13 2009
@@ -32,6 +32,9 @@
 namespace llvm {
   template<>
   struct DOTGraphTraits<ScheduleDAG*> : public DefaultDOTGraphTraits {
+
+  DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
+
     static std::string getGraphName(const ScheduleDAG *G) {
       return G->MF.getFunction()->getName();
     }

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp?rev=90133&r1=90132&r2=90133&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Mon Nov 30 06:38:13 2009
@@ -35,6 +35,9 @@
 namespace llvm {
   template<>
   struct DOTGraphTraits<SelectionDAG*> : public DefaultDOTGraphTraits {
+
+    DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
+
     static bool hasEdgeDestLabels() {
       return true;
     }
@@ -48,8 +51,8 @@
     }
 
     /// edgeTargetsEdgeSource - This method returns true if this outgoing edge
-    /// should actually target another edge source, not a node.  If this method is
-    /// implemented, getEdgeTarget should be implemented.
+    /// should actually target another edge source, not a node.  If this method
+    /// is implemented, getEdgeTarget should be implemented.
     template<typename EdgeIter>
     static bool edgeTargetsEdgeSource(const void *Node, EdgeIter I) {
       return true;

Modified: llvm/trunk/tools/opt/GraphPrinters.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/GraphPrinters.cpp?rev=90133&r1=90132&r2=90133&view=diff

==============================================================================
--- llvm/trunk/tools/opt/GraphPrinters.cpp (original)
+++ llvm/trunk/tools/opt/GraphPrinters.cpp Mon Nov 30 06:38:13 2009
@@ -46,6 +46,9 @@
 namespace llvm {
   template<>
   struct DOTGraphTraits<CallGraph*> : public DefaultDOTGraphTraits {
+
+  DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
+
     static std::string getGraphName(CallGraph *F) {
       return "Call Graph";
     }





More information about the llvm-commits mailing list