-/**
- * Generates constraints which interrelate x with y variables.
- * x1 and x2 have the different colors ==> y_12 = 1
- */
-static void pi_add_constr_E(problem_instance_t *pi) {
- unit_t *curr;
- bitset_t *root_regs, *arg_regs;
- int cst_counter = 0;
- unsigned nregs = pi->co->chordal_env->cls->n_regs;
- root_regs = bitset_alloca(nregs);
- arg_regs = bitset_alloca(nregs);
-
- DBG((dbg, LEVEL_2, "Add E constraints...\n"));
- /* for all roots of optimization units */
- list_for_each_entry(unit_t, curr, &pi->co->units, units) {
- ir_node *root, *arg;
- int rootnr, argnr, color;
- int y_idx, i;
- char buf[32];
-
- root = curr->nodes[0];
- rootnr = get_irn_graph_nr(root);
- bitset_clear_all(root_regs);
- arch_get_allocatable_regs(pi->co->chordal_env->arch_env, root, arch_pos_make_out(0), pi->co->chordal_env->cls, root_regs);
-
- /* for all arguments of root */
- for (i = 1; i < curr->node_count; ++i) {
- arg = curr->nodes[i];
- argnr = get_irn_graph_nr(arg);
- bitset_clear_all(arg_regs);
- arch_get_allocatable_regs(pi->co->chordal_env->arch_env, arg, arch_pos_make_out(0), pi->co->chordal_env->cls, arg_regs);
-
- /* Introduce new variable and set factor in objective function */
- mangle_var(buf, 'y', rootnr, argnr);
- y_idx = lpp_add_var(pi->curr_lp, buf, continous, curr->costs[i]);
-
- /* set starting value */
- //lpp_set_start_value(pi->curr_lp, y_idx, (get_irn_col(pi->co, root) != get_irn_col(pi->co, arg)));
-
- /* For all colors root and arg have in common, add 2 constraints to E */
- bitset_and(arg_regs, root_regs);
- bitset_foreach(arg_regs, color) {
- int root_idx, arg_idx, cst_idx;
- mangle_var(buf, 'x', rootnr, color);
- root_idx = lpp_get_var_idx(pi->curr_lp, buf);
- mangle_var(buf, 'x', argnr, color);
- arg_idx = lpp_get_var_idx(pi->curr_lp, buf);
-
- /* add root-arg-y <= 0 */
- mangle_cst(buf, 'E', cst_counter++);
- cst_idx = lpp_add_cst(pi->curr_lp, buf, less, 0);
- lpp_set_factor_fast(pi->curr_lp, cst_idx, root_idx, 1);
- lpp_set_factor_fast(pi->curr_lp, cst_idx, arg_idx, -1);
- lpp_set_factor_fast(pi->curr_lp, cst_idx, y_idx, -1);
-
- /* add arg-root-y <= 0 */
- mangle_cst(buf, 'E', cst_counter++);
- cst_idx = lpp_add_cst(pi->curr_lp, buf, less, 0);
- lpp_set_factor_fast(pi->curr_lp, cst_idx, root_idx, -1);
- lpp_set_factor_fast(pi->curr_lp, cst_idx, arg_idx, 1);
- lpp_set_factor_fast(pi->curr_lp, cst_idx, y_idx, -1);
- }
- /* TODO:
- * \forall c \in p(v_i) \ p(v_j)
- * y_ij >= x_ic
- * \forall c \in p(v_j) \ p(v_i)
- * y_ij >= x_jc
- */
+void sr_reinsert(size_red_t *sr) {
+ coloring_suffix_t *cs;
+ be_ifg_t *ifg = sr->co->cenv->ifg;
+ bitset_t *used_cols = bitset_alloca(arch_register_class_n_regs(sr->co->cls));
+ void *iter = be_ifg_neighbours_iter_alloca(ifg);
+
+ /* color the removed nodes in right order */
+ for (cs = sr->col_suff; cs; cs = cs->next) {
+ int free_col;
+ ir_node *other, *irn;
+
+ /* get free color by inspecting all neighbors */
+ irn = cs->irn;
+ bitset_clear_all(used_cols);
+
+ be_ifg_foreach_neighbour(ifg, iter, irn, other) {
+ if (!sr_is_removed(sr, other)) /* only inspect nodes which are in graph right now */
+ bitset_set(used_cols, get_irn_col(sr->co, other));