refactor mode_b lowerer to have a create_set callback
[libfirm] / ir / be / becopyopt.c
index 57cd046..cde32cd 100644 (file)
@@ -171,8 +171,10 @@ static int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, const
 {
        if (env->ifg)
                return be_ifg_connected(env->ifg, a, b);
-       else
-               return be_values_interfere(env->birg->lv, a, b);
+       else {
+               be_lv_t *lv = be_get_irg_liveness(env->irg);
+               return be_values_interfere(lv, a, b);
+       }
 }
 
 
@@ -272,8 +274,9 @@ int co_get_costs_exec_freq(const copy_opt_t *co, ir_node *root, ir_node* arg, in
        int res;
        ir_node *root_bl = get_nodes_block(root);
        ir_node *copy_bl = is_Phi(root) ? get_Block_cfgpred_block(root_bl, pos) : root_bl;
+       ir_exec_freq *exec_freq = be_get_irg_exec_freq(co->cenv->irg);
        (void) arg;
-       res = get_block_execfreq_ulong(co->cenv->birg->exec_freq, copy_bl);
+       res = get_block_execfreq_ulong(exec_freq, copy_bl);
 
        /* don't allow values smaller than one. */
        return res < 1 ? 1 : res;
@@ -391,10 +394,13 @@ static int ou_max_ind_set_costs(unit_t *ou)
 
 static void co_collect_units(ir_node *irn, void *env)
 {
-       const arch_register_req_t *req = arch_get_register_req_out(irn);
+       const arch_register_req_t *req;
        copy_opt_t                *co  = env;
        unit_t *unit;
 
+       if (get_irn_mode(irn) == mode_T)
+               return;
+       req = arch_get_register_req_out(irn);
        if (req->cls != co->cls)
                return;
        if (!co_is_optimizable_root(irn))
@@ -796,11 +802,14 @@ static inline void add_edges(copy_opt_t *co, ir_node *n1, ir_node *n2, int costs
 
 static void build_graph_walker(ir_node *irn, void *env)
 {
-       const arch_register_req_t *req = arch_get_register_req_out(irn);
+       const arch_register_req_t *req;
        copy_opt_t                *co  = env;
        int pos, max;
        const arch_register_t *reg;
 
+       if (get_irn_mode(irn) == mode_T)
+               return;
+       req = arch_get_register_req_out(irn);
        if (req->cls != co->cls || arch_irn_is_ignore(irn))
                return;
 
@@ -849,8 +858,6 @@ void co_free_graph_structure(copy_opt_t *co)
        co->nodes = NULL;
 }
 
-/* co_solve_ilp1() co_solve_ilp2() are implemented in becopyilpX.c */
-
 int co_gs_is_optimizable(copy_opt_t *co, ir_node *irn)
 {
        affinity_node_t new_node, *n;
@@ -1006,7 +1013,7 @@ static const char *get_dot_color_name(size_t col)
        return col < sizeof(names)/sizeof(names[0]) ? names[col] : "white";
 }
 
-typedef struct _co_ifg_dump_t {
+typedef struct co_ifg_dump_t {
        const copy_opt_t *co;
        unsigned flags;
 } co_ifg_dump_t;
@@ -1121,10 +1128,11 @@ static FILE *my_open(const be_chordal_env_t *env, const char *prefix, const char
        char buf[1024];
        size_t i, n;
        char *tu_name;
+       const char *cup_name = be_get_irg_main_env(env->irg)->cup_name;
 
-       n = strlen(env->birg->main_env->cup_name);
+       n = strlen(cup_name);
        tu_name = XMALLOCN(char, n + 1);
-       strcpy(tu_name, env->birg->main_env->cup_name);
+       strcpy(tu_name, cup_name);
        for (i = 0; i < n; ++i)
                if (tu_name[i] == '.')
                        tu_name[i] = '_';
@@ -1153,7 +1161,7 @@ void co_driver(be_chordal_env_t *cenv)
        if (selected_copyopt->copyopt == void_algo)
                return;
 
-       be_liveness_assure_chk(be_get_birg_liveness(cenv->birg));
+       be_liveness_assure_chk(be_get_irg_liveness(cenv->irg));
 
        co = new_copy_opt(cenv, cost_func);
        co_build_ou_structure(co);