X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Fircgcons.c;h=558f57661b06bd2d02aac61beebcb27938cb8895;hb=73e2ad70593e4c2c6535033739c46668df4d02dc;hp=d1181f74eb1bd183d123c2951c77b9ab179e644c;hpb=28026a9f6aee143c644be2be98d16f2fa66b34f4;p=libfirm diff --git a/ir/ir/ircgcons.c b/ir/ir/ircgcons.c index d1181f74e..558f57661 100644 --- a/ir/ir/ircgcons.c +++ b/ir/ir/ircgcons.c @@ -1,23 +1,35 @@ /* - * 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-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. */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#ifdef HAVE_STRING_H -#include -#endif +/** + * @file + * @brief Construction and removal of interprocedural representation + * (explicit interprocedural dependencies). + * @author Hubert Schmid + * @date 09.06.2002 + * @version $Id$ + */ +#include "config.h" + +#ifdef INTERPROCEDURAL_VIEW +#include #include #include "ircgcons.h" @@ -55,10 +67,9 @@ typedef struct { ir_node * except, * except_mem; /* EndExcept and Mem for exception return */ } irg_data_t; -static irg_data_t * irg_data_create(void) { - irg_data_t *data = xmalloc(sizeof(*data)); - memset(data, 0, sizeof(*data)); /* init */ - return data; +static irg_data_t * irg_data_create(void) +{ + return XMALLOCZ(irg_data_t); } /** Count the number of callers of each method and mark open methods. @@ -82,7 +93,7 @@ static void caller_init(int arr_length, ir_entity ** free_methods) { ir_node * call; /* We collected all call nodes in a link list at the end node. */ for (call = get_irn_link(get_irg_end(irg)); call; call = get_irn_link(call)) { - if (get_irn_op(call) != op_Call) continue; + if (!is_Call(call)) continue; for (j = get_Call_n_callees(call) - 1; j >= 0; --j) { ir_entity * ent = get_Call_callee(call, j); if (get_entity_irg(ent)) { @@ -100,7 +111,7 @@ static void caller_init(int arr_length, ir_entity ** free_methods) { } /* -static INLINE ir_node * tail(ir_node * node) { +static inline ir_node * tail(ir_node * node) { ir_node * link; for (; (link = get_irn_link(node)); node = link) ; return node; @@ -112,7 +123,7 @@ static INLINE ir_node * tail(ir_node * node) { * (auch bei Proj->Call Operationen) und Phi-Operationen in die Liste ihres * Grundblocks einfügen. */ static void collect_phicallproj_walker(ir_node * node, ir_node ** call_tail) { - if (get_irn_op(node) == op_Call) { + if (is_Call(node)) { /* Die Liste von Call an call_tail anhängen. */ ir_node * link; assert(get_irn_link(*call_tail) == NULL); @@ -164,7 +175,6 @@ static void collect_phicallproj(void) { * auch wenn sie nicht im intraprozeduralen Graphen erreichbar * sind. */ link(start, get_irg_frame(irg)); - link(start, get_irg_globals(irg)); /* walk */ irg_walk_graph(irg, firm_clear_link, (irg_walk_func *) collect_phicallproj_walker, &end); @@ -193,6 +203,7 @@ static ir_node * create_Block(int n, ir_node ** in) { ir_node * block; set_optimize(0); block = new_Block(n, in); + set_cur_block(block); set_optimize(rem_opt); return block; } @@ -206,7 +217,7 @@ static void prepare_irg_end_except(ir_graph * irg, irg_data_t * data); * cause cycles we don't want to see, as Unknwon is in the Start Block * of the procedure. Use unknown of outermost irg where the start * block has no predecessors. */ -static INLINE ir_node *get_cg_Unknown(ir_mode *m) { +static inline ir_node *get_cg_Unknown(ir_mode *m) { assert((get_Block_n_cfgpreds(get_irg_start_block(get_irp_main_irg())) == 1) && (get_nodes_block(get_Block_cfgpred(get_irg_start_block(get_irp_main_irg()), 0)) == get_irg_start_block(get_irp_main_irg()))); @@ -248,9 +259,9 @@ static void prepare_irg(ir_graph * irg, irg_data_t * data) { * dass oben für "verschiedene" Proj-Operationen wegen CSE nur eine * Filter-Operation erzeugt worden sein kann. */ for (link = get_irg_start(irg), proj = get_irn_link(link); proj; proj = get_irn_link(proj)) { - if (get_irn_op(proj) == op_Id) { /* replaced with filter */ + if (is_Id(proj)) { /* replaced with filter */ ir_node * filter = get_Id_pred(proj); - assert(get_irn_op(filter) == op_Filter); + assert(is_Filter(filter)); if (filter != link && get_irn_link(filter) == NULL) { set_irn_link(link, filter); link = filter; @@ -258,15 +269,15 @@ static void prepare_irg(ir_graph * irg, irg_data_t * data) { } } /* Globle Einträge für ersetzte Operationen korrigieren. */ - set_irg_frame (irg, skip_Id(get_irg_frame(irg))); - set_irg_globals (irg, skip_Id(get_irg_globals(irg))); - set_irg_initial_mem(irg, skip_Id(get_irg_initial_mem(irg))); + set_irg_initial_exec(irg, skip_Id(get_irg_initial_exec(irg))); + set_irg_frame (irg, skip_Id(get_irg_frame(irg))); + set_irg_initial_mem (irg, skip_Id(get_irg_initial_mem(irg))); /* Unbekannten Aufrufer sofort eintragen. */ if (data->open) { set_Block_cg_cfgpred(start_block, 0, get_cg_Unknown(mode_X)); for (proj = get_irn_link(get_irg_start(irg)); proj; proj = get_irn_link(proj)) { - if (get_irn_op(proj) == op_Filter) { + if (is_Filter(proj)) { set_Filter_cg_pred(proj, 0, get_cg_Unknown(get_irn_mode(proj))); } } @@ -444,7 +455,7 @@ static void move_nodes(ir_node * from_block, ir_node * to_block, ir_node * node) /* Move projs of this node. */ proj = get_irn_link(node); for (; proj; proj = skip_Id(get_irn_link(proj))) { - if (get_irn_op(proj) != op_Proj && get_irn_op(proj) != op_Filter) continue; + if (get_irn_op(proj) != op_Proj && !is_Filter(proj)) continue; if ((get_nodes_block(proj) == from_block) && (skip_Proj(get_irn_n(proj, 0)) == node)) set_nodes_block(proj, to_block); } @@ -454,11 +465,13 @@ 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(ir_entity * caller, ir_entity * callee, - ir_node * call, ir_node * exec) { + 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. */ @@ -467,7 +480,7 @@ static void construct_start(ir_entity * caller, ir_entity * callee, set_Block_cg_cfgpred(get_nodes_block(start), data->count, exec); for (filter = get_irn_link(start); filter; filter = get_irn_link(filter)) { - if (get_irn_op(filter) != op_Filter) continue; + if (!is_Filter(filter)) continue; if (get_Proj_pred(filter) == start) { switch ((int) get_Proj_proj(filter)) { case pn_Start_M: @@ -558,7 +571,7 @@ static ir_node * get_except(ir_node * call) { * Aufrufstelle nur ein einziges Mal aufgerufen. */ ir_node * proj; for (proj = get_irn_link(call); proj && get_irn_op(proj) == op_Proj; proj = get_irn_link(proj)) { - if (get_Proj_proj(proj) == 1 && get_irn_op(get_Proj_pred(proj)) == op_Call) { + if (get_Proj_proj(proj) == 1 && is_Call(get_Proj_pred(proj))) { return proj; } } @@ -592,6 +605,7 @@ static bool is_outermost_graph(ir_graph *irg) { return true; } +#ifdef INTERPROCEDURAL_VIEW /* Grundblock der Call-Operation aufteilen. CallBegin- und Filter-Operationen * einfügen. Die Steuer- und Datenflussabhängigkeiten von den aufgerufenen * Methoden auf die CallBegin-Operation, und von der Aufrufstelle auf die @@ -611,7 +625,7 @@ static void construct_call(ir_node * call) { get_Block_cfgpred_arr(post_block)); /* block vor dem Aufruf (mit CallBegin) */ except_block = NULL; jmp = new_Break(); /* Sprung für intraprozedurale Darstellung (in * pre_block) */ - call_begin = new_CallBegin(call); /* (in pre_block) */ + call_begin = new_CallBegin(get_Call_ptr(call), call); /* (in pre_block) */ /* CallBegin might be entry to endless recursion. */ add_End_keepalive(get_irg_end(get_irn_irg(pre_block)), pre_block); @@ -802,6 +816,7 @@ static void construct_call(ir_node * call) { DEL_ARR_F(irgs); DEL_ARR_F(data); } +#endif void cg_construct(int arr_len, ir_entity ** free_methods_arr) { @@ -840,7 +855,7 @@ void cg_construct(int arr_len, ir_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) { + if (is_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))) @@ -861,8 +876,10 @@ void cg_construct(int arr_len, ir_entity ** free_methods_arr) { -static void destruct_walker(ir_node * node, void * env) { - if (get_irn_op(node) == op_Block) { +static void destruct_walker(ir_node * node, void * env) +{ + (void) env; + if (is_Block(node)) { remove_Block_cg_cfgpred_arr(node); /* Do not turn Break into Jmp. Better: merge blocks right away. Well, but there are Breaks left. @@ -872,13 +889,13 @@ static void destruct_walker(ir_node * node, void * env) { if (get_irn_op(pred) == op_Break) exchange(node, get_nodes_block(pred)); } - } else if (get_irn_op(node) == op_Filter) { + } else if (is_Filter(node)) { set_irg_current_block(current_ir_graph, get_nodes_block(node)); exchange(node, new_Proj(get_Filter_pred(node), get_irn_mode(node), get_Filter_proj(node))); } else if (get_irn_op(node) == op_Break) { set_irg_current_block(current_ir_graph, get_nodes_block(node)); exchange(node, new_Jmp()); - } else if (get_irn_op(node) == op_Call) { + } else if (is_Call(node)) { remove_Call_callee_arr(node); } else if (get_irn_op(node) == op_Proj) { /* some ProjX end up in strange blocks. */ @@ -894,11 +911,11 @@ void cg_destruct(void) { ir_graph * irg = get_irp_irg(i); irg_walk_graph(irg, destruct_walker, firm_clear_link, NULL); - set_irg_frame (irg, skip_Id(get_irg_frame(irg))); - set_irg_globals (irg, skip_Id(get_irg_globals(irg))); - set_irg_initial_mem(irg, skip_Id(get_irg_initial_mem(irg))); - set_irg_end_reg (irg, get_irg_end(irg)); - set_irg_end_except (irg, get_irg_end(irg)); + set_irg_initial_exec(irg, skip_Id(get_irg_initial_exec(irg))); + set_irg_frame (irg, skip_Id(get_irg_frame(irg))); + set_irg_initial_mem (irg, skip_Id(get_irg_initial_mem(irg))); + set_irg_end_reg (irg, get_irg_end(irg)); + set_irg_end_except (irg, get_irg_end(irg)); set_irg_callee_info_state(irg, irg_callee_info_none); } @@ -906,3 +923,5 @@ void cg_destruct(void) { set_irp_ip_view(ip_view_no); } } + +#endif