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