15 #include "bephicongr_t.h"
16 #include "bephicoal_t.h"
19 #define CUMULATIVE_FILE "~/all.phistat"
21 static firm_dbg_module_t *dbgphi = NULL;
23 static void phi_node_walker(ir_node *node, void *env) {
24 if (is_Phi(node) && mode_is_datab(get_irn_mode(node)))
25 pset_insert_ptr((pset *)env, node);
29 void be_phi_opt(ir_graph* irg) {
31 pset *all_phi_nodes, *all_phi_classes;
36 /* get all phi nodes */
37 printf("-----------------------> Collecting phi nodes <-----------------------\n");
38 all_phi_nodes = pset_new_ptr(64);
39 irg_walk_graph(irg, phi_node_walker, NULL, all_phi_nodes);
41 /* get all phi congruence classes */
42 printf("-----------------------> Collecting phi classes <-----------------------\n");
43 all_phi_classes = be_phi_congr_classes(all_phi_nodes);
45 /* do some statistics */
46 printf("-----------------------> Collecting phi stats <-----------------------\n");
48 phi_stat_collect(irg, all_phi_nodes, all_phi_classes);
49 snprintf(buf, sizeof(buf), "%s.phistat", get_entity_name(get_irg_entity(irg)));
50 //phi_stat_dump_pretty(buf);
51 phi_stat_dump(buf, CUMULATIVE_FILE);
53 /* try to coalesce the colors of each phi class */
54 printf("-----------------------> Building domtree <-----------------------\n");
55 dominfo = domtree_create(irg);
56 printf("-----------------------> Coalescing <-----------------------\n");
57 be_phi_coalesce_locals(all_phi_classes, dominfo);
58 printf("-----------------------> Destroying domtree <-----------------------\n");
59 domtree_free(dominfo);
63 void be_phi_opt_init(void) {
64 dbgphi = firm_dbg_register("Phi optimizer");
65 firm_dbg_set_mask(dbgphi, 1);
67 be_phi_congr_class_init();