localopt stuff for const-code irg
[libfirm] / ir / be / bechordal.c
index 1dcc8db..ba9df02 100644 (file)
@@ -32,7 +32,6 @@
 #include "list.h"
 #include "bitset.h"
 #include "raw_bitset.h"
-#include "iterator.h"
 #include "bipartite.h"
 #include "hungarian.h"
 
@@ -176,8 +175,6 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env,
        int *assignment;
        pmap *partners;
        int i, n_alloc;
-       size_t col;
-       const ir_edge_t *edge;
        ir_node *perm = NULL;
        //int match_res, cost;
        be_chordal_env_t *env  = alloc_env->chordal_env;
@@ -196,7 +193,7 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env,
         * Perms inserted before the constraint handling phase are considered to be
         * correctly precolored. These Perms arise during the ABI handling phase.
         */
-       if (!insn->has_constraints)
+       if (!insn->has_constraints || is_Phi(irn))
                goto end;
 
        n_regs      = env->cls->n_regs;
@@ -332,7 +329,7 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env,
                        DBG((dbg, LEVEL_2, "\tsetting %+F to register %s\n", irn, reg->name));
                }
 
-               irn = (ir_node*)pmap_get(partners, alloc_nodes[i]);
+               irn = pmap_get(ir_node, partners, alloc_nodes[i]);
                if (irn != NULL) {
                        arch_set_irn_register(irn, reg);
                        (void) pset_hinsert_ptr(alloc_env->pre_colored, irn);
@@ -361,7 +358,7 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env,
                        DBG((dbg, LEVEL_2, "\tchecking reg of %+F: %s\n", proj, reg ? reg->name : "<none>"));
 
                        if (reg == NULL) {
-                               col = get_next_free_reg(alloc_env, bs);
+                               size_t const col = get_next_free_reg(alloc_env, bs);
                                reg = arch_register_for_index(env->cls, col);
                                bitset_set(bs, reg->index);
                                arch_set_irn_register(proj, reg);
@@ -380,69 +377,6 @@ end:
        return res;
 }
 
-static unsigned check_alignment_constraints(ir_node *node)
-{
-       const arch_register_req_t *req = arch_get_irn_register_req(node);
-       return /* req->type == arch_register_req_type_aligned
-               || */ req->width > 1;
-}
-
-
-static ir_node *handle_split(be_chordal_alloc_env_t *alloc_env,
-                             ir_node *irn)
-{
-       ir_node *perm = NULL;
-       be_chordal_env_t *env  = alloc_env->chordal_env;
-       void *base             = obstack_base(env->obst);
-       be_insn_t *insn        = chordal_scan_insn(env, irn);
-       ir_node *res           = insn->next_insn;
-
-       /*
-        * Perms are inserted later before constrained instruction.
-     * So, this function does not split here.
-        */
-       if (!insn->has_constraints) {
-               ir_node *value;
-               unsigned has_alignment_constraints = 0;
-               const arch_register_class_t *cls = env->cls;
-
-               be_foreach_definition (irn, cls, value,
-                                                          has_alignment_constraints
-                                                          |= check_alignment_constraints(value);
-                       );
-
-               if (has_alignment_constraints) {
-                       /*
-                        * Make the Perm, recompute liveness and re-scan the insn since the
-                        * in operands are now the Projs of the Perm.
-                        */
-                       perm = insert_Perm_after(env->irg, env->cls, sched_prev(insn->irn));
-                       if(perm != NULL) {
-                               DBG((dbg, LEVEL_2, "\tsplit before %+F with node %+F\n", irn, perm));
-                       }
-               }
-       }
-
-       obstack_free(env->obst, base);
-       return res;
-}
-
-/**
- * Add split points before operations that have pairing constraints.
- * handle_split() inserts Perm nodes which perm
- * over all values live at the constrained node right in front
- * of the constrained node.
- */
-static void split(ir_node *bl, void *data)
-{
-       be_chordal_alloc_env_t *env    = (be_chordal_alloc_env_t*)data;
-       ir_node                *irn;
-
-       for (irn = sched_first(bl); !sched_is_end(irn);) {
-               irn = handle_split(env, irn);
-       }
-}
-
 /**
  * Handle constraint nodes in each basic block.
  * handle_constraints() inserts Perm nodes which perm
@@ -470,10 +404,6 @@ static void assign(ir_node *block, void *env_ptr)
        struct list_head *head      = get_block_border_head(env, block);
        be_lv_t *lv                 = be_get_irg_liveness(env->irg);
 
-       const ir_node *irn;
-       border_t *b;
-       int idx;
-
        bitset_clear_all(colors);
        bitset_clear_all(live);
        bitset_clear_all(in_colors);
@@ -490,8 +420,7 @@ static void assign(ir_node *block, void *env_ptr)
         * Since their colors have already been assigned (The dominators were
         * allocated before), we have to mark their colors as used also.
         */
-       be_lv_foreach(lv, block, be_lv_state_in, idx) {
-               irn = be_lv_get_irn(lv, block, idx);
+       be_lv_foreach(lv, block, be_lv_state_in, irn) {
                if (has_reg_class(env, irn)) {
                        const arch_register_t *reg = arch_get_irn_register(irn);
                        int col;
@@ -581,9 +510,6 @@ void be_ra_chordal_color(be_chordal_env_t *chordal_env)
 
        be_timer_push(T_SPLIT);
 
-       /* Add split points before operations that have pairing constraints */
-       dom_tree_walk_irg(irg, split, NULL, &env);
-
        if (chordal_env->opts->dump_flags & BE_CH_DUMP_SPLIT) {
                snprintf(buf, sizeof(buf), "%s-split", chordal_env->cls->name);
                dump_ir_graph(chordal_env->irg, buf);