-
-int co_get_interferer_count(const copy_opt_t *co) {
- int res = 0;
- unit_t *curr;
- list_for_each_entry(unit_t, curr, &co->units, units)
- res += curr->interf;
- return res;
-}
-
-/**
- * Needed for result checking
- */
-static void co_collect_for_checker(ir_node *block, void *env) {
- copy_opt_t *co = env;
- struct list_head *head = get_block_border_head(co->chordal_env, block);
- border_t *curr;
-
- list_for_each_entry_reverse(border_t, curr, head, list)
- if (curr->is_def && curr->is_real && is_curr_reg_class(curr->irn))
- obstack_ptr_grow(&co->ob, curr->irn);
-}
-
-/**
- * This O(n^2) checker checks if
- * two ifg-connected nodes have the same color
- * register constraint are satisfied
- */
-void co_check_allocation(copy_opt_t *co) {
- ir_node **nodes, *n1, *n2;
- int i, o;
-
- obstack_init(&co->ob);
- dom_tree_walk_irg(co->chordal_env->irg, co_collect_for_checker, NULL, co);
- obstack_ptr_grow(&co->ob, NULL);
-
- nodes = (ir_node **) obstack_finish(&co->ob);
- for (i = 0, n1 = nodes[i]; n1; n1 = nodes[++i]) {
- assert(arch_reg_is_allocatable(co->chordal_env->arch_env, n1, arch_pos_make_out(0),
- arch_get_irn_register(co->chordal_env->arch_env, n1, 0)) && "Constraint does not hold");
- for (o = i+1, n2 = nodes[o]; n2; n2 = nodes[++o])
- if (nodes_interfere(co->chordal_env, n1, n2)
- && get_irn_col(co, n1) == get_irn_col(co, n2)) {
- DBG((dbg, 0, "Error in graph %s: %n %d and %n %d have the same color %d.\n", co->name, n1, get_irn_graph_nr(n1), n2, get_irn_graph_nr(n2), get_irn_col(co, n1)));
- assert(0 && "Interfering values have the same color!");
- }
- }
- obstack_free(&co->ob, NULL);
- DBG((dbg, 2, "The checker seems to be happy!\n"));
-}