[llvm-commits] CVS: llvm/include/Support/GraphWriter.h
Chris Lattner
lattner at cs.uiuc.edu
Tue Oct 15 21:04:01 PDT 2002
Changes in directory llvm/include/Support:
GraphWriter.h updated: 1.6 -> 1.7
---
Log message:
* Factor printing code again, add emitSimpleNode method
---
Diffs of the changes:
Index: llvm/include/Support/GraphWriter.h
diff -u llvm/include/Support/GraphWriter.h:1.6 llvm/include/Support/GraphWriter.h:1.7
--- llvm/include/Support/GraphWriter.h:1.6 Tue Oct 15 20:44:59 2002
+++ llvm/include/Support/GraphWriter.h Tue Oct 15 21:03:18 2002
@@ -124,8 +124,7 @@
void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) {
if (NodeType *TargetNode = *EI) {
- O << "\tNode" << (void*)Node << ":g" << edgeidx << " -> Node"
- << (void*)TargetNode;
+ int DestPort = -1;
if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) {
child_iterator TargetIt = DOTTraits::getEdgeTarget(Node, EI);
@@ -133,14 +132,36 @@
unsigned Offset = std::distance(GTraits::child_begin(TargetNode),
TargetIt);
if (Offset > 64) Offset = 64; // Targetting the truncated part?
- O << ":g" << Offset;
+ DestPort = (int)Offset;
}
-
- std::string EdgeAttributes = DOTTraits::getEdgeAttributes(Node, EI);
- if (!EdgeAttributes.empty())
- O << "[" << EdgeAttributes << "]";
- O << ";\n";
+
+ emitEdge((void *)Node, edgeidx, (void*)TargetNode, DestPort,
+ DOTTraits::getEdgeAttributes(Node, EI));
}
+ }
+
+ /// emitSimpleNode - Outputs a simple (non-record) node
+ void emitSimpleNode(void *ID, const std::string &Attr,
+ const std::string &Label) {
+ O << "\tNode" << ID << "[ ";
+ if (!Attr.empty())
+ O << Attr << ",";
+ O << " label =\"" << DOT::EscapeString(Label) << "\"];\n";
+ }
+
+ /// emitEdge - Output an edge from a simple node into the graph...
+ void emitEdge(void *SrcNodeID, int SrcNodePort,
+ void *DestNodeID, int DestNodePort, const std::string &Attrs) {
+ O << "\tNode" << SrcNodeID;
+ if (SrcNodePort >= 0)
+ O << ":g" << SrcNodePort;
+ O << " -> Node" << (void*)DestNodeID;
+ if (DestNodePort >= 0)
+ O << ":g" << DestNodePort;
+
+ if (!Attrs.empty())
+ O << "[" << Attrs << "]";
+ O << ";\n";
}
};
More information about the llvm-commits
mailing list