X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbenode.c;h=3916616130dbbdd21811e905ce1f75b90f76dddb;hb=ab11945ab757f3f22a717a35d639be264b0f649c;hp=6998e34ed1ec5dc7900b2e6e73679c13011021ac;hpb=b9391dcc75fa2d4a5b99ab9644bd3da9eaff2bcf;p=libfirm diff --git a/ir/be/benode.c b/ir/be/benode.c index 6998e34ed..391661613 100644 --- a/ir/be/benode.c +++ b/ir/be/benode.c @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2011 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. */ /** @@ -231,8 +217,7 @@ static void init_node_attr(ir_node *node, int n_inputs, int n_outputs) } info->in_reqs = in_reqs; - info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_outputs); - memset(info->out_infos, 0, n_outputs * sizeof(info->out_infos[0])); + info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_outputs); for (int i = 0; i < n_outputs; ++i) { info->out_infos[i].req = arch_no_register_req; } @@ -265,6 +250,7 @@ ir_node *be_new_Spill(const arch_register_class_t *cls, be_node_set_reg_class_in(res, n_be_Spill_frame, cls_frame); be_node_set_reg_class_in(res, n_be_Spill_val, cls); arch_set_irn_register_req_out(res, 0, arch_no_register_req); + arch_add_irn_flags(res, arch_irn_flags_spill); return res; } @@ -400,8 +386,8 @@ ir_node *be_new_MemPerm(ir_node *block, int n, ir_node *in[]) be_node_set_reg_class_in(irn, 0, sp->reg_class); attr = (be_memperm_attr_t*)get_irn_generic_attr(irn); - attr->in_entities = OALLOCNZ(irg->obst, ir_entity*, n); - attr->out_entities = OALLOCNZ(irg->obst, ir_entity*, n); + attr->in_entities = OALLOCNZ(get_irg_obstack(irg), ir_entity*, n); + attr->out_entities = OALLOCNZ(get_irg_obstack(irg), ir_entity*, n); return irn; } @@ -470,14 +456,13 @@ void be_Keep_add_node(ir_node *keep, const arch_register_class_t *cls, ir_node * add_register_req_in(keep, cls->class_req); } -ir_node *be_new_Call(dbg_info *dbg, ir_graph *irg, ir_node *bl, ir_node *mem, +ir_node *be_new_Call(dbg_info *dbg, ir_node *bl, ir_node *mem, const arch_register_req_t *sp_req, ir_node *sp, const arch_register_req_t *ptr_req, ir_node *ptr, int n_outs, int n, ir_node *in[], ir_type *call_tp) { be_call_attr_t *a; int real_n = n_be_Call_first_arg + n; - ir_node *irn; ir_node **real_in; NEW_ARR_A(ir_node *, real_in, real_n); @@ -486,7 +471,8 @@ ir_node *be_new_Call(dbg_info *dbg, ir_graph *irg, ir_node *bl, ir_node *mem, real_in[n_be_Call_ptr] = ptr; memcpy(&real_in[n_be_Call_first_arg], in, n * sizeof(in[0])); - irn = new_ir_node(dbg, irg, bl, op_be_Call, mode_T, real_n, real_in); + ir_graph *const irg = get_Block_irg(bl); + ir_node *const irn = new_ir_node(dbg, irg, bl, op_be_Call, mode_T, real_n, real_in); init_node_attr(irn, real_n, n_outs); a = (be_call_attr_t*)get_irn_generic_attr(irn); a->ent = NULL; @@ -538,17 +524,14 @@ unsigned be_Call_get_pop(const ir_node *call) return a->pop; } -ir_node *be_new_Return(dbg_info *dbg, ir_graph *irg, ir_node *block, int n_res, - unsigned pop, int n, ir_node *in[]) +ir_node *be_new_Return(dbg_info *const dbg, ir_node *const block, int const n_res, unsigned const pop, int const n, ir_node **const in) { - be_return_attr_t *a; - ir_node *res; - - res = new_ir_node(dbg, irg, block, op_be_Return, mode_X, n, in); + ir_graph *const irg = get_Block_irg(block); + ir_node *const res = new_ir_node(dbg, irg, block, op_be_Return, mode_X, n, in); init_node_attr(res, n, 1); be_set_constr_out(res, 0, arch_no_register_req); - a = (be_return_attr_t*)get_irn_generic_attr(res); + be_return_attr_t *const a = (be_return_attr_t*)get_irn_generic_attr(res); a->num_ret_vals = n_res; a->pop = pop; a->emit_pop = 0; @@ -973,11 +956,9 @@ static const arch_irn_ops_t be_node_irn_ops = { static int get_start_reg_index(ir_graph *irg, const arch_register_t *reg) { ir_node *start = get_irg_start(irg); - unsigned n_outs = arch_get_irn_n_outs(start); - int i; /* do a naive linear search... */ - for (i = 0; i < (int)n_outs; ++i) { + be_foreach_out(start, i) { arch_register_req_t const *const out_req = arch_get_irn_register_req_out(start, i); if (!arch_register_req_is(out_req, limited)) continue; @@ -1007,24 +988,6 @@ ir_node *be_get_initial_reg_value(ir_graph *irg, const arch_register_t *reg) return new_r_Proj(start, mode, i); } -int be_find_return_reg_input(ir_node *ret, const arch_register_t *reg) -{ - int arity = get_irn_arity(ret); - int i; - /* do a naive linear search... */ - for (i = 0; i < arity; ++i) { - const arch_register_req_t *req = arch_get_irn_register_req_in(ret, i); - if (!arch_register_req_is(req, limited)) - continue; - if (req->cls != reg->reg_class) - continue; - if (!rbitset_is_set(req->limited, reg->index)) - continue; - return i; - } - panic("Tried querying undefined register '%s' at Return", reg->name); -} - static ir_entity* dummy_get_frame_entity(const ir_node *node) { (void) node; @@ -1065,11 +1028,10 @@ ir_node *be_new_Phi(ir_node *block, int n_ins, ir_node **ins, ir_mode *mode, int i; ir_node *phi = new_ir_node(NULL, irg, block, op_Phi, mode, n_ins, ins); - phi->attr.phi.u.backedge = new_backedge_arr(irg->obst, n_ins); + phi->attr.phi.u.backedge = new_backedge_arr(get_irg_obstack(irg), n_ins); info = be_get_info(phi); - info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1); - memset(info->out_infos, 0, 1 * sizeof(info->out_infos[0])); - info->in_reqs = OALLOCN(obst, const arch_register_req_t*, n_ins); + info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, 1); + info->in_reqs = OALLOCN(obst, const arch_register_req_t*, n_ins); info->out_infos[0].req = req; for (i = 0; i < n_ins; ++i) { @@ -1096,6 +1058,10 @@ void be_set_phi_reg_req(ir_node *node, const arch_register_req_t *req) void be_dump_phi_reg_reqs(FILE *F, const ir_node *node, dump_reason_t reason) { + ir_graph *irg = get_irn_irg(node); + if (!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_BACKEND)) + return; + switch (reason) { case dump_node_opcode_txt: fputs(get_op_name(get_irn_op(node)), F); @@ -1106,13 +1072,8 @@ void be_dump_phi_reg_reqs(FILE *F, const ir_node *node, dump_reason_t reason) case dump_node_nodeattr_txt: break; case dump_node_info_txt: - { - backend_info_t *info = be_get_info(node); - if (info != NULL && info->out_infos[0].req != NULL) { - arch_dump_reqs_and_registers(F, node); - } + arch_dump_reqs_and_registers(F, node); break; - } default: break;