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=\"%s:%d:%d\"]\n", bb
,
31 stream_name(bb
->pos
.stream
), bb
->pos
.line
, bb
->pos
.pos
);
32 } END_FOR_EACH_PTR(bb
);
33 FOR_EACH_PTR(ep
->bbs
, bb
) {
34 struct basic_block
*child
;
35 FOR_EACH_PTR(bb
->children
, child
) {
36 printf("bb%p -> bb%p;\n", bb
, child
);
37 } END_FOR_EACH_PTR(child
);
38 } END_FOR_EACH_PTR(bb
);
39 printf("ep%p -> bb%p;\n", ep
, ep
->entry
->bb
);
42 static void graph_symbols(struct symbol_list
*list
)
46 FOR_EACH_PTR(list
, sym
) {
47 struct entrypoint
*ep
;
50 ep
= linearize_symbol(sym
);
53 } END_FOR_EACH_PTR(sym
);
56 int main(int argc
, char **argv
)
58 struct string_list
*filelist
= NULL
;
61 printf("digraph control_flow {\n");
62 graph_symbols(sparse_initialize(argc
, argv
, &filelist
));
64 FOR_EACH_PTR_NOTAG(filelist
, file
) {
65 graph_symbols(sparse(file
));
66 } END_FOR_EACH_PTR_NOTAG(file
);