X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firdump.c;h=862b58b322eeb033c12e3d20685e64f1334bbb3c;hb=1852308bd33b77378f0fca9e5347d4f9082464c4;hp=97b934bccac7bce911140d5dfaaf263b8da4272d;hpb=2ece936daec565575739be72f568a241207a5083;p=libfirm diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 97b934bcc..862b58b32 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -29,8 +29,6 @@ #include #include -#include "firm_common_t.h" - #include "list.h" #include "irnode_t.h" @@ -40,6 +38,7 @@ #include "irop.h" #include "irdump_t.h" +#include "irpass_t.h" #include "irgwalk.h" #include "tv_t.h" @@ -330,6 +329,19 @@ static void print_vcg_color(FILE *F, ird_color_t color) { fprintf(F, "color:%s", color_names[color]); } +/** + * Prints the edge kind of a given IR node. + * + * Projs should be dumped near their predecessor, so they get "nearedge". + */ +static void print_node_edge_kind(FILE *F, ir_node *node) { + if (is_Proj(node)) { + fprintf(F, "nearedge: "); + } else { + fprintf(F, "edge: "); + } +} + /** * Prints the edge from a type S to a type T with additional info fmt, ... * to the file F. @@ -759,9 +771,6 @@ int dump_node_opcode(FILE *F, ir_node *n) case symconst_enum_const: fprintf(F, "SymC %s enum", get_enumeration_name(get_SymConst_enum(n))); break; - case symconst_label: - fprintf(F, "SymC %lu label", get_SymConst_label(n)); - break; } break; @@ -1581,7 +1590,8 @@ static void dump_ir_data_edges(FILE *F, ir_node *n) { ir_node *dep = get_irn_dep(n, i); if (dep) { - fprintf(F, "edge: {sourcename: \""); + print_node_edge_kind(F, n); + fprintf(F, "{sourcename: \""); PRINT_NODEID(n); fprintf(F, "\" targetname: "); if ((get_opt_dump_const_local()) && is_constlike_node(dep)) { @@ -1606,8 +1616,10 @@ static void dump_ir_data_edges(FILE *F, ir_node *n) { if (dump_backedge_information_flag && is_backedge(n, i)) fprintf(F, "backedge: {sourcename: \""); - else - fprintf(F, "edge: {sourcename: \""); + else { + print_node_edge_kind(F, n); + fprintf(F, "{sourcename: \""); + } PRINT_NODEID(n); fprintf(F, "\" targetname: "); if ((get_opt_dump_const_local()) && is_constlike_node(pred)) { @@ -1642,7 +1654,8 @@ dump_ir_edges(FILE *F, ir_node *n) { foreach_out_edge(n, edge) { ir_node *succ = get_edge_src_irn(edge); - fprintf(F, "edge: {sourcename: \""); + print_node_edge_kind(F, succ); + fprintf(F, "{sourcename: \""); PRINT_NODEID(n); fprintf(F, "\" targetname: \""); PRINT_NODEID(succ); @@ -2030,7 +2043,9 @@ static void dump_enum_item(FILE *F, ir_type *tp, int pos) * Dumps a new style initializer. */ static void dump_entity_initializer(FILE *F, const ir_entity *ent) { - + /* TODO */ + (void) F; + (void) ent; } /** Dumps a type or entity and it's edges. */ @@ -2212,7 +2227,8 @@ dump_out_edge(ir_node *n, void *env) { for (i = get_irn_n_outs(n) - 1; i >= 0; --i) { ir_node *succ = get_irn_out(n, i); assert(succ); - fprintf(F, "edge: {sourcename: \""); + print_node_edge_kind(F, succ); + fprintf(F, "{sourcename: \""); PRINT_NODEID(n); fprintf(F, "\" targetname: \""); PRINT_NODEID(succ); @@ -2366,7 +2382,7 @@ void dump_vcg_header(FILE *F, const char *name, const char *layout, const char * * @param suffix1 first filename suffix * @param suffix2 second filename suffix */ -FILE *vcg_open(ir_graph *irg, const char *suffix1, const char *suffix2) { +FILE *vcg_open(const ir_graph *irg, const char *suffix1, const char *suffix2) { FILE *F; const char *nm = get_irg_dump_name(irg); int len = strlen(nm), i, j; @@ -2981,6 +2997,39 @@ void dump_all_ir_graphs(dump_graph_func *dmp_grph, const char *suffix) { dmp_grph(get_irp_irg(i), suffix); } +struct pass_t { + ir_prog_pass_t pass; + dump_graph_func *dump_graph; + char suffix[1]; +}; + +/** + * Wrapper around dump_all_ir_graphs(). + */ +static int dump_all_ir_graphs_wrapper(ir_prog *irp, void *context) { + struct pass_t *pass = context; + + (void)irp; + dump_all_ir_graphs(pass->dump_graph, pass->suffix); + return 0; +} + +ir_prog_pass_t *dump_all_ir_graph_pass( + const char *name, dump_graph_func *dump_graph, const char *suffix) { + size_t len = strlen(suffix); + struct pass_t *pass = xmalloc(sizeof(*pass) + len); + ir_prog_pass_t *res = def_prog_pass_constructor( + &pass->pass, name ? name : "dump_all_graphs", dump_all_ir_graphs_wrapper); + + /* this pass does not change anything, so neither dump nor verify is needed. */ + res->dump_irprog = ir_prog_no_dump; + res->verify_irprog = ir_prog_no_verify; + + pass->dump_graph = dump_graph; + strcpy(pass->suffix, suffix); + + return res; +} /*--------------------------------------------------------------------------------* * Dumps a stand alone loop graph with firm nodes which belong to one loop node *