1 /* Copyright © International Business Machines Corp., 2006
3 * Author: Josh Triplett <josh@freedesktop.org>
5 * Licensed under the Open Software License version 1.1
20 #include "expression.h"
21 #include "linearize.h"
23 static void graph_ep(struct entrypoint
*ep
)
25 struct basic_block
*bb
;
27 printf("ep%p [label=\"%s\",shape=ellipse];\n",
28 ep
, show_ident(ep
->name
->ident
));
29 FOR_EACH_PTR(ep
->bbs
, bb
) {
30 printf("bb%p [shape=record,label=\"bb at %p\"]\n", bb
, bb
);
31 } END_FOR_EACH_PTR(bb
);
32 FOR_EACH_PTR(ep
->bbs
, bb
) {
33 struct basic_block
*child
;
34 FOR_EACH_PTR(bb
->children
, child
) {
35 printf("bb%p -> bb%p;\n", bb
, child
);
36 } END_FOR_EACH_PTR(child
);
37 } END_FOR_EACH_PTR(bb
);
38 printf("ep%p -> bb%p;\n", ep
, ep
->entry
->bb
);
41 static void graph_symbols(struct symbol_list
*list
)
45 FOR_EACH_PTR(list
, sym
) {
46 struct entrypoint
*ep
;
49 ep
= linearize_symbol(sym
);
52 } END_FOR_EACH_PTR(sym
);
55 int main(int argc
, char **argv
)
57 printf("digraph control_flow {\n");
58 graph_symbols(sparse_initialize(argc
, argv
));
60 graph_symbols(sparse(argv
));