Remove the attribute const arch_env_t *arch_env from struct ia32_code_gen_t. We...
[libfirm] / ir / be / bespill.c
index a2d5954..c6b13d2 100644 (file)
@@ -24,9 +24,7 @@
  * @date               29.09.2005
  * @version     $Id$
  */
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include <stdlib.h>
 #include <stdbool.h>
@@ -55,7 +53,6 @@
 #include "belive_t.h"
 #include "benode_t.h"
 #include "bechordal_t.h"
-#include "bejavacoal.h"
 #include "bespilloptions.h"
 #include "bestatevent.h"
 #include "bessaconstr.h"
@@ -155,7 +152,7 @@ spill_env_t *be_new_spill_env(be_irg_t *birg)
 {
        const arch_env_t *arch_env = birg->main_env->arch_env;
 
-       spill_env_t *env        = xmalloc(sizeof(env[0]));
+       spill_env_t *env = XMALLOC(spill_env_t);
        env->spills                     = new_set(cmp_spillinfo, 1024);
        env->irg            = be_get_birg_irg(birg);
        env->birg           = birg;
@@ -200,7 +197,7 @@ void be_add_spill(spill_env_t *env, ir_node *to_spill, ir_node *after)
        spill_t      *s;
        spill_t      *last;
 
-       assert(! arch_irn_is(env->arch_env, to_spill, dont_spill));
+       assert(!arch_irn_is(to_spill, dont_spill));
        DB((dbg, LEVEL_1, "Add spill of %+F after %+F\n", to_spill, after));
 
        /* Just for safety make sure that we do not insert the spill in front of a phi */
@@ -266,7 +263,7 @@ void be_add_reload2(spill_env_t *env, ir_node *to_spill, ir_node *before,
        spill_info_t *info;
        reloader_t *rel;
 
-       assert(! arch_irn_is(env->arch_env, to_spill, dont_spill));
+       assert(!arch_irn_is(to_spill, dont_spill));
 
        info = get_spillinfo(env, to_spill);
 
@@ -447,7 +444,7 @@ static void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
 
                after = skip_keeps_phis(after);
 
-               spill->spill   = be_spill(env->arch_env, block, to_spill);
+               spill->spill = be_spill(block, to_spill);
                sched_add_after(after, spill->spill);
                DB((dbg, LEVEL_1, "\t%+F after %+F\n", spill->spill, after));
 #ifdef FIRM_STATISTICS
@@ -573,7 +570,7 @@ static int is_value_available(spill_env_t *env, const ir_node *arg,
        /*
         * Ignore registers are always available
         */
-       if(arch_irn_is(env->arch_env, arg, ignore)) {
+       if (arch_irn_is(arg, ignore)) {
                return 1;
        }
 
@@ -605,13 +602,11 @@ static int is_value_available(spill_env_t *env, const ir_node *arg,
 /**
  * Checks whether the node can principally be rematerialized
  */
-static int is_remat_node(spill_env_t *env, const ir_node *node)
+static int is_remat_node(const ir_node *node)
 {
-       const arch_env_t *arch_env = env->arch_env;
-
        assert(!be_is_Spill(node));
 
-       if(arch_irn_is(arch_env, node, rematerializable))
+       if (arch_irn_is(node, rematerializable))
                return 1;
 
        return 0;
@@ -634,18 +629,18 @@ static int check_remat_conditions_costs(spill_env_t *env,
        int argremats;
        int costs = 0;
 
-       if(!is_remat_node(env, spilled))
+       if (!is_remat_node(spilled))
                return REMAT_COST_INFINITE;
 
        if(be_is_Reload(spilled)) {
                costs += 2;
        } else {
-               costs += arch_get_op_estimated_cost(env->arch_env, spilled);
+               costs += arch_get_op_estimated_cost(spilled);
        }
        if(parentcosts + costs >= env->reload_cost + env->spill_cost) {
                return REMAT_COST_INFINITE;
        }
-       if(arch_irn_is(env->arch_env, spilled, modify_flags)) {
+       if (arch_irn_is(spilled, modify_flags)) {
                return REMAT_COST_INFINITE;
        }
 
@@ -804,7 +799,7 @@ static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo)
        if(spillinfo->spill_costs >= 0)
                return;
 
-       assert(! arch_irn_is(env->arch_env, to_spill, dont_spill));
+       assert(!arch_irn_is(to_spill, dont_spill));
        assert(!be_is_Reload(to_spill));
 
        /* some backends have virtual noreg/unknown nodes that are not scheduled
@@ -909,7 +904,6 @@ void make_spill_locations_dominate_irn(spill_env_t *env, ir_node *irn)
 
 void be_insert_spills_reloads(spill_env_t *env)
 {
-       const arch_env_t      *arch_env  = env->arch_env;
        const ir_exec_freq    *exec_freq = env->exec_freq;
        spill_info_t          *si;
        ir_nodeset_iterator_t  iter;
@@ -1012,7 +1006,7 @@ void be_insert_spills_reloads(spill_env_t *env)
                                /* create a reload, use the first spill for now SSA
                                 * reconstruction for memory comes below */
                                assert(si->spills != NULL);
-                               copy = be_reload(arch_env, si->reload_cls, rld->reloader, mode,
+                               copy = be_reload(si->reload_cls, rld->reloader, mode,
                                                 si->spills->spill);
 #ifdef FIRM_STATISTICS
                                env->reload_count++;