Fixed small copy & paste error in the "foreach" defines and added additional defines...
[libfirm] / ir / be / becopyoptmain.c
1 /**
2  * Author:      Daniel Grund
3  * Date:                11.04.2005
4  * Copyright:   (c) Universitaet Karlsruhe
5  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
6
7  * Main file for the optimization reducing the copies needed for:
8  * - phi coalescing
9  * - register-constrained nodes
10  */
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
14
15 #include "debug.h"
16 #include "becopyopt.h"
17 #include "becopystat.h"
18 #include "becopyoptmain.h"
19
20 #define DO_HEUR
21 #undef DO_ILP
22
23 #define DEBUG_LVL SET_LEVEL_1
24 static firm_dbg_module_t *dbg = NULL;
25
26 void be_copy_opt_init(void) {
27         dbg = firm_dbg_register("ir.be.copyoptmain");
28         firm_dbg_set_mask(dbg, LEVEL_1);
29 }
30
31 void be_copy_opt(be_chordal_env_t *chordal_env) {
32         copy_opt_t *co;
33         int lb, copies;
34
35         co = new_copy_opt(chordal_env);
36         DBG((dbg, LEVEL_1, "===>  %s  <===\n", co->name));
37         co_check_allocation(co);
38
39 #ifdef DO_STAT
40         copies = co_get_copy_count(co);
41         curr_vals[I_COPIES_INIT] += copies;
42         DBG((dbg, LEVEL_1, "Init copies: %3d\n", copies));
43 #endif
44
45 #ifdef DO_HEUR
46         co_heur_opt(co);
47         co_check_allocation(co);
48 #ifdef DO_STAT
49         copies = co_get_copy_count(co);
50         curr_vals[I_COPIES_HEUR] += copies;
51         DBG((dbg, LEVEL_1, "Heur copies: %3d\n", copies));
52 #endif
53 #endif
54
55 #ifdef DO_ILP
56         lb = co_get_lower_bound(co);
57         copies = co_get_copy_count(co);
58         assert(copies>=lb && "At least one computation of these two is boooogy");
59
60         if (copies > lb) {
61                 co_ilp_opt(co);
62                 co_check_allocation(co);
63         }
64
65 #ifdef DO_STAT
66         copies = co_get_copy_count(co);
67         curr_vals[I_COPIES_OPT] += copies;
68         DBG((dbg, LEVEL_1, "Opt  copies: %3d\n", copies));
69         assert(copies>=lb && "At least one computation of these two is boooogy");
70 #endif
71 #endif
72
73         free_copy_opt(co);
74 }