X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Fircons.c;h=bcd8b7bdda94af3b58f0ebeef2b8dcff224c2847;hb=cb91bddc9cacdab7c28e4336847bd3dc248aa549;hp=398cfe22f117e66909d4f2bdbad0152048975356;hpb=58ed1dbc91297e868c47ffb3b622c66f28065105;p=libfirm diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 398cfe22f..bcd8b7bdd 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -155,9 +155,6 @@ new_rd_Const (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, tarval { type *tp = unknown_type; /* removing this somehow causes errors in jack. */ - if (tarval_is_entity(con)) - tp = find_pointer_type_to_type(get_entity_type(get_tarval_entity(con))); - return new_rd_Const_type (db, irg, block, mode, con, tp); } @@ -183,7 +180,7 @@ new_rd_Proj (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *arg, ir_mode assert(res); assert(get_Proj_pred(res)); - assert(get_nodes_Block(get_Proj_pred(res))); + assert(get_nodes_block(get_Proj_pred(res))); res = optimize_node(res); @@ -585,7 +582,7 @@ new_rd_Raise (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, ir_no INLINE ir_node * new_rd_Load (dbg_info* db, ir_graph *irg, ir_node *block, - ir_node *store, ir_node *adr) + ir_node *store, ir_node *adr, ir_mode *mode) { ir_node *in[2]; ir_node *res; @@ -593,6 +590,8 @@ new_rd_Load (dbg_info* db, ir_graph *irg, ir_node *block, in[0] = store; in[1] = adr; res = new_ir_node(db, irg, block, op_Load, mode_T, 2, in); + res->attr.load.load_mode = mode; + res->attr.load.volatility = volatility_non_volatile; res = optimize_node(res); IRN_VRFY_IRG(res, irg); return res; @@ -609,6 +608,7 @@ new_rd_Store (dbg_info* db, ir_graph *irg, ir_node *block, in[1] = adr; in[2] = val; res = new_ir_node(db, irg, block, op_Store, mode_T, 3, in); + res->attr.store.volatility = volatility_non_volatile; res = optimize_node(res); IRN_VRFY_IRG(res, irg); return res; @@ -839,7 +839,7 @@ new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg, ir_mod assert(res); assert(get_Proj_pred(res)); - assert(get_nodes_Block(get_Proj_pred(res))); + assert(get_nodes_block(get_Proj_pred(res))); res = optimize_node(res); IRN_VRFY_IRG(res, irg); @@ -1000,8 +1000,8 @@ INLINE ir_node *new_r_Phi (ir_graph *irg, ir_node *block, int arity, return new_rd_Phi(NULL, irg, block, arity, in, mode); } INLINE ir_node *new_r_Load (ir_graph *irg, ir_node *block, - ir_node *store, ir_node *adr) { - return new_rd_Load(NULL, irg, block, store, adr); + ir_node *store, ir_node *adr, ir_mode *mode) { + return new_rd_Load(NULL, irg, block, store, adr, mode); } INLINE ir_node *new_r_Store (ir_graph *irg, ir_node *block, ir_node *store, ir_node *adr, ir_node *val) { @@ -1117,9 +1117,11 @@ new_d_Block (dbg_info* db, int arity, ir_node **in) res = new_rd_Block(db, current_ir_graph, arity, in); /* 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); + if (get_irg_phase_state(current_ir_graph) == phase_building) { + 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); + } for (i = arity-1; i >= 0; i--) if (get_irn_op(in[i]) == op_Unknown) { @@ -1145,7 +1147,7 @@ new_d_Block (dbg_info* db, int arity, ir_node **in) Call Graph: ( A ---> B == A "calls" B) - get_value mature_block + get_value mature_immBlock | | | | | | @@ -1367,7 +1369,7 @@ phi_merge (ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins) The call order get_value (makes Phi0, put's it into graph_arr) set_value (overwrites Phi0 in graph_arr) - mature_block (upgrades Phi0, puts it again into graph_arr, overwriting + mature_immBlock (upgrades Phi0, puts it again into graph_arr, overwriting the proper value.) fails. */ if (!block->attr.block.graph_arr[pos]) { @@ -1458,7 +1460,7 @@ get_r_value_internal (ir_node *block, int pos, ir_mode *mode) /* The block is not mature, we don't know how many in's are needed. A Phi with zero predecessors is created. Such a Phi node is called Phi0 node. (There is also an obsolete Phi0 opcode.) The Phi0 is then added - to the list of Phi0 nodes in this block to be matured by mature_block + to the list of Phi0 nodes in this block to be matured by mature_immBlock later. The Phi0 has to remember the pos of it's internal value. If the real Phi is computed, pos is used to update the array with the local @@ -1604,14 +1606,22 @@ static INLINE ir_node ** new_frag_arr (ir_node *n) return arr; } +/** + * returns the frag_arr from a node + */ static INLINE ir_node ** get_frag_arr (ir_node *n) { - if (get_irn_op(n) == op_Call) { + switch (get_irn_opcode(n)) { + case iro_Call: return n->attr.call.frag_arr; - } else if (get_irn_op(n) == op_Alloc) { + case iro_Alloc: return n->attr.a.frag_arr; - } else { - return n->attr.frag_arr; + case iro_Load: + return n->attr.load.frag_arr; + case iro_Store: + return n->attr.store.frag_arr; + default: + return n->attr.except.frag_arr; } } @@ -1762,7 +1772,7 @@ phi_merge (ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins) optimization possibilities. The Phi0 node either is allocated in this function, or it comes from a former call to get_r_value_internal. In this case we may not yet - exchange phi0, as this is done in mature_block. */ + exchange phi0, as this is done in mature_immBlock. */ if (!phi0) { phi0_all = block->attr.block.graph_arr[pos]; if (!((get_irn_op(phi0_all) == op_Phi) && @@ -1859,7 +1869,7 @@ get_r_value_internal (ir_node *block, int pos, ir_mode *mode) /* The block is not mature, we don't know how many in's are needed. A Phi with zero predecessors is created. Such a Phi node is called Phi0 node. The Phi0 is then added to the list of Phi0 nodes in this block - to be matured by mature_block later. + to be matured by mature_immBlock later. The Phi0 has to remember the pos of it's internal value. If the real Phi is computed, pos is used to update the array with the local values. */ @@ -1891,7 +1901,7 @@ get_r_value_internal (ir_node *block, int pos, ir_mode *mode) /** Finalize a Block node, when all control flows are known. */ /** Acceptable parameters are only Block nodes. */ void -mature_block (ir_node *block) +mature_immBlock (ir_node *block) { int ins; @@ -2049,7 +2059,7 @@ new_d_Quot (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2) res = new_rd_Quot (db, current_ir_graph, current_ir_graph->current_block, memop, op1, op2); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Quot, &res->attr.frag_arr); /* Could be optimized away. */ + allocate_frag_arr(res, op_Quot, &res->attr.except.frag_arr); /* Could be optimized away. */ #endif return res; @@ -2062,7 +2072,7 @@ new_d_DivMod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2) res = new_rd_DivMod (db, current_ir_graph, current_ir_graph->current_block, memop, op1, op2); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_DivMod, &res->attr.frag_arr); /* Could be optimized away. */ + allocate_frag_arr(res, op_DivMod, &res->attr.except.frag_arr); /* Could be optimized away. */ #endif return res; @@ -2075,7 +2085,7 @@ new_d_Div (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2) res = new_rd_Div (db, current_ir_graph, current_ir_graph->current_block, memop, op1, op2); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Div, &res->attr.frag_arr); /* Could be optimized away. */ + allocate_frag_arr(res, op_Div, &res->attr.except.frag_arr); /* Could be optimized away. */ #endif return res; @@ -2088,7 +2098,7 @@ new_d_Mod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2) res = new_rd_Mod (db, current_ir_graph, current_ir_graph->current_block, memop, op1, op2); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Mod, &res->attr.frag_arr); /* Could be optimized away. */ + allocate_frag_arr(res, op_Mod, &res->attr.except.frag_arr); /* Could be optimized away. */ #endif return res; @@ -2205,13 +2215,13 @@ new_d_Raise (dbg_info* db, ir_node *store, ir_node *obj) } ir_node * -new_d_Load (dbg_info* db, ir_node *store, ir_node *addr) +new_d_Load (dbg_info* db, ir_node *store, ir_node *addr, ir_mode *mode) { ir_node *res; res = new_rd_Load (db, current_ir_graph, current_ir_graph->current_block, - store, addr); + store, addr, mode); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Load, &res->attr.frag_arr); /* Could be optimized away. */ + allocate_frag_arr(res, op_Load, &res->attr.load.frag_arr); /* Could be optimized away. */ #endif return res; @@ -2224,7 +2234,7 @@ new_d_Store (dbg_info* db, ir_node *store, ir_node *addr, ir_node *val) res = new_rd_Store (db, current_ir_graph, current_ir_graph->current_block, store, addr, val); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Store, &res->attr.frag_arr); /* Could be optimized away. */ + allocate_frag_arr(res, op_Store, &res->attr.store.frag_arr); /* Could be optimized away. */ #endif return res; @@ -2404,7 +2414,7 @@ new_immBlock (void) { /* add an adge to a jmp/control flow node */ void -add_in_edge (ir_node *block, ir_node *jmp) +add_immBlock_pred (ir_node *block, ir_node *jmp) { if (block->attr.block.matured) { assert(0 && "Error: Block already matured!\n"); @@ -2417,7 +2427,7 @@ add_in_edge (ir_node *block, ir_node *jmp) /* changing the current block */ void -switch_block (ir_node *target) +set_cur_block (ir_node *target) { current_ir_graph->current_block = target; } @@ -2477,7 +2487,7 @@ keep_alive (ir_node *ka) /** Useful access routines **/ /* Returns the current block of the current graph. To set the current - block use switch_block(). */ + block use set_cur_block. */ ir_node *get_cur_block() { return get_irg_current_block(current_ir_graph); } @@ -2610,8 +2620,8 @@ ir_node *new_Cast (ir_node *op, type *to_tp) { ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode) { return new_d_Phi(NULL, arity, in, mode); } -ir_node *new_Load (ir_node *store, ir_node *addr) { - return new_d_Load(NULL, store, addr); +ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode) { + return new_d_Load(NULL, store, addr, mode); } ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val) { return new_d_Store(NULL, store, addr, val);