co->irg = chordal_env->irg;
co->cls = chordal_env->cls;
co->get_costs = get_costs;
co->irg = chordal_env->irg;
co->cls = chordal_env->cls;
co->get_costs = get_costs;
s2 = get_entity_name(get_irg_entity(co->irg));
s3 = chordal_env->cls->name;
len = strlen(s1) + strlen(s2) + strlen(s3) + 5;
s2 = get_entity_name(get_irg_entity(co->irg));
s3 = chordal_env->cls->name;
len = strlen(s1) + strlen(s2) + strlen(s3) + 5;
snprintf(co->name, len, "%s__%s__%s", s1, s2, s3);
return co;
snprintf(co->name, len, "%s__%s__%s", s1, s2, s3);
return co;
-int co_is_optimizable_root(const copy_opt_t *co, ir_node *irn) {
+/**
+ * Checks if a node is optimizable, viz. has something to do with coalescing
+ * @param irn The irn to check
+ */
+static int co_is_optimizable_root(ir_node *irn)
+{
- req = arch_get_register_req(co->aenv, irn, -1);
- if (is_Reg_Phi(irn) || is_Perm_Proj(co->aenv, irn) || is_2addr_code(req))
+ req = arch_get_register_req(irn, -1);
+ if (is_Reg_Phi(irn) || is_Perm_Proj(irn) || is_2addr_code(req))
- unit->nodes = xmalloc((arity+1) * sizeof(*unit->nodes));
- unit->costs = xmalloc((arity+1) * sizeof(*unit->costs));
+ unit->nodes = XMALLOCN(ir_node*, arity + 1);
+ unit->costs = XMALLOCN(int, arity + 1);
/* Else insert the argument of the phi to the members of this ou */
DBG((dbg, LEVEL_1, "\t Member: %+F\n", arg));
/* Else insert the argument of the phi to the members of this ou */
DBG((dbg, LEVEL_1, "\t Member: %+F\n", arg));
/* Check if arg has occurred at a prior position in the arg/list */
arg_pos = 0;
for (o=1; o<unit->node_count; ++o) {
/* Check if arg has occurred at a prior position in the arg/list */
arg_pos = 0;
for (o=1; o<unit->node_count; ++o) {
- unit->nodes = xrealloc(unit->nodes, unit->node_count * sizeof(*unit->nodes));
- unit->costs = xrealloc(unit->costs, unit->node_count * sizeof(*unit->costs));
- } else if (is_Perm_Proj(co->aenv, irn)) {
+ unit->nodes = XREALLOC(unit->nodes, ir_node*, unit->node_count);
+ unit->costs = XREALLOC(unit->costs, int, unit->node_count);
+ } else if (is_Perm_Proj(irn)) {
/* Proj of a perm with corresponding arg */
assert(!nodes_interfere(co->cenv, irn, get_Perm_src(irn)));
/* Proj of a perm with corresponding arg */
assert(!nodes_interfere(co->cenv, irn, get_Perm_src(irn)));
- unit->nodes = xmalloc(2 * sizeof(*unit->nodes));
- unit->costs = xmalloc(2 * sizeof(*unit->costs));
+ unit->nodes = XMALLOCN(ir_node*, 2);
+ unit->costs = XMALLOCN(int, 2);
unit->node_count = 2;
unit->nodes[0] = irn;
unit->nodes[1] = get_Perm_src(irn);
unit->costs[1] = co->get_costs(co, irn, unit->nodes[1], -1);
} else {
unit->node_count = 2;
unit->nodes[0] = irn;
unit->nodes[1] = get_Perm_src(irn);
unit->costs[1] = co->get_costs(co, irn, unit->nodes[1], -1);
} else {
- const arch_register_req_t *req =
- arch_get_register_req(co->aenv, irn, -1);
+ const arch_register_req_t *req = arch_get_register_req(irn, -1);
for (i = 0; (1U << i) <= other; ++i) {
if (other & (1U << i)) {
ir_node *o = get_irn_n(skip_Proj(irn), i);
for (i = 0; (1U << i) <= other; ++i) {
if (other & (1U << i)) {
ir_node *o = get_irn_n(skip_Proj(irn), i);
- unit->nodes = xmalloc(count * sizeof(*unit->nodes));
- unit->costs = xmalloc(count * sizeof(*unit->costs));
+ unit->nodes = XMALLOCN(ir_node*, count);
+ unit->costs = XMALLOCN(int, count);
unit->node_count = count;
unit->nodes[k++] = irn;
for (i = 0; 1U << i <= other; ++i) {
if (other & (1U << i)) {
ir_node *o = get_irn_n(skip_Proj(irn), i);
unit->node_count = count;
unit->nodes[k++] = irn;
for (i = 0; 1U << i <= other; ++i) {
if (other & (1U << i)) {
ir_node *o = get_irn_n(skip_Proj(irn), i);
!nodes_interfere(co->cenv, irn, o)) {
unit->nodes[k] = o;
unit->costs[k] = co->get_costs(co, irn, o, -1);
!nodes_interfere(co->cenv, irn, o)) {
unit->nodes[k] = o;
unit->costs[k] = co->get_costs(co, irn, o, -1);
const unit_t *u2 = *((const unit_t **) k2);
int i, o, u1_has_constr, u2_has_constr;
arch_register_req_t req;
const unit_t *u2 = *((const unit_t **) k2);
int i, o, u1_has_constr, u2_has_constr;
arch_register_req_t req;
- arch_get_register_req(aenv, &req, u1->nodes[i], -1);
+ arch_get_register_req(&req, u1->nodes[i], -1);
- arch_get_register_req(aenv, &req, u2->nodes[i], -1);
+ arch_get_register_req(&req, u2->nodes[i], -1);
ASSERT_OU_AVAIL(co);
list_for_each_entry(unit_t, curr, &co->units, units) {
ASSERT_OU_AVAIL(co);
list_for_each_entry(unit_t, curr, &co->units, units) {
DBG((dbg, LEVEL_1, " %3d costs for root %+F color %d\n", curr->inevitable_costs, curr->nodes[0], root_col));
res += curr->inevitable_costs;
for (i=1; i<curr->node_count; ++i) {
DBG((dbg, LEVEL_1, " %3d costs for root %+F color %d\n", curr->inevitable_costs, curr->nodes[0], root_col));
res += curr->inevitable_costs;
for (i=1; i<curr->node_count; ++i) {
if (root_col != arg_col) {
DBG((dbg, LEVEL_1, " %3d for arg %+F color %d\n", curr->costs[i], curr->nodes[i], arg_col));
res += curr->costs[i];
if (root_col != arg_col) {
DBG((dbg, LEVEL_1, " %3d for arg %+F color %d\n", curr->costs[i], curr->nodes[i], arg_col));
res += curr->costs[i];
- if (!is_curr_reg_class(co, irn) || arch_irn_is(co->aenv, irn, ignore))
+ if (!is_curr_reg_class(co, irn) || arch_irn_is(irn, ignore))
ir_node *arg = get_irn_n(irn, pos);
add_edges(co, irn, arg, co->get_costs(co, irn, arg, pos));
}
ir_node *arg = get_irn_n(irn, pos);
add_edges(co, irn, arg, co->get_costs(co, irn, arg, pos));
}
ir_node *arg = get_Perm_src(irn);
add_edges(co, irn, arg, co->get_costs(co, irn, arg, 0));
}
else { /* 2-address code */
ir_node *arg = get_Perm_src(irn);
add_edges(co, irn, arg, co->get_costs(co, irn, arg, 0));
}
else { /* 2-address code */
for (i = 0; 1U << i <= other; ++i) {
if (other & (1U << i)) {
ir_node *other = get_irn_n(skip_Proj(irn), i);
for (i = 0; 1U << i <= other; ++i) {
if (other & (1U << i)) {
ir_node *other = get_irn_n(skip_Proj(irn), i);
add_edges(co, irn, other, co->get_costs(co, irn, other, 0));
}
}
add_edges(co, irn, other, co->get_costs(co, irn, other, 0));
}
}
if(arch_register_req_is(req, limited))
rbitset_copy_to_bitset(req->limited, constr[j]);
else
if(arch_register_req_is(req, limited))
rbitset_copy_to_bitset(req->limited, constr[j]);
else
node_map[get_irn_idx(irn)] = n++;
}
fprintf(f, "%d %d\n", n, n_regs);
be_ifg_foreach_node(ifg, it, irn) {
node_map[get_irn_idx(irn)] = n++;
}
fprintf(f, "%d %d\n", n, n_regs);
be_ifg_foreach_node(ifg, it, irn) {
int idx = node_map[get_irn_idx(irn)];
affinity_node_t *a = get_affinity_info(co, irn);
const arch_register_req_t *req;
ir_node *adj;
int idx = node_map[get_irn_idx(irn)];
affinity_node_t *a = get_affinity_info(co, irn);
const arch_register_req_t *req;
ir_node *adj;
if(arch_register_req_is(req, limited)) {
for(i = 0; i < co->cls->n_regs; ++i) {
if(!rbitset_is_set(req->limited, i) && color_map[i] >= 0)
if(arch_register_req_is(req, limited)) {
for(i = 0; i < co->cls->n_regs; ++i) {
if(!rbitset_is_set(req->limited, i) && color_map[i] >= 0)
}
be_ifg_foreach_neighbour(ifg, nit, irn, adj) {
}
be_ifg_foreach_neighbour(ifg, nit, irn, adj) {
- if(!arch_irn_is(co->aenv, adj, ignore) && !co_dump_appel_disjoint_constraints(co, irn, adj)) {
+ if (!arch_irn_is(adj, ignore) &&
+ !co_dump_appel_disjoint_constraints(co, irn, adj)) {
int adj_idx = node_map[get_irn_idx(adj)];
if(idx < adj_idx)
fprintf(f, "%d %d -1\n", idx, adj_idx);
int adj_idx = node_map[get_irn_idx(adj)];
if(idx < adj_idx)
fprintf(f, "%d %d -1\n", idx, adj_idx);
int n_idx = node_map[get_irn_idx(n->irn)];
if(idx < n_idx)
fprintf(f, "%d %d %d\n", idx, n_idx, (int) n->costs);
int n_idx = node_map[get_irn_idx(n->irn)];
if(idx < n_idx)
fprintf(f, "%d %d %d\n", idx, n_idx, (int) n->costs);
- co_ifg_dump_t *cod = self;
- return !arch_irn_is(cod->co->aenv, irn, ignore);
+ (void)self;
+ return !arch_irn_is(irn, ignore);
}
static void ifg_dump_node_attr(FILE *f, void *self, ir_node *irn)
{
co_ifg_dump_t *env = self;
}
static void ifg_dump_node_attr(FILE *f, void *self, ir_node *irn)
{
co_ifg_dump_t *env = self;
limited = arch_register_req_is(req, limited);
if(env->flags & CO_IFG_DUMP_LABELS) {
limited = arch_register_req_is(req, limited);
if(env->flags & CO_IFG_DUMP_LABELS) {
unsigned aidx = get_irn_idx(a->irn);
neighb_t *n;
co_gs_foreach_neighb(a, n) {
unsigned aidx = get_irn_idx(a->irn);
neighb_t *n;
co_gs_foreach_neighb(a, n) {