#define is_curr_reg_class(irn) (arch_get_irn_reg_class(co->chordal_env->arch_env, irn, arch_pos_make_out(0)) == co->chordal_env->cls)
#define MIN(a,b) ((a<b)?(a):(b))
+#define MAX(a,b) ((a<b)?(b):(a))
/**
* Computes the weight of a 'max independent set' wrt. ifg-edges only
while ((max = bitset_popcnt(curr)) != 0) {
/* check if curr is a stable set */
int i, o, is_stable_set = 1;
+
+ /* copy the irns */
+ i = 0;
bitset_foreach(curr, pos)
- irns[pos] = ou->nodes[1+pos];
+ irns[i++] = ou->nodes[1+pos];
+ assert(i==max);
+
for(i=0; i<max; ++i)
for(o=i+1; o<max; ++o) /* !!!!! difference to qnode_max_ind_set(): NOT o=i */
if (nodes_interfere(ou->co->chordal_env, irns[i], irns[o])) {
unit->costs = xmalloc((arity+1) * sizeof(*unit->costs));
unit->nodes[0] = root;
unit->complete_costs = 0;
- unit->avg_costs = 0;
+ unit->sort_key = 0;
INIT_LIST_HEAD(&unit->queue);
/* check all args */
int o, arg_pos = 0;
if (nodes_interfere(co->chordal_env, root, arg))
assert(0 && "root and arg interfere");
- //TODO do not insert duplicate args
DBG((dbg, LEVEL_1, "\t Member: %n %N\n", arg, arg));
/* check if arg has occurred at a prior position in the arg/list */
}
if (!arg_pos) { /* a new argument */
- /* TODO Think about the next 2 lines. (inserting in arg-order) */
- if (is_optimizable(co->chordal_env->arch_env, arg))
- co_append_unit(co, arg);
/* insert node, set costs */
unit->nodes[unit->node_count] = arg;
unit->costs[unit->node_count] = co->get_costs(root, arg, i);
/* TODO add ou's for 2-addr-code instructions */
- for(i=1; i<unit->node_count; ++i)
+ for(i=1; i<unit->node_count; ++i) {
+ unit->sort_key = MAX(unit->sort_key, unit->costs[i]);
unit->complete_costs += unit->costs[i];
-
- assert(unit->node_count > 1);
- unit->avg_costs = (100 * unit->complete_costs) / (unit->node_count-1);
+ }
/* insert according to average costs */
tmp = &co->units;
- while (tmp->next != &co->units && list_entry_units(tmp->next)->avg_costs > unit->avg_costs)
+ while (tmp->next != &co->units && list_entry_units(tmp->next)->sort_key > unit->sort_key)
tmp = tmp->next;
list_add(&unit->units, tmp);