X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fir%2Firdump.c;h=4022274fbb50638fb327a42731f81ef7ac3050ac;hb=58aa0d5491aa03f6c71a3dec8dc13d2959f3d1bb;hp=12cb4ceccf03fb69784299541db4d1f7c0217062;hpb=cece184ac1757c87ae006320e2031be17c55859b;p=libfirm diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 12cb4cecc..4022274fb 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -35,7 +35,7 @@ #define MEM_EDGE_ATTR "color: blue" /* Attributes of edges between Firm nodes and type/entity nodes */ -#define NODE2TYPE_EDGE_ATTR "" +#define NODE2TYPE_EDGE_ATTR "class: 2 priority: 2 linestyle: dotted" /* Attributes of edges in type/entity graphs. */ #define TYPE_METH_NODE_ATTR "color: lightyellow" @@ -49,14 +49,20 @@ #define UNION_EDGE_ATTR "class: 8 label: \"component\" color: blue" #define PTR_PTS_TO_EDGE_ATTR "class: 9 label: \"points to\" color:green" #define ARR_ELT_TYPE_EDGE_ATTR "class: 10 label: \"arr elt\" color:green" +#define ENT_OVERWRITES_EDGE_ATTR "class: 11 label: \"overwrites\" color:red" +#define TYPE_MEMBER_EDGE_ATTR "class: 12 label: \"member\" color:blue" #define PRINT_NODEID(X) fprintf(F, "%p", X) /* file to dump to */ static FILE *F; +/* A compiler option to turn off edge labels */ int edge_label = 1; +/* A global variable to record output of the Bad node. */ +int Bad_dumped; + /*******************************************************************/ /* routines to dump information about a single node */ /*******************************************************************/ @@ -77,8 +83,8 @@ dump_node_opcode (ir_node *n) xfprintf (F, "%I", get_SymConst_ptrinfo(n)); } else { assert(get_kind(get_SymConst_type(n)) == k_type); - assert(get_type_nameid(get_SymConst_type(n))); - xfprintf (F, "%s ", id_to_str(get_type_nameid(get_SymConst_type(n)))); + assert(get_type_ident(get_SymConst_type(n))); + xfprintf (F, "%s ", id_to_str(get_type_ident(get_SymConst_type(n)))); if (get_SymConst_kind == type_tag) xfprintf (F, "tag"); else @@ -321,7 +327,7 @@ dump_ir_node (ir_node *n) break; case iro_SymConst: assert(get_kind(get_SymConst_type(n)) == k_type); - assert(get_type_nameid(get_SymConst_type(n))); + assert(get_type_ident(get_SymConst_type(n))); xfprintf (F, "\"%s ", get_type_name(get_SymConst_type(n))); switch (n->attr.i.num){ case type_tag: @@ -439,7 +445,7 @@ dump_ir_data_edges(ir_node *n) { assert(get_irn_n(n, i)); xfprintf (F, "edge: {sourcename: \"%p\" targetname: \"%p\"", n, get_irn_n(n, i)); - fprintf (F, " label: \"%d\" ", i+1); + fprintf (F, " label: \"%d\" ", i); print_edge_vcgattr(n, i); fprintf (F, "}\n"); } @@ -493,56 +499,70 @@ dump_type_info (type_or_ent *tore, void *env) { case k_entity: { entity *ent = (entity *)tore; - xfprintf (F, "\"ent %I\" " ENTITY_NODE_ATTR "}\n", get_entity_ident(ent)); - xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " + xfprintf (F, "\"ent %I\" " ENTITY_NODE_ATTR , get_entity_ident(ent)); + if(dynamic_allocated == get_entity_allocation(ent)) + xfprintf (F, " info1:\"dynamic allocated\"}\n"); + else + xfprintf (F, " info1:\"static allocated\"}\n"); + xfprintf (F, "nearedge: { sourcename: \"%p\" targetname: \"%p\" " ENT_OWN_EDGE_ATTR "}\n", tore, get_entity_owner(ent)); xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " ENT_TYPE_EDGE_ATTR "}\n", tore, get_entity_type(ent)); + for(i = 0; i < get_entity_n_overwrites(ent); i++) + xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " + ENT_OVERWRITES_EDGE_ATTR "}\n", tore, get_entity_overwrites(ent, i)); } break; case k_type: { - /* why can't I cast here??? @@@ */ - type *type = tore; - xfprintf (F, "\"%I %I", get_type_tpop_nameid(type), get_type_nameid(type)); + type *tp = (type *)tore; + xfprintf (F, "\"%I %I", get_type_tpop_nameid(tp), get_type_ident(tp)); - switch (get_type_tpop_code(type)) { + switch (get_type_tpop_code(tp)) { case tpo_class: { xfprintf (F, "\" " TYPE_CLASS_NODE_ATTR "}\n"); - for (i=0; i < get_class_n_supertype(type); i++) + for (i=0; i < get_class_n_supertype(tp); i++) xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " TYPE_SUPER_EDGE_ATTR "}\n", - type, get_class_supertype(type, i)); + tp, get_class_supertype(tp, i)); + for (i=0; i < get_class_n_member(tp); i++) + xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " + TYPE_MEMBER_EDGE_ATTR "}\n", + tp, get_class_member(tp, i)); } break; case tpo_struct: { xfprintf (F, "\"}\n"); + for (i=0; i < get_struct_n_member(tp); i++) + xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " + TYPE_MEMBER_EDGE_ATTR "}\n", + tp, get_struct_member(tp, i)); } break; case tpo_method: { xfprintf (F, "\" " TYPE_METH_NODE_ATTR "}\n"); - for (i = 0; i < get_method_n_params(type); i++) + for (i = 0; i < get_method_n_params(tp); i++) xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " METH_PAR_EDGE_ATTR "}\n", - type, get_method_param_type(type, i), i); - for (i = 0; i < get_method_n_res(type); i++) + tp, get_method_param_type(tp, i), i); + for (i = 0; i < get_method_n_res(tp); i++) xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " METH_RES_EDGE_ATTR "}\n", - type, get_method_res_type(type, i), i); + tp, get_method_res_type(tp, i), i); } break; case tpo_union: { xfprintf (F, "\"}\n"); - for (i = 0; i < get_union_n_members(type); i++) + for (i = 0; i < get_union_n_members(tp); i++) xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " "label: \"\"f" UNION_EDGE_ATTR "}\n", - type, get_union_member(type, i)); + tp, get_union_member(tp, i)); } break; case tpo_array: { xfprintf (F, "\"}\n"); xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " - ARR_ELT_TYPE_EDGE_ATTR "}\n", type, get_array_element_type(type), i); + ARR_ELT_TYPE_EDGE_ATTR "}\n", tp, get_array_element_type(tp), i); } break; case tpo_enumeration: { @@ -552,17 +572,17 @@ dump_type_info (type_or_ent *tore, void *env) { { xfprintf (F, "\"}\n"); xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" " - PTR_PTS_TO_EDGE_ATTR "}\n", type, - get_pointer_points_to_type(type), i); + PTR_PTS_TO_EDGE_ATTR "}\n", tp, + get_pointer_points_to_type(tp), i); } break; case tpo_primitive: { - xfprintf (F, "mode %I\"}\n", get_mode_ident(get_type_mode(type))); + xfprintf (F, " (mode %I)\"}\n", get_mode_ident(get_type_mode(tp))); } break; default: break; } /* switch type */ - - } break; /* case k_type */ + } + break; /* case k_type */ default: { xfprintf (F, "\" faulty type \"}\n"); @@ -629,6 +649,8 @@ void vcg_open (ir_graph *irg, char *suffix) { "classname 8: \"Union\"" "classname 9: \"Points-to\"" "classname 10: \"Array Element Type\"" + "classname 11: \"Overwrites\"" + "classname 12: \"Member\"" , cp, label); xfprintf (F, "\n"); /* a separator */ @@ -665,14 +687,16 @@ void vcg_open_name (const char *name) { "orientation: bottom_to_top\n" "classname 1: \"Data\"\n" "classname 2: \"Block\"\n" - "classname 3: \"Entity type\"" - "classname 4: \"Entity owner\"" - "classname 5: \"Method Param\"" - "classname 6: \"Method Res\"" - "classname 7: \"Super\"" - "classname 8: \"Union\"" - "classname 9: \"Points-to\"" - "classname 10: \"Array Element Type\"" + "classname 3: \"Entity type\"\n" + "classname 4: \"Entity owner\"\n" + "classname 5: \"Method Param\"\n" + "classname 6: \"Method Res\"\n" + "classname 7: \"Super\"\n" + "classname 8: \"Union\"\n" + "classname 9: \"Points-to\"\n" + "classname 10: \"Array Element Type\"\n" + "classname 11: \"Overwrites\"\n" + "classname 12: \"Member\"\n" , name, label); xfprintf (F, "\n"); /* a separator */ @@ -724,6 +748,8 @@ dump_ir_blocks_nodes (ir_node *n, void *env) { dump_node(n); dump_ir_data_edges(n); } + if (get_irn_op(n) == op_Bad) + Bad_dumped = 1; } void @@ -751,6 +777,32 @@ dump_ir_block (ir_node *block, void *env) { } } + +void +dump_blockless_nodes (ir_node *n, void *env) { + if (is_no_Block(n) && get_irn_op(get_nodes_Block(n)) == op_Bad) { + dump_node(n); + dump_ir_data_edges(n); + dump_ir_block_edge(n); + } + if (get_irn_op(n) == op_Bad) + Bad_dumped = 1; +} + +void dump_ir_block_graph_2 (ir_graph *irg) +{ + Bad_dumped = 0; + /* walk over the blocks in the graph */ + irg_block_walk(irg->end, dump_ir_block, NULL, irg); + + /* dump all nodes that are not in a Block */ + irg_walk(irg->end, dump_blockless_nodes, NULL, NULL); + + /* dump the Bad node */ + if (!Bad_dumped) + dump_node(get_irg_bad(irg)); +} + void dump_ir_block_graph (ir_graph *irg) { @@ -760,8 +812,7 @@ dump_ir_block_graph (ir_graph *irg) vcg_open (irg, ""); - /* walk over the blocks in the graph */ - irg_block_walk(irg->end, dump_ir_block, NULL, irg); + dump_ir_block_graph_2 (irg); vcg_close(); current_ir_graph = rem; @@ -853,7 +904,6 @@ dump_ir_graph_w_types (ir_graph *irg) vcg_open (irg, "-all"); /* dump common ir graph */ - /* irg_block_walk(irg->end, dump_ir_block, NULL, irg); */ irg_walk(irg->end, dump_whole_node, NULL, NULL); /* dump type info */ type_walk_irg(irg, dump_type_info, NULL, NULL); @@ -864,6 +914,26 @@ dump_ir_graph_w_types (ir_graph *irg) current_ir_graph = rem; } +void +dump_ir_block_graph_w_types (ir_graph *irg) +{ + ir_graph *rem; + rem = current_ir_graph; + current_ir_graph = irg; + + vcg_open (irg, "-all"); + + /* dump common blocked ir graph */ + dump_ir_block_graph_2(irg); + /* dump type info */ + type_walk_irg(irg, dump_type_info, NULL, NULL); + /* dump edges from graph to type info */ + irg_walk(irg->end, dump_node2type_edges, NULL, NULL); + + vcg_close(); + current_ir_graph = rem; +} + /***********************************************************************/ /* dumps all graphs with the graph-dumper passed. Possible dumpers: */ /* dump_ir_graph */