const arch_register_req_t *req;
ci->adm_cache = bitset_obstack_alloc(phase_obst(&env->ph), env->n_regs);
req = arch_get_register_req_out(ci->irn);
const arch_register_req_t *req;
ci->adm_cache = bitset_obstack_alloc(phase_obst(&env->ph), env->n_regs);
req = arch_get_register_req_out(ci->irn);
- for(i = 0; i < n; ++i) {
- if(rbitset_is_set(req->limited, i))
+ for (i = 0; i < n; ++i) {
+ if (rbitset_is_set(req->limited, i))
col_t col = get_col(env, n->irn);
col_costs[col].costs = add_saturated(col_costs[col].costs, -n->costs * 128);
}
col_t col = get_col(env, n->irn);
col_costs[col].costs = add_saturated(col_costs[col].costs, -n->costs * 128);
}
it = be_ifg_neighbours_iter_alloca(ifg);
be_ifg_foreach_neighbour(ifg, it, irn, pos) {
col_t col = get_col(env, pos);
it = be_ifg_neighbours_iter_alloca(ifg);
be_ifg_foreach_neighbour(ifg, it, irn, pos) {
col_t col = get_col(env, pos);
DBG((env->dbg, LEVEL_3, "\t\t%2{firm:indent}trying color %d(%d) on %+F\n", depth, tgt_col, costs, irn));
/* If the costs for that color (and all successive) are infinite, bail out we won't make it anyway. */
DBG((env->dbg, LEVEL_3, "\t\t%2{firm:indent}trying color %d(%d) on %+F\n", depth, tgt_col, costs, irn));
/* If the costs for that color (and all successive) are infinite, bail out we won't make it anyway. */
DB((env->dbg, LEVEL_4, "\t\t%2{firm:indent}color %d infeasible\n", depth, tgt_col));
ci->tmp_fixed = 0;
return 0;
DB((env->dbg, LEVEL_4, "\t\t%2{firm:indent}color %d infeasible\n", depth, tgt_col));
ci->tmp_fixed = 0;
return 0;
be_ifg_foreach_neighbour(ifg, it, irn, n) {
/* try to re-color the neighbor if it has the target color. */
be_ifg_foreach_neighbour(ifg, it, irn, n) {
/* try to re-color the neighbor if it has the target color. */
INIT_LIST_HEAD(&tmp);
neigh_ok = change_color_not(env, n, tgt_col, &tmp, depth + 1);
list_splice(&tmp, &changed);
INIT_LIST_HEAD(&tmp);
neigh_ok = change_color_not(env, n, tgt_col, &tmp, depth + 1);
list_splice(&tmp, &changed);
We managed to assign the target color to all neighbors, so from the perspective
of the current node, every thing was ok and we can return safely.
*/
We managed to assign the target color to all neighbors, so from the perspective
of the current node, every thing was ok and we can return safely.
*/
DBG((env->dbg, LEVEL_3, "\t\t%2{firm:indent}color %d(%d) was ok\n", depth, tgt_col, costs));
list_splice(&changed, parent_changed);
res = 1;
DBG((env->dbg, LEVEL_3, "\t\t%2{firm:indent}color %d(%d) was ok\n", depth, tgt_col, costs));
list_splice(&changed, parent_changed);
res = 1;
DBG((env->dbg, LEVEL_3, "\t\t%2{firm:indent}clearing %+F(%d) of color %d\n", depth, irn, col, not_col));
/* the node does not have to forbidden color. That's fine, mark it as visited and return. */
DBG((env->dbg, LEVEL_3, "\t\t%2{firm:indent}clearing %+F(%d) of color %d\n", depth, irn, col, not_col));
/* the node does not have to forbidden color. That's fine, mark it as visited and return. */
int n_regs = env->co->cls->n_regs;
col_cost_pair_t *csts = ALLOCAN(col_cost_pair_t, n_regs);
int n_regs = env->co->cls->n_regs;
col_cost_pair_t *csts = ALLOCAN(col_cost_pair_t, n_regs);
DBG((env->dbg, LEVEL_3, "\t\t%2{firm:indent}trying to set %+F(%d) to color %d\n", depth, irn, col, tgt_col));
/* the node has the wanted color. That's fine, mark it as visited and return. */
DBG((env->dbg, LEVEL_3, "\t\t%2{firm:indent}trying to set %+F(%d) to color %d\n", depth, irn, col, tgt_col));
/* the node has the wanted color. That's fine, mark it as visited and return. */
- if(!color_is_fix(env, irn) && is_color_admissible(env, ci, tgt_col)) {
+ if (!color_is_fix(env, irn) && is_color_admissible(env, ci, tgt_col)) {
int n_regs = env->co->cls->n_regs;
col_cost_pair_t *seq = ALLOCAN(col_cost_pair_t, n_regs);
int n_regs = env->co->cls->n_regs;
col_cost_pair_t *seq = ALLOCAN(col_cost_pair_t, n_regs);
co2_irn_t *ni = get_co2_irn(env, irn);
admissible_colors(env, ni, bs);
co2_irn_t *ni = get_co2_irn(env, irn);
admissible_colors(env, ni, bs);
node_color_badness(ci, ci->color_badness);
/* Collect the color badness for the whole subtree */
node_color_badness(ci, ci->color_badness);
/* Collect the color badness for the whole subtree */
co2_cloud_irn_t *child = ci->mst_childs[i];
determine_color_badness(child, depth + 1);
co2_cloud_irn_t *child = ci->mst_childs[i];
determine_color_badness(child, depth + 1);
DBG((env->dbg, LEVEL_2, "%2{firm:indent}%+F col %d badness %d\n", depth, ci->inh.irn, j, ci->color_badness[j]));
}
DBG((env->dbg, LEVEL_2, "%2{firm:indent}%+F col %d badness %d\n", depth, ci->inh.irn, j, ci->color_badness[j]));
}
seq[parent_col].costs = min_badness - 1;
/* Sort the colors. The will be processed in that ordering. */
seq[parent_col].costs = min_badness - 1;
/* Sort the colors. The will be processed in that ordering. */
DBG((env->dbg, LEVEL_2, "\t%2{firm:indent}starting top-down coalesce for %+F\n", depth, ci->inh.irn));
INIT_LIST_HEAD(&changed);
DBG((env->dbg, LEVEL_2, "\t%2{firm:indent}starting top-down coalesce for %+F\n", depth, ci->inh.irn));
INIT_LIST_HEAD(&changed);
unfix_subtree(ci);
INIT_LIST_HEAD(&changed);
ok = change_color_single(env, ci->inh.irn, col, &changed, depth);
unfix_subtree(ci);
INIT_LIST_HEAD(&changed);
ok = change_color_single(env, ci->inh.irn, col, &changed, depth);
co2_cloud_irn_t *child = ci->mst_childs[j];
ok = coalesce_top_down(child, j, depth + 1) >= 0;
co2_cloud_irn_t *child = ci->mst_childs[j];
ok = coalesce_top_down(child, j, depth + 1) >= 0;
continue;
subtree_costs = examine_subtree_coloring(ci, col);
sum_costs = subtree_costs + add_cost;
DBG((env->dbg, LEVEL_2, "\t%2{firm:indent}-> %+F costing %d + %d is ok.\n", depth, ci->inh.irn, subtree_costs, add_cost));
continue;
subtree_costs = examine_subtree_coloring(ci, col);
sum_costs = subtree_costs + add_cost;
DBG((env->dbg, LEVEL_2, "\t%2{firm:indent}-> %+F costing %d + %d is ok.\n", depth, ci->inh.irn, subtree_costs, add_cost));
int *front = FRONT_BASE(ci->mst_parent, parent_col);
front[child_nr] = best_col;
}
int *front = FRONT_BASE(ci->mst_parent, parent_col);
front[child_nr] = best_col;
}
co_gs_foreach_neighb(a, n) {
costs += n->costs;
DB((env->dbg, LEVEL_3, "\t\tneigh %+F cost %d\n", n->irn, n->costs));
co_gs_foreach_neighb(a, n) {
costs += n->costs;
DB((env->dbg, LEVEL_3, "\t\tneigh %+F cost %d\n", n->irn, n->costs));
// assert(ok && "Color changing may not fail while committing the coloring");
materialize_coloring(&changed);
// assert(ok && "Color changing may not fail while committing the coloring");
materialize_coloring(&changed);
apply_coloring(ci->mst_childs[i], front[i], depth + 1);
}
}
static co2_cloud_irn_t *find_mst_root(co2_cloud_irn_t *ci)
{
apply_coloring(ci->mst_childs[i], front[i], depth + 1);
}
}
static co2_cloud_irn_t *find_mst_root(co2_cloud_irn_t *ci)
{
/* Collect all edges in the cloud on an obstack and sort the increasingly */
obstack_init(&cloud->obst);
/* Collect all edges in the cloud on an obstack and sort the increasingly */
obstack_init(&cloud->obst);
co2_cloud_irn_t *ci = cloud->seq[i];
neighb_t *n;
co_gs_foreach_neighb(ci->inh.aff, n) {
co2_cloud_irn_t *ni = get_co2_cloud_irn(cloud->env, n->irn);
co2_cloud_irn_t *ci = cloud->seq[i];
neighb_t *n;
co_gs_foreach_neighb(ci->inh.aff, n) {
co2_cloud_irn_t *ni = get_co2_cloud_irn(cloud->env, n->irn);
/* Compute the maximum spanning tree using Kruskal/Union-Find */
DBG((env->dbg, LEVEL_2, "computing spanning tree of cloud with master %+F\n", cloud->master->inh.irn));
/* Compute the maximum spanning tree using Kruskal/Union-Find */
DBG((env->dbg, LEVEL_2, "computing spanning tree of cloud with master %+F\n", cloud->master->inh.irn));
edge_t *e = &edges[i];
co2_cloud_irn_t *rs = find_mst_root(e->src);
co2_cloud_irn_t *rt = find_mst_root(e->tgt);
/* if the union/find roots are different */
edge_t *e = &edges[i];
co2_cloud_irn_t *rs = find_mst_root(e->src);
co2_cloud_irn_t *rt = find_mst_root(e->tgt);
/* if the union/find roots are different */
cloud->master->mst_parent = cloud->master;
cloud->mst_root = cloud->master;
q = new_pdeq1(cloud->master);
cloud->master->mst_parent = cloud->master;
cloud->mst_root = cloud->master;
q = new_pdeq1(cloud->master);
co2_cloud_irn_t *ci = pdeq_getl(q);
int ofs = ci->index * cloud->n_memb;
int end = ofs + cloud->n_memb;
int i;
ci->mst_n_childs = 0;
co2_cloud_irn_t *ci = pdeq_getl(q);
int ofs = ci->index * cloud->n_memb;
int end = ofs + cloud->n_memb;
int i;
ci->mst_n_childs = 0;
DEBUG_ONLY(co2_cloud_irn_t *ci = cloud->seq[i]);
DBG((env->dbg, LEVEL_3, "\t%+F -> %+F\n", ci->inh.irn, ci->mst_parent->inh.irn));
}
DEBUG_ONLY(co2_cloud_irn_t *ci = cloud->seq[i]);
DBG((env->dbg, LEVEL_3, "\t%+F -> %+F\n", ci->inh.irn, ci->mst_parent->inh.irn));
}
ci->fronts = OALLOCNZ(&cloud->obst, int, n_regs * n_childs);
ci->color_badness = OALLOCNZ(&cloud->obst, int, n_regs);
ci->fronts = OALLOCNZ(&cloud->obst, int, n_regs * n_childs);
ci->color_badness = OALLOCNZ(&cloud->obst, int, n_regs);
cloud->mst_root->inh.irn, best_col, examine_subtree_coloring(cloud->mst_root, best_col)));
/* Fix all nodes in the cloud. */
cloud->mst_root->inh.irn, best_col, examine_subtree_coloring(cloud->mst_root, best_col)));
/* Fix all nodes in the cloud. */
co2_irn_t *ci = (co2_irn_t *) cloud->seq[i];
col_t col = get_col(cloud->env, ci->irn);
co_gs_foreach_neighb(ci->aff, n) {
co2_irn_t *ci = (co2_irn_t *) cloud->seq[i];
col_t col = get_col(cloud->env, ci->irn);
co_gs_foreach_neighb(ci->aff, n) {
co_gs_foreach_aff_node(env->co, a) {
co2_cloud_irn_t *ci = get_co2_cloud_irn(env, a->irn);
co_gs_foreach_aff_node(env->co, a) {
co2_cloud_irn_t *ci = get_co2_cloud_irn(env, a->irn);
clouds[i++] = pos;
qsort(clouds, n_clouds, sizeof(clouds[0]), cmp_clouds_gt);
clouds[i++] = pos;
qsort(clouds, n_clouds, sizeof(clouds[0]), cmp_clouds_gt);
ir_snprintf(buf, sizeof(buf), "ifg_%F_%s_cloud_%d.dot", env->co->irg, env->co->cls->name, i);
f = fopen(buf, "wt");
ir_snprintf(buf, sizeof(buf), "ifg_%F_%s_cloud_%d.dot", env->co->irg, env->co->cls->name, i);
f = fopen(buf, "wt");
be_ifg_dump_dot(env->co->cenv->ifg, env->co->irg, f, &ifg_dot_cb, env);
fclose(f);
}
be_ifg_dump_dot(env->co->cenv->ifg, env->co->irg, f, &ifg_dot_cb, env);
fclose(f);
}
const arch_register_t *reg = arch_register_for_index(env->co->cls, irn->orig_col);
arch_set_irn_register((ir_node*)irn->irn, reg);
}
const arch_register_t *reg = arch_register_for_index(env->co->cls, irn->orig_col);
arch_set_irn_register((ir_node*)irn->irn, reg);
}
ir_snprintf(buf, sizeof(buf), "%+F", cci->cloud->mst_root->inh.irn);
}
ir_snprintf(buf, sizeof(buf), "%+F", cci->cloud->mst_root->inh.irn);
}
fprintf(file, "\tn%d -- n%d [style=dotted color=blue arrowhead=normal];\n", idx, get_irn_idx(ai->mst_parent->inh.irn));
co_gs_foreach_neighb(a, n) {
int nidx = get_irn_idx(n->irn);
co2_cloud_irn_t *ci = get_co2_cloud_irn(env, n->irn);
fprintf(file, "\tn%d -- n%d [style=dotted color=blue arrowhead=normal];\n", idx, get_irn_idx(ai->mst_parent->inh.irn));
co_gs_foreach_neighb(a, n) {
int nidx = get_irn_idx(n->irn);
co2_cloud_irn_t *ci = get_co2_cloud_irn(env, n->irn);
const char *color = get_col(env, a->irn) == get_col(env, n->irn) ? "black" : "red";
const char *arr = "arrowhead=dot arrowtail=dot";
const char *color = get_col(env, a->irn) == get_col(env, n->irn) ? "black" : "red";
const char *arr = "arrowhead=dot arrowtail=dot";
arr = "arrowhead=normal";
fprintf(file, "\tn%d -- n%d [label=\"%d\" %s style=dashed color=%s weight=0.01];\n", idx, nidx, n->costs, arr, color);
arr = "arrowhead=normal";
fprintf(file, "\tn%d -- n%d [label=\"%d\" %s style=dashed color=%s weight=0.01];\n", idx, nidx, n->costs, arr, color);
FIRM_DBG_REGISTER(env.dbg, "firm.be.co2");
INIT_LIST_HEAD(&env.cloud_head);
FIRM_DBG_REGISTER(env.dbg, "firm.be.co2");
INIT_LIST_HEAD(&env.cloud_head);
ir_snprintf(buf, sizeof(buf), "ifg_%F_%s_before.dot", co->irg, co->cls->name);
f = fopen(buf, "wt");
if (f != NULL) {
ir_snprintf(buf, sizeof(buf), "ifg_%F_%s_before.dot", co->irg, co->cls->name);
f = fopen(buf, "wt");
if (f != NULL) {
ir_snprintf(buf, sizeof(buf), "ifg_%F_%s_after.dot", co->irg, co->cls->name);
f = fopen(buf, "wt");
if (f != NULL) {
ir_snprintf(buf, sizeof(buf), "ifg_%F_%s_after.dot", co->irg, co->cls->name);
f = fopen(buf, "wt");
if (f != NULL) {
lc_opt_entry_t *chordal_grp = lc_opt_get_grp(ra_grp, "chordal");
lc_opt_entry_t *co2_grp = lc_opt_get_grp(chordal_grp, "co2");
lc_opt_entry_t *chordal_grp = lc_opt_get_grp(ra_grp, "chordal");
lc_opt_entry_t *co2_grp = lc_opt_get_grp(chordal_grp, "co2");
static co_algo_info copyheur = {
co_solve_heuristic_new, 0
};
static co_algo_info copyheur = {
co_solve_heuristic_new, 0
};