2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief A data structure to treat nodes and node-proj collections uniformly.
23 * @author Sebastian Hack
27 #include "irgraph_t.h"
32 #include "bechordal_t.h"
36 #include "raw_bitset.h"
38 be_insn_t *be_scan_insn(be_chordal_env_t *const env, ir_node *const irn)
40 struct obstack *const obst = &env->obst;
44 be_insn_t *insn = OALLOCZ(obst, be_insn_t);
46 bool has_constraints = false;
48 const arch_register_class_t *cls = env->cls;
50 be_foreach_definition(irn, cls, p,
51 /* found a def: create a new operand */
52 arch_register_req_t const *const req = arch_get_irn_register_req(p);
53 if (arch_register_req_is(req, limited)) {
54 o.regs = req->limited;
55 has_constraints = true;
57 o.regs = env->allocatable_regs->data;
58 has_constraints |= req->width > 1;
62 obstack_grow(obst, &o, sizeof(o));
66 insn->use_start = insn->n_ops;
68 /* now collect the uses for this node */
69 for (i = 0, n = get_irn_arity(irn); i < n; ++i) {
70 ir_node *op = get_irn_n(irn, i);
72 if (arch_irn_consider_in_reg_alloc(env->cls, op)) {
73 /* found a register use, create an operand */
74 arch_register_req_t const *const req = arch_get_irn_register_req_in(irn, i);
75 if (arch_register_req_is(req, limited)) {
76 o.regs = req->limited;
77 has_constraints = true;
79 o.regs = env->allocatable_regs->data;
83 obstack_grow(obst, &o, sizeof(o));
91 insn->ops = (be_operand_t*)obstack_finish(obst);