X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbespillremat.c;h=eaf4aa3f92289d8207686345743a68aa223f9a23;hb=cf027c3576652c0f6938130fe89b0f1ea0df706a;hp=f215f20bafe51c3304fcd0ccce42770bfd8577a5;hpb=2c3a6c49851468d09916c17d206ed0eb22a80f1f;p=libfirm diff --git a/ir/be/bespillremat.c b/ir/be/bespillremat.c index f215f20ba..eaf4aa3f9 100644 --- a/ir/be/bespillremat.c +++ b/ir/be/bespillremat.c @@ -24,9 +24,7 @@ * @date 06.04.2006 * @version $Id$ */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #ifdef WITH_ILP @@ -280,7 +278,7 @@ typedef struct _memoperand_t { ilp_var_t ilp; /**< the ilp var for this memory operand */ } memoperand_t; -static INLINE int +static inline int has_reg_class(const spill_ilp_t * si, const ir_node * irn) { return arch_irn_consider_in_reg_alloc(si->cls, irn); @@ -403,7 +401,7 @@ set_find_spill(set * set, const ir_node * value) #define pset_foreach(s,i) for((i)=pset_first((s)); (i); (i)=pset_next((s))) #define set_foreach(s,i) for((i)=set_first((s)); (i); (i)=set_next((s))) #define foreach_post_remat(s,i) for((i)=next_post_remat((s)); (i); (i)=next_post_remat((i))) -#define foreach_pre_remat(si,s,i) for((i)=next_pre_remat((si),(s)); (i); (i)=next_pre_remat((si),(i))) +#define foreach_pre_remat(s,i) for((i)=next_pre_remat((s)); (i); (i)=next_pre_remat((i))) #define sched_foreach_op(s,i) for((i)=sched_next_op((s));!sched_is_end((i));(i)=sched_next_op((i))) static int @@ -467,7 +465,7 @@ static double get_cost(const ir_node *irn) /** * Checks, whether node and its operands have suitable reg classes */ -static INLINE int +static inline int is_rematerializable(const spill_ilp_t * si, const ir_node * irn) { int n; @@ -492,7 +490,7 @@ is_rematerializable(const spill_ilp_t * si, const ir_node * irn) /** * Try to create a remat from @p op with destination value @p dest_value */ -static INLINE remat_t * +static inline remat_t * get_remat_from_op(spill_ilp_t * si, const ir_node * dest_value, const ir_node * op) { remat_t *remat = NULL; @@ -571,7 +569,7 @@ get_remat_from_op(spill_ilp_t * si, const ir_node * dest_value, const ir_node * } -static INLINE void +static inline void add_remat(const spill_ilp_t * si, const remat_t * remat) { remat_info_t *remat_info, @@ -641,7 +639,7 @@ get_irn_n_nonignore_args(const spill_ilp_t * si, const ir_node * irn) return ret; } -static INLINE void +static inline void get_remats_from_op(spill_ilp_t * si, const ir_node * op) { int n; @@ -674,7 +672,7 @@ get_remats_from_op(spill_ilp_t * si, const ir_node * op) } } -static INLINE int +static inline int value_is_defined_before(const spill_ilp_t * si, const ir_node * pos, const ir_node * val) { ir_node *block; @@ -707,16 +705,15 @@ value_is_defined_before(const spill_ilp_t * si, const ir_node * pos, const ir_no return ret; } -static INLINE ir_node * -sched_block_last_noncf(const spill_ilp_t * si, const ir_node * bb) +static inline ir_node *sched_block_last_noncf(const ir_node * bb) { - return sched_skip((ir_node*)bb, 0, sched_skip_cf_predicator, (void *) si->birg->main_env->arch_env); + return sched_skip((ir_node*)bb, 0, sched_skip_cf_predicator, NULL); } /** * Returns first non-Phi node of block @p bb */ -static INLINE ir_node * +static inline ir_node * sched_block_first_nonphi(const ir_node * bb) { return sched_skip((ir_node*)bb, 1, sched_skip_phi_predicator, NULL); @@ -729,7 +726,7 @@ sched_skip_proj_predicator(const ir_node * irn, void * data) return (is_Proj(irn)); } -static INLINE ir_node * +static inline ir_node * sched_next_nonproj(const ir_node * irn, int forward) { return sched_skip((ir_node*)irn, forward, sched_skip_proj_predicator, NULL); @@ -739,7 +736,7 @@ sched_next_nonproj(const ir_node * irn, int forward) * Returns next operation node (non-Proj) after @p irn * or the basic block of this node */ -static INLINE ir_node * +static inline ir_node * sched_next_op(const ir_node * irn) { ir_node *next = sched_next(irn); @@ -754,7 +751,7 @@ sched_next_op(const ir_node * irn) * Returns previous operation node (non-Proj) before @p irn * or the basic block of this node */ -static INLINE ir_node * +static inline ir_node * sched_prev_op(const ir_node * irn) { ir_node *prev = sched_prev(irn); @@ -777,11 +774,10 @@ sched_put_after(ir_node * insert, ir_node * irn) sched_add_before(insert, irn); } -static void -sched_put_before(const spill_ilp_t * si, ir_node * insert, ir_node * irn) +static void sched_put_before(ir_node * insert, ir_node * irn) { if(is_Block(insert)) { - insert = sched_block_last_noncf(si, insert); + insert = sched_block_last_noncf(insert); } else { insert = sched_next_nonproj(insert, 0); insert = sched_prev(insert); @@ -814,14 +810,13 @@ next_post_remat(const ir_node * irn) } -static ir_node * -next_pre_remat(const spill_ilp_t * si, const ir_node * irn) +static ir_node *next_pre_remat(const ir_node * irn) { op_t *op; ir_node *ret; if(is_Block(irn)) { - ret = sched_block_last_noncf(si, irn); + ret = sched_block_last_noncf(irn); ret = sched_next(ret); ret = sched_prev_op(ret); } else { @@ -842,7 +837,7 @@ next_pre_remat(const spill_ilp_t * si, const ir_node * irn) /** * Tells you whether a @p remat can be placed before the irn @p pos */ -static INLINE int +static inline int can_remat_before(const spill_ilp_t * si, const remat_t * remat, const ir_node * pos, const pset * live) { const ir_node *op = remat->op; @@ -851,7 +846,7 @@ can_remat_before(const spill_ilp_t * si, const remat_t * remat, const ir_node * res = 1; if(is_Block(pos)) { - prev = sched_block_last_noncf(si, pos); + prev = sched_block_last_noncf(pos); prev = sched_next_nonproj(prev, 0); } else { prev = sched_prev_op(pos); @@ -891,7 +886,7 @@ can_remat_before(const spill_ilp_t * si, const remat_t * remat, const ir_node * /** * Tells you whether a @p remat can be placed after the irn @p pos */ -static INLINE int +static inline int can_remat_after(const spill_ilp_t * si, const remat_t * remat, const ir_node * pos, const pset * live) { if(is_Block(pos)) { @@ -936,7 +931,7 @@ insert_copy_before(const spill_ilp_t * si, const ir_node * irn, ir_node * pos) set_phi_class(si->pc, copy, NULL); set_nodes_block(copy, bb); - sched_put_before(si, pos, copy); + sched_put_before(pos, copy); return copy; } @@ -1100,7 +1095,7 @@ get_live_end(spill_ilp_t * si, ir_node * bb, pset * live) sched_foreach_reverse(bb, irn) { int i; - if(!sched_skip_cf_predicator(irn, si->birg->main_env->arch_env)) break; + if (!sched_skip_cf_predicator(irn, NULL)) break; for(i=get_irn_arity(irn)-1; i>=0; --i) { ir_node *arg = get_irn_n(irn,i); @@ -1114,7 +1109,7 @@ get_live_end(spill_ilp_t * si, ir_node * bb, pset * live) * find values that are used by remats at end of block * and insert them into live set */ - foreach_pre_remat(si, bb, irn) { + foreach_pre_remat(bb, irn) { int n; for (n=get_irn_arity(irn)-1; n>=0; --n) { @@ -1146,7 +1141,7 @@ walker_regclass_copy_insertor(ir_node * irn, void * data) if(!has_reg_class(si, phi_arg)) { ir_node *copy = be_new_Copy(si->cls, si->birg->irg, bb, phi_arg); - ir_node *pos = sched_block_last_noncf(si, bb); + ir_node *pos = sched_block_last_noncf(bb); op_t *op = obstack_alloc(si->obst, sizeof(*op)); DBG((si->dbg, LEVEL_2, "\t copy to my regclass for arg %+F of %+F\n", phi_arg, irn)); @@ -1264,7 +1259,7 @@ walker_remat_insertor(ir_node * bb, void * data) } /* do not place post remats after jumps */ - if(sched_skip_cf_predicator(irn, si->birg->main_env->arch_env)) { + if (sched_skip_cf_predicator(irn, si->birg->main_env->arch_env)) { del_pset(used); del_pset(args); break; @@ -1478,7 +1473,7 @@ luke_endwalker(ir_node * bb, void * data) * find values that are used by remats at end of block * and insert them into live set */ - foreach_pre_remat(si, bb, irn) { + foreach_pre_remat(bb, irn) { int n; for (n=get_irn_arity(irn)-1; n>=0; --n) { @@ -1495,7 +1490,7 @@ luke_endwalker(ir_node * bb, void * data) sched_foreach_reverse(bb, irn) { int n; - if(!sched_skip_cf_predicator(irn, si->birg->main_env->arch_env)) break; + if (!sched_skip_cf_predicator(irn, si->birg->main_env->arch_env)) break; for (n=get_irn_arity(irn)-1; n>=0; --n) { ir_node *irn_arg = get_irn_n(irn, n); @@ -1754,7 +1749,7 @@ insert_mem_copy_position(spill_ilp_t * si, pset * live, const ir_node * block) lpp_set_factor_fast(si->lpp, cst, to_copy_spill->reg_out, -1.0); if(reload != ILP_UNDEF) lpp_set_factor_fast(si->lpp, cst, reload, -1.0); lpp_set_factor_fast(si->lpp, cst, to_copy_op->attr.live_range.ilp, -1.0); - foreach_pre_remat(si, block, tmp) { + foreach_pre_remat(block, tmp) { op_t *remat_op = get_irn_link(tmp); if(remat_op->attr.remat.remat->value == to_copy) { lpp_set_factor_fast(si->lpp, cst, remat_op->attr.remat.ilp, -1.0); @@ -1827,7 +1822,7 @@ luke_blockwalker(ir_node * bb, void * data) lpp_set_factor_fast(si->lpp, cst, spill->reg_out, 1.0); if(reload != ILP_UNDEF) lpp_set_factor_fast(si->lpp, cst, reload, -1.0); lpp_set_factor_fast(si->lpp, cst, op->attr.live_range.ilp, -1.0); - foreach_pre_remat(si, bb, tmp) { + foreach_pre_remat(bb, tmp) { op_t *remat_op = get_irn_link(tmp); if(remat_op->attr.remat.remat->value == irn) { lpp_set_factor_fast(si->lpp, cst, remat_op->attr.remat.ilp, -1.0); @@ -1841,7 +1836,7 @@ luke_blockwalker(ir_node * bb, void * data) lpp_set_factor_fast(si->lpp, cst, spill->reg_out, 1.0); if(reload != ILP_UNDEF) lpp_set_factor_fast(si->lpp, cst, reload, -1.0); lpp_set_factor_fast(si->lpp, cst, op->attr.live_range.ilp, -1.0); - foreach_pre_remat(si, bb, tmp) { + foreach_pre_remat(bb, tmp) { op_t *remat_op = get_irn_link(tmp); if(remat_op->attr.remat.remat->value == irn) { lpp_set_factor_fast(si->lpp, cst, remat_op->attr.remat.ilp, -1.0); @@ -1876,7 +1871,7 @@ luke_blockwalker(ir_node * bb, void * data) /* * assure the remat args are available */ - foreach_pre_remat(si, bb, tmp) { + foreach_pre_remat(bb, tmp) { op_t *remat_op = get_irn_link(tmp); int n; @@ -1922,7 +1917,7 @@ luke_blockwalker(ir_node * bb, void * data) * B A S I C B L O C K B O D Y **************************************/ - sched_foreach_reverse_from(sched_block_last_noncf(si, bb), irn) { + sched_foreach_reverse_from(sched_block_last_noncf(bb), irn) { op_t *op; op_t *tmp_op; int n, @@ -1983,7 +1978,7 @@ luke_blockwalker(ir_node * bb, void * data) } } } - foreach_pre_remat(si, irn, tmp) { + foreach_pre_remat(irn, tmp) { for (n=get_irn_arity(tmp)-1; n>=0; --n) { ir_node *remat_arg = get_irn_n(tmp, n); if(has_reg_class(si, remat_arg)) { @@ -2378,7 +2373,7 @@ skip_one_must_die: lpp_set_factor_fast(si->lpp, requirements, arg_op->attr.live_range.ilp, 1.0); lpp_set_factor_fast(si->lpp, requirements, op->attr.live_range.args.reloads[i], 1.0); - foreach_pre_remat(si, irn, tmp) { + foreach_pre_remat(irn, tmp) { op_t *remat_op = get_irn_link(tmp); if(remat_op->attr.remat.remat->value == arg) { lpp_set_factor_fast(si->lpp, requirements, remat_op->attr.remat.ilp, 1.0); @@ -2427,7 +2422,7 @@ skip_one_must_die: } /* requirements for remats */ - foreach_pre_remat(si, irn, tmp) { + foreach_pre_remat(irn, tmp) { op_t *remat_op = get_irn_link(tmp); int n; @@ -3240,7 +3235,7 @@ memcopyhandler(spill_ilp_t * si) } -static INLINE int +static inline int is_zero(double x) { return fabs(x) < 0.00001; @@ -3428,8 +3423,8 @@ static ir_node *be_spill2(ir_node *irn, ir_node *insert) ir_node *frame = get_irg_frame(irg); ir_node *spill; ir_node *next; - const arch_register_class_t *cls = arch_get_irn_reg_class(irn, -1); - const arch_register_class_t *cls_frame = arch_get_irn_reg_class(frame, -1); + const arch_register_class_t *cls = arch_get_irn_reg_class_out(irn); + const arch_register_class_t *cls_frame = arch_get_irn_reg_class_out(frame); spill = be_new_Spill(cls, cls_frame, irg, bl, frame, irn); @@ -3702,7 +3697,6 @@ insert_reload(spill_ilp_t * si, const ir_node * value, ir_node * after) defs_t *defs; ir_node *reload, *spill; - const arch_env_t *arch_env = si->birg->main_env->arch_env; DBG((si->dbg, LEVEL_3, "\t inserting reload for value %+F before %+F\n", value, after)); @@ -3711,7 +3705,7 @@ insert_reload(spill_ilp_t * si, const ir_node * value, ir_node * after) spill = defs->spills; assert(spill && "no spill placed before reload"); - reload = be_reload(arch_env, si->cls, after, get_irn_mode(value), spill); + reload = be_reload(si->cls, after, get_irn_mode(value), spill); /* enter into the linked list */ set_irn_link(reload, defs->remats); @@ -3925,7 +3919,7 @@ walker_reload_placer(ir_node * bb, void * data) { if(!is_zero(name->value)) { ir_node *reload; ir_node *insert_pos = bb; - ir_node *prev = sched_block_last_noncf(si, bb); + ir_node *prev = sched_block_last_noncf(bb); op_t *prev_op = get_irn_link(prev); while(be_is_Spill(prev)) {