X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbespillbelady.c;h=c5a021ee601b9603b6d64c32bb2e6c48a3070219;hb=4d7a9507baf1737297cd4f7fc91eab209fd5d398;hp=0447d0398cebe2dd52d796558075c076044bccef;hpb=b80dc0bbc9697becc681c9119df8589d1ea39c9f;p=libfirm diff --git a/ir/be/bespillbelady.c b/ir/be/bespillbelady.c index 0447d0398..c5a021ee6 100644 --- a/ir/be/bespillbelady.c +++ b/ir/be/bespillbelady.c @@ -20,12 +20,14 @@ #include "obst.h" #include "set.h" #include "pset.h" +#include "irprintf_t.h" #include "irgraph.h" #include "irnode.h" #include "irmode.h" #include "irgwalk.h" #include "iredges_t.h" #include "ircons_t.h" +#include "irprintf.h" #include "beutil.h" #include "bearch.h" @@ -74,6 +76,15 @@ struct _workset_t { loc_t vals[1]; /**< inlined array of the values/distances in this working set */ }; +void workset_print(const workset_t *w) +{ + int i; + + for(i = 0; i < w->len; ++i) { + ir_printf("%+F %d\n", w->vals[i].irn, w->vals[i].time); + } +} + /** * Alloc a new workset on obstack @p ob with maximum size @p max */ @@ -242,12 +253,18 @@ static int is_mem_phi(const ir_node *irn, void *data) { * @return The distance to the next use * Or 0 if irn is an ignore node */ -#define get_distance(bel, from, from_step, def, skip_from_uses) \ - ((arch_irn_is_ignore(bel->arch, def) ) ? 0 : be_get_next_use(bel->uses, from, from_step, def, skip_from_uses)) +static INLINE unsigned get_distance(belady_env_t *bel, const ir_node *from, unsigned from_step, const ir_node *def, int skip_from_uses) +{ + arch_irn_flags_t fl = arch_irn_get_flags(bel->arch, def); + if((fl & (arch_irn_flags_ignore | arch_irn_flags_dont_spill)) != 0) + return 0; + else + return be_get_next_use(bel->uses, from, from_step, def, skip_from_uses); +} /** - * Performs the actions neccessary to grant the request that: + * Performs the actions necessary to grant the request that: * - new_vals can be held in registers * - as few as possible other values are disposed * - the worst values get disposed @@ -378,7 +395,7 @@ static block_info_t *compute_block_start_info(ir_node *blk, void *env) { /* If we have only one predecessor, we want the start_set of blk to be the end_set of pred */ - if (get_irn_arity(blk) == 1 && blk != get_irg_start_block(get_irn_irg(blk))) { + if (get_Block_n_cfgpreds(blk) == 1 && blk != get_irg_start_block(get_irn_irg(blk))) { ir_node *pred_blk = get_Block_cfgpred_block(blk, 0); block_info_t *pred_info = get_block_info(pred_blk); @@ -469,7 +486,7 @@ static void belady(ir_node *blk, void *env) { /* projs are handled with the tuple value. - * Phis are no real instr (see insert_starters) + * Phis are no real instr (see insert_starters()) * instr_nr does not increase */ if (is_Proj(irn) || is_Phi(irn)) { DBG((dbg, DBG_DECIDE, " ...%+F skipped\n", irn)); @@ -571,16 +588,15 @@ static void remove_copies(belady_env_t *bel) { ir_node *irn; for (irn = pset_first(bel->copies); irn; irn = pset_next(bel->copies)) { - ir_node *src, *spill; + ir_node *src, *user; assert(be_is_Copy(irn)); assert(get_irn_n_edges(irn) == 1 && "This is not a copy introduced in 'compute_block_start_info()'. Who created it?"); - spill = get_irn_edge(get_irn_irg(irn), irn, 0)->src; - assert(be_is_Spill(spill) && "This is not a copy introduced in 'compute_block_start_info()'. Who created it?"); + user = get_irn_edge(get_irn_irg(irn), irn, 0)->src; - src = get_irn_n(irn, 0); - set_irn_n(spill, 0, src); + src = get_irn_n(irn, be_pos_Copy_orig); + set_irn_n(user, 0, src); } } @@ -596,7 +612,7 @@ static void remove_unused_reloads(ir_graph *irg, belady_env_t *bel) { ir_node *spill; DBG((dbg, DBG_SPILL, "Removing %+F before %+F in %+F\n", irn, sched_next(irn), get_nodes_block(irn))); - spill = get_irn_n(irn, 0); + spill = get_irn_n(irn, be_pos_Reload_mem); /* remove reload */ set_irn_n(irn, 0, new_Bad()); @@ -618,11 +634,11 @@ void be_spill_belady(const be_chordal_env_t *chordal_env) { /* init belady env */ obstack_init(&bel.ob); - bel.arch = chordal_env->main_env->arch_env; + bel.arch = chordal_env->birg->main_env->arch_env; bel.cls = chordal_env->cls; bel.n_regs = arch_register_class_n_regs(bel.cls); bel.ws = new_workset(&bel.ob, &bel); - bel.uses = be_begin_uses(chordal_env->irg, chordal_env->main_env->arch_env, bel.cls); + bel.uses = be_begin_uses(chordal_env->irg, chordal_env->birg->main_env->arch_env, bel.cls); bel.senv = be_new_spill_env(dbg, chordal_env, is_mem_phi, NULL); bel.reloads = pset_new_ptr_default(); bel.copies = pset_new_ptr_default();