X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Fircgcons.c;h=558f57661b06bd2d02aac61beebcb27938cb8895;hb=e1397b01aceb38b6bb62c319007146af3b922f39;hp=794e468237a3ca7284fc55681e15a05dc7937316;hpb=1ce363f80e6a204d4011f85813362d9bd1d0e7e4;p=libfirm diff --git a/ir/ir/ircgcons.c b/ir/ir/ircgcons.c index 794e46823..558f57661 100644 --- a/ir/ir/ircgcons.c +++ b/ir/ir/ircgcons.c @@ -25,9 +25,7 @@ * @date 09.06.2002 * @version $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" #ifdef INTERPROCEDURAL_VIEW @@ -69,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. @@ -96,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)) { @@ -114,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; @@ -126,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); @@ -178,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); @@ -207,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; } @@ -220,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()))); @@ -262,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; @@ -272,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))); } } @@ -458,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); } @@ -483,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: @@ -574,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; } } @@ -628,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); @@ -858,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))) @@ -882,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. @@ -892,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. */ @@ -914,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); }