change pn_XXX_max enum to really be the maximum pn and not maximum+1, add n_XXX_max...
[libfirm] / ir / be / bespillutil.c
index ea4d2f0..7c04690 100644 (file)
@@ -106,12 +106,10 @@ struct spill_env_t {
        ir_nodeset_t      mem_phis;       /**< set of all spilled phis. */
        ir_exec_freq     *exec_freq;
 
-#ifdef FIRM_STATISTICS
        unsigned          spill_count;
        unsigned          reload_count;
        unsigned          remat_count;
        unsigned          spilled_phi_count;
-#endif
 };
 
 /**
@@ -162,12 +160,10 @@ spill_env_t *be_new_spill_env(ir_graph *irg)
        env->exec_freq      = be_get_irg_exec_freq(irg);
        obstack_init(&env->obst);
 
-#ifdef FIRM_STATISTICS
        env->spill_count       = 0;
        env->reload_count      = 0;
        env->remat_count       = 0;
        env->spilled_phi_count = 0;
-#endif
 
        return env;
 }
@@ -255,14 +251,6 @@ void be_add_reload2(spill_env_t *env, ir_node *to_spill, ir_node *before,
 
        assert(!is_Proj(before) && !be_is_Keep(before));
 
-       /* adjust before point to not be in the epilog */
-       while (true) {
-               ir_node *before_prev = sched_prev(before);
-               if (! (arch_irn_get_flags(before_prev) & arch_irn_flags_epilog))
-                       break;
-               before = sched_prev(before);
-       }
-
        /* put reload into list */
        rel                   = OALLOC(&env->obst, reloader_t);
        rel->next             = info->reloaders;
@@ -311,8 +299,7 @@ static ir_node *determine_spill_point(ir_node *node)
        node = skip_Proj(node);
        while (true) {
                ir_node *next = sched_next(node);
-               if (!is_Phi(next) && !be_is_Keep(next) && !be_is_CopyKeep(next)
-                               && !(arch_irn_get_flags(next) & arch_irn_flags_prolog))
+               if (!is_Phi(next) && !be_is_Keep(next) && !be_is_CopyKeep(next))
                        break;
                node = next;
        }
@@ -420,7 +407,7 @@ static void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
        if (!sched_is_scheduled(insn)) {
                /* override spillinfos or create a new one */
                ir_graph *irg = get_irn_irg(to_spill);
-               spillinfo->spills->spill = new_r_NoMem(irg);
+               spillinfo->spills->spill = get_irg_no_mem(irg);
                DB((dbg, LEVEL_1, "don't spill %+F use NoMem\n", to_spill));
                return;
        }
@@ -436,9 +423,7 @@ static void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
                spill->spill = be_spill(block, to_spill);
                sched_add_after(skip_Proj(after), spill->spill);
                DB((dbg, LEVEL_1, "\t%+F after %+F\n", spill->spill, after));
-#ifdef FIRM_STATISTICS
                env->spill_count++;
-#endif
        }
        DBG((dbg, LEVEL_1, "\n"));
 }
@@ -486,9 +471,7 @@ static void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
        sched_add_after(block, spill->spill);
 
        spillinfo->spills = spill;
-#ifdef FIRM_STATISTICS
        env->spilled_phi_count++;
-#endif
 
        for (i = 0; i < arity; ++i) {
                ir_node      *arg      = get_irn_n(phi, i);
@@ -656,10 +639,8 @@ static ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader)
                        ins[i] = arg;
                } else {
                        ins[i] = do_remat(env, arg, reloader);
-#ifdef FIRM_STATISTICS
                        /* don't count the recursive call as remat */
                        env->remat_count--;
-#endif
                }
        }
 
@@ -676,9 +657,7 @@ static ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader)
                /* insert in schedule */
                sched_reset(res);
                sched_add_before(reloader, res);
-#ifdef FIRM_STATISTICS
                env->remat_count++;
-#endif
        }
 
        return res;
@@ -772,7 +751,7 @@ static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo)
                spill_t *spill = OALLOC(&env->obst, spill_t);
                spill->after = NULL;
                spill->next  = NULL;
-               spill->spill = new_r_NoMem(irg);
+               spill->spill = get_irg_no_mem(irg);
 
                spillinfo->spills      = spill;
                spillinfo->spill_costs = 0;
@@ -968,9 +947,7 @@ void be_insert_spills_reloads(spill_env_t *env)
                                assert(si->spills != NULL);
                                copy = be_reload(si->reload_cls, rld->reloader, mode,
                                                 si->spills->spill);
-#ifdef FIRM_STATISTICS
                                env->reload_count++;
-#endif
                        }
 
                        DBG((dbg, LEVEL_1, " %+F of %+F before %+F\n",
@@ -1043,7 +1020,7 @@ void be_insert_spills_reloads(spill_env_t *env)
        be_timer_pop(T_RA_SPILL_APPLY);
 }
 
-BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spill);
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spill)
 void be_init_spill(void)
 {
        FIRM_DBG_REGISTER(dbg, "firm.be.spill");