-/**
- * Checks if a node is simplicial in the graph
- * heeding the already removed nodes.
- */
-static INLINE int pi_is_simplicial(problem_instance_t *pi, const ir_node *ifn) {
- int i, o, size = 0;
- ir_node **all, *curr;
- be_ifg_t *ifg = pi->co->cenv->ifg;
- void *iter = be_ifg_neighbours_iter_alloca(ifg);
-
- all = alloca(be_ifg_degree(ifg, ifn) * sizeof(*all));
-
- /* get all non-removed neighbors */
- be_ifg_foreach_neighbour(ifg, iter, ifn, curr)
- if (!is_removed(curr))
- all[size++] = curr;
-
- /* check if these form a clique */
- for (i=0; i<size; ++i)
- for (o=i+1; o<size; ++o)
- if (!be_ifg_connected(ifg, all[i], all[o]))
- return 0;
-
- /* all edges exist so this is a clique */
- return 1;
-}
-
-static int irn_cmp(const void *a, const void *b, size_t n)
-{
- return a != b;
-}
-
-/**
- * Iterative finds and 'removes' from the graph all nodes which are
- * simplicial AND not member of a equal-color-wish
- */
-static void pi_find_simplicials(problem_instance_t *pi) {
- ir_node *irn;
- int redo = 1;
- int n_nodes = 0;
- const be_ifg_t *ifg = pi->co->cenv->ifg;
- void *iter = be_ifg_neighbours_iter_alloca(ifg);
-
- DBG((dbg, LEVEL_2, "Find simlicials...\n"));
-
- while (redo) {
- arch_register_req_t req;
- redo = 0;
- be_ifg_foreach_node(ifg, iter, irn) {
- if (!is_removed(irn) && !co_is_optimizable(pi->co->aenv, irn, &req) && !co_is_optimizable_arg(pi->co, irn)) {
- if (pi_is_simplicial(pi, irn)) {
- simpl_t *s = xmalloc(sizeof(*s));
- s->irn = irn;
- list_add(&s->chain, &pi->simplicials);
- pset_insert_ptr(pi->removed, irn);
- redo = 1;
- DBG((dbg, LEVEL_2, " Removed %+F\n", irn));
- }
- }
- }
- }
-
- /* TODO: Count inside the last look */
- be_ifg_foreach_node(ifg, iter, irn) {
- n_nodes++;
- }
-
- if (n_nodes == pset_count(pi->removed))
- pi->all_simplicial = 1;
-}
-
-#ifdef NO_NULL_COLORS
-static void pi_add_constr_no_null_colors(problem_instance_t *pi) {
- int cst_counter=0, col, var_idx, cst_idx;
- int n_colors = pi->co->chordal_env->cls->n_regs;
- char buf[40];
-
- for (col = 0; col < n_colors; ++col) {
- mangle_var1(buf, 'u', col);
-#ifdef NO_NULL_COLORS_WITH_COSTS
- var_idx = lpp_add_var(pi->curr_lp, buf, lpp_binary, 1.0 / (double) (1 << (col+1)) );
-#else
- var_idx = lpp_add_var(pi->curr_lp, buf, lpp_binary, 1.0 / (2.0 * n_colors) );
-#endif
- if (!pi->first_nnc_var_idx)
- pi->first_nnc_var_idx = var_idx;
- }
-
-#ifdef NO_NULL_COLORS_EXTRA_CSTS
- for (col = 0; col < n_colors; ++col) {
- mangle_cst(buf, 'U', cst_counter++);
- cst_idx = lpp_add_cst(pi->curr_lp, buf, lpp_greater, 0);
- if (!pi->first_nnc_cst_idx)
- pi->first_nnc_cst_idx = cst_idx;
- lpp_set_factor_fast(pi->curr_lp, cst_idx, pi->first_nnc_var_idx+col, -1);
- }
-#endif
-
-#ifndef NO_NULL_COLORS_WITH_COSTS
- for (col = 0; col < n_colors - 1; ++col) {
- mangle_cst(buf, 'U', cst_counter++);
- cst_idx = lpp_add_cst(pi->curr_lp, buf, lpp_greater, 0);
- lpp_set_factor_fast(pi->curr_lp, cst_idx, pi->first_nnc_var_idx+col , 1);
- lpp_set_factor_fast(pi->curr_lp, cst_idx, pi->first_nnc_var_idx+col+1, -1);
- }
-#endif
-
-}
-#endif
-