X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fbe%2Fbechordal.c;h=2a71e7967724d033add4bc3c5086971e499ba8f5;hb=df2faee01a5832057bb3ca0ba5f67e979c916e19;hp=18039e5c86cedbbc12f85cfed7fa1050887a9d84;hpb=29c8dba268326ee680f441874ee1444dae711d5e;p=libfirm diff --git a/ir/be/bechordal.c b/ir/be/bechordal.c index 18039e5c8..2a71e7967 100644 --- a/ir/be/bechordal.c +++ b/ir/be/bechordal.c @@ -50,14 +50,12 @@ static int get_next_free_reg(bitset_t *const available) return bitset_next_set(available, 0); } -static bitset_t const *get_decisive_partner_regs(be_operand_t const *const o1) +static unsigned const *get_decisive_partner_regs(be_operand_t const *const o1, size_t const n_regs) { be_operand_t const *const o2 = o1->partner; - assert(!o2 || o1->req->cls == o2->req->cls); - - if (!o2 || bitset_contains(o1->regs, o2->regs)) { + if (!o2 || rbitset_contains(o1->regs, o2->regs, n_regs)) { return o1->regs; - } else if (bitset_contains(o2->regs, o1->regs)) { + } else if (rbitset_contains(o2->regs, o1->regs, n_regs)) { return o2->regs; } else { return NULL; @@ -69,7 +67,7 @@ static void pair_up_operands(be_chordal_env_t const *const env, be_insn_t *const /* For each out operand, try to find an in operand which can be assigned the * same register as the out operand. */ int const n_regs = env->cls->n_regs; - bitset_t *const bs = bitset_alloca(n_regs); + unsigned *const bs = rbitset_alloca(n_regs); be_lv_t *const lv = be_get_irg_liveness(env->irg); for (int j = 0; j < insn->use_start; ++j) { /* Try to find an in operand which has ... */ @@ -78,13 +76,13 @@ static void pair_up_operands(be_chordal_env_t const *const env, be_insn_t *const be_operand_t *const out_op = &insn->ops[j]; for (int i = insn->use_start; i < insn->n_ops; ++i) { be_operand_t *const op = &insn->ops[i]; - if (op->partner || be_values_interfere(lv, op->irn, op->carrier)) + if (op->partner || be_values_interfere(lv, insn->irn, op->carrier)) continue; - bitset_copy(bs, op->regs); - bitset_and(bs, out_op->regs); - int const n_total = bitset_popcount(op->regs); - if (!bitset_is_empty(bs) && n_total < smallest_n_regs) { + rbitset_copy(bs, op->regs, n_regs); + rbitset_and(bs, out_op->regs, n_regs); + int const n_total = rbitset_popcount(op->regs, n_regs); + if (!rbitset_is_empty(bs, n_regs) && n_total < smallest_n_regs) { smallest = op; smallest_n_regs = n_total; } @@ -113,12 +111,12 @@ static bool list_contains_irn(ir_node *const *const list, size_t const n, ir_nod static void handle_constraints(be_chordal_env_t *const env, ir_node *const irn) { - void *const base = obstack_base(env->obst); + void *const base = obstack_base(&env->obst); be_insn_t *insn = be_scan_insn(env, irn); /* Perms inserted before the constraint handling phase are considered to be * correctly precolored. These Perms arise during the ABI handling phase. */ - if (!insn->has_constraints || is_Phi(irn)) + if (!insn || is_Phi(irn)) goto end; /* Prepare the constraint handling of this node. @@ -162,11 +160,11 @@ static void handle_constraints(be_chordal_env_t *const env, ir_node *const irn) DBG((dbg, LEVEL_2, "\tassociating %+F and %+F\n", op->carrier, partner)); - bitset_t const *const bs = get_decisive_partner_regs(op); + unsigned const *const bs = get_decisive_partner_regs(op, n_regs); if (bs) { DBG((dbg, LEVEL_2, "\tallowed registers for %+F: %B\n", op->carrier, bs)); - bitset_foreach(bs, col) { + rbitset_foreach(bs, n_regs, col) { #if USE_HUNGARIAN hungarian_add(bp, n_alloc, col, 1); #else @@ -278,7 +276,7 @@ static void handle_constraints(be_chordal_env_t *const env, ir_node *const irn) pmap_destroy(partners); end: - obstack_free(env->obst, base); + obstack_free(&env->obst, base); } /** @@ -317,16 +315,14 @@ static void assign(ir_node *const block, void *const env_ptr) /* Add initial defs for all values live in. * Since their colors have already been assigned (The dominators were * allocated before), we have to mark their colors as used also. */ - be_lv_foreach(lv, block, be_lv_state_in, irn) { - if (arch_irn_consider_in_reg_alloc(env->cls, irn)) { - arch_register_t const *const reg = arch_get_irn_register(irn); + be_lv_foreach_cls(lv, block, be_lv_state_in, env->cls, irn) { + arch_register_t const *const reg = arch_get_irn_register(irn); - assert(reg && "Node must have been assigned a register"); - DBG((dbg, LEVEL_4, "%+F has reg %s\n", irn, reg->name)); + assert(reg && "Node must have been assigned a register"); + DBG((dbg, LEVEL_4, "%+F has reg %s\n", irn, reg->name)); - /* Mark the color of the live in value as used. */ - bitset_clear(available, reg->index); - } + /* Mark the color of the live in value as used. */ + bitset_clear(available, reg->index); } /* Mind that the sequence of defs from back to front defines a perfect @@ -368,13 +364,6 @@ static void be_ra_chordal_color(be_chordal_env_t *const chordal_env) be_assure_live_sets(irg); assure_doms(irg); - be_timer_push(T_SPLIT); - if (chordal_env->opts->dump_flags & BE_CH_DUMP_SPLIT) { - snprintf(buf, sizeof(buf), "%s-split", chordal_env->cls->name); - dump_ir_graph(irg, buf); - } - be_timer_pop(T_SPLIT); - be_timer_push(T_CONSTR); /* Handle register targeting constraints */