13 #include "bephicongr_t.h"
14 #include "bephicoal_t.h"
17 #define CUMULATIVE_FILE "~/all.phistat"
19 static void phi_node_walker(ir_node *node, void *env) {
20 if (is_Phi(node) && mode_is_datab(get_irn_mode(node)))
21 pset_insert_ptr((pset *)env, node);
25 void be_phi_opt(ir_graph* irg) {
27 pset *all_phi_nodes, *all_phi_classes;
30 /* get all phi nodes */
31 printf("-----------------------> Collecting phi nodes <-----------------------\n");
32 all_phi_nodes = pset_new_ptr(64);
33 irg_walk_graph(irg, phi_node_walker, NULL, all_phi_nodes);
35 /* get all phi congruence classes */
36 printf("-----------------------> Collecting phi classes <-----------------------\n");
37 all_phi_classes = be_phi_congr_classes(all_phi_nodes);
39 /* do some statistics */
40 printf("-----------------------> Collecting phi stats <-----------------------\n");
42 phi_stat_collect(irg, all_phi_nodes, all_phi_classes);
43 snprintf(buf, sizeof(buf), "%s.phistat", get_entity_name(get_irg_entity(irg)));
44 //phi_stat_dump_pretty(buf);
45 phi_stat_dump(buf, CUMULATIVE_FILE);
47 /* try to coalesce the colors of each phi class */
48 printf("-----------------------> Building domtree <-----------------------\n");
49 dominfo = domtree_create(irg);
50 printf("-----------------------> Coalescing <-----------------------\n");
51 be_phi_coalesce_locals(all_phi_classes, dominfo);
52 printf("-----------------------> Destroying domtree <-----------------------\n");
53 domtree_free(dominfo);
57 void be_phi_opt_init(void) {
58 be_phi_congr_class_init();