X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbestate.c;h=52dc3df93a5b5622ea06b98a011deb2c368b08fc;hb=929bd10ba046d7482e572d97ec592a4055c65970;hp=b7035dac5443670715537304a5e76314048e2464;hpb=a572aa3cb3a08690a3d2d6567bd26ab7c52a81c5;p=libfirm diff --git a/ir/be/bestate.c b/ir/be/bestate.c index b7035dac5..52dc3df93 100644 --- a/ir/be/bestate.c +++ b/ir/be/bestate.c @@ -23,7 +23,6 @@ * algorithm optimized for the 1-register case. * @author Matthias Braun * @date 26.03.2007 - * @version $Id$ */ #include "config.h" @@ -38,10 +37,11 @@ #include "ircons_t.h" #include "irgmod.h" #include "irnodeset.h" -#include "irnodemap.h" -#include "adt/cpset.h" +#include "irnodehashmap.h" +#include "cpset.h" #include "bearch.h" +#include "beirg.h" #include "beuses.h" #include "besched.h" #include "belive_t.h" @@ -67,7 +67,7 @@ typedef struct minibelady_env_t { create_reload_func create_reload; create_spill_func create_spill; spill_info_t *spills; - ir_nodemap_t spill_infos; + ir_nodehashmap_t spill_infos; be_uses_t *uses; /**< env for the next-use magic */ } minibelady_env_t; @@ -100,7 +100,7 @@ static inline spill_info_t *create_spill_info(minibelady_env_t *env, ir_node *st spill_info->value = state; spill_info->reloads = NEW_ARR_F(ir_node*, 0); - ir_nodemap_insert(&env->spill_infos, state, spill_info); + ir_nodehashmap_insert(&env->spill_infos, state, spill_info); //ir_fprintf(stderr, "Insert %+F -> %p\n", state, spill_info); spill_info->next = env->spills; @@ -111,8 +111,7 @@ static inline spill_info_t *create_spill_info(minibelady_env_t *env, ir_node *st static inline spill_info_t *get_spill_info(minibelady_env_t *env, const ir_node *node) { - spill_info_t *spill_info - = (spill_info_t*) ir_nodemap_get(&env->spill_infos, node); + spill_info_t *spill_info = ir_nodehashmap_get(spill_info_t, &env->spill_infos, node); //ir_fprintf(stderr, "Get %+F -> %p\n", node, spill_info); return spill_info; } @@ -135,8 +134,7 @@ static spill_info_t *create_spill(minibelady_env_t *env, ir_node *state, int for do { after = next; next = sched_next(after); - } while (is_Proj(next) || is_Phi(next) || be_is_Keep(next) - || (arch_irn_get_flags(next) & arch_irn_flags_prolog)); + } while (is_Proj(next) || is_Phi(next) || be_is_Keep(next)); } else { after = state; } @@ -162,7 +160,7 @@ static void spill_phi(minibelady_env_t *env, ir_node *phi) ir_graph *irg = get_irn_irg(phi); ir_node *block = get_nodes_block(phi); int arity = get_irn_arity(phi); - ir_node **in = ALLOCAN(ir_node*, arity); + ir_node **phi_in = ALLOCAN(ir_node*, arity); ir_node *dummy = new_r_Dummy(irg, mode_M); ir_node *spill_to_kill = NULL; spill_info_t *spill_info; @@ -178,13 +176,14 @@ static void spill_phi(minibelady_env_t *env, ir_node *phi) /* create a new phi-M with bad preds */ for (i = 0; i < arity; ++i) { - in[i] = dummy; + phi_in[i] = dummy; } DBG((dbg, LEVEL_2, "\tcreate Phi-M for %+F\n", phi)); /* create a Phi-M */ - spill_info->spill = be_new_Phi(block, arity, in, mode_M, NULL); + spill_info->spill = be_new_Phi(block, arity, phi_in, mode_M, + arch_no_register_req); sched_add_after(block, spill_info->spill); if (spill_to_kill != NULL) { @@ -216,11 +215,9 @@ static block_info_t *compute_block_start_state(minibelady_env_t *env, ir_node *b be_next_use_t next_use; ir_loop *loop; ir_node *best_starter, *first; - ir_node *node; int n_cfgpreds; unsigned best_time; int outer_loop_allowed; - int i; /* Create the block info for this block. */ block_info = new_block_info(&env->obst, block); @@ -303,9 +300,7 @@ static block_info_t *compute_block_start_state(minibelady_env_t *env, ir_node *b } /* check all Live-Ins */ - be_lv_foreach(env->lv, block, be_lv_state_in, i) { - node = be_lv_get_irn(env->lv, block, i); - + be_lv_foreach(env->lv, block, be_lv_state_in, node) { if (!mode_is_data(get_irn_mode(node))) continue; @@ -352,17 +347,6 @@ static block_info_t *compute_block_start_state(minibelady_env_t *env, ir_node *b return block_info; } -static ir_node *get_reload_point(ir_node *before) -{ - while (true) { - ir_node *prev = sched_prev(before); - if (! (arch_irn_get_flags(prev) & arch_irn_flags_epilog)) - break; - before = prev; - } - return before; -} - /** * For the given block @p block, decide for each values * whether it is used from a register or is reloaded @@ -371,7 +355,6 @@ static ir_node *get_reload_point(ir_node *before) static void belady(minibelady_env_t *env, ir_node *block) { ir_node *current_state; - ir_node *node; block_info_t *block_info; /* Don't do a block twice */ @@ -419,8 +402,8 @@ static void belady(minibelady_env_t *env, ir_node *block) } /* create a reload to match state if necessary */ if (need_val != NULL && need_val != current_state) { + ir_node *before = node; DBG((dbg, LEVEL_3, "\t... reloading %+F\n", need_val)); - ir_node *before = get_reload_point(node); create_reload(env, need_val, before, current_state); current_state = need_val; } @@ -429,8 +412,6 @@ static void belady(minibelady_env_t *env, ir_node *block) /* record state changes by the node */ if (get_irn_mode(node) == mode_T) { - const ir_edge_t *edge; - foreach_out_edge(node, edge) { const arch_register_t *reg; ir_node *proj = get_edge_src_irn(edge); @@ -538,13 +519,10 @@ void be_assure_state(ir_graph *irg, const arch_register_t *reg, void *func_env, { minibelady_env_t env; spill_info_t *info; - be_lv_t *lv = be_assure_liveness(irg); + be_lv_t *lv = be_get_irg_liveness(irg); - be_liveness_assure_sets(lv); - /* construct control flow loop tree */ - if (! (get_irg_loopinfo_state(irg) & loopinfo_cf_consistent)) { - construct_cf_backedges(irg); - } + be_assure_live_sets(irg); + assure_loopinfo(irg); obstack_init(&env.obst); env.reg = reg; @@ -554,7 +532,7 @@ void be_assure_state(ir_graph *irg, const arch_register_t *reg, void *func_env, env.lv = be_get_irg_liveness(irg); env.uses = be_begin_uses(irg, env.lv); env.spills = NULL; - ir_nodemap_init(&env.spill_infos); + ir_nodehashmap_init(&env.spill_infos); assure_doms(irg); ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED | IR_RESOURCE_IRN_LINK); @@ -609,12 +587,12 @@ void be_assure_state(ir_graph *irg, const arch_register_t *reg, void *func_env, /* some nodes might be dead now. */ be_remove_dead_nodes_from_schedule(irg); - ir_nodemap_destroy(&env.spill_infos); + ir_nodehashmap_destroy(&env.spill_infos); be_end_uses(env.uses); obstack_free(&env.obst, NULL); } -BE_REGISTER_MODULE_CONSTRUCTOR(be_init_state); +BE_REGISTER_MODULE_CONSTRUCTOR(be_init_state) void be_init_state(void) { FIRM_DBG_REGISTER(dbg, "firm.be.state");