X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbestate.c;h=e14633cd85284f2db898a402a050095bb80b2a0c;hb=f1faabdafa40558bab4d171999c7c4871dfee5a6;hp=146640da58bd5b1e8dd7b81b9729ad40f10b0714;hpb=f8cc15664f571aa7ef89d6f6bc8d5bd2b8ca7d53;p=libfirm diff --git a/ir/be/bestate.c b/ir/be/bestate.c index 146640da5..e14633cd8 100644 --- a/ir/be/bestate.c +++ b/ir/be/bestate.c @@ -38,15 +38,17 @@ #include "irgmod.h" #include "irnodeset.h" #include "irnodehashmap.h" -#include "adt/cpset.h" +#include "cpset.h" #include "bearch.h" +#include "beirg.h" #include "beuses.h" #include "besched.h" #include "belive_t.h" #include "bemodule.h" #include "benode.h" #include "beirgmod.h" +#include "bespillutil.h" #include "bessaconstr.h" DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;) @@ -110,8 +112,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_nodehashmap_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; } @@ -134,7 +135,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)); + } while (is_Phi(next) || be_is_Keep(next)); } else { after = state; } @@ -182,7 +183,8 @@ static void spill_phi(minibelady_env_t *env, ir_node *phi) DBG((dbg, LEVEL_2, "\tcreate Phi-M for %+F\n", phi)); /* create a Phi-M */ - spill_info->spill = be_new_Phi(block, arity, phi_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) { @@ -214,11 +216,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); @@ -301,12 +301,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); - - if (!mode_is_data(get_irn_mode(node))) - continue; - + be_lv_foreach_cls(env->lv, block, be_lv_state_in, env->reg->reg_class, node) { if (arch_get_irn_register(node) != env->reg) continue; @@ -358,7 +353,6 @@ static block_info_t *compute_block_start_state(minibelady_env_t *env, ir_node *b 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 */ @@ -382,11 +376,9 @@ static void belady(minibelady_env_t *env, ir_node *block) int i, arity; ir_node *need_val = NULL; - /* projs are handled with the tuple value. - * Phis are no real instr (see insert_starters()) */ - if (is_Proj(node) || is_Phi(node)) { + /* Phis are no real instr (see insert_starters()) */ + if (is_Phi(node)) continue; - } /* check which state is desired for the node */ arity = get_irn_arity(node); @@ -415,31 +407,15 @@ static void belady(minibelady_env_t *env, ir_node *block) DBG((dbg, LEVEL_3, " ...%+F\n", node)); /* 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); - - if (!mode_is_data(get_irn_mode(proj))) - continue; - - reg = arch_get_irn_register(proj); - if (reg == env->reg) { - current_state = proj; - DBG((dbg, LEVEL_3, "\t... current_state <- %+F\n", current_state)); - } - } - } else { - if (mode_is_data(get_irn_mode(node))) { - const arch_register_t *reg = arch_get_irn_register(node); - if (reg == env->reg) { - current_state = node; - DBG((dbg, LEVEL_3, "\t... current_state <- %+F\n", current_state)); - } - } - } + be_foreach_value(node, value, + if (!mode_is_data(get_irn_mode(value))) + continue; + arch_register_t const *const reg = arch_get_irn_register(value); + if (reg != env->reg) + continue; + current_state = value; + DBG((dbg, LEVEL_3, "\t... current_state <- %+F\n", current_state)); + ); } /* Remember end-workset for this block */ @@ -452,39 +428,16 @@ static void belady_walker(ir_node *block, void *data) belady((minibelady_env_t*) data, block); } -static ir_node *get_end_of_block_insertion_point(ir_node *block) -{ - ir_node *last = sched_last(block); - - /* skip Projs and Keep-alikes behind the jump... */ - while (is_Proj(last) || be_is_Keep(last)) { - last = sched_prev(last); - } - - if (!is_cfop(last)) { - last = sched_next(last); - /* last node must be a cfop, only exception is the start block */ - assert(last == get_irg_start_block(get_irn_irg(block))); - } - - return last; -} - /** * We must adapt the live-outs to the live-ins at each block-border. */ static void fix_block_borders(ir_node *block, void *data) { minibelady_env_t *env = (minibelady_env_t*)data; - ir_graph *irg = get_irn_irg(block); - ir_node *startblock = get_irg_start_block(irg); int i; int arity; block_info_t *block_info; - if (block == startblock) - return; - DBG((dbg, LEVEL_3, "\n")); block_info = get_block_info(block); @@ -510,10 +463,8 @@ static void fix_block_borders(ir_node *block, void *data) pred_info->end_state, need_state)); if (pred_info->end_state != need_state) { - ir_node *insert_point = get_end_of_block_insertion_point(pred); - - DBG((dbg, LEVEL_3, " Creating reload for %+F\n", need_state)); + ir_node *const insert_point = be_get_end_of_block_insertion_point(pred); create_reload(env, need_state, insert_point, pred_info->end_state); } } @@ -525,9 +476,9 @@ 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); + be_assure_live_sets(irg); assure_loopinfo(irg); obstack_init(&env.obst);