Fix fehler171
[libfirm] / ir / be / bespillbelady.c
index 4e4000d..dc0f872 100644 (file)
 #include "irnodeset.h"
 
 #include "beutil.h"
-#include "bearch_t.h"
+#include "bearch.h"
 #include "beuses.h"
-#include "besched_t.h"
+#include "besched.h"
 #include "beirgmod.h"
 #include "belive_t.h"
-#include "benode_t.h"
+#include "benode.h"
 #include "bechordal_t.h"
-#include "bespilloptions.h"
-#include "beloopana.h"
-#include "beirg_t.h"
 #include "bespill.h"
+#include "beloopana.h"
+#include "beirg.h"
+#include "bespillutil.h"
 #include "bemodule.h"
 
 #define DBG_SPILL     1
@@ -96,9 +96,9 @@ static unsigned                     instr_nr; /**< current instruction number
 static spill_env_t                 *senv;   /**< see bespill.h */
 static ir_node                    **blocklist;
 
-static bool                         move_spills      = true;
-static bool                         respectloopdepth = true;
-static bool                         improve_known_preds = true;
+static int                          move_spills      = true;
+static int                          respectloopdepth = true;
+static int                          improve_known_preds = true;
 /* factor to weight the different costs of reloading/rematerializing a node
    (see bespill.h be_get_reload_costs_no_weight) */
 static int                          remat_bonus      = 10;
@@ -132,12 +132,7 @@ void workset_print(const workset_t *w)
  */
 static workset_t *new_workset(void)
 {
-       workset_t *res;
-       size_t     size = sizeof(*res) + n_regs * sizeof(res->vals[0]);
-
-       res  = obstack_alloc(&obst, size);
-       memset(res, 0, size);
-       return res;
+       return OALLOCFZ(&obst, workset_t, vals, n_regs);
 }
 
 /**
@@ -145,10 +140,8 @@ static workset_t *new_workset(void)
  */
 static workset_t *workset_clone(workset_t *workset)
 {
-       workset_t *res;
-       size_t size = sizeof(*res) + n_regs * sizeof(res->vals[0]);
-       res = obstack_alloc(&obst, size);
-       memcpy(res, workset, size);
+       workset_t *res = OALLOCF(&obst, workset_t, vals, n_regs);
+       memcpy(res, workset, sizeof(*res) + n_regs * sizeof(res->vals[0]));
        return res;
 }
 
@@ -262,12 +255,9 @@ typedef struct _block_info_t
 } block_info_t;
 
 
-static void *new_block_info(void)
+static block_info_t *new_block_info(void)
 {
-       block_info_t *res = obstack_alloc(&obst, sizeof(res[0]));
-       memset(res, 0, sizeof(res[0]));
-
-       return res;
+       return OALLOCZ(&obst, block_info_t);
 }
 
 #define get_block_info(block)        ((block_info_t *)get_irn_link(block))
@@ -280,11 +270,10 @@ static inline unsigned get_distance(ir_node *from, unsigned from_step,
                                     const ir_node *def, int skip_from_uses)
 {
        be_next_use_t use;
-       int           flags = arch_irn_get_flags(def);
        unsigned      costs;
        unsigned      time;
 
-       assert(! (flags & arch_irn_flags_ignore));
+       assert(!arch_irn_is_ignore(def));
 
        use  = be_get_next_use(uses, from, from_step, def, skip_from_uses);
        time = use.time;
@@ -292,7 +281,7 @@ static inline unsigned get_distance(ir_node *from, unsigned from_step,
                return USES_INFINITY;
 
        /* We have to keep nonspillable nodes in the workingset */
-       if (flags & arch_irn_flags_dont_spill)
+       if (arch_irn_get_flags(skip_Proj_const(def)) & arch_irn_flags_dont_spill)
                return 0;
 
        /* give some bonus to rematerialisable nodes */
@@ -486,7 +475,7 @@ static loc_t to_take_or_not_to_take(ir_node* first, ir_node *node,
        }
 
        /* We have to keep nonspillable nodes in the workingset */
-       if (arch_irn_get_flags(node) & arch_irn_flags_dont_spill) {
+       if (arch_irn_get_flags(skip_Proj_const(node)) & arch_irn_flags_dont_spill) {
                loc.time = 0;
                DB((dbg, DBG_START, "    %+F taken (dontspill node)\n", node, loc.time));
                return loc;
@@ -955,12 +944,6 @@ static void fix_block_borders(ir_node *block, void *data)
        }
 }
 
-static void add_block(ir_node *block, void *data)
-{
-       (void) data;
-       ARR_APP1(ir_node*, blocklist, block);
-}
-
 static void be_spill_belady(be_irg_t *birg, const arch_register_class_t *rcls)
 {
        int i;
@@ -991,8 +974,7 @@ static void be_spill_belady(be_irg_t *birg, const arch_register_class_t *rcls)
        uses      = be_begin_uses(irg, lv);
        loop_ana  = be_new_loop_pressure(birg, cls);
        senv      = be_new_spill_env(birg);
-       blocklist = NEW_ARR_F(ir_node*, 0);
-       irg_block_edges_walk(get_irg_start_block(irg), NULL, add_block, NULL);
+       blocklist = be_get_cfgpostorder(irg);
        stat_ev_tim_pop("belady_time_init");
 
        stat_ev_tim_push();