X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbespillbelady2.c;h=b48b8dc8d2c8cd6cfab4570305b924a9df3fced8;hb=505d3662efed6efbca2c43eea2fe23b87816b285;hp=a1e2459c7a9fb1b67bff6a1d44997e4961de5b12;hpb=0161c9599a7082e078193440aec516576b3764a8;p=libfirm diff --git a/ir/be/bespillbelady2.c b/ir/be/bespillbelady2.c index a1e2459c7..b48b8dc8d 100644 --- a/ir/be/bespillbelady2.c +++ b/ir/be/bespillbelady2.c @@ -69,8 +69,8 @@ #include "bemodule.h" #include "bespill.h" -#include -#include +#include "lc_opts.h" +#include "lc_opts_enum.h" #define DBG_SPILL 1 #define DBG_WSETS 2 @@ -127,15 +127,16 @@ typedef struct _belady_env_t { be_lv_t *lv; ir_exec_freq *ef; - ir_node **blocks; /**< Array of all blocks. */ - int n_blocks; /**< Number of blocks in the graph. */ - int n_regs; /**< number of regs in this reg-class */ - workset_t *ws; /**< the main workset used while processing a block. ob-allocated */ - ir_node *instr; /**< current instruction */ - int instr_nr; /**< current instruction number (relative to block start) */ + ir_node **blocks; /**< Array of all blocks. */ + int n_blocks; /**< Number of blocks in the graph. */ + int n_regs; /**< number of regs in this reg-class */ + workset_t *ws; /**< the main workset used while processing a block. ob-allocated */ + ir_node *instr; /**< current instruction */ + int instr_nr; /**< current instruction number (relative to block start) */ - spill_env_t *senv; /**< see bespill.h */ - bitset_t *spilled; /**< bitset to keep all the irns which have already been spilled. */ + spill_env_t *senv; /**< see bespill.h */ + bitset_t *spilled; /**< bitset to keep all the irns which have already been spilled. */ + ir_nodeset_t *extra_spilled; /** All nodes for which a special spill location has been computed. */ } belady_env_t; @@ -306,7 +307,7 @@ static INLINE void *new_block_info(belady_env_t *bel, int id) res->bl = bl; res->id = id; res->exec_freq = get_block_execfreq(bel->ef, bl); - res->reload_cost = bel->arch->isa->reload_cost * res->exec_freq; + res->reload_cost = bel->arch->reload_cost * res->exec_freq; res->free_at_jump = bel->n_regs; INIT_LIST_HEAD(&res->br_head); set_irn_link(bl, res); @@ -1327,7 +1328,8 @@ static void optimize_variable(global_end_state_t *ges, bring_in_t *br) DBG((dbg, DBG_GLOBAL, "\t-> use blocked. local reload: %+F, try spill at: %+F\n", br->first_use, better_spill_loc)); be_add_reload(env->senv, irn, br->first_use, env->cls, 1); - be_add_spill(env->senv, irn, sched_next(better_spill_loc)); + be_add_spill(env->senv, irn, better_spill_loc); + ir_nodeset_insert(env->extra_spilled, irn); } /* @@ -1398,8 +1400,10 @@ static bring_in_t **determine_global_order(belady_env_t *env) static void global_assign(belady_env_t *env) { + ir_nodeset_iterator_t iter; global_end_state_t ges; bring_in_t **br; + ir_node *irn; int i, j; /* @@ -1448,6 +1452,10 @@ static void global_assign(belady_env_t *env) be_spill_phi(env->senv, irn); } } + + /* check dominance for specially spilled nodes. */ + foreach_ir_nodeset (env->extra_spilled, irn, iter) + make_spill_locations_dominate_irn(env->senv, irn); } static void collect_blocks(ir_node *bl, void *data) @@ -1490,6 +1498,7 @@ void be_spill_belady(be_irg_t *birg, const arch_register_class_t *cls) env.senv = be_new_spill_env(birg); env.ef = be_get_birg_exec_freq(birg); env.spilled = bitset_irg_obstack_alloc(&env.ob, irg); + env.extra_spilled = ir_nodeset_new(64); env.n_blocks = 0; irg_block_walk_graph(irg, NULL, collect_blocks, &env); @@ -1508,11 +1517,21 @@ void be_spill_belady(be_irg_t *birg, const arch_register_class_t *cls) global_assign(&env); + /* check dominance for specially spilled nodes. */ + { + ir_nodeset_iterator_t iter; + ir_node *irn; + + foreach_ir_nodeset (env.extra_spilled, irn, iter) + make_spill_locations_dominate_irn(env.senv, irn); + } + /* Insert spill/reload nodes into the graph and fix usages */ be_insert_spills_reloads(env.senv); /* clean up */ be_delete_spill_env(env.senv); + ir_nodeset_del(env.extra_spilled); obstack_free(&env.ob, NULL); }