X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Fircgcons.c;h=ca32dea81287e988790a9aa071817bfe4fcad0a5;hb=a947c2090825c6a49b3fbfaafc00c8c34d649a40;hp=74215b9aec89659e55fcb06effb58a2724e1206f;hpb=10e8d8749b8740ef7e585698cc254dc2e9fbaae8;p=libfirm diff --git a/ir/ir/ircgcons.c b/ir/ir/ircgcons.c index 74215b9ae..ca32dea81 100644 --- a/ir/ir/ircgcons.c +++ b/ir/ir/ircgcons.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -25,14 +25,11 @@ * @date 09.06.2002 * @version $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" -#ifdef HAVE_STRING_H -#include -#endif +#ifdef INTERPROCEDURAL_VIEW +#include #include #include "ircgcons.h" @@ -70,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. @@ -97,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)) { @@ -115,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; @@ -127,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); @@ -179,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); @@ -208,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; } @@ -221,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()))); @@ -263,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; @@ -273,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))); } } @@ -459,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); } @@ -484,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: @@ -575,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; } } @@ -609,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 @@ -819,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) { @@ -857,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))) @@ -881,7 +879,7 @@ void cg_construct(int arr_len, ir_entity ** free_methods_arr) { static void destruct_walker(ir_node * node, void * env) { (void) env; - if (get_irn_op(node) == op_Block) { + 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. @@ -891,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. */ @@ -913,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); } @@ -925,3 +923,5 @@ void cg_destruct(void) { set_irp_ip_view(ip_view_no); } } + +#endif