Moved to new lpp library
[libfirm] / ir / be / becopyoptmain.c
index bea9ec3..a648064 100644 (file)
@@ -1,67 +1,71 @@
 /**
+ * Author:      Daniel Grund
+ * Date:               11.04.2005
+ * Copyright:   (c) Universitaet Karlsruhe
+ * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+
  * Main file for the optimization reducing the copies needed for:
  * - phi coalescing
  * - register-constrained nodes
- *
- * @author Daniel Grund
- * @date 11.04.2005
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
+#include "debug.h"
 #include "becopyopt.h"
 #include "becopystat.h"
 #include "becopyoptmain.h"
 
 #define DO_HEUR
-#define DO_ILP
+#undef DO_ILP
 
 #define DEBUG_LVL SET_LEVEL_1
 static firm_dbg_module_t *dbg = NULL;
 
 void be_copy_opt_init(void) {
-       dbg = firm_dbg_register("ir.be.copyopt");
-       firm_dbg_set_mask(dbg, DEBUG_LVL);
+       dbg = firm_dbg_register("ir.be.copyoptmain");
+       firm_dbg_set_mask(dbg, LEVEL_1);
 }
 
-void be_copy_opt(ir_graph* irg, const arch_isa_if_t *isa, const arch_register_class_t *cls) {
+void be_copy_opt(be_chordal_env_t *chordal_env) {
        copy_opt_t *co;
-       int lb, copies;
+       int lb, copy_costs;
 
-       DBG((dbg, LEVEL_1, "\nIRG: %s\n\n", get_entity_name(get_irg_entity(irg))));
-       co = new_copy_opt(irg, isa, cls);
-       co_check_allocation(co);
+       co = new_copy_opt(chordal_env, get_costs_loop_depth);
+       DBG((dbg, LEVEL_1, "===>  %s  <===\n", co->name));
 
 #ifdef DO_STAT
-       copies = co_get_copy_count(co);
-       curr_vals[I_COPIES_INIT] += copies;
-       DBG((dbg, 1, "Init copies: %3d\n", copies));
+       copy_costs = co_get_copy_costs(co);
+       curr_vals[I_COPIES_INIT] += copy_costs;
+       DBG((dbg, LEVEL_1, "Init costs: %3d\n", copy_costs));
 #endif
 
 #ifdef DO_HEUR
        co_heur_opt(co);
-       co_check_allocation(co);
+       be_ra_chordal_check(chordal_env);
 #ifdef DO_STAT
-       copies = co_get_copy_count(co);
-       curr_vals[I_COPIES_HEUR] += copies;
-       DBG((dbg, 1, "Heur copies: %3d\n", copies));
+       copy_costs = co_get_copy_costs(co);
+       curr_vals[I_COPIES_HEUR] += copy_costs;
+       DBG((dbg, LEVEL_1, "Heur costs: %3d\n", copy_costs));
 #endif
 #endif
 
 #ifdef DO_ILP
        lb = co_get_lower_bound(co);
-       copies = co_get_copy_count(co);
-//TODO remove checks and enable lb
-       assert(copies>=lb && "At least one computation of these two is boooogy");
-//     if (copies > lb) {
+       copy_costs = co_get_copy_costs(co);
+       assert(copy_costs>=lb && "At least one computation of these two is boooogy");
+
+       if (copy_costs > lb) {
                co_ilp_opt(co);
-               co_check_allocation(co);
-//     }
-       copies = co_get_copy_count(co);
-       assert(copies>=lb && "At least one computation of these two is boooogy");
+               be_ra_chordal_check(chordal_env);
+       }
 
 #ifdef DO_STAT
-       copies = co_get_copy_count(co);
-       curr_vals[I_COPIES_HEUR] += copies;
-       DBG((dbg, 1, "Opt  copies: %3d\n", copies));
+       copy_costs = co_get_copy_costs(co);
+       curr_vals[I_COPIES_OPT] += copy_costs;
+       DBG((dbg, LEVEL_1, "Opt  costs: %3d\n", copy_costs));
+       assert(copy_costs>=lb && "At least one computation of these two is boooogy");
 #endif
 #endif