Add edge source labels to SelectionDAG graphs, now that the graph printing
authorDan Gohman <gohman@apple.com>
Tue, 1 Dec 2009 19:20:00 +0000 (19:20 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 1 Dec 2009 19:20:00 +0000 (19:20 +0000)
framework omits differentiated edge sources in the case where the labels
are empty strings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90254 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SelectionDAGNodes.h
lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp

index 950fd322da2e303d8fd265e909c7bdb754fb754f..79dbd73e97f5222e1d103f654b48cbab7f399796 100644 (file)
@@ -2397,6 +2397,11 @@ public:
   SDNodeIterator operator++(int) { // Postincrement
     SDNodeIterator tmp = *this; ++*this; return tmp;
   }
+  size_t operator-(SDNodeIterator Other) const {
+    assert(Node == Other.Node &&
+           "Cannot compare iterators of two different nodes!");
+    return Operand - Other.Operand;
+  }
 
   static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
   static SDNodeIterator end  (SDNode *N) {
index 74f7e51220d9759e73ca4633c44a8dea0d27696b..83fa5a8fd1ba710b7151fc66d09e36cc52e1bd7b 100644 (file)
@@ -50,6 +50,11 @@ namespace llvm {
       return ((const SDNode *) Node)->getValueType(i).getEVTString();
     }
 
+    template<typename EdgeIter>
+    static std::string getEdgeSourceLabel(const void *Node, EdgeIter I) {
+      return itostr(I - SDNodeIterator::begin((SDNode *) Node));
+    }
+
     /// 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.