X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeinsn.c;h=f8e98ecf5b01a1ac8006fe2b3c5115a039683dac;hb=8a700094481e615687fa4f026d92a2c5a59b27a7;hp=0ca12813833f654b253fcb25aa279099b7806f62;hpb=0570a14ad2d910107d0692ab2e2a76d6d265b9d2;p=libfirm diff --git a/ir/be/beinsn.c b/ir/be/beinsn.c index 0ca128138..f8e98ecf5 100644 --- a/ir/be/beinsn.c +++ b/ir/be/beinsn.c @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. - * * This file is part of libFirm. - * - * This file may be distributed and/or modified under the terms of the - * GNU General Public License version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * Licensees holding valid libFirm Professional Edition licenses may use - * this file in accordance with the libFirm Commercial License. - * Agreement provided with the Software. - * - * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. + * Copyright (C) 2012 University of Karlsruhe. */ /** @@ -35,83 +21,52 @@ #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); - 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); + bool has_constraints = false; - /* 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 */ - o.req = arch_get_irn_register_req(p); - o.carrier = p; - o.irn = irn; - o.partner = NULL; - obstack_grow(obst, &o, sizeof(o)); - insn->n_ops++; - insn->has_constraints |= arch_register_req_is(o.req, limited) | (o.req->width > 1); - } + const arch_register_class_t *cls = env->cls; + insn->irn = 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; + } else { + o.regs = env->allocatable_regs->data; + has_constraints |= req->width > 1; } - } else if (arch_irn_consider_in_reg_alloc(env->cls, irn)) { - /* only one def, create one operand */ - o.req = arch_get_irn_register_req(irn); - o.carrier = irn; - o.irn = irn; + o.carrier = p; o.partner = NULL; obstack_grow(obst, &o, sizeof(o)); insn->n_ops++; - insn->has_constraints |= arch_register_req_is(o.req, limited) | (o.req->width > 1); - } + ); 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 */ - o.req = arch_get_irn_register_req_in(irn, i); - o.carrier = op; - o.irn = irn; - o.partner = NULL; - obstack_grow(obst, &o, sizeof(o)); - insn->n_ops++; - insn->has_constraints |= arch_register_req_is(o.req, limited); - } - } - - insn->ops = (be_operand_t*)obstack_finish(obst); - - /* Compute the admissible registers bitsets. */ - for (i = 0; i < insn->n_ops; ++i) { - be_operand_t *const op = &insn->ops[i]; - arch_register_req_t const *const req = op->req; - assert(req->cls == env->cls); - - if (req->type & arch_register_req_type_limited) { - bitset_t *regs = bitset_obstack_alloc(obst, env->cls->n_regs); - rbitset_copy_to_bitset(req->limited, regs); - op->regs = regs; + 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 { - op->regs = env->allocatable_regs; + 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; + + insn->ops = (be_operand_t*)obstack_finish(obst); return insn; }