From 783b4082a1a3ff818d88227ba367d043c16a4aa1 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 6 Nov 2012 21:50:29 +0900 Subject: [PATCH] Produce tidier dag dumps. --- tools/qfcc/source/dot_dag.c | 73 +++++++++++++++++++++++++++------- tools/qfcc/source/dot_sblock.c | 2 +- 2 files changed, 59 insertions(+), 16 deletions(-) diff --git a/tools/qfcc/source/dot_dag.c b/tools/qfcc/source/dot_dag.c index 68fc12c52..bed0179b1 100644 --- a/tools/qfcc/source/dot_dag.c +++ b/tools/qfcc/source/dot_dag.c @@ -50,40 +50,79 @@ static int print_count; +static void +print_node_def (dstring_t *dstr, dagnode_t *node, int recurse) +{ + if (!node->a && (node->b || node->c)) { + dasprintf (dstr, " \"dagnode_%p\" [label=\"bad node\"];\n", node); + return; + } + dasprintf (dstr, " \"dagnode_%p\" [%slabel=\"%s\"];\n", node, + node->a ? "" : "shape=none,", daglabel_string (node->label)); + if (recurse) { + if (node->a) + print_node_def (dstr, node->a, 1); + if (node->b) + print_node_def (dstr, node->b, 1); + if (node->c) + print_node_def (dstr, node->c, 1); + } +} + +static void +print_root_nodes (dstring_t *dstr, dagnode_t *dag) +{ + dasprintf (dstr, " subgraph roots_%p {", dag); + dasprintf (dstr, " rank=same;"); + for (; dag; dag = dag->next) + print_node_def (dstr, dag, 0); + dasprintf (dstr, " }\n"); +} + +static void +print_child_nodes (dstring_t *dstr, dagnode_t *dag) +{ + for (; dag; dag = dag->next) { + if (!dag->a && (dag->b || dag->c)) + continue; + if (dag->a) + print_node_def (dstr, dag->a, 1); + if (dag->b) + print_node_def (dstr, dag->b, 1); + if (dag->c) + print_node_def (dstr, dag->c, 1); + } +} + static void print_node (dstring_t *dstr, dagnode_t *node) { if (node->print_count == print_count) return; node->print_count = print_count; - if (!node->a && (node->b || node->c)) { - dasprintf (dstr, " \"dag_%p\" [label=\"bad node\"];\n", node); - return; - } if (node->a) { - dasprintf (dstr, " \"dag_%p\" -> \"dag_%p\" [label=a];\n", node, - node->a); + dasprintf (dstr, " \"dagnode_%p\" -> \"dagnode_%p\" [label=a];\n", + node, node->a); print_node (dstr, node->a); } if (node->b) { - dasprintf (dstr, " \"dag_%p\" -> \"dag_%p\" [label=b];\n", node, - node->b); + dasprintf (dstr, " \"dagnode_%p\" -> \"dagnode_%p\" [label=b];\n", + node, node->b); print_node (dstr, node->b); } if (node->c) { - dasprintf (dstr, " \"dag_%p\" -> \"dag_%p\" [label=c];\n", node, - node->c); + dasprintf (dstr, " \"dagnode_%p\" -> \"dagnode_%p\" [label=c];\n", + node, node->c); print_node (dstr, node->c); } if (node->next) - dasprintf (dstr, " \"dag_%p\" -> \"dag_%p\" [style=dashed];\n", node, - node->next); - dasprintf (dstr, " \"dag_%p\" [%slabel=\"%s\"];\n", node, - node->a ? "" : "shape=none,", daglabel_string (node->label)); + dasprintf (dstr, + " \"dagnode_%p\" -> \"dagnode_%p\" [style=dashed];\n", + node, node->next); if (node->identifiers) { daglabel_t *id; - dasprintf (dstr, " \"dag_%p\" -> \"dagid_%p\" " + dasprintf (dstr, " \"dagnode_%p\" -> \"dagid_%p\" " "[style=dashed,dir=none];\n", node, node); dasprintf (dstr, " \"dagid_%p\" [shape=none,label=<\n", node); dasprintf (dstr, " next) print_node (dstr, dag); + dasprintf (dstr, " }\n"); } diff --git a/tools/qfcc/source/dot_sblock.c b/tools/qfcc/source/dot_sblock.c index 52d8be881..b4cfd70ef 100644 --- a/tools/qfcc/source/dot_sblock.c +++ b/tools/qfcc/source/dot_sblock.c @@ -74,7 +74,7 @@ flow_sblock (dstring_t *dstr, sblock_t *sblock, int blockno) ex_label_t *l; if (sblock->dag) { - dasprintf (dstr, " sb_%p -> dag_%p;", sblock, sblock->dag); + dasprintf (dstr, " sb_%p -> dagnode_%p;", sblock, sblock->dag); print_dag (dstr, sblock->dag); } dasprintf (dstr, " sb_%p [shape=none,label=<\n", sblock);