X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbespill.c;h=2746cb042f720e34510148de38fd997bf63eb7d2;hb=dcb0342ffc45ffe11ab32835a9673b8dd3b5ec2e;hp=3676e9196283c0503293d9ca3aa2ac1684b90187;hpb=e07b61c6ed5d198a484761f8a40a4f26520d964d;p=libfirm diff --git a/ir/be/bespill.c b/ir/be/bespill.c index 3676e9196..2746cb042 100644 --- a/ir/be/bespill.c +++ b/ir/be/bespill.c @@ -24,9 +24,7 @@ * @date 29.09.2005 * @version $Id$ */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include #include @@ -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" @@ -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 @@ -486,7 +483,7 @@ static void spill_phi(spill_env_t *env, spill_info_t *spillinfo) /* build a new PhiM */ arity = get_irn_arity(phi); - ins = alloca(sizeof(ir_node*) * arity); + ins = ALLOCAN(ir_node*, arity); unknown = new_r_Unknown(irg, mode_M); for(i = 0; i < arity; ++i) { ins[i] = unknown; @@ -565,39 +562,19 @@ static int is_value_available(spill_env_t *env, const ir_node *arg, if(arg == get_irg_frame(env->irg)) return 1; +#if 0 /* hack for now (happens when command should be inserted at end of block) */ - if(is_Block(reloader)) { + if(is_Block(reloader)) return 0; - } +#else + (void)reloader; +#endif /* * Ignore registers are always available */ - if(arch_irn_is(env->arch_env, arg, ignore)) { + if (arch_irn_is_ignore(arg)) return 1; - } - - /* the following test does not work while spilling, - * because the liveness info is not adapted yet to the effects of the - * additional spills/reloads. - */ -#if 0 - /* we want to remat before the insn reloader - * thus an arguments is alive if - * - it interferes with the reloaders result - * - or it is (last-) used by reloader itself - */ - if (values_interfere(env->birg->lv, reloader, arg)) { - return 1; - } - - arity = get_irn_arity(reloader); - for (i = 0; i < arity; ++i) { - ir_node *rel_arg = get_irn_n(reloader, i); - if (rel_arg == arg) - return 1; - } -#endif return 0; } @@ -605,13 +582,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 +609,22 @@ 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)) { + /* never rematerialize a node which modifies the flags. + * (would be better to test wether the flags are actually live at point + * reloader...) + */ + if (arch_irn_is(spilled, modify_flags)) { return REMAT_COST_INFINITE; } @@ -694,7 +673,7 @@ static ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader) bl = get_nodes_block(reloader); } - ins = alloca(get_irn_arity(spilled) * sizeof(ins[0])); + ins = ALLOCAN(ir_node*, get_irn_arity(spilled)); for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) { ir_node *arg = get_irn_n(spilled, i); @@ -804,7 +783,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 @@ -840,7 +819,7 @@ static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo) spill_t *s; double spills_execfreq; - /* calculate sum of executaion frequencies of individual spills */ + /* calculate sum of execution frequencies of individual spills */ spills_execfreq = 0; s = spillinfo->spills; for( ; s != NULL; s = s->next) { @@ -909,7 +888,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 +990,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++;