X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fbe%2Fbeinsn.c;h=bbe72e92a1399230240f9d08e78effff34651b87;hb=fef8dc3eff6468d7d65485af8e1ac9884c504e1a;hp=609119afbdef70e3466cdfbd989a35714d21f58c;hpb=b6aaf00ca3e0065b823ffc6672a625520da8eb10;p=libfirm diff --git a/ir/be/beinsn.c b/ir/be/beinsn.c index 609119afb..bbe72e92a 100644 --- a/ir/be/beinsn.c +++ b/ir/be/beinsn.c @@ -35,48 +35,19 @@ #include "beabi.h" #include "raw_bitset.h" -be_insn_t *be_scan_insn(be_chordal_env_t const *const env, ir_node *const irn) +be_insn_t *be_scan_insn(be_chordal_env_t *const env, ir_node *const irn) { - struct obstack *obst = env->obst; + struct obstack *const obst = &env->obst; be_operand_t o; - int i, n; be_insn_t *insn = OALLOCZ(obst, be_insn_t); bool has_constraints = false; + const arch_register_class_t *cls = env->cls; insn->irn = irn; - if (get_irn_mode(irn) == mode_T) { - ir_node *p; - - /* This instruction might create more than one def. These are handled - by Proj's, find them. */ - foreach_out_edge(irn, edge) { - p = get_edge_src_irn(edge); - - /* did not work if the result is a ProjT. This should NOT happen - in the backend, but check it for now. */ - assert(get_irn_mode(p) != mode_T); - - if (arch_irn_consider_in_reg_alloc(env->cls, p)) { - /* found a def: create a new operand */ - arch_register_req_t const *const req = arch_get_irn_register_req(p); - if (arch_register_req_is(req, limited)) { - o.regs = req->limited; - has_constraints = true; - } else { - o.regs = env->allocatable_regs->data; - has_constraints |= req->width > 1; - } - o.carrier = p; - o.partner = NULL; - obstack_grow(obst, &o, sizeof(o)); - insn->n_ops++; - } - } - } else if (arch_irn_consider_in_reg_alloc(env->cls, irn)) { - /* only one def, create one operand */ - arch_register_req_t const *const req = arch_get_irn_register_req(irn); + be_foreach_definition(irn, cls, p, req, + /* found a def: create a new operand */ if (arch_register_req_is(req, limited)) { o.regs = req->limited; has_constraints = true; @@ -84,33 +55,28 @@ be_insn_t *be_scan_insn(be_chordal_env_t const *const env, ir_node *const irn) o.regs = env->allocatable_regs->data; has_constraints |= req->width > 1; } - o.carrier = irn; + o.carrier = p; o.partner = NULL; obstack_grow(obst, &o, sizeof(o)); insn->n_ops++; - } + ); insn->use_start = insn->n_ops; /* now collect the uses for this node */ - for (i = 0, n = get_irn_arity(irn); i < n; ++i) { - ir_node *op = get_irn_n(irn, i); - - if (arch_irn_consider_in_reg_alloc(env->cls, op)) { - /* found a register use, create an operand */ - arch_register_req_t const *const req = arch_get_irn_register_req_in(irn, i); - if (arch_register_req_is(req, limited)) { - o.regs = req->limited; - has_constraints = true; - } else { - o.regs = env->allocatable_regs->data; - } - o.carrier = op; - o.partner = NULL; - obstack_grow(obst, &o, sizeof(o)); - insn->n_ops++; + be_foreach_use(irn, cls, in_req, op, op_req, + /* found a register use, create an operand */ + if (arch_register_req_is(in_req, limited)) { + o.regs = in_req->limited; + has_constraints = true; + } else { + o.regs = env->allocatable_regs->data; } - } + o.carrier = op; + o.partner = NULL; + obstack_grow(obst, &o, sizeof(o)); + insn->n_ops++; + ); if (!has_constraints) return NULL;