X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbespillbelady.c;h=277994b074b605812496a3b1b84430ad0c4b595a;hb=1500e59dff75cfa53802276d5091765a238a1e71;hp=962d1c3a156bd146cfa05a78665b4ebb2d634385;hpb=16fc4cdb8f7bc9d203f4e024d0bad50f79867c4f;p=libfirm diff --git a/ir/be/bespillbelady.c b/ir/be/bespillbelady.c index 962d1c3a1..277994b07 100644 --- a/ir/be/bespillbelady.c +++ b/ir/be/bespillbelady.c @@ -22,14 +22,12 @@ * @brief Beladys spillalgorithm. * @author Daniel Grund, Matthias Braun * @date 20.09.2005 - * @version $Id$ */ #include "config.h" #include #include "obst.h" -#include "irprintf_t.h" #include "irgraph.h" #include "irnode.h" #include "irmode.h" @@ -39,6 +37,9 @@ #include "ircons_t.h" #include "irprintf.h" #include "irnodeset.h" +#include "irtools.h" +#include "statev_t.h" +#include "util.h" #include "beutil.h" #include "bearch.h" @@ -77,7 +78,7 @@ typedef struct loc_t { typedef struct workset_t { unsigned len; /**< current length */ - loc_t vals[0]; /**< array of the values/distances in this working set */ + loc_t vals[]; /**< array of the values/distances in this working set */ } workset_t; static struct obstack obst; @@ -211,9 +212,17 @@ static const loc_t *workset_contains(const workset_t *ws, const ir_node *val) static int loc_compare(const void *a, const void *b) { - const loc_t *p = (const loc_t*)a; - const loc_t *q = (const loc_t*)b; - return p->time - q->time; + const loc_t *p = ((const loc_t*) a); + const loc_t *q = ((const loc_t*) b); + const unsigned pt = p->time; + const unsigned qt = q->time; + + if (pt < qt) + return -1; + if (pt > qt) + return 1; + + return get_irn_node_nr(p->node) - get_irn_node_nr(q->node); } static void workset_sort(workset_t *workset) @@ -293,7 +302,7 @@ static unsigned get_distance(ir_node *from, const ir_node *def, int skip_from_us return USES_INFINITY; /* We have to keep nonspillable nodes in the workingset */ - if (arch_irn_get_flags(skip_Proj_const(def)) & arch_irn_flags_dont_spill) + if (arch_get_irn_flags(skip_Proj_const(def)) & arch_irn_flags_dont_spill) return 0; /* give some bonus to rematerialisable nodes */ @@ -479,7 +488,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(skip_Proj_const(node)) & arch_irn_flags_dont_spill) { + if (arch_get_irn_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; @@ -531,13 +540,11 @@ static void decide_start_workset(const ir_node *block) { ir_loop *loop = get_irn_loop(block); ir_node *first; - ir_node *node; loc_t loc; loc_t *starters; loc_t *delayed; unsigned len; unsigned i; - int in; unsigned ws_count; int free_slots, free_pressure_slots; unsigned pressure; @@ -549,7 +556,7 @@ static void decide_start_workset(const ir_node *block) arity = get_irn_arity(block); pred_worksets = ALLOCAN(workset_t*, arity); all_preds_known = true; - for (in = 0; in < arity; ++in) { + for (int in = 0; in < arity; ++in) { ir_node *pred_block = get_Block_cfgpred_block(block, in); block_info_t *pred_info = get_block_info(pred_block); @@ -596,8 +603,7 @@ static void decide_start_workset(const ir_node *block) } /* check all Live-Ins */ - be_lv_foreach(lv, block, be_lv_state_in, in) { - ir_node *node = be_lv_get_irn(lv, block, in); + be_lv_foreach(lv, block, be_lv_state_in, node) { unsigned available; if (all_preds_known) { @@ -752,7 +758,6 @@ static void decide_start_workset(const ir_node *block) static void process_block(ir_node *block) { workset_t *new_vals; - ir_node *irn; unsigned iter; block_info_t *block_info; int arity; @@ -766,7 +771,7 @@ static void process_block(ir_node *block) /* no predecessor -> empty set */ workset_clear(ws); } else if (arity == 1) { - /* one predecessor, copy it's end workset */ + /* one predecessor, copy its end workset */ ir_node *pred_block = get_Block_cfgpred_block(block, 0); block_info_t *pred_info = get_block_info(pred_block); @@ -784,9 +789,11 @@ static void process_block(ir_node *block) set_block_info(block, block_info); DB((dbg, DBG_WSETS, "Start workset for %+F:\n", block)); - workset_foreach(ws, irn, iter) { - DB((dbg, DBG_WSETS, " %+F (%u)\n", irn, - workset_get_time(ws, iter))); + { + ir_node *irn; + workset_foreach(ws, irn, iter) { + DB((dbg, DBG_WSETS, " %+F (%u)\n", irn, workset_get_time(ws, iter))); + } } block_info->start_workset = workset_clone(ws); @@ -798,7 +805,6 @@ static void process_block(ir_node *block) sched_foreach(block, irn) { int i, arity; - ir_node *value; assert(workset_get_length(ws) <= n_regs); /* Phis are no real instr (see insert_starters()) */ @@ -834,8 +840,11 @@ static void process_block(ir_node *block) /* Remember end-workset for this block */ block_info->end_workset = workset_clone(ws); DB((dbg, DBG_WSETS, "End workset for %+F:\n", block)); - workset_foreach(ws, irn, iter) - DB((dbg, DBG_WSETS, " %+F (%u)\n", irn, workset_get_time(ws, iter))); + { + ir_node *irn; + workset_foreach(ws, irn, iter) + DB((dbg, DBG_WSETS, " %+F (%u)\n", irn, workset_get_time(ws, iter))); + } } /** @@ -945,13 +954,10 @@ static void be_spill_belady(ir_graph *irg, const arch_register_class_t *rcls) { int i; - be_liveness_assure_sets(be_assure_liveness(irg)); + be_assure_live_sets(irg); stat_ev_tim_push(); - /* construct control flow loop tree */ - if (! (get_irg_loopinfo_state(irg) & loopinfo_cf_consistent)) { - construct_cf_backedges(irg); - } + assure_loopinfo(irg); stat_ev_tim_pop("belady_time_backedges"); stat_ev_tim_push(); @@ -999,7 +1005,7 @@ static void be_spill_belady(ir_graph *irg, const arch_register_class_t *rcls) obstack_free(&obst, NULL); } -BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spillbelady); +BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spillbelady) void be_init_spillbelady(void) { static be_spiller_t belady_spiller = {