X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbelive.c;h=ce7d6b8bd70b2bf336bbf99f1d10c3247a95c17c;hb=23b71abac8014aa6bfee3b47648fdb8fe8687b8f;hp=368d8f1fd0a5b52da5e47faaf3963c616bba53ad;hpb=e824098ad68e42ccf587aa5ac0ce07280bfd0626;p=libfirm diff --git a/ir/be/belive.c b/ir/be/belive.c index 368d8f1fd..ce7d6b8bd 100644 --- a/ir/be/belive.c +++ b/ir/be/belive.c @@ -151,16 +151,54 @@ static int cmp_irn_live(const void *a, const void *b, size_t size) return !(p->block == q->block && p->irn == q->irn); } +static int (*old_dump_block_func)(ir_node *self, FILE *F, dump_reason_t reason) = NULL; + +static int dump_block_func(ir_node *self, FILE *F, dump_reason_t reason) +{ + switch(reason) { + case dump_node_opcode_txt: + fprintf(F, get_irn_opname(self)); + break; + case dump_node_mode_txt: + fprintf(F, get_irn_modename(self)); + break; + case dump_node_nodeattr_txt: + break; + case dump_node_info_txt: + if(!get_irg_live_info(get_irn_irg(self))->live) + return 0; + + fprintf(F, "liveness information:\n"); + { + irn_live_t *li; + live_foreach(self, li) { + ir_fprintf(F, "%+F", li->irn); + if(live_is_in(li)) + fprintf(F, " in"); + if(live_is_end(li)) + fprintf(F, " end"); + if(live_is_out(li)) + fprintf(F, " out"); + + fprintf(F, "\n"); + } + } + } + + return 0; +} + void be_liveness(ir_graph *irg) { irg_live_info_t *live_info = get_irg_live_info(irg); if(live_info->live) del_set(live_info->live); - ir_fprintf(stderr, "%F\n", irg); - live_info->live = new_set(cmp_irn_live, 8192); irg_walk_graph(irg, liveness_for_node, NULL, NULL); + + old_dump_block_func = op_Block->ops.dump_node; + op_Block->ops.dump_node = dump_block_func; } static void dump_liveness_walker(ir_node *bl, void *data) @@ -191,9 +229,20 @@ void be_liveness_dump(ir_graph *irg, FILE *f) irg_block_walk_graph(irg, dump_liveness_walker, NULL, f); } +void be_liveness_dumpto(ir_graph *irg, const char *cls_name) +{ + FILE *f; + char buf[128]; + ir_snprintf(buf, sizeof(buf), "%F_%s-live.txt", irg, cls_name); + if((f = fopen(buf, "wt")) != NULL) { + be_liveness_dump(irg, f); + fclose(f); + } +} + static void dom_check(ir_node *irn, void *data) { - if(!is_block(irn)) { + if(!is_Block(irn) && irn != get_irg_end(get_irn_irg(irn))) { int i, n; ir_node *bl = get_nodes_block(irn); @@ -205,9 +254,10 @@ static void dom_check(ir_node *irn, void *data) if(is_Phi(irn)) use_bl = get_Block_cfgpred_block(bl, i); - if(!block_dominates(def_bl, use_bl)) - ir_fprintf(stderr, "In %+F(%d:%+Fr): %+F must dominate %+F\n", - irn, i, op, def_bl, use_bl); + if(!block_dominates(def_bl, use_bl)) { + ir_fprintf(stderr, "%+F in %+F must dominate %+F for user %+F\n", op, def_bl, use_bl, irn); + assert(0); + } } } }