fehler109
[libfirm] / ir / be / bespill.c
index 2d370a5..9f88ad5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
 #include "benode_t.h"
 #include "bechordal_t.h"
 #include "bejavacoal.h"
-#include "benodesets.h"
 #include "bespilloptions.h"
 #include "bestatevent.h"
 #include "bessaconstr.h"
 #include "beirg_t.h"
 #include "beintlive_t.h"
 #include "bemodule.h"
+#include "be_t.h"
 
 DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
 
@@ -136,7 +136,7 @@ static int cmp_spillinfo(const void *x, const void *y, size_t size)
 static spill_info_t *get_spillinfo(const spill_env_t *env, ir_node *value)
 {
        spill_info_t info, *res;
-       int hash = nodeset_hash(value);
+       int hash = hash_irn(value);
 
        info.to_spill = value;
        res = set_find(env->spills, &info, sizeof(info), hash);
@@ -202,6 +202,7 @@ void be_add_spill(spill_env_t *env, ir_node *to_spill, ir_node *before)
        spill_t      *s;
        spill_t      *last;
 
+       assert(! arch_irn_is(env->arch_env, to_spill, dont_spill));
        DB((dbg, LEVEL_1, "Add spill of %+F before %+F\n", to_spill, before));
 
        /* spills that are dominated by others are not needed */
@@ -265,6 +266,8 @@ 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));
+
        info = get_spillinfo(env, to_spill);
 
        if (is_Phi(to_spill)) {
@@ -737,6 +740,19 @@ double be_get_spill_costs(spill_env_t *env, ir_node *to_spill, ir_node *before)
        return env->spill_cost * freq;
 }
 
+unsigned be_get_reload_costs_no_weight(spill_env_t *env, const ir_node *to_spill,
+                                       const ir_node *before)
+{
+       if(be_do_remats) {
+               /* is the node rematerializable? */
+               unsigned costs = check_remat_conditions_costs(env, to_spill, before, 0);
+               if(costs < (unsigned) env->reload_cost)
+                       return costs;
+       }
+
+       return env->reload_cost;
+}
+
 double be_get_reload_costs(spill_env_t *env, ir_node *to_spill, ir_node *before)
 {
        ir_node      *block = get_nodes_block(before);
@@ -871,6 +887,8 @@ void be_insert_spills_reloads(spill_env_t *env)
        ir_nodeset_iterator_t  iter;
        ir_node               *node;
 
+       BE_TIMER_PUSH(t_ra_spill_apply);
+
        env->new_nodes_idx = get_irg_last_idx(irg);
 
        /* create all phi-ms first, this is needed so, that phis, hanging on
@@ -1041,6 +1059,8 @@ void be_insert_spills_reloads(spill_env_t *env)
        be_liveness_invalidate(env->birg->lv);
 
        be_remove_dead_nodes_from_schedule(env->birg);
+
+       BE_TIMER_POP(t_ra_spill_apply);
 }
 
 void be_init_spill(void)