* @date 06.04.2006
* @version $Id$
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#ifdef WITH_ILP
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);
#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
/**
* 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;
/**
* 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;
}
-static INLINE void
+static inline void
add_remat(const spill_ilp_t * si, const remat_t * remat)
{
remat_info_t *remat_info,
return ret;
}
-static INLINE void
+static inline void
get_remats_from_op(spill_ilp_t * si, const ir_node * op)
{
int n;
}
}
-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;
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);
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);
* 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);
* 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);
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);
}
-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 {
/**
* 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;
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);
/**
* 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)) {
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;
}
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);
* 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) {
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));
}
/* 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;
* 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) {
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);
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);
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);
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);
/*
* 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;
* 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,
}
}
}
- 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)) {
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);
}
/* requirements for remats */
- foreach_pre_remat(si, irn, tmp) {
+ foreach_pre_remat(irn, tmp) {
op_t *remat_op = get_irn_link(tmp);
int n;
}
-static INLINE int
+static inline int
is_zero(double x)
{
return fabs(x) < 0.00001;
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);
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));
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);
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)) {