X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Fircons.c;h=277d3fec466a9590a69eac1e5d9a49cb69bd9be9;hb=31ef53136fdb86d4a98919c2148c95cadea4ea81;hp=5b85701cb4d3f6df885cfc6ad8befa0c20da2127;hpb=222c1d46a0a3f0bddf3df3d84523287a4a960720;p=libfirm diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 5b85701cb..277d3fec4 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -40,12 +40,11 @@ #include "iropt_t.h" #include "irgmod.h" #include "irhooks.h" -#include "array.h" +#include "array_t.h" #include "irbackedge_t.h" #include "irflag_t.h" #include "iredges_t.h" #include "irflag_t.h" -#include "xmalloc.h" #if USE_EXPLICIT_PHI_IN_STACK /* A stack needed for the automatic Phi node construction in constructor @@ -254,7 +253,7 @@ new_bd_Phi(dbg_info *db, ir_node *block, int arity, ir_node **in, ir_mode *mode) res->attr.phi.u.backedge = new_backedge_arr(irg->obst, arity); for (i = arity - 1; i >= 0; --i) - if (get_irn_op(in[i]) == op_Unknown) { + if (is_Unknown(in[i])) { has_unknown = 1; break; } @@ -395,7 +394,7 @@ NEW_BD_UNOP(Not) NEW_BD_BINOP(Shl) NEW_BD_BINOP(Shr) NEW_BD_BINOP(Shrs) -NEW_BD_BINOP(Rot) +NEW_BD_BINOP(Rotl) NEW_BD_UNOP(Abs) NEW_BD_BINOP(Carry) NEW_BD_BINOP(Borrow) @@ -617,9 +616,9 @@ new_bd_SymConst_type(dbg_info *db, ir_node *block, ir_mode *mode, ir_graph *irg = current_ir_graph; ir_node *res = new_ir_node(db, irg, block, op_SymConst, mode, 0, NULL); - res->attr.symc.num = symkind; - res->attr.symc.sym = value; - res->attr.symc.tp = tp; + res->attr.symc.kind = symkind; + res->attr.symc.sym = value; + res->attr.symc.tp = tp; res = optimize_node(res); IRN_VRFY_IRG(res, irg); @@ -748,30 +747,6 @@ new_bd_Mux(dbg_info *db, ir_node *block, return res; } /* new_bd_Mux */ -static ir_node * -new_bd_Psi(dbg_info *db, ir_node *block, - int arity, ir_node *cond[], ir_node *vals[], ir_mode *mode) { - ir_node **in; - ir_node *res; - ir_graph *irg = current_ir_graph; - int i; - - NEW_ARR_A(ir_node *, in, 2 * arity + 1); - - for (i = 0; i < arity; ++i) { - in[2 * i] = cond[i]; - in[2 * i + 1] = vals[i]; - } - in[2 * i] = vals[i]; - - res = new_ir_node(db, irg, block, op_Psi, mode, 2 * arity + 1, in); - assert(res); - - res = optimize_node(res); - IRN_VRFY_IRG(res, irg); - return res; -} /* new_bd_Psi */ - static ir_node * new_bd_CopyB(dbg_info *db, ir_node *block, ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type) { @@ -862,12 +837,12 @@ new_bd_ASM(dbg_info *db, ir_node *block, int arity, ir_node *in[], ir_asm_constr res->attr.assem.pin_state = op_pin_state_pinned; res->attr.assem.inputs = NEW_ARR_D(ir_asm_constraint, irg->obst, arity); res->attr.assem.outputs = NEW_ARR_D(ir_asm_constraint, irg->obst, n_outs); - res->attr.assem.clobber = NEW_ARR_D(ident *, irg->obst, n_clobber); + res->attr.assem.clobber = NEW_ARR_D(ident *, irg->obst, n_clobber); res->attr.assem.asm_text = asm_text; - memcpy(res->attr.assem.inputs, inputs, sizeof(inputs[0]) * arity); - memcpy(res->attr.assem.outputs, outputs, sizeof(outputs[0]) * n_outs); - memcpy(res->attr.assem.clobber, clobber, sizeof(clobber[0]) * n_clobber); + memcpy(res->attr.assem.inputs, inputs, sizeof(inputs[0]) * arity); + memcpy(res->attr.assem.outputs, outputs, sizeof(outputs[0]) * n_outs); + memcpy(res->attr.assem.clobber, clobber, sizeof(clobber[0]) * n_clobber); res = optimize_node(res); IRN_VRFY_IRG(res, irg); @@ -1050,7 +1025,7 @@ NEW_RD_UNOP(Not) NEW_RD_BINOP(Shl) NEW_RD_BINOP(Shr) NEW_RD_BINOP(Shrs) -NEW_RD_BINOP(Rot) +NEW_RD_BINOP(Rotl) NEW_RD_UNOP(Abs) NEW_RD_BINOP(Carry) NEW_RD_BINOP(Borrow) @@ -1395,19 +1370,6 @@ new_rd_Mux(dbg_info *db, ir_graph *irg, ir_node *block, return res; } /* new_rd_Mux */ -ir_node * -new_rd_Psi(dbg_info *db, ir_graph *irg, ir_node *block, - int arity, ir_node *cond[], ir_node *vals[], ir_mode *mode) { - ir_node *res; - ir_graph *rem = current_ir_graph; - - current_ir_graph = irg; - res = new_bd_Psi(db, block, arity, cond, vals, mode); - current_ir_graph = rem; - - return res; -} /* new_rd_Psi */ - ir_node *new_rd_CopyB(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type) { ir_node *res; @@ -1607,9 +1569,9 @@ ir_node *new_r_Shrs(ir_graph *irg, ir_node *block, ir_node *op, ir_node *k, ir_mode *mode) { return new_rd_Shrs(NULL, irg, block, op, k, mode); } -ir_node *new_r_Rot(ir_graph *irg, ir_node *block, +ir_node *new_r_Rotl(ir_graph *irg, ir_node *block, ir_node *op, ir_node *k, ir_mode *mode) { - return new_rd_Rot(NULL, irg, block, op, k, mode); + return new_rd_Rotl(NULL, irg, block, op, k, mode); } ir_node *new_r_Carry(ir_graph *irg, ir_node *block, ir_node *op, ir_node *k, ir_mode *mode) { @@ -1701,10 +1663,6 @@ ir_node *new_r_Mux(ir_graph *irg, ir_node *block, ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode) { return new_rd_Mux(NULL, irg, block, sel, ir_false, ir_true, mode); } -ir_node *new_r_Psi(ir_graph *irg, ir_node *block, - int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode) { - return new_rd_Psi(NULL, irg, block, arity, conds, vals, mode); -} ir_node *new_r_CopyB(ir_graph *irg, ir_node *block, ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type) { return new_rd_CopyB(NULL, irg, block, store, dst, src, data_type); @@ -1785,7 +1743,7 @@ new_d_Block(dbg_info *db, int arity, ir_node **in) { } for (i = arity-1; i >= 0; i--) - if (get_irn_op(in[i]) == op_Unknown) { + if (is_Unknown(in[i])) { has_unknown = 1; break; } @@ -1938,11 +1896,11 @@ static INLINE ir_node **new_frag_arr(ir_node *n) { finished yet. */ opt = get_opt_optimize(); set_optimize(0); /* Here we rely on the fact that all frag ops have Memory as first result! */ - if (get_irn_op(n) == op_Call) + if (is_Call(n)) { arr[0] = new_Proj(n, mode_M, pn_Call_M_except); - else if (get_irn_op(n) == op_CopyB) + } else if (is_CopyB(n)) { arr[0] = new_Proj(n, mode_M, pn_CopyB_M_except); - else { + } else { assert((pn_Quot_M == pn_DivMod_M) && (pn_Quot_M == pn_Div_M) && (pn_Quot_M == pn_Mod_M) && @@ -2386,24 +2344,30 @@ NEW_D_BINOP(Mul) NEW_D_BINOP(Mulh) /** - * Allocate the frag array. + * Allocate a frag array for a node if the current graph state is phase_building. + * + * @param irn the node for which the frag array should be allocated + * @param op the opcode of the (original) node, if does not match opcode of irn, + * nothing is done + * @param frag_store the address of the frag store in irn attributes, if this + * address contains a value != NULL, does nothing */ -static void allocate_frag_arr(ir_node *res, ir_op *op, ir_node ***frag_store) { +void firm_alloc_frag_arr(ir_node *irn, ir_op *op, ir_node ***frag_store) { if (get_opt_precise_exc_context()) { if ((current_ir_graph->phase_state == phase_building) && - (get_irn_op(res) == op) && /* Could be optimized away. */ + (get_irn_op(irn) == op) && /* Could be optimized away. */ !*frag_store) /* Could be a cse where the arr is already set. */ { - *frag_store = new_frag_arr(res); + *frag_store = new_frag_arr(irn); } } -} /* allocate_frag_arr */ +} /* firm_alloc_frag_arr */ ir_node * new_d_Quot(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) { ir_node *res; res = new_bd_Quot(db, current_ir_graph->current_block, memop, op1, op2, mode, state); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Quot, &res->attr.except.frag_arr); /* Could be optimized away. */ + firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr); #endif return res; @@ -2414,7 +2378,7 @@ new_d_DivMod(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode * ir_node *res; res = new_bd_DivMod(db, current_ir_graph->current_block, memop, op1, op2, mode, state); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_DivMod, &res->attr.except.frag_arr); /* Could be optimized away. */ + firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr); #endif return res; @@ -2425,7 +2389,7 @@ new_d_Div(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mod ir_node *res; res = new_bd_Div(db, current_ir_graph->current_block, memop, op1, op2, mode, state); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Div, &res->attr.except.frag_arr); /* Could be optimized away. */ + firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr); #endif return res; @@ -2436,7 +2400,7 @@ new_d_DivRL(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *m ir_node *res; res = new_bd_DivRL(db, current_ir_graph->current_block, memop, op1, op2, mode, state); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Div, &res->attr.except.frag_arr); /* Could be optimized away. */ + firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr); #endif return res; @@ -2447,7 +2411,7 @@ new_d_Mod(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mod ir_node *res; res = new_bd_Mod(db, current_ir_graph->current_block, memop, op1, op2, mode, state); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Mod, &res->attr.except.frag_arr); /* Could be optimized away. */ + firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr); #endif return res; @@ -2460,7 +2424,7 @@ NEW_D_UNOP(Not) NEW_D_BINOP(Shl) NEW_D_BINOP(Shr) NEW_D_BINOP(Shrs) -NEW_D_BINOP(Rot) +NEW_D_BINOP(Rotl) NEW_D_UNOP(Abs) NEW_D_BINOP(Carry) NEW_D_BINOP(Borrow) @@ -2492,7 +2456,7 @@ new_d_Call(dbg_info *db, ir_node *store, ir_node *callee, int arity, ir_node **i res = new_bd_Call(db, current_ir_graph->current_block, store, callee, arity, in, tp); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr); /* Could be optimized away. */ + firm_alloc_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr); #endif return res; @@ -2510,7 +2474,7 @@ new_d_Load(dbg_info *db, ir_node *store, ir_node *addr, ir_mode *mode) { res = new_bd_Load(db, current_ir_graph->current_block, store, addr, mode); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr); /* Could be optimized away. */ + firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr); #endif return res; @@ -2522,7 +2486,7 @@ new_d_Store(dbg_info *db, ir_node *store, ir_node *addr, ir_node *val) { res = new_bd_Store(db, current_ir_graph->current_block, store, addr, val); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr); /* Could be optimized away. */ + firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr); #endif return res; @@ -2535,7 +2499,7 @@ new_d_Alloc(dbg_info *db, ir_node *store, ir_node *size, ir_type *alloc_type, res = new_bd_Alloc(db, current_ir_graph->current_block, store, size, alloc_type, where); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr); /* Could be optimized away. */ + firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr); #endif return res; @@ -2635,19 +2599,13 @@ new_d_Mux(dbg_info *db, ir_node *sel, ir_node *ir_false, sel, ir_false, ir_true, mode); } /* new_d_Mux */ -ir_node * -new_d_Psi(dbg_info *db,int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode) { - return new_bd_Psi(db, current_ir_graph->current_block, - arity, conds, vals, mode); -} /* new_d_Psi */ - ir_node *new_d_CopyB(dbg_info *db,ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type) { ir_node *res; res = new_bd_CopyB(db, current_ir_graph->current_block, store, dst, src, data_type); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr); + firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr); #endif return res; } /* new_d_CopyB */ @@ -2669,7 +2627,7 @@ ir_node *new_d_Bound(dbg_info *db,ir_node *store, res = new_bd_Bound(db, current_ir_graph->current_block, store, idx, lower, upper); #if PRECISE_EXC_CONTEXT - allocate_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr); + firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr); #endif return res; } /* new_d_Bound */ @@ -2892,9 +2850,9 @@ ir_type *get_cur_frame_type(void) { /* call once for each run of the library */ void -init_cons(uninitialized_local_variable_func_t *func) { +firm_init_cons(uninitialized_local_variable_func_t *func) { default_initialize_local_variable = func; -} /* init_cons */ +} /* firm_init_cons */ void irp_finalize_cons(void) { @@ -3010,8 +2968,8 @@ ir_node *new_Shr(ir_node *op, ir_node *k, ir_mode *mode) { ir_node *new_Shrs(ir_node *op, ir_node *k, ir_mode *mode) { return new_d_Shrs(NULL, op, k, mode); } -ir_node *new_Rot(ir_node *op, ir_node *k, ir_mode *mode) { - return new_d_Rot(NULL, op, k, mode); +ir_node *new_Rotl(ir_node *op, ir_node *k, ir_mode *mode) { + return new_d_Rotl(NULL, op, k, mode); } ir_node *new_Carry(ir_node *op1, ir_node *op2, ir_mode *mode) { return new_d_Carry(NULL, op1, op2, mode); @@ -3093,9 +3051,6 @@ ir_node *new_NoMem(void) { ir_node *new_Mux(ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode) { return new_d_Mux(NULL, sel, ir_false, ir_true, mode); } -ir_node *new_Psi(int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode) { - return new_d_Psi(NULL, arity, conds, vals, mode); -} ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type) { return new_d_CopyB(NULL, store, dst, src, data_type); }