-
-static void descend_and_dump(FILE *F, ir_node *n, int depth, pset *mark_set) {
- if (pset_find_ptr(mark_set, n)) return;
-
- pset_insert_ptr(mark_set, n);
-
- if (depth > 0) {
- int i, start = is_Block(n) ? 0 : -1;
- dump_whole_node(n, F);
- for (i = start; i < get_irn_arity(n); ++i)
- descend_and_dump(F, get_irn_n(n, i), depth-1, mark_set);
- } else {
- dump_node(F, n);
- /* Don't dump edges to nodes further out. These might be edges to
- nodes we already dumped, if there is a shorter path to these. */
- }
-}
-
-static int subgraph_counter = 0;
-void dump_subgraph(ir_node *root, int depth, const char *suffix) {
- FILE *F;
- char buf[32];
-
- sprintf(buf, "-subg_%03d", subgraph_counter++);
- F = vcg_open(get_irn_irg(root), suffix, buf);
- if (F != NULL) {
- pset *mark_set = pset_new_ptr(1);
- dump_vcg_header(F, get_irg_dump_name(get_irn_irg(root)), NULL, NULL);
- descend_and_dump(F, root, depth, mark_set);
- dump_vcg_footer(F);
- fclose(F);
- del_pset(mark_set);
- }
-}
-
-#ifdef INTERPROCEDURAL_VIEW
-void dump_callgraph(const char *suffix) {
- FILE *F = vcg_open_name("Callgraph", suffix);
-
- if (F != NULL) {
- int i, rem = edge_label;
- //int colorize;
- edge_label = 1;
- dump_vcg_header(F, "Callgraph", NULL);
-
- //colorize = get_irp_callgraph_state() == irp_callgraph_and_calltree_consistent;
-
- for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
- ir_graph *irg = get_irp_irg(i);
- ir_entity *ent = get_irg_entity(irg);
- int j;
- //int n_callees = get_irg_n_callees(irg);
- int color;
-
- //color = colorize ? get_entity_color(ent) : ird_color_green;
- color = ird_color_green;
- dump_entity_node(F, ent, color);
- for (j = 0; j < n_callees; ++j) {
- ir_entity *c = get_irg_entity(get_irg_callee(irg, j));
- //if (id_is_prefix(prefix, get_entity_ld_ident(c))) continue;
- int be = is_irg_callee_backedge(irg, j);
- char *attr;
- attr = (be) ?
- "label:\"recursion %d\" color:%d" :
- "label:\"calls %d\" color:%d";
- print_ent_ent_edge(F, ent, c, be, attr, get_irg_callee_loop_depth(irg, j), color);
- }
+void dump_callgraph(FILE *F)
+{
+ size_t i;
+ ir_dump_flags_t old_flags = ir_get_dump_flags();
+
+ ir_remove_dump_flags(ir_dump_flag_disable_edge_labels);
+ dump_vcg_header(F, "Callgraph", "Hierarchic", NULL);
+
+ for (i = get_irp_n_irgs(); i > 0;) {
+ ir_graph *irg = get_irp_irg(--i);
+ ir_entity *ent = get_irg_entity(irg);
+ size_t j, n_callees = get_irg_n_callees(irg);
+
+ dump_entity_node(F, ent);
+ for (j = 0; j < n_callees; ++j) {
+ ir_entity *c = get_irg_entity(get_irg_callee(irg, j));
+ int be = is_irg_callee_backedge(irg, j);
+ const char *attr = be
+ ? "label:\"recursion %zu\""
+ : "label:\"calls %zu\"";
+ print_ent_ent_edge(F, ent, c, be, ird_color_entity, attr,
+ get_irg_callee_loop_depth(irg, j));