#include "irloop_t.h"
#include "phiclass.h"
#include "iredges.h"
+#include "execfreq.h"
#include <lpp/lpp.h>
#include <lpp/lpp_net.h>
#define COLLECT_INVERSE_REMATS /* enable placement of inverse remats */
#define REMAT_WHILE_LIVE /* only remat values that are live */
//#define NO_ENLARGE_L1V3N355 /* do not remat after the death of some operand */
-#define EXECFREQ_LOOPDEPH /* compute execution frequency from loop depth only */
+//#define EXECFREQ_LOOPDEPH /* compute execution frequency from loop depth only */
//#define MAY_DIE_AT_PRE_REMAT /* allow values to die after a pre remat */
//#define CHECK_POST_REMAT /* check pressure after post remats (conservative but otherwise we can temporarily exceed the register pressure) */
#define NO_SINGLE_USE_REMATS /* do not repair schedule */
#define LPP_SERVER "i44pc52"
#define LPP_SOLVER "cplex"
-#ifndef EXECFREQ_LOOPDEPH
-#include "execfreq.h"
-#endif
-
#define COST_LOAD 10
#define COST_STORE 50
#define COST_REMAT 1
-#define ILP_TIMEOUT 20
+#define ILP_TIMEOUT 30
#define ILP_UNDEF -1
ir_node *keep;
#endif
set *values; /**< for collecting all definitions of values before running ssa-construction */
-#ifndef EXECFREQ_LOOPDEPH
set *execfreqs;
-#endif
DEBUG_ONLY(firm_dbg_module_t * dbg);
} spill_ilp_t;
return !(p->key == q->key);
}
-static float
+static double
execution_frequency(const spill_ilp_t * si, const ir_node * irn)
{
-#ifdef EXECFREQ_LOOPDEPH
- if(is_Block(irn))
- return expf((float)get_loop_depth(get_irn_loop(irn)) * logf(10));
- else
- return expf((float)get_loop_depth(get_irn_loop(get_nodes_block(irn))) * logf(10));
-#else
- if(is_Block(irn)) {
- return get_block_execfreq(si->execfreqs, irn);
+ if(si->execfreqs) {
+ if(is_Block(irn)) {
+ return get_block_execfreq(si->execfreqs, irn);
+ } else {
+ return get_block_execfreq(si->execfreqs, get_nodes_block(irn));
+ }
} else {
- return get_block_execfreq(si->execfreqs, get_nodes_block(irn));
+ if(is_Block(irn))
+ return exp(get_loop_depth(get_irn_loop(irn)) * log(10));
+ else
+ return exp(get_loop_depth(get_irn_loop(get_nodes_block(irn))) * log(10));
}
-#endif
}
/**
remat = obstack_alloc(si->obst, sizeof(*remat));
remat->op = op;
- remat->cost = COST_REMAT; /* TODO ask backend for real cost */
+ remat->cost = arch_get_op_estimated_cost(si->chordal_env->birg->main_env->arch_env, op);
remat->value = dest_value;
remat->proj = proj;
remat->inverse = 0;
}
}
- set_irn_link(bb, (void*)pset_count(live));
+ set_irn_link(bb, INT_TO_PTR(pset_count(live)));
sched_foreach_reverse(bb, irn) {
if(is_Phi(irn)) {
- set_irn_link(irn, (void*)pset_count(live));
+ set_irn_link(irn, INT_TO_PTR(pset_count(live)));
continue;
}
if(has_reg_class(si, arg)) pset_insert_ptr(live, arg);
}
- set_irn_link(irn, (void*)pset_count(live)+projs);
+ set_irn_link(irn, INT_TO_PTR(pset_count(live)+projs));
}
del_pset(live);
walker_reload_mover(ir_node * bb, void * data)
{
spill_ilp_t *si = data;
- ir_node *irn;
+ ir_node *tmp;
- sched_foreach(bb, irn) {
- if(be_is_Reload(irn) && has_reg_class(si, irn)) {
- ir_node *reload = irn;
- ir_node *irn = irn;
+ sched_foreach(bb, tmp) {
+ if(be_is_Reload(tmp) && has_reg_class(si, tmp)) {
+ ir_node *reload = tmp;
+ ir_node *irn = tmp;
/* move reload upwards */
while(pressure < si->n_regs) {
if(sched_is_end(irn) || (be_is_Reload(irn) && has_reg_class(si, irn))) break;
- set_irn_link(irn, (void*)(pressure+1));
+ set_irn_link(irn, INT_TO_PTR(pressure+1));
DBG((si->dbg, LEVEL_5, "new regpressure before %+F: %d\n", irn, pressure+1));
irn = sched_prev(irn);
si.inverse_ops = pset_new_ptr_default();
#ifndef EXECFREQ_LOOPDEPH
si.execfreqs = compute_execfreq(chordal_env->irg);
+#else
+ si.execfreqs = NULL;
#endif
#ifdef KEEPALIVE
si.keep = NULL;
del_pset(si.inverse_ops);
del_pset(si.all_possible_remats);
#ifndef EXECFREQ_LOOPDEPH
- del_set(si.execfreqs);
+ free_execfreq(si.execfreqs);
#endif
free_lpp(si.lpp);
obstack_free(&obst, NULL);