X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Fircons.c;h=5b8e16f06881834eb4011df54ecb84ebc4634e6b;hb=5f8ddee6b08c8040c0a304a347d65045c1141d52;hp=78cadf3c025b43317480c185acc71e98a44e4346;hpb=b629f9f2c86fa8a50576bb4933b2ecdeb9f41008;p=libfirm diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 78cadf3c0..5b8e16f06 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -9,6 +9,9 @@ ** by Goetz Lindenmaier */ +# include "irgraph_t.h" +# include "irnode_t.h" +# include "irmode_t.h" # include "ircons.h" # include "common.h" # include "irvrfy.h" @@ -18,29 +21,31 @@ # include "array.h" /* memset belongs to string.h */ # include "string.h" -# include "irnode.h" #if USE_EXPICIT_PHI_IN_STACK /* A stack needed for the automatic Phi node construction in constructor - Phi_in. */ + Phi_in. Redefinition in irgraph.c!! */ struct Phi_in_stack { ir_node **stack; int pos; }; +typedef struct Phi_in_stack Phi_in_stack; #endif /*********************************************** */ /** privat interfaces, for professional use only */ /* Constructs a Block with a fixed number of predecessors. - Does not set current_block. */ - + Does not set current_block. Can not be used with automatic + Phi node construction. */ inline ir_node * new_r_Block (ir_graph *irg, int arity, ir_node **in) { ir_node *res; - res = new_ir_node (current_ir_graph, NULL, op_Block, mode_R, arity, in); + res = new_ir_node (irg, NULL, op_Block, mode_R, arity, in); + set_Block_matured(res, 1); + set_Block_block_visited(res, 0); irn_vrfy (res); return res; @@ -526,12 +531,17 @@ new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store, ir_node *objptr, } inline ir_node * -new_r_SymConst (ir_graph *irg, ir_node *block, type_or_id *value, +new_r_SymConst (ir_graph *irg, ir_node *block, type_or_id_p value, symconst_kind symkind) { ir_node *in[0] = {}; ir_node *res; - res = new_ir_node (irg, block, op_SymConst, mode_I, 0, in); + ir_mode *mode; + if (symkind == linkage_ptr_info) + mode = mode_p; + else + mode = mode_I; + res = new_ir_node (irg, block, op_SymConst, mode, 0, in); res->attr.i.num = symkind; if (symkind == linkage_ptr_info) { @@ -596,30 +606,35 @@ new_End (void) return res; } +#if 1 +/* Constructs a Block with a fixed number of predecessors. + Does set current_block. Can be used with automatic Phi + node construction. */ ir_node * -new_Block (void) +new_Block (int arity, ir_node **in) { ir_node *res; - res = new_ir_node (current_ir_graph, NULL, op_Block, mode_R, -1, NULL); + res = new_r_Block (current_ir_graph, arity, in); current_ir_graph->current_block = res; - res->attr.block.matured = 0; - set_Block_block_visited(res, 0); - /* forget this optimization. use this only if mature !!!! - res = optimize (res); */ - irn_vrfy (res); - - /** create a new dynamic array, which stores all parameters in irnodes */ - /** using the same obstack as the whole irgraph */ + /* Create and initialize array for Phi-node construction. */ res->attr.block.graph_arr = NEW_ARR_D (ir_node *, current_ir_graph->obst, - current_ir_graph->params); + current_ir_graph->n_loc); + memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc); - /** initialize the parameter array */ - memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->params); + res = optimize (res); + irn_vrfy (res); return res; } +#else +ir_node * +new_Block (void) +{ + return new_immBlock(); +} +#endif /*************************************************************************/ /* Methods necessary for automatic Phi node creation */ @@ -1473,7 +1488,7 @@ new_Sel (ir_node *store, ir_node *objptr, int n_index, ir_node **index, entity * } ir_node * -new_SymConst (type_or_id *value, symconst_kind kind) +new_SymConst (type_or_id_p value, symconst_kind kind) { return new_r_SymConst (current_ir_graph, current_ir_graph->current_block, value, kind); @@ -1496,7 +1511,31 @@ new_Bad (void) /*************************************************************************/ /* Comfortable interface with automatic Phi node construction. */ /* (Uses also constructors of ?? interface, except new_Block. */ -/* add an adge to a jmp node */ +/*************************************************************************/ + +/** Block construction **/ +/* immature Block without predecessors */ +ir_node *new_immBlock (void) { + ir_node *res; + + /* creates a new dynamic in-array as length of in is -1 */ + res = new_ir_node (current_ir_graph, NULL, op_Block, mode_R, -1, NULL); + current_ir_graph->current_block = res; + res->attr.block.matured = 0; + set_Block_block_visited(res, 0); + + /* Create and initialize array for Phi-node construction. */ + res->attr.block.graph_arr = NEW_ARR_D (ir_node *, current_ir_graph->obst, + current_ir_graph->n_loc); + memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc); + + /* Immature block may not be optimized! */ + irn_vrfy (res); + + return res; +} + +/* add an adge to a jmp/control flow node */ void add_in_edge (ir_node *block, ir_node *jmp) {