typo fixed
[libfirm] / ir / be / becopyopt.c
index e256cac..667bf90 100644 (file)
@@ -10,6 +10,9 @@
 #ifdef HAVE_ALLOCA_H
 #include <alloca.h>
 #endif
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 
 #include "irprog.h"
 
@@ -103,7 +106,7 @@ conflict_found:
 static void co_append_unit(copy_opt_t *co, ir_node *root) {
        int i, arity;
        unit_t *unit;
-       DBG((dbg, LEVEL_1, "\t  Root: %n\n", root));
+       DBG((dbg, LEVEL_1, "\t  Root: %n %N\n", root, root));
        /* check if we encountered this root earlier */
        if (pset_find_ptr(co->roots, root))
                return;
@@ -128,8 +131,8 @@ static void co_append_unit(copy_opt_t *co, ir_node *root) {
                        assert(is_curr_reg_class(arg) && "Argument not in same register class.");
                        if (arg != root) {
                                if (!nodes_interfere(co->chordal_env, root, arg)) {
-                                       DBG((dbg, LEVEL_1, "\t  Member: %n\n", arg));
-                                       if (is_optimizable(arg))
+                                       DBG((dbg, LEVEL_1, "\t   Member: %n %N\n", arg, arg));
+                                       if (is_optimizable(co->chordal_env->arch_env, arg))
                                                co_append_unit(co, arg);
                                        unit->nodes[unit->node_count++] = arg;
                                } else
@@ -137,7 +140,7 @@ static void co_append_unit(copy_opt_t *co, ir_node *root) {
                        }
                }
                unit->nodes = xrealloc(unit->nodes, unit->node_count * sizeof(*unit->nodes));
-       } else if (is_Copy(root)) {
+       } else if (is_Copy(co->chordal_env->arch_env, root)) {
                assert(!nodes_interfere(co->chordal_env, root, get_Copy_src(root)));
                unit->nodes[unit->node_count++] = get_Copy_src(root);
                unit->nodes = xrealloc(unit->nodes, 2 * sizeof(*unit->nodes));
@@ -155,7 +158,7 @@ static void co_collect_in_block(ir_node *block, void *env) {
        border_t *curr;
 
        list_for_each_entry_reverse(border_t, curr, head, list)
-               if (curr->is_def && curr->is_real && is_optimizable(curr->irn))
+               if (curr->is_def && curr->is_real && is_optimizable(co->chordal_env->arch_env, curr->irn))
                        co_append_unit(co, curr->irn);
 }
 
@@ -182,9 +185,11 @@ copy_opt_t *new_copy_opt(be_chordal_env_t *chordal_env) {
        s3 = chordal_env->cls->name;
        len = strlen(s1) + strlen(s2) + strlen(s3) + 5;
        co->name = xmalloc(len);
-       if (!strcmp(co->name, DEBUG_IRG))
-               firm_dbg_set_mask(dbg, -1);
        snprintf(co->name, len, "%s__%s__%s", s1, s2, s3);
+       if (!strcmp(co->name, DEBUG_IRG))
+               firm_dbg_set_mask(dbg, DEBUG_LVL_CO);
+       else
+               firm_dbg_set_mask(dbg, DEBUG_LVL);
 
        INIT_LIST_HEAD(&co->units);
        co_collect_units(co);
@@ -204,7 +209,7 @@ int is_optimizable_arg(const copy_opt_t *co, ir_node *irn) {
        int i, max;
        for(i=0, max=get_irn_n_outs(irn); i<max; ++i) {
                ir_node *n = get_irn_out(irn, i);
-               if ((is_Phi(n) || is_Perm(n)) && (irn == n || !nodes_interfere(co->chordal_env, irn, n)))
+               if ((is_Phi(n) || is_Perm(co->chordal_env->arch_env, n)) && (irn == n || !nodes_interfere(co->chordal_env, irn, n)))
                        return 1;
        }
        return 0;
@@ -216,9 +221,12 @@ int co_get_copy_count(const copy_opt_t *co) {
        list_for_each_entry(unit_t, curr, &co->units, units) {
                int root_col = get_irn_col(co, curr->nodes[0]);
                res += curr->interf;
+               DBG((dbg, LEVEL_1, "%n %N has %d intf\n", curr->nodes[0], curr->nodes[0], curr->interf));
                for (i=1; i<curr->node_count; ++i)
-                       if (root_col != get_irn_col(co, curr->nodes[i]))
+                       if (root_col != get_irn_col(co, curr->nodes[i])) {
+                               DBG((dbg, LEVEL_1, "  %n %N\n", curr->nodes[i], curr->nodes[i]));
                                res++;
+                       }
        }
        return res;
 }