X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Fircgcons.c;h=74215b9aec89659e55fcb06effb58a2724e1206f;hb=20a054e20083e0b0e996aceabf561254c663277a;hp=78df170a4fa117fa2052884d32b4294ebfb769f6;hpb=609ef4bb04cf6fc1ad442e68b0a8ca8586ffa762;p=libfirm diff --git a/ir/ir/ircgcons.c b/ir/ir/ircgcons.c index 78df170a4..74215b9ae 100644 --- a/ir/ir/ircgcons.c +++ b/ir/ir/ircgcons.c @@ -1,14 +1,29 @@ /* - * Project: libFIRM - * File name: ir/ir/ircgcons.c - * Purpose: Construction and removal of interprocedural representation - * (explicit interprocedural dependencies). - * Author: Hubert Schmid - * Modified by: - * Created: 09.06.2002 - * CVS-ID: $Id$ - * Copyright: (c) 2002-2003 Universität Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + * Copyright (C) 1995-2007 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. + */ + +/** + * @file + * @brief Construction and removal of interprocedural representation + * (explicit interprocedural dependencies). + * @author Hubert Schmid + * @date 09.06.2002 + * @version $Id$ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -68,7 +83,7 @@ static irg_data_t * irg_data_create(void) { * - are external visible * - are dereferenced somewhere within the program (i.e., the address of the * method is stored somewhere). */ -static void caller_init(int arr_length, entity ** free_methods) { +static void caller_init(int arr_length, ir_entity ** free_methods) { int i, j; for (i = get_irp_n_irgs() - 1; i >= 0; --i) { set_entity_link(get_irg_entity(get_irp_irg(i)), irg_data_create()); @@ -84,16 +99,16 @@ static void caller_init(int arr_length, entity ** free_methods) { for (call = get_irn_link(get_irg_end(irg)); call; call = get_irn_link(call)) { if (get_irn_op(call) != op_Call) continue; for (j = get_Call_n_callees(call) - 1; j >= 0; --j) { - entity * ent = get_Call_callee(call, j); - if (get_entity_irg(ent)) { - irg_data_t * data = get_entity_link(ent); + ir_entity * ent = get_Call_callee(call, j); + if (get_entity_irg(ent)) { + irg_data_t * data = get_entity_link(ent); # ifndef CATE_jni - assert(get_entity_irg(ent) && data); - ++data->count; + assert(get_entity_irg(ent) && data); + ++data->count; # endif /* ndef CATE_jni */ - } else { - set_entity_link(ent, NULL); - } + } else { + set_entity_link(ent, NULL); + } } } } @@ -150,12 +165,16 @@ static void link(ir_node * head, ir_node * node) { * ... -> Proj -> NULL. */ static void collect_phicallproj(void) { int i; + for (i = get_irp_n_irgs() - 1; i >= 0; --i) { ir_graph * irg = get_irp_irg(i); ir_node * start = get_irg_start(irg); ir_node * end = get_irg_end(irg); current_ir_graph = irg; assert(irg && start); + + set_using_irn_link(irg); + /* Die speziellen Parameter der Start-Operation extra verlinken, * auch wenn sie nicht im intraprozeduralen Graphen erreichbar * sind. */ @@ -163,6 +182,8 @@ static void collect_phicallproj(void) { link(start, get_irg_globals(irg)); /* walk */ irg_walk_graph(irg, firm_clear_link, (irg_walk_func *) collect_phicallproj_walker, &end); + + clear_using_irn_link(irg); } } @@ -284,12 +305,12 @@ static void prepare_irg_end(ir_graph * irg, irg_data_t * data) { int n_ret = 0; for (i = get_Block_n_cfgpreds(end_block) - 1; i >= 0; --i) { - if (get_irn_op(cfgpred_arr[i]) == op_Return) { + if (is_Return(cfgpred_arr[i])) { if (ret_arr) { - ARR_APP1(ir_node *, ret_arr, cfgpred_arr[i]); + ARR_APP1(ir_node *, ret_arr, cfgpred_arr[i]); } else { - ret_arr = NEW_ARR_F(ir_node *, 1); - ret_arr[0] = cfgpred_arr[i]; + ret_arr = NEW_ARR_F(ir_node *, 1); + ret_arr[0] = cfgpred_arr[i]; } ++n_ret; } @@ -351,12 +372,12 @@ static void prepare_irg_end_except(ir_graph * irg, irg_data_t * data) { int n_except = 0; ir_node ** cfgpred_arr = get_Block_cfgpred_arr(end_block); for (i = get_Block_n_cfgpreds(end_block) - 1; i >= 0; --i) { - if (get_irn_op(cfgpred_arr[i]) != op_Return) { + if (! is_Return(cfgpred_arr[i])) { if (except_arr) { - ARR_APP1(ir_node *, except_arr, cfgpred_arr[i]); + ARR_APP1(ir_node *, except_arr, cfgpred_arr[i]); } else { - except_arr = NEW_ARR_F(ir_node *, 1); - except_arr[0] = cfgpred_arr[i]; + except_arr = NEW_ARR_F(ir_node *, 1); + except_arr[0] = cfgpred_arr[i]; } ++n_except; } @@ -369,15 +390,18 @@ static void prepare_irg_end_except(ir_graph * irg, irg_data_t * data) { data->except = new_EndExcept(); /* mem */ for (i = n_except - 1; i >= 0; --i) { - ir_node * node = skip_Proj(skip_Tuple(except_arr[i])); - if (get_irn_op(node) == op_Call) { - in[i] = new_r_Proj(irg, get_nodes_block(node), node, mode_M, 3); - } else if (get_irn_op(node) == op_Raise) { - in[i] = new_r_Proj(irg, get_nodes_block(node), node, mode_M, 1); + ir_node *node = skip_Proj(skip_Tuple(except_arr[i])); + ir_op *op = get_irn_op(node); + if (op == op_Call) { + in[i] = new_r_Proj(irg, get_nodes_block(node), node, mode_M, pn_Call_M_except); + } else if (op == op_Raise) { + in[i] = new_r_Proj(irg, get_nodes_block(node), node, mode_M, pn_Raise_M); + } else if (op == op_CopyB) { + in[i] = new_r_Proj(irg, get_nodes_block(node), node, mode_M, pn_CopyB_M_except); } else { - assert(is_fragile_op(node)); - /* We rely that all cfops have the memory output at the same position. */ - in[i] = new_r_Proj(irg, get_nodes_block(node), node, mode_M, 0); + assert(is_fragile_op(node)); + /* We rely that all cfops have the memory output at the same position. */ + in[i] = new_r_Proj(irg, get_nodes_block(node), node, mode_M, 0); } } data->except_mem = new_Phi(n_except, in, mode_M); @@ -394,7 +418,7 @@ static void prepare_irg_end_except(ir_graph * irg, irg_data_t * data) { /* Zwischengespeicherte Daten wieder freigeben. */ static void cleanup_irg(ir_graph * irg) { - entity * ent = get_irg_entity(irg); + ir_entity * ent = get_irg_entity(irg); irg_data_t * data = get_entity_link(ent); assert(data); if (data->res) DEL_ARR_F(data->res); @@ -444,12 +468,14 @@ static void move_nodes(ir_node * from_block, ir_node * to_block, ir_node * node) /* Abhängigkeiten vom Start-Block und den Filter-Operationen im * Start-Block auf den Aufrufer hinzufügen. */ -static void construct_start(entity * caller, entity * callee, - ir_node * call, ir_node * exec) { +static void construct_start(ir_entity * caller, ir_entity * callee, + ir_node * call, ir_node * exec) +{ irg_data_t *data = get_entity_link(callee); ir_graph *irg = get_entity_irg(callee); ir_node *start = get_irg_start(irg); ir_node *filter; + (void) caller; assert(irg); assert(get_entity_peculiarity(callee) == peculiarity_existent); /* Else data is not initalized. */ @@ -591,8 +617,8 @@ static void construct_call(ir_node * call) { int i, n_callees; ir_node *post_block, *pre_block, *except_block, * proj, *jmp, *call_begin; ir_node ** in; - entity * caller; - entity ** callees; + ir_entity * caller; + ir_entity ** callees; ir_graph ** irgs; irg_data_t ** data; @@ -608,7 +634,7 @@ static void construct_call(ir_node * call) { in = NEW_ARR_F(ir_node *, n_callees); caller = get_irg_entity(current_ir_graph); /* entity des aktuellen ir_graph */ - callees = NEW_ARR_F(entity *, n_callees); /* aufgerufene Methoden: entity */ + callees = NEW_ARR_F(ir_entity *, n_callees); /* aufgerufene Methoden: entity */ irgs = NEW_ARR_F(ir_graph *, n_callees); /* aufgerufene Methoden: ir_graph */ data = NEW_ARR_F(irg_data_t *, n_callees); /* aufgerufene Methoden: irg_data_t */ @@ -681,7 +707,7 @@ static void construct_call(ir_node * call) { set_nodes_block(proj, except_block); exchange(proj, new_Break()); set_irg_current_block(current_ir_graph, pre_block); - set_irn_n(except_block, 0, new_Proj(call, mode_X, 1)); + set_irn_n(except_block, 0, new_Proj(call, mode_X, pn_Call_X_except)); set_irg_current_block(current_ir_graph, post_block); } @@ -692,7 +718,7 @@ static void construct_call(ir_node * call) { set_interprocedural_view(1); for (i = 0; i < n_callees; ++i) { - entity * callee = get_Call_callee(call, i); + ir_entity * callee = get_Call_callee(call, i); if (data[i]) { /* explicit */ if (data[i]->except) { in[i] = new_r_Proj(get_entity_irg(callee), get_nodes_block(data[i]->except), @@ -795,7 +821,7 @@ static void construct_call(ir_node * call) { } -void cg_construct(int arr_len, entity ** free_methods_arr) { +void cg_construct(int arr_len, ir_entity ** free_methods_arr) { int i; if (get_irp_ip_view_state() == ip_view_valid) return; @@ -810,7 +836,7 @@ void cg_construct(int arr_len, entity ** free_methods_arr) { /* prepare irgs */ for (i = get_irp_n_irgs() - 1; i >= 0; --i) { ir_graph * irg = get_irp_irg(i); - entity * ent = get_irg_entity(irg); + ir_entity * ent = get_irg_entity(irg); irg_data_t * data = get_entity_link(ent); if (data->count) { prepare_irg(irg, data); @@ -832,12 +858,12 @@ void cg_construct(int arr_len, entity ** free_methods_arr) { current_ir_graph = get_irp_irg(i); for (node = get_irn_link(get_irg_end(current_ir_graph)); node; node = get_irn_link(node)) { if (get_irn_op(node) == op_Call) { - int j, n_callees = get_Call_n_callees(node); - for (j = 0; j < n_callees; ++j) - if (get_entity_irg(get_Call_callee(node, j))) - break; - if (j < n_callees) /* There is an entity with a graph */ - construct_call(node); + int j, n_callees = get_Call_n_callees(node); + for (j = 0; j < n_callees; ++j) + if (get_entity_irg(get_Call_callee(node, j))) + break; + if (j < n_callees) /* There is an entity with a graph */ + construct_call(node); } } } @@ -852,7 +878,9 @@ void cg_construct(int arr_len, entity ** free_methods_arr) { -static void destruct_walker(ir_node * node, void * env) { +static void destruct_walker(ir_node * node, void * env) +{ + (void) env; if (get_irn_op(node) == op_Block) { remove_Block_cg_cfgpred_arr(node); /* Do not turn Break into Jmp. Better: merge blocks right away.