Commit 9eed6245 authored by Daniel Grund's avatar Daniel Grund
Browse files

enabled right defines

parent 2f10d963
......@@ -31,7 +31,7 @@
#include "becopystat.h"
#define QUICK_AND_DIRTY_HACK
#undef QUICK_AND_DIRTY_HACK
/******************************************************************************
_____ _
......@@ -390,10 +390,12 @@ static int compare_ous(const void *k1, const void *k2) {
return u2_has_constr - u1_has_constr;
/* Now check, whether the two units are connected */
#if 0
for (i=0; i<u1->node_count; ++i)
for (o=0; o<u2->node_count; ++o)
if (u1->nodes[i] == u2->nodes[o])
return 0;
#endif
/* After all, the sort key decides. Greater keys come first. */
return u2->sort_key - u1->sort_key;
......@@ -404,27 +406,38 @@ static int compare_ous(const void *k1, const void *k2) {
* Sort the ou's according to constraints and their sort_key
*/
static void co_sort_units(copy_opt_t *co) {
int i, count = 0;
unit_t *tmp, *ou, **ous;
int i, count = 0, costs;
unit_t *ou, **ous;
/* get the number of ous, remove them form the list and fill the array */
list_for_each_entry(unit_t, ou, &co->units, units)
count++;
ous = alloca(count * sizeof(*ous));
costs = co_get_max_copy_costs(co);
i = 0;
list_for_each_entry_safe(unit_t, ou, tmp, &co->units, units) {
list_for_each_entry(unit_t, ou, &co->units, units)
ous[i++] = ou;
list_del(&ou->units);
}
assert(count == i);
INIT_LIST_HEAD(&co->units);
assert(count == i && list_empty(&co->units));
for (i=0; i<count; ++i)
ir_printf("%+F\n", ous[i]->nodes[0]);
qsort(ous, count, sizeof(*ous), compare_ous);
ir_printf("\n\n");
for (i=0; i<count; ++i)
ir_printf("%+F\n", ous[i]->nodes[0]);
/* reinsert into list in correct order */
for (i=0; i<count; ++i)
list_add_tail(&ous[i]->units, &co->units);
assert(costs == co_get_max_copy_costs(co));
}
#endif
......
......@@ -27,6 +27,7 @@
#include "benode_t.h"
#include "bechordal_t.h"
#undef REMAT
/* This enables re-computation of values. Current state: Unfinished and buggy. */
#undef BUGGY_REMAT
......@@ -182,6 +183,7 @@ static void phi_walker(ir_node *irn, void *env) {
}
}
#ifdef REMAT
#ifdef BUGGY_REMAT
......@@ -237,6 +239,18 @@ is_alive: ;
return 1;
}
#else /* BUGGY_REMAT */
static int check_remat_conditions(spill_env_t *senv, ir_node *spill, ir_node *spilled, ir_node *reloader) {
const arch_env_t *aenv = senv->chordal_env->birg->main_env->arch_env;
return get_irn_arity(spilled) == 0 &&
be_is_Spill(spill) &&
arch_irn_is(aenv, spilled, rematerializable);
}
#endif /* BUGGY_REMAT */
static ir_node *do_remat(spill_env_t *senv, ir_node *spilled, ir_node *reloader) {
ir_node *res;
ir_node *bl = (is_Block(reloader)) ? reloader : get_nodes_block(reloader);
......@@ -247,6 +261,7 @@ static ir_node *do_remat(spill_env_t *senv, ir_node *spilled, ir_node *reloader)
get_irn_mode(spilled),
get_irn_arity(spilled),
get_irn_in(spilled));
copy_node_attr(spilled, res);
DBG((senv->dbg, LEVEL_1, "Insert remat %+F before reloader %+F\n", res, reloader));
......@@ -304,7 +319,7 @@ void be_insert_spills_reloads(spill_env_t *senv, pset *reload_set) {
/* the spill for this reloader */
ir_node *spill = be_spill_node(senv, si->spilled_node);
#ifdef BUGGY_REMAT
#ifdef REMAT
if (check_remat_conditions(senv, spill, si->spilled_node, rld->reloader))
new_val = do_remat(senv, si->spilled_node, rld->reloader);
else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment