[llvm-commits] CVS: llvm/include/llvm/Support/DOTGraphTraits.h GraphWriter.h

Chris Lattner lattner at cs.uiuc.edu
Mon Jan 10 16:25:14 PST 2005



Changes in directory llvm/include/llvm/Support:

DOTGraphTraits.h updated: 1.11 -> 1.12
GraphWriter.h updated: 1.21 -> 1.22
---
Log message:

Add support for bottom-up graphs.


---
Diffs of the changes:  (+20 -3)

Index: llvm/include/llvm/Support/DOTGraphTraits.h
diff -u llvm/include/llvm/Support/DOTGraphTraits.h:1.11 llvm/include/llvm/Support/DOTGraphTraits.h:1.12
--- llvm/include/llvm/Support/DOTGraphTraits.h:1.11	Wed Oct 27 11:14:51 2004
+++ llvm/include/llvm/Support/DOTGraphTraits.h	Mon Jan 10 18:24:59 2005
@@ -39,6 +39,13 @@
     return "";
   }
 
+  /// renderGraphFromBottomUp - If this function returns true, the graph is
+  /// emitted bottom-up instead of top-down.  This requires graphviz 2.0 to work
+  /// though.
+  static bool renderGraphFromBottomUp() {
+    return false;
+  }
+
   /// getNodeLabel - Given a node and a pointer to the top level graph, return
   /// the label to print in the node.
   static std::string getNodeLabel(const void *Node, const void *Graph) {


Index: llvm/include/llvm/Support/GraphWriter.h
diff -u llvm/include/llvm/Support/GraphWriter.h:1.21 llvm/include/llvm/Support/GraphWriter.h:1.22
--- llvm/include/llvm/Support/GraphWriter.h:1.21	Mon Jan 10 17:05:07 2005
+++ llvm/include/llvm/Support/GraphWriter.h	Mon Jan 10 18:24:59 2005
@@ -78,6 +78,9 @@
     else
       O << "digraph " << Name << " {\n";
 
+    if (DOTTraits::renderGraphFromBottomUp())
+      O << "\trankdir=\"BT\";\n";
+
     std::string GraphName = DOTTraits::getGraphName(G);
     if (!GraphName.empty())
       O << "\tlabel=\"" << DOT::EscapeString(GraphName) << "\";\n";
@@ -106,14 +109,17 @@
       
     O << "\tNode" << reinterpret_cast<const void*>(Node) << " [shape=record,";
     if (!NodeAttributes.empty()) O << NodeAttributes << ",";
-    O << "label=\"{"
-      << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
+    O << "label=\"{";
+
+    if (!DOTTraits::renderGraphFromBottomUp())
+      O << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
     
     // Print out the fields of the current node...
     child_iterator EI = GTraits::child_begin(Node);
     child_iterator EE = GTraits::child_end(Node);
     if (EI != EE) {
-      O << "|{";
+      if (!DOTTraits::renderGraphFromBottomUp()) O << "|";
+      O << "{";
       
       for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) {
         if (i) O << "|";
@@ -123,7 +129,11 @@
       if (EI != EE)
         O << "|<g64>truncated...";
       O << "}";
+      if (DOTTraits::renderGraphFromBottomUp()) O << "|";
     }
+    if (DOTTraits::renderGraphFromBottomUp())
+      O << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
+      
     O << "}\"];\n";   // Finish printing the "node" line
     
     // Output all of the edges now






More information about the llvm-commits mailing list