X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbephiopt.c;h=31a7786ffee1c46ee8891f32fbebcbc95fac6620;hb=321ae93c651a24f17e2b7540e67a959db803c40d;hp=c2eed514ed64443c0cad5e8eed58d10c517b0442;hpb=0d8c0aa0e0d08680dfdae1f408814b4393d52098;p=libfirm diff --git a/ir/be/bephiopt.c b/ir/be/bephiopt.c index c2eed514e..31a7786ff 100644 --- a/ir/be/bephiopt.c +++ b/ir/be/bephiopt.c @@ -3,20 +3,29 @@ * @date 04.01.2005 */ +#include #include #include "pset.h" #include "irgraph.h" #include "irnode.h" #include "irgwalk.h" +#include "irdom.h" -#include "domtree.h" #include "bephiopt.h" #include "bephicongr_t.h" #include "bephicoal_t.h" #include "phistat.h" -#define CUMULATIVE_FILE "~/all.phistat" +#define DEBUG_LVL SET_LEVEL_1 + +#define DO_PHI_STATISTICS +#undef DUMP_IRG_PHI_STAT + +#define DUMP_CUMULATIVE +#define CUMULATIVE_FILE "all.phistat" + +#define ENV_PHI_STAT "PHI_STAT" static firm_dbg_module_t *dbgphi = NULL; @@ -27,42 +36,53 @@ static void phi_node_walker(ir_node *node, void *env) { void be_phi_opt(ir_graph* irg) { - dominfo_t *dominfo; pset *all_phi_nodes, *all_phi_classes; - char buf[1024]; + DBG((dbgphi, 1, "\n\n=======================> IRG: %s\n\n", get_entity_name(get_irg_entity(irg)))); /* get all phi nodes */ - printf("-----------------------> Collecting phi nodes <-----------------------\n"); + DBG((dbgphi, 1, "-----------------------> Collecting phi nodes <-----------------------\n\n")); all_phi_nodes = pset_new_ptr(64); irg_walk_graph(irg, phi_node_walker, NULL, all_phi_nodes); + /* get all phi congruence classes */ - printf("-----------------------> Collecting phi classes <-----------------------\n"); + DBG((dbgphi, 1, "-----------------------> Collecting phi classes <---------------------\n\n")); all_phi_classes = be_phi_congr_classes(all_phi_nodes); + /* do some statistics */ - printf("-----------------------> Collecting phi stats <-----------------------\n"); +#ifdef DO_PHI_STATISTICS + DBG((dbgphi, 1, "-----------------------> Collecting phi stats <-----------------------\n\n")); phi_stat_reset(); phi_stat_collect(irg, all_phi_nodes, all_phi_classes); - snprintf(buf, sizeof(buf), "%s.phistat", get_entity_name(get_irg_entity(irg))); - //phi_stat_dump_pretty(buf); - phi_stat_dump(buf, CUMULATIVE_FILE); +#ifdef DUMP_IRG_PHI_STAT + { + char buf[1024]; + snprintf(buf, sizeof(buf), "%s.phistat", get_entity_name(get_irg_entity(irg))); + //phi_stat_dump(buf); + phi_stat_dump_pretty(buf); + } +#endif +#ifdef DUMP_CUMULATIVE + phi_stat_update(CUMULATIVE_FILE); +#endif + phi_stat_update(getenv(ENV_PHI_STAT)); +#endif + /* try to coalesce the colors of each phi class */ - printf("-----------------------> Building domtree <-----------------------\n"); - dominfo = domtree_create(irg); - printf("-----------------------> Coalescing <-----------------------\n"); - /* be_phi_coalesce_locals(all_phi_classes, dominfo); */ - printf("-----------------------> Destroying domtree <-----------------------\n"); - domtree_free(dominfo); + DBG((dbgphi, 1, "-----------------------> Coalescing <---------------------------------\n\n")); + compute_doms(irg); + be_phi_coalesce(all_phi_classes); + free_dom_and_peace(irg); } void be_phi_opt_init(void) { dbgphi = firm_dbg_register("Phi optimizer"); - firm_dbg_set_mask(dbgphi, 1); + firm_dbg_set_mask(dbgphi, DEBUG_LVL); be_phi_congr_class_init(); be_phi_coal_init();