X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firdump.c;h=48a07027dbbb466a633213d11387f330ec914452;hb=5225bb5ec3dbafc23dae1caf5099f7f447c2578c;hp=a62b899ae7b09be3d6673ddcc2f8b7c14c65403c;hpb=13b24046c78b528486d07cf4852cad65659f5c2f;p=libfirm diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index a62b899ae..48a07027d 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -11,25 +11,22 @@ */ -#ifdef HAVE_CONFIG_H -# include -#endif - #include #include #include +#include "firm_common_t.h" + #include "irnode_t.h" #include "irgraph_t.h" +#include "irprog_t.h" #include "entity_t.h" #include "irop_t.h" -#include "firm_common_t.h" #include "irdump.h" #include "irgwalk.h" #include "typewalk.h" -#include "irprog.h" #include "tv_t.h" #include "type_or_entity.h" #include "irouts.h" @@ -112,6 +109,11 @@ SeqNo get_Block_seqno(ir_node *n); #define PRINT_ITEMID(X,Y) fprintf(F, "i%pT%d", (void *) (X), (Y)) #endif + +/* basis for a color range for vcg */ +static int n_colors = 0; +static int base_color = 0; + static const char *get_mode_name_ex(ir_mode *mode, int *bad) { if (is_mode(mode)) @@ -233,11 +235,6 @@ static void print_enum_item_edge(FILE *F, type *E, int item, const char *fmt, .. /* global and ahead declarations */ /*******************************************************************/ -/* A suffix to manipulate the file name. */ -char *dump_file_suffix = ""; - -char *dump_file_filter = ""; - static void dump_whole_node(ir_node *n, void *env); static INLINE void dump_loop_nodes_into_graph(FILE *F, ir_graph *irg); @@ -291,8 +288,8 @@ static void clear_link(ir_node * node, void * env) { static int node_floats(ir_node *n) { - return ((get_op_pinned(get_irn_op(n)) == floats) && - (get_irg_pinned(current_ir_graph) == floats)); + return ((get_op_pinned(get_irn_op(n)) == op_pin_state_floats) && + (get_irg_pinned(current_ir_graph) == op_pin_state_floats)); } static const char *get_ent_dump_name(entity *ent) { @@ -305,7 +302,7 @@ static const char *get_ent_dump_name(entity *ent) { static const char *get_irg_dump_name(ir_graph *irg) { /* Don't use get_entity_ld_ident (ent) as it computes the mangled name! */ - entity *ent = get_irg_ent(irg); + entity *ent = get_irg_entity(irg); return get_ent_dump_name(ent); } @@ -327,7 +324,7 @@ static void collect_node(ir_node * node, void *env) { /** Construct lists to walk ir block-wise. * - * Collects all blocks, nodes not pinned, + * Collects all blocks, nodes not op_pin_state_pinned, * Bad and Unknown into a flexible array in link field of * irg they belong to. Sets the irg link field to NULL in all * graphs not visited. @@ -358,6 +355,8 @@ static ir_node ** construct_block_lists(ir_graph *irg) { /* flags to steer output */ /*******************************************************************/ +const char *dump_file_filter = ""; + /* A compiler option to turn off edge labels */ int edge_label = 1; /* A compiler option to turn off dumping values of constant entities */ @@ -382,6 +381,11 @@ INLINE bool get_opt_dump_const_local(void) { return false; } +void only_dump_method_with_name(ident *name) { + dump_file_filter = get_id_str(name); +} + + /* To turn off display of edge labels. Edge labels offen cause xvcg to abort with a segmentation fault. */ void turn_off_edge_labels(void) { @@ -476,7 +480,7 @@ dump_node_opcode(FILE *F, ir_node *n) case iro_Filter: { if (!interprocedural_view) fprintf(F, "Proj'"); - else fprintf(F, "%s", get_irn_opname(n)); + else goto default_case; } break; case iro_Proj: { @@ -491,16 +495,31 @@ dump_node_opcode(FILE *F, ir_node *n) * fprintf (F, "Arg"); */ else - fprintf (F, "%s", get_irn_opname(n)); + goto default_case; } break; - - case iro_Start: { + case iro_Start: + case iro_End: + case iro_EndExcept: + case iro_EndReg: { if (interprocedural_view) { - fprintf(F, "%s %s", get_irn_opname(n), get_ent_dump_name(get_irg_ent(get_irn_irg(n)))); + fprintf(F, "%s %s", get_irn_opname(n), get_ent_dump_name(get_irg_entity(get_irn_irg(n)))); break; - } - } /* fall through */ + } else + goto default_case; + } + case iro_CallBegin: { + ir_node *addr = get_CallBegin_ptr(n); + entity *ent = NULL; + if (get_irn_op(addr) == op_Sel) + ent = get_Sel_entity(addr); + else if ((get_irn_op(addr) == op_SymConst) && (get_SymConst_kind(addr) == symconst_addr_ent)) + ent = get_SymConst_entity(addr); + fprintf (F, "%s", get_irn_opname(n)); + if (ent) fprintf (F, " %s", get_entity_name(ent)); + break; + } +default_case: default: { fprintf (F, "%s", get_irn_opname(n)); } @@ -565,7 +584,7 @@ dump_node_nodeattr(FILE *F, ir_node *n) switch (get_irn_opcode(n)) { case iro_Start: if (false && interprocedural_view) { - fprintf (F, "%s", get_ent_dump_name(get_irg_ent(current_ir_graph))); + fprintf (F, "%s", get_ent_dump_name(get_irg_entity(current_ir_graph))); } break; case iro_Proj: @@ -667,7 +686,7 @@ static INLINE int dump_node_info(FILE *F, ir_node *n) /* Source types */ switch (get_irn_opcode(n)) { case iro_Start: { - type *tp = get_entity_type(get_irg_ent(get_irn_irg(n))); + type *tp = get_entity_type(get_irg_entity(get_irn_irg(n))); fprintf(F, "start of method of type %s \n", get_type_name_ex(tp, &bad)); for (i = 0; i < get_method_n_params(tp); ++i) fprintf(F, " param %d type: %s \n", i, get_type_name_ex(get_method_param_type(tp, i), &bad)); @@ -697,14 +716,14 @@ static INLINE int dump_node_info(FILE *F, ir_node *n) fprintf(F, " param %d type: %s \n", i, get_type_name_ex(get_method_param_type(tp, i), &bad)); for (i = 0; i < get_method_n_ress(tp); ++i) fprintf(F, " resul %d type: %s \n", i, get_type_name_ex(get_method_res_type(tp, i), &bad)); - if (Call_has_callees(n)) { + if (0 && Call_has_callees(n)) { fprintf(F, "possible callees: \n"); for (i = 0; i < get_Call_n_callees(n); i++) { - if (!get_Call_callee(n, i)) { - fprintf(F, " %d external method\n", i); - } else { - fprintf(F, " %d: %s\n", i, get_ent_dump_name(get_Call_callee(n, i))); - } + if (!get_Call_callee(n, i)) { + fprintf(F, " %d external method\n", i); + } else { + fprintf(F, " %d: %s\n", i, get_ent_dump_name(get_Call_callee(n, i))); + } } } } break; @@ -723,7 +742,7 @@ static INLINE int dump_node_info(FILE *F, ir_node *n) } break; case iro_Return: { if (!interprocedural_view) { - type *tp = get_entity_type(get_irg_ent(get_irn_irg(n))); + type *tp = get_entity_type(get_irg_entity(get_irn_irg(n))); fprintf(F, "return in method of type %s \n", get_type_name_ex(tp, &bad)); for (i = 0; i < get_method_n_ress(tp); ++i) fprintf(F, " res %d type: %s \n", i, get_type_name_ex(get_method_res_type(tp, i), &bad)); @@ -734,6 +753,22 @@ static INLINE int dump_node_info(FILE *F, ir_node *n) assert(tp != none_type); fprintf(F, "Const of type %s \n", get_type_name_ex(get_Const_type(n), &bad)); } break; + case iro_SymConst: { + switch(get_SymConst_kind(n)) { + case symconst_addr_name: + fprintf(F, "kind addr_name\n"); + break; + case symconst_addr_ent: + fprintf(F, "kind addr_ent\n"); + break; + case symconst_type_tag: + fprintf(F, "kind type_tag\n"); + break; + case symconst_size: + fprintf(F, "kind size\n"); + break; + } + } break; case iro_Filter: { int i; if (interprocedural_view) { @@ -1118,7 +1153,7 @@ dump_whole_block(FILE *F, ir_node *block) { } /** dumps a graph block-wise. Expects all blockless nodes in arr in irgs link. - * The outermost nodes: blocks and nodes not pinned, Bad, Unknown. */ + * The outermost nodes: blocks and nodes not op_pin_state_pinned, Bad, Unknown. */ static void dump_block_graph(FILE *F, ir_graph *irg) { int i; @@ -1139,7 +1174,8 @@ dump_block_graph(FILE *F, ir_graph *irg) { } } - if (dump_loop_information_flag) dump_loop_nodes_into_graph(F, irg); + if (dump_loop_information_flag && (get_irg_loopinfo_state(irg) & loopinfo_valid)) + dump_loop_nodes_into_graph(F, irg); current_ir_graph = rem; } @@ -1152,7 +1188,7 @@ static void dump_graph(FILE *F, ir_graph *irg) { fprintf(F, "graph: { title: \""); PRINT_IRGID(irg); fprintf(F, "\" label: \"%s\" status:clustered color:white \n", - get_ent_dump_name(get_irg_ent(irg))); + get_ent_dump_name(get_irg_entity(irg))); dump_block_graph(F, irg); @@ -1305,54 +1341,21 @@ static int print_type_node(FILE *F, type *tp) } #define X(a) case a: fprintf(F, #a); break -void dump_entity_node(FILE *F, entity *ent) +void dump_entity_node(FILE *F, entity *ent, int color) { fprintf (F, "node: {title: \""); PRINT_ENTID(ent); fprintf(F, "\""); fprintf (F, DEFAULT_TYPE_ATTRIBUTE); fprintf (F, "label: "); - fprintf (F, "\"ent %s\" " ENTITY_NODE_ATTR , get_ent_dump_name(ent)); - fprintf (F, "\n info1: \"\nid: "); PRINT_ENTID(ent); - - fprintf (F, "\nallocation: "); - switch (get_entity_allocation(ent)) { - X(allocation_dynamic); - X(allocation_automatic); - X(allocation_static); - X(allocation_parameter); - } - - fprintf (F, "\nvisibility: "); - switch (get_entity_visibility(ent)) { - X(visibility_local); - X(visibility_external_visible); - X(visibility_external_allocated); - } - - fprintf (F, "\nvariability: "); - switch (get_entity_variability(ent)) { - X(variability_uninitialized); - X(variability_initialized); - X(variability_part_constant); - X(variability_constant); - } + fprintf (F, "\"ent %s\" ", get_ent_dump_name(ent)); + if (color) + fprintf(F, "color: %d", color); + else + fprintf (F, ENTITY_NODE_ATTR); + fprintf (F, "\n info1: \""); - fprintf (F, "\nvolatility: "); - switch (get_entity_volatility(ent)) { - X(volatility_non_volatile); - X(volatility_is_volatile); - } + dump_entity_to_file(F, ent, dump_verbosity_entattrs | dump_verbosity_entconsts); - fprintf(F, "\npeculiarity: %s", get_peculiarity_string(get_entity_peculiarity(ent))); - fprintf(F, "\nname: %s\nld_name: %s", - get_entity_name(ent), ent->ld_name ? get_entity_ld_name(ent) : "no yet set"); - fprintf(F, "\noffset(bits): %d", get_entity_offset_bits(ent)); - if (is_method_type(get_entity_type(ent))) { - if (get_entity_irg(ent)) /* can be null */ - { fprintf (F, "\nirg = "); PRINT_IRGID(get_entity_irg(ent)); } - else - { fprintf (F, "\nirg = NULL"); } - } fprintf(F, "\"\n}\n"); } #undef X @@ -1386,7 +1389,7 @@ dump_type_info(type_or_ent *tore, void *env) { entity *ent = (entity *)tore; ir_node *value; /* The node */ - dump_entity_node(F, ent); + dump_entity_node(F, ent, 0); /* The Edges */ /* skip this to reduce graph. Member edge of type is parallel to this edge. * fprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " @@ -1512,13 +1515,14 @@ dump_class_hierarchy_node (type_or_ent *tore, void *ctx) { case k_entity: { entity *ent = (entity *)tore; if (get_entity_owner(ent) == get_glob_type()) break; + if (!is_method_type(get_entity_type(ent))) break; /* GL */ if (env->dump_ent && is_class_type(get_entity_owner(ent))) { /* The node */ - dump_entity_node(F, ent); + dump_entity_node(F, ent, 0); /* The edges */ print_type_ent_edge(F,get_entity_owner(ent),ent,TYPE_MEMBER_EDGE_ATTR); for(i = 0; i < get_entity_n_overwrites(ent); i++) - print_ent_ent_edge(F,get_entity_overwrites(ent, i),ent, 0, ENT_OVERWRITES_EDGE_ATTR); + print_ent_ent_edge(F, get_entity_overwrites(ent, i), ent, 0, ENT_OVERWRITES_EDGE_ATTR); } } break; /* case k_entity */ case k_type: @@ -1687,6 +1691,39 @@ dump_vcg_header(FILE *F, const char *name, const char *orientation) { "infoname 2: \"Verification errors\"\n", name, label, orientation); + /* don't use all, the range is too whith/black. */ + n_colors = 18; + base_color = 105; + fprintf (F, + "colorentry 100: 0 0 0\n" + "colorentry 101: 20 0 0\n" + "colorentry 102: 40 0 0\n" + "colorentry 103: 60 0 0\n" + "colorentry 104: 80 0 0\n" + "colorentry 105: 100 0 0\n" + "colorentry 106: 120 0 0\n" + "colorentry 107: 140 0 0\n" + "colorentry 108: 150 0 0\n" + "colorentry 109: 180 0 0\n" + "colorentry 110: 200 0 0\n" + "colorentry 111: 220 0 0\n" + "colorentry 112: 240 0 0\n" + "colorentry 113: 255 0 0\n" + "colorentry 113: 255 20 20\n" + "colorentry 114: 255 40 40\n" + "colorentry 115: 255 60 60\n" + "colorentry 116: 255 80 80\n" + "colorentry 117: 255 100 100\n" + "colorentry 118: 255 120 120\n" + "colorentry 119: 255 140 140\n" + "colorentry 120: 255 150 150\n" + "colorentry 121: 255 180 180\n" + "colorentry 122: 255 200 200\n" + "colorentry 123: 255 220 220\n" + "colorentry 124: 255 240 240\n" + "colorentry 125: 255 250 250\n" + ); + fprintf (F, "\n"); /* a separator */ } @@ -1800,21 +1837,18 @@ vcg_close (FILE *F) { /** Routine to dump a graph, blocks as conventional nodes. */ void -dump_ir_graph (ir_graph *irg) +dump_ir_graph (ir_graph *irg, const char *suffix ) { FILE *f; ir_graph *rem; - char *suffix; + char *suffix1; rem = current_ir_graph; - /* if a filter is set, dump only the irg's that match the filter */ - if (strncmp(get_entity_name(get_irg_ent(irg)), dump_file_filter, strlen(dump_file_filter)) != 0) - return; - + if (strncmp(get_entity_name(get_irg_entity(irg)), dump_file_filter, strlen(dump_file_filter)) != 0) return; current_ir_graph = irg; - if (interprocedural_view) suffix = "-pure-ip"; - else suffix = "-pure"; - f = vcg_open(irg, dump_file_suffix, suffix); + if (interprocedural_view) suffix1 = "-pure-ip"; + else suffix1 = "-pure"; + f = vcg_open(irg, suffix, suffix1); dump_vcg_header(f, get_irg_dump_name(irg), NULL); /* walk over the graph */ @@ -1822,8 +1856,8 @@ dump_ir_graph (ir_graph *irg) irg_walk(get_irg_end(irg), NULL, dump_whole_node, f); /* dump the out edges in a separate walk */ - if ((dump_out_edge_flag) && (get_irg_outs_state(irg) != no_outs)) { - irg_out_walk(get_irg_start(irg), dump_out_edge, NULL, f); + if ((dump_out_edge_flag) && (get_irg_outs_state(irg) != outs_none)) { + irg_out_walk(get_irg_start(irg), dump_out_edge, NULL, NULL); } vcg_close(f); @@ -1833,19 +1867,16 @@ dump_ir_graph (ir_graph *irg) void -dump_ir_block_graph (ir_graph *irg) +dump_ir_block_graph (ir_graph *irg, const char *suffix) { FILE *f; int i; - char *suffix; + char *suffix1; - /* if a filter is set, dump only the irg's that match the filter */ - if (strncmp(get_entity_name(get_irg_ent(irg)), dump_file_filter, strlen(dump_file_filter)) != 0) - return; - - if (interprocedural_view) suffix = "-ip"; - else suffix = ""; - f = vcg_open(irg, dump_file_suffix, suffix); + if(strncmp(get_entity_name(get_irg_entity(irg)),dump_file_filter,strlen(dump_file_filter))!=0) return; + if (interprocedural_view) suffix1 = "-ip"; + else suffix1 = ""; + f = vcg_open(irg, suffix, suffix1); dump_vcg_header(f, get_irg_dump_name(irg), NULL); construct_block_lists(irg); @@ -1864,21 +1895,21 @@ dump_ir_block_graph (ir_graph *irg) /** dumps a graph with type information */ void -dump_ir_graph_w_types (ir_graph *irg) +dump_ir_graph_w_types (ir_graph *irg, const char *suffix) { FILE *f; ir_graph *rem = current_ir_graph; - char *suffix; + char *suffix1; /* if a filter is set, dump only the irg's that match the filter */ - if (strncmp(get_irg_dump_name(irg), dump_file_filter, strlen(dump_file_filter)) != 0) + if (strncmp(get_entity_name(get_irg_entity(irg)), dump_file_filter, strlen(dump_file_filter)) != 0) return; current_ir_graph = irg; - if (interprocedural_view) suffix = "-pure-wtypes-ip"; - else suffix = "-pure-wtypes"; - f = vcg_open(irg, dump_file_suffix, suffix); + if (interprocedural_view) suffix1 = "-pure-wtypes-ip"; + else suffix1 = "-pure-wtypes"; + f = vcg_open(irg,suffix, suffix1); dump_vcg_header(f, get_irg_dump_name(irg), NULL); /* dump common ir graph */ @@ -1894,20 +1925,20 @@ dump_ir_graph_w_types (ir_graph *irg) } void -dump_ir_block_graph_w_types (ir_graph *irg) +dump_ir_block_graph_w_types (ir_graph *irg, const char *suffix) { FILE *f; int i; - char *suffix; + char *suffix1; ir_graph *rem = current_ir_graph; /* if a filter is set, dump only the irg's that match the filter */ - if (strncmp(get_irg_dump_name(irg), dump_file_filter, strlen(dump_file_filter)) != 0) + if (strncmp(get_entity_name(get_irg_entity(irg)), dump_file_filter, strlen(dump_file_filter)) != 0) return; - if (interprocedural_view) suffix = "-wtypes-ip"; - else suffix = "-wtypes"; - f = vcg_open(irg, dump_file_suffix, suffix); + if (interprocedural_view) suffix1 = "-wtypes-ip"; + else suffix1 = "-wtypes"; + f = vcg_open(irg, suffix, suffix1); dump_vcg_header(f, get_irg_dump_name(irg), NULL); /* dump common blocked ir graph */ @@ -1933,9 +1964,9 @@ dump_ir_block_graph_w_types (ir_graph *irg) vcg_close(f); } -/***********************************************************************/ +/*---------------------------------------------------------------------*/ /* The following routines dump a control flow graph. */ -/***********************************************************************/ +/*---------------------------------------------------------------------*/ static void dump_block_to_cfg(ir_node *block, void *env) { @@ -1946,21 +1977,34 @@ dump_block_to_cfg(ir_node *block, void *env) { if (is_Block(block)) { /* This is a block. Dump a node for the block. */ fprintf (F, "node: {title: \""); PRINT_NODEID(block); - fprintf (F, "\" label: \"%s ", get_op_name(get_irn_op(block))); + fprintf (F, "\" label: \""); + if (block == get_irg_start_block(get_irn_irg(block))) + fprintf(F, "Start "); + if (block == get_irg_end_block(get_irn_irg(block))) + fprintf(F, "End "); + + fprintf (F, "%s ", get_op_name(get_irn_op(block))); PRINT_NODEID(block); fprintf (F, "\" "); + fprintf(F, "info1:\""); if (dump_dominator_information_flag) - fprintf(F, "info1:dom depth %d", get_Block_dom_depth(block)); + fprintf(F, "info1:\"dom depth %d\n", get_Block_dom_depth(block)); + fprintf (F, "\""); /* closing quote of info */ + + if ((block == get_irg_start_block(get_irn_irg(block))) || + (block == get_irg_end_block(get_irn_irg(block))) ) + fprintf(F, " color:blue "); + fprintf (F, "}\n"); /* Dump the edges */ for ( i = 0; i < get_Block_n_cfgpreds(block); i++) if (get_irn_op(skip_Proj(get_Block_cfgpred(block, i))) != op_Bad) { - pred = get_nodes_block(skip_Proj(get_Block_cfgpred(block, i))); - fprintf (F, "edge: { sourcename: \""); - PRINT_NODEID(block); - fprintf (F, "\" targetname: \""); - PRINT_NODEID(pred); - fprintf (F, "\"}\n"); + pred = get_nodes_block(skip_Proj(get_Block_cfgpred(block, i))); + fprintf (F, "edge: { sourcename: \""); + PRINT_NODEID(block); + fprintf (F, "\" targetname: \""); + PRINT_NODEID(pred); + fprintf (F, "\"}\n"); } /* Dump dominator edge */ @@ -1976,7 +2020,7 @@ dump_block_to_cfg(ir_node *block, void *env) { } void -dump_cfg (ir_graph *irg) +dump_cfg (ir_graph *irg, const char *suffix) { FILE *f; ir_graph *rem = current_ir_graph; @@ -1984,12 +2028,12 @@ dump_cfg (ir_graph *irg) int ipv = interprocedural_view; /* if a filter is set, dump only the irg's that match the filter */ - if (strncmp(get_irg_dump_name(irg), dump_file_filter, strlen(dump_file_filter)) != 0) + if (strncmp(get_entity_name(get_irg_entity(irg)), dump_file_filter, strlen(dump_file_filter)) != 0) return; current_ir_graph = irg; - f = vcg_open(irg, dump_file_suffix, "-cfg"); + f = vcg_open(irg, suffix, "-cfg"); dump_vcg_header(f, get_irg_dump_name(irg), NULL); if (interprocedural_view) { @@ -2010,44 +2054,88 @@ dump_cfg (ir_graph *irg) current_ir_graph = rem; } +static int weight_overall(int rec, int loop) { + return 2*rec + loop; +} + +static int compute_color (int my, int max) { + int color; + if (!max) { + color = 0; + } else { + /* if small, scale to the full color range. */ + if (max < n_colors) + my = my * (n_colors/max); + int step = 1 + (max / n_colors); -void dump_callgraph(char *filesuffix) { + color = my/step; + } + return base_color + n_colors - color; +} + +static int get_entity_color(entity *ent) { + assert(get_entity_irg(ent)); + ir_graph *irg = get_entity_irg(ent); + + int rec_depth = get_irg_recursion_depth(irg); + int loop_depth = get_irg_loop_depth(irg); + int overall_depth = weight_overall(rec_depth, loop_depth); + + int max_rec_depth = irp->max_callgraph_recursion_depth; + int max_loop_depth = irp->max_callgraph_loop_depth; + int max_overall_depth = weight_overall(max_rec_depth, max_loop_depth); + + int my_rec_color = compute_color(rec_depth, max_rec_depth); + int my_loop_color = compute_color(loop_depth, max_loop_depth); + int my_overall_color = compute_color(overall_depth, max_overall_depth);; + + return my_overall_color; +} + +void dump_callgraph(const char *suffix) { FILE *F; int i, n_irgs = get_irp_n_irgs(); + int rem = edge_label; + edge_label = 1; + //ident *prefix = new_id_from_str("java/"); - F = vcg_open_name("Callgraph", filesuffix); + F = vcg_open_name("Callgraph", suffix); dump_vcg_header(F, "Callgraph", NULL); for (i = 0; i < n_irgs; ++i) { ir_graph *irg = get_irp_irg(i); - entity *ent = get_irg_ent(irg); + entity *ent = get_irg_entity(irg); int j, n_callees = get_irg_n_callees(irg); - dump_entity_node(F, ent); + /* Do not dump runtime system. */ + //if (id_is_prefix(prefix, get_entity_ld_ident(ent))) continue; + + dump_entity_node(F, ent, get_entity_color(ent)); for (j = 0; j < n_callees; ++j) { 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\" color:red" : - "label:\"calls\""; - print_ent_ent_edge(F, ent, c, be, attr); + "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), get_entity_color(ent)); } } + edge_label = rem; vcg_close(F); } - /* Dump all irgs in interprocedural view to a single file. */ -void dump_all_cg_block_graph(void) { +void dump_all_cg_block_graph(const char *suffix) { FILE *f; int i; int rem_view = interprocedural_view; interprocedural_view = 1; - f = vcg_open_name("All_graphs", dump_file_suffix); + f = vcg_open_name("All_graphs", suffix); dump_vcg_header(f, "All_graphs", NULL); /* collect nodes in all irgs reachable in call graph*/ @@ -2073,18 +2161,18 @@ void dump_all_cg_block_graph(void) { /***********************************************************************/ void -dump_type_graph (ir_graph *irg) +dump_type_graph (ir_graph *irg, const char *suffix) { FILE *f; ir_graph *rem; rem = current_ir_graph; /* if a filter is set, dump only the irg's that match the filter */ - if (strncmp(get_irg_dump_name(irg), dump_file_filter, strlen(dump_file_filter)) != 0) return; + if (strncmp(get_entity_name(get_irg_entity(irg)), dump_file_filter, strlen(dump_file_filter)) != 0) return; current_ir_graph = irg; - f = vcg_open(irg, dump_file_suffix, "-type"); + f = vcg_open(irg, suffix, "-type"); dump_vcg_header(f, get_irg_dump_name(irg), NULL); /* walk over the blocks in the graph */ @@ -2100,9 +2188,9 @@ dump_type_graph (ir_graph *irg) } void -dump_all_types (void) +dump_all_types (const char *suffix) { - FILE *f = vcg_open_name("All_types", dump_file_suffix); + FILE *f = vcg_open_name("All_types", suffix); dump_vcg_header(f, "All_types", NULL); type_walk(dump_type_info, NULL, f); inc_irg_visited(get_const_code_irg()); @@ -2110,9 +2198,9 @@ dump_all_types (void) } void -dump_class_hierarchy (bool entities) +dump_class_hierarchy (bool entities, const char *suffix) { - FILE *f = vcg_open_name("class_hierarchy", dump_file_suffix); + FILE *f = vcg_open_name("class_hierarchy", suffix); h_env_t env; env.f = f; @@ -2134,21 +2222,19 @@ dump_class_hierarchy (bool entities) /* dump_ir_graph_w_types */ /***********************************************************************/ -void dump_all_ir_graphs(dump_graph_func *dmp_grph) { +void dump_all_ir_graphs(dump_graph_func *dmp_grph, const char *suffix) { int i; for (i=0; i < get_irp_n_irgs(); i++) { - dmp_grph(get_irp_irg(i)); + dmp_grph(get_irp_irg(i), suffix); } } /********************************************************************************** * Dumps a stand alone loop graph with firm nodes which belong to one loop nodes * - * packed together in one subgraph * + * packed together in one subgraph/box * **********************************************************************************/ - - void dump_loops_standalone(FILE *F, ir_loop *loop) { int i = 0, loop_node_started = 0, son_number = 0, first = 0; loop_element le; @@ -2200,14 +2286,11 @@ void dump_loops_standalone(FILE *F, ir_loop *loop) { fprintf (F, " "); bad |= dump_node_nodeattr(F, n); fprintf (F, " %ld", get_irn_node_nr(n)); - } -#if CALLGRAPH_LOOP_TREE - else { + if (is_Block(n)) fprintf (F, "\t ->%d", (int)get_irn_link(n)); + } else { /* for callgraph loop tree */ assert(get_kind(son) == k_ir_graph); /* We are a loop node -> Collect firm graphs */ - ir_graph *n = (ir_graph *)le.node; - if (!loop_node_started) { /* Start a new node which contains all firm nodes of the current loop */ fprintf (F, "node: { title: \""); @@ -2218,10 +2301,9 @@ void dump_loops_standalone(FILE *F, ir_loop *loop) { } else fprintf(F, "\n"); - fprintf (F, " %s", get_irg_dump_name(n)); + /* fprintf (F, " %s (depth %d)", get_irg_dump_name(n), n->callgraph_weighted_loop_depth); */ } -#endif } if (loop_node_started) { @@ -2235,7 +2317,7 @@ void dump_loops_standalone(FILE *F, ir_loop *loop) { } } -void dump_loop_tree(ir_graph *irg, char *suffix) +void dump_loop_tree(ir_graph *irg, const char *suffix) { FILE *f; ir_graph *rem = current_ir_graph; @@ -2243,7 +2325,7 @@ void dump_loop_tree(ir_graph *irg, char *suffix) edge_label = 1; /* if a filter is set, dump only the irg's that match the filter */ - if (strncmp(get_irg_dump_name(irg), dump_file_filter, strlen(dump_file_filter)) != 0) + if (strncmp(get_entity_name(get_irg_entity(irg)), dump_file_filter, strlen(dump_file_filter)) != 0) return; current_ir_graph = irg; @@ -2259,15 +2341,13 @@ void dump_loop_tree(ir_graph *irg, char *suffix) current_ir_graph = rem; } -#if CALLGRAPH_LOOP_TREE -/* works, but the tree is meaningless. */ -void dump_callgraph_loop_tree(ir_loop *l, char *suffix) { - vcg_open_name("callgraph_looptree", suffix); - dump_vcg_header("callgraph_looptree", "top_to_bottom"); - dump_loops_standalone(l); - vcg_close(); +void dump_callgraph_loop_tree(const char *suffix) { + FILE *F; + F = vcg_open_name("Callgraph_looptree", suffix); + dump_vcg_header(F, "callgraph looptree", "top_to_bottom"); + dump_loops_standalone(F, irp->outermost_cg_loop); + vcg_close(F); } -#endif /*******************************************************************************/ @@ -2316,7 +2396,7 @@ void collect_nodeloop_external_nodes(ir_loop *loop, eset *loopnodes, eset *extno } } -void dump_loop(ir_loop *l, char *suffix) { +void dump_loop(ir_loop *l, const char *suffix) { FILE *F; char name[50]; eset *loopnodes = eset_create();