Uncommented missing function
[libfirm] / ir / be / bephiopt.c
1 /**
2  * @author Daniel Grund
3  * @date 04.01.2005
4  */
5
6 #include <stdio.h>
7
8 #include "pset.h"
9 #include "irgraph.h"
10 #include "irnode.h"
11 #include "irgwalk.h"
12
13 #include "domtree.h"
14 #include "bephiopt.h"
15 #include "bephicongr_t.h"
16 #include "bephicoal_t.h"
17 #include "phistat.h"
18
19 #define CUMULATIVE_FILE "~/all.phistat"
20
21 static firm_dbg_module_t *dbgphi = NULL;
22
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);
26 }
27
28
29 void be_phi_opt(ir_graph* irg) {
30         dominfo_t *dominfo;
31         pset *all_phi_nodes, *all_phi_classes;
32         char buf[1024];
33
34
35
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);
40
41         /* get all phi congruence classes */
42         printf("-----------------------> Collecting phi classes <-----------------------\n");
43         all_phi_classes = be_phi_congr_classes(all_phi_nodes);
44
45         /* do some statistics */
46         printf("-----------------------> Collecting phi stats <-----------------------\n");
47         phi_stat_reset();
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);
52
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);
60 }
61
62
63 void be_phi_opt_init(void) {
64         dbgphi = firm_dbg_register("Phi optimizer");
65         firm_dbg_set_mask(dbgphi, 1);
66
67         be_phi_congr_class_init();
68         be_phi_coal_init();
69 }