remove unnecessary members from be_abi_irg_t structure, cleanup beabi a bit
[libfirm] / ir / be / becopyopt.c
index 08ca33a..868dc92 100644 (file)
@@ -50,7 +50,7 @@
 #include "bearch.h"
 #include "benode.h"
 #include "beutil.h"
-#include "beifg_t.h"
+#include "beifg.h"
 #include "beintlive_t.h"
 #include "becopyopt_t.h"
 #include "becopystat.h"
@@ -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;
@@ -311,7 +314,7 @@ static int ou_max_ind_set_costs(unit_t *ou)
        int i, o, safe_count, safe_costs, unsafe_count, *unsafe_costs;
        bitset_t *curr;
        unsigned  pos;
-       int max, curr_weight, best_weight = 0;
+       int curr_weight, best_weight = 0;
 
        /* assign the nodes into two groups.
         * safe: node has no interference, hence it is in every max stable set.
@@ -363,7 +366,7 @@ static int ou_max_ind_set_costs(unit_t *ou)
                /* Exact Algorithm: Brute force */
                curr = bitset_alloca(unsafe_count);
                bitset_set_all(curr);
-               while ((max = bitset_popcount(curr)) != 0) {
+               while (bitset_popcount(curr) != 0) {
                        /* check if curr is a stable set */
                        for (i=bitset_next_set(curr, 0); i!=-1; i=bitset_next_set(curr, i+1))
                                for (o=bitset_next_set(curr, i+1); o!=-1; o=bitset_next_set(curr, o+1)) /* !!!!! difference to qnode_max_ind_set(): NOT (curr, i) */
@@ -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;
 
@@ -893,7 +902,8 @@ void co_dump_appel_graph(const copy_opt_t *co, FILE *f)
        int      *node_map  = XMALLOCN(int, get_irg_last_idx(co->irg) + 1);
 
        ir_node *irn;
-       void *it, *nit;
+       nodes_iter_t it;
+       neighbours_iter_t nit;
        int n, n_regs;
        unsigned i;
 
@@ -908,11 +918,8 @@ void co_dump_appel_graph(const copy_opt_t *co, FILE *f)
         * the values below n are the pre-colored register nodes
         */
 
-       it  = be_ifg_nodes_iter_alloca(ifg);
-       nit = be_ifg_neighbours_iter_alloca(ifg);
-
        n = n_regs;
-       be_ifg_foreach_node(ifg, it, irn) {
+       be_ifg_foreach_node(ifg, &it, irn) {
                if (arch_irn_is_ignore(irn))
                        continue;
                node_map[get_irn_idx(irn)] = n++;
@@ -920,7 +927,7 @@ void co_dump_appel_graph(const copy_opt_t *co, FILE *f)
 
        fprintf(f, "%d %d\n", n, n_regs);
 
-       be_ifg_foreach_node(ifg, it, irn) {
+       be_ifg_foreach_node(ifg, &it, irn) {
                if (!arch_irn_is_ignore(irn)) {
                        int idx                        = node_map[get_irn_idx(irn)];
                        affinity_node_t           *a   = get_affinity_info(co, irn);
@@ -934,7 +941,7 @@ void co_dump_appel_graph(const copy_opt_t *co, FILE *f)
                                }
                        }
 
-                       be_ifg_foreach_neighbour(ifg, nit, irn, adj) {
+                       be_ifg_foreach_neighbour(ifg, &nit, irn, adj) {
                                if (!arch_irn_is_ignore(adj) &&
                                                !co_dump_appel_disjoint_constraints(co, irn, adj)) {
                                        int adj_idx = node_map[get_irn_idx(adj)];
@@ -1068,7 +1075,7 @@ static void ifg_dump_at_end(FILE *file, void *self)
 
                        if (aidx < nidx) {
                                const char *color = nr == ar ? "blue" : "red";
-                               fprintf(file, "\tn%d -- n%d [weight=0.01 ", aidx, nidx);
+                               fprintf(file, "\tn%u -- n%u [weight=0.01 ", aidx, nidx);
                                if (env->flags & CO_IFG_DUMP_LABELS)
                                        fprintf(file, "label=\"%d\" ", n->costs);
                                if (env->flags & CO_IFG_DUMP_COLORS)
@@ -1123,10 +1130,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] = '_';
@@ -1155,7 +1163,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);
@@ -1223,7 +1231,7 @@ void co_driver(be_chordal_env_t *cenv)
        /* Dump the interference graph in Appel's format. */
        if (dump_flags & DUMP_APPEL) {
                FILE *f = my_open(cenv, "", ".apl");
-               fprintf(f, "# %lld %lld\n", after.costs, after.unsatisfied_edges);
+               fprintf(f, "# %llu %llu\n", after.costs, after.unsatisfied_edges);
                co_dump_appel_graph(co, f);
                fclose(f);
        }