* Date: 17.05.2005
* Copyright: (c) Universitaet Karlsruhe
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+ * CVS-ID: $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
return res;
assert(0 && "One of them must work");
+ return -1;
}
static void check_ecc_and_add_cut(problem_instance_t *pi, ir_node **path, int length, pset *remain, ir_node *tgt) {
problem_instance_t *pi = env;
be_chordal_env_t *cenv;
int i, o, max;
- ir_node *m;
+ ir_node *m, **cls;
pset *class = get_phi_class(irn);
if (!class || pset_find_ptr(pi->done, class))
return;
/* pset to array */
max = pset_count(class);
- ir_node **cls = alloca(max * sizeof(*cls));
+ cls = alloca(max * sizeof(*cls));
for(i=0, m = pset_first(class); m; i++, m = pset_next(class)) {
DBG((dbg, LEVEL_1, " class member: %+F\n", m));
cls[i] = m;
* Invoke a solver
*/
static void pi_solve_ilp(problem_instance_t *pi) {
+ double lower_bound;
+
pi_set_start_sol(pi);
- double lower_bound = co_get_lower_bound(pi->co) - co_get_inevit_copy_costs(pi->co);
+ lower_bound = co_get_lower_bound(pi->co) - co_get_inevit_copy_costs(pi->co);
lpp_set_bound(pi->curr_lp, lower_bound);
lpp_solve_net(pi->curr_lp, LPP_HOST, LPP_SOLVER);
// lpp_solve_cplex(pi->curr_lp);
copy_opt_t *co;
int costs, costs_init=-1, costs_heur=-1, costs_ilp_5_sec=-1, costs_ilp_30_sec=-1, costs_ilp=-1;
int lower_bound;
+ int was_optimal = 0;
color_save_t saver;
+
saver.arch_env = chordal_env->session_env->main_env->arch_env;
saver.chordal_env = chordal_env;
saver.saved_colors = pmap_create();
save_colors(&saver);
#ifdef DO_HEUR
- lc_timer_t *timer = lc_timer_register("heur", NULL);
- lc_timer_reset_and_start(timer);
- co_heur_opt(co);
- lc_timer_stop(timer);
- copystat_add_heur_time(lc_timer_elapsed_msec(timer));
+ {
+ lc_timer_t *timer = lc_timer_register("heur", NULL);
+ lc_timer_reset_and_start(timer);
+ co_heur_opt(co);
+ lc_timer_stop(timer);
+ copystat_add_heur_time(lc_timer_elapsed_msec(timer));
+ }
#ifdef DO_STAT
costs = co_get_copy_costs(co);
costs_heur = costs;
assert(lower_bound == -1 || costs_heur == -1 || lower_bound <= costs_heur);
#endif
- int was_optimal = 0;
-
#ifdef DO_ILP_5_SEC
load_colors(&saver);
was_optimal = co_ilp_opt(co, 5.0);
* Copyright: (c) Universitaet Karlsruhe
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef HAVE_ALLOCA_H
#include <alloca.h>
+#endif
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
#include "obst.h"
#include "set.h"
#include "pset.h"
static int is_mem_phi(const ir_node *irn, void *data) {
+ workset_t *sws;
ir_node *blk = get_nodes_block(irn);
+
DBG((dbg, DBG_SPILL, "Is %+F a mem-phi?\n", irn));
- workset_t *sws = ((block_info_t *)get_irn_link(blk))->ws_start;
+ sws = ((block_info_t *)get_irn_link(blk))->ws_start;
DBG((dbg, DBG_SPILL, " %d\n", !workset_contains(sws, irn)));
return !workset_contains(sws, irn);
}
}
/**
- * 'decide' is block-local and makes assumtions
+ * 'decide' is block-local and makes assumptions
* about the set of live-ins. Thus we must adapt the
* live-outs to the live-ins at each block-border.
*/
static void fix_block_borders(ir_node *blk, void *env) {
belady_env_t *bel = env;
int i, max;
+ workset_t *wsb;
DBG((dbg, DBG_FIX, "\n"));
DBG((dbg, DBG_FIX, "Fixing %+F\n", blk));
- workset_t *wsb = ((block_info_t *)get_irn_link(blk))->ws_start;
+ wsb = ((block_info_t *)get_irn_link(blk))->ws_start;
/* process all pred blocks */
for (i=0, max=get_irn_arity(blk); i<max; ++i) {
irg_walk_graph(irg, rescue_used_reloads, NULL, bel->reloads);
for(irn = pset_first(bel->reloads); irn; irn = pset_next(bel->reloads)) {
+ ir_node *spill;
DBG((dbg, DBG_SPILL, "Removing %+F before %+F in %+F\n", irn, sched_next(irn), get_nodes_block(irn)));
- ir_node *spill = get_irn_n(irn, 0);
+ spill = get_irn_n(irn, 0);
- /* remove reaload */
+ /* remove reload */
set_irn_n(irn, 0, new_Bad());
sched_remove(irn);
}
void be_spill_belady(const be_main_session_env_t *session, const arch_register_class_t *cls) {
+ belady_env_t bel;
dbg = firm_dbg_register("ir.be.spillbelady");
firm_dbg_set_mask(dbg, DEBUG_LVL);
/* init belady env */
- belady_env_t *bel = alloca(sizeof(*bel));
- obstack_init(&bel->ob);
- bel->factory = session->main_env->node_factory;
- bel->arch = session->main_env->arch_env;
- bel->cls = cls;
- bel->n_regs = arch_register_class_n_regs(cls);
- bel->ws = new_workset(&bel->ob, bel);
- bel->uses = be_begin_uses(session->irg, session->main_env->arch_env, cls);
- bel->senv = be_new_spill_env(dbg, session, cls, is_mem_phi, NULL);
- bel->reloads = pset_new_ptr_default();
+ obstack_init(&bel.ob);
+ bel.factory = session->main_env->node_factory;
+ bel.arch = session->main_env->arch_env;
+ bel.cls = cls;
+ bel.n_regs = arch_register_class_n_regs(cls);
+ bel.ws = new_workset(&bel.ob, &bel);
+ bel.uses = be_begin_uses(session->irg, session->main_env->arch_env, cls);
+ bel.senv = be_new_spill_env(dbg, session, cls, is_mem_phi, NULL);
+ bel.reloads = pset_new_ptr_default();
/* do the work */
- irg_block_walk_graph(session->irg, decide, NULL, bel);
- irg_block_walk_graph(session->irg, fix_block_borders, NULL, bel);
- be_insert_spills_reloads(bel->senv, bel->reloads);
- remove_unused_reloads(session->irg, bel);
+ irg_block_walk_graph(session->irg, decide, NULL, &bel);
+ irg_block_walk_graph(session->irg, fix_block_borders, NULL, &bel);
+ be_insert_spills_reloads(bel.senv, bel.reloads);
+ remove_unused_reloads(session->irg, &bel);
/* clean up */
- del_pset(bel->reloads);
- be_delete_spill_env(bel->senv);
- be_end_uses(bel->uses);
- obstack_free(&bel->ob, NULL);
+ del_pset(bel.reloads);
+ be_delete_spill_env(bel.senv);
+ be_end_uses(bel.uses);
+ obstack_free(&bel.ob, NULL);
}