* Pass the DSGraph around instead of the Function to printing fns

* Print the globals list in the node
* Print the scalars in the scalar node
* Eliminate Scalar "label" edges in the graph
* Print fake edges lighter instead of dotted


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2880 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-07-11 20:33:32 +00:00
parent f9ae4c5cb6
commit 76d5b489e3

View File

@ -12,9 +12,10 @@
void DSNode::dump() const { print(std::cerr, 0); }
std::string DSNode::getCaption(Function *F) const {
std::string DSNode::getCaption(const DSGraph *G) const {
std::stringstream OS;
WriteTypeSymbolic(OS, getType(), F ? F->getParent() : 0);
Module *M = G ? G->getFunction().getParent() : 0;
WriteTypeSymbolic(OS, getType(), M);
OS << " ";
if (NodeType & ScalarNode) OS << "S";
@ -24,6 +25,21 @@ std::string DSNode::getCaption(Function *F) const {
if (NodeType & SubElement) OS << "E";
if (NodeType & CastNode ) OS << "C";
for (unsigned i = 0, e = Globals.size(); i != e; ++i) {
OS << "\n";
WriteAsOperand(OS, Globals[i], false, true, M);
}
if ((NodeType & ScalarNode) && G) {
const std::map<Value*, DSNodeHandle> &VM = G->getValueMap();
for (std::map<Value*, DSNodeHandle>::const_iterator I = VM.begin(),
E = VM.end(); I != E; ++I)
if (I->second == this) {
OS << "\n";
WriteAsOperand(OS, I->first, false, true, M);
}
}
return OS.str();
}
@ -49,6 +65,7 @@ static void replaceIn(std::string &S, char From, const std::string &To) {
static string escapeLabel(const string &In) {
string Label(In);
replaceIn(Label, '\\', "\\\\"); // Escape caption...
replaceIn(Label, '\n', "\\n");
replaceIn(Label, ' ', "\\ ");
replaceIn(Label, '{', "\\{");
replaceIn(Label, '}', "\\}");
@ -67,8 +84,8 @@ static void writeEdge(std::ostream &O, const void *SrcNode,
O << ";\n";
}
void DSNode::print(std::ostream &O, Function *F) const {
string Caption = escapeLabel(getCaption(F));
void DSNode::print(std::ostream &O, const DSGraph *G) const {
string Caption = escapeLabel(getCaption(G));
O << "\tNode" << (void*)this << " [ label =\"{" << Caption;
@ -97,22 +114,15 @@ void DSGraph::print(std::ostream &O) const {
// Output all of the nodes...
for (unsigned i = 0, e = Nodes.size(); i != e; ++i)
Nodes[i]->print(O, &Func);
Nodes[i]->print(O, this);
O << "\n";
// Output all of the nodes edges for scalar labels
for (std::map<Value*, DSNodeHandle>::const_iterator I = ValueMap.begin(),
E = ValueMap.end(); I != E; ++I) {
O << "\tNode" << (void*)I->first << "[ shape=circle, label =\""
<< escapeLabel(getValueName(I->first, Func)) << "\",style=dotted];\n";
writeEdge(O, I->first, "",-1, I->second.get(),"arrowtail=tee,style=dotted");
}
// Output the returned value pointer...
if (RetNode != 0) {
O << "\tNode0x1" << "[ shape=circle, label =\""
<< escapeLabel("Return") << "\"];\n";
writeEdge(O, (void*)1, "", -1, RetNode, "arrowtail=tee,style=dotted");
O << "\tNode0x1" << "[ plaintext=circle, label =\""
<< escapeLabel("returning") << "\"];\n";
writeEdge(O, (void*)1, "", -1, RetNode, "arrowtail=tee,color=gray63");
}
// Output all of the call nodes...
@ -127,7 +137,7 @@ void DSGraph::print(std::ostream &O) const {
for (unsigned j = 0, e = Call.size(); j != e; ++j)
if (Call[j])
writeEdge(O, &Call, ":g", j, Call[j]);
writeEdge(O, &Call, ":g", j, Call[j], "color=gray63");
}