X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fir%2Fircons.c;h=6d7a3fc6a2b2975c6dad194df0f2667c4fdfa98f;hb=3f57d89fcb7055fc726a41aa63214aab97854cdf;hp=bc0b254ea887d10134161761f459bab78b69ac2c;hpb=bc35052031be38b7243401b37fe1d791728c7df2;p=libfirm diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index bc0b254ea..6d7a3fc6a 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -32,7 +32,7 @@ #include "irnode_t.h" #include "irmode_t.h" #include "ircons_t.h" -#include "irvrfy.h" +#include "irverify.h" #include "irop_t.h" #include "iropt_t.h" #include "irgmod.h" @@ -42,12 +42,13 @@ #include "irflag_t.h" #include "iredges_t.h" #include "irflag_t.h" +#include "error.h" /* when we need verifying */ #ifdef NDEBUG -# define IRN_VRFY_IRG(res, irg) +# define IRN_VERIFY_IRG(res, irg) #else -# define IRN_VRFY_IRG(res, irg) irn_vrfy_irg(res, irg) +# define IRN_VERIFY_IRG(res, irg) irn_verify_irg(res, irg) #endif /* NDEBUG */ /** @@ -55,135 +56,27 @@ */ static uninitialized_local_variable_func_t *default_initialize_local_variable = NULL; -/* creates a bd constructor for a binop */ -#define NEW_BD_BINOP(instr) \ -static ir_node * \ -new_bd_##instr(dbg_info *db, ir_node *block, \ - ir_node *op1, ir_node *op2, ir_mode *mode) \ -{ \ - ir_node *in[2]; \ - ir_node *res; \ - ir_graph *irg = current_ir_graph; \ - in[0] = op1; \ - in[1] = op2; \ - res = new_ir_node(db, irg, block, op_##instr, mode, 2, in); \ - res = optimize_node(res); \ - IRN_VRFY_IRG(res, irg); \ - return res; \ -} - -/* creates a bd constructor for an unop */ -#define NEW_BD_UNOP(instr) \ -static ir_node * \ -new_bd_##instr(dbg_info *db, ir_node *block, \ - ir_node *op, ir_mode *mode) \ -{ \ - ir_node *res; \ - ir_graph *irg = current_ir_graph; \ - res = new_ir_node(db, irg, block, op_##instr, mode, 1, &op); \ - res = optimize_node(res); \ - IRN_VRFY_IRG(res, irg); \ - return res; \ -} - -/* creates a bd constructor for an divop */ -#define NEW_BD_DIVOP(instr) \ -static ir_node * \ -new_bd_##instr(dbg_info *db, ir_node *block, \ - ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) \ -{ \ - ir_node *in[3]; \ - ir_node *res; \ - ir_graph *irg = current_ir_graph; \ - in[0] = memop; \ - in[1] = op1; \ - in[2] = op2; \ - res = new_ir_node(db, irg, block, op_##instr, mode_T, 3, in); \ - res->attr.divmod.exc.pin_state = state; \ - res->attr.divmod.resmode = mode; \ - res->attr.divmod.no_remainder = 0; \ - res = optimize_node(res); \ - IRN_VRFY_IRG(res, irg); \ - return res; \ -} - -/* creates a rd constructor for a binop */ -#define NEW_RD_BINOP(instr) \ -ir_node * \ -new_rd_##instr(dbg_info *db, ir_graph *irg, ir_node *block, \ - ir_node *op1, ir_node *op2, ir_mode *mode) \ -{ \ - ir_node *res; \ - ir_graph *rem = current_ir_graph; \ - current_ir_graph = irg; \ - res = new_bd_##instr(db, block, op1, op2, mode); \ - current_ir_graph = rem; \ - return res; \ -} - -/* creates a rd constructor for an unop */ -#define NEW_RD_UNOP(instr) \ -ir_node * \ -new_rd_##instr(dbg_info *db, ir_graph *irg, ir_node *block, \ - ir_node *op, ir_mode *mode) \ -{ \ - ir_node *res; \ - ir_graph *rem = current_ir_graph; \ - current_ir_graph = irg; \ - res = new_bd_##instr(db, block, op, mode); \ - current_ir_graph = rem; \ - return res; \ -} - -/* creates a rd constructor for an divop */ -#define NEW_RD_DIVOP(instr) \ -ir_node * \ -new_rd_##instr(dbg_info *db, ir_graph *irg, ir_node *block, \ - ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) \ -{ \ - ir_node *res; \ - ir_graph *rem = current_ir_graph; \ - current_ir_graph = irg; \ - res = new_bd_##instr(db, block, memop, op1, op2, mode, state);\ - current_ir_graph = rem; \ - return res; \ -} - -/* creates a d constructor for an binop */ -#define NEW_D_BINOP(instr) \ -ir_node * \ -new_d_##instr(dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode) { \ - return new_bd_##instr(db, current_ir_graph->current_block, op1, op2, mode); \ -} - -/* creates a d constructor for an unop */ -#define NEW_D_UNOP(instr) \ -ir_node * \ -new_d_##instr(dbg_info *db, ir_node *op, ir_mode *mode) { \ - return new_bd_##instr(db, current_ir_graph->current_block, op, mode); \ -} - #include "gen_ir_cons.c.inl" -static ir_node * -new_bd_Start(dbg_info *db, ir_node *block) { +static ir_node *new_bd_Start(dbg_info *db, ir_node *block) +{ ir_node *res; - ir_graph *irg = current_ir_graph; + ir_graph *irg = get_irn_irg(block); res = new_ir_node(db, irg, block, op_Start, mode_T, 0, NULL); - IRN_VRFY_IRG(res, irg); + IRN_VERIFY_IRG(res, irg); return res; } /* new_bd_Start */ -static ir_node * -new_bd_End(dbg_info *db, ir_node *block) { +static ir_node *new_bd_End(dbg_info *db, ir_node *block) +{ ir_node *res; - ir_graph *irg = current_ir_graph; + ir_graph *irg = get_irn_irg(block); res = new_ir_node(db, irg, block, op_End, mode_X, -1, NULL); - IRN_VRFY_IRG(res, irg); + IRN_VERIFY_IRG(res, irg); return res; } /* new_bd_End */ @@ -191,10 +84,10 @@ new_bd_End(dbg_info *db, ir_node *block) { * Creates a Phi node with all predecessors. Calling this constructor * is only allowed if the corresponding block is mature. */ -static ir_node * -new_bd_Phi(dbg_info *db, ir_node *block, int arity, ir_node **in, ir_mode *mode) { +static ir_node *new_bd_Phi(dbg_info *db, ir_node *block, int arity, ir_node **in, ir_mode *mode) +{ ir_node *res; - ir_graph *irg = current_ir_graph; + ir_graph *irg = get_irn_irg(block); int i; int has_unknown = 0; @@ -214,7 +107,7 @@ new_bd_Phi(dbg_info *db, ir_node *block, int arity, ir_node **in, ir_mode *mode) } if (!has_unknown) res = optimize_node(res); - IRN_VRFY_IRG(res, irg); + IRN_VERIFY_IRG(res, irg); /* Memory Phis in endless loops must be kept alive. As we can't distinguish these easily we keep all of them alive. */ @@ -223,54 +116,53 @@ new_bd_Phi(dbg_info *db, ir_node *block, int arity, ir_node **in, ir_mode *mode) return res; } /* new_bd_Phi */ -static ir_node * -new_bd_Const_type(dbg_info *db, tarval *con, ir_type *tp) { +static ir_node *new_bd_Const_type(dbg_info *db, tarval *con, ir_type *tp) +{ ir_node *res; ir_graph *irg = current_ir_graph; res = new_ir_node(db, irg, get_irg_start_block(irg), op_Const, get_tarval_mode(con), 0, NULL); - res->attr.con.tv = con; + res->attr.con.tarval = con; set_Const_type(res, tp); /* Call method because of complex assertion. */ res = optimize_node (res); assert(get_Const_type(res) == tp); - IRN_VRFY_IRG(res, irg); + IRN_VERIFY_IRG(res, irg); return res; } /* new_bd_Const_type */ -static ir_node * -new_bd_Const(dbg_info *db, tarval *con) { +static ir_node *new_bd_Const(dbg_info *db, tarval *con) +{ ir_graph *irg = current_ir_graph; return new_rd_Const_type(db, irg, con, firm_unknown_type); } /* new_bd_Const */ -static ir_node * -new_bd_Const_long(dbg_info *db, ir_mode *mode, long value) { +static ir_node *new_bd_Const_long(dbg_info *db, ir_mode *mode, long value) +{ ir_graph *irg = current_ir_graph; return new_rd_Const(db, irg, new_tarval_from_long(value, mode)); } /* new_bd_Const_long */ -static ir_node * -new_bd_defaultProj(dbg_info *db, ir_node *block, ir_node *arg, - long max_proj) { +static ir_node *new_bd_defaultProj(dbg_info *db, ir_node *arg, long max_proj) +{ ir_node *res; assert(arg->op == op_Cond); - arg->attr.cond.kind = fragmentary; arg->attr.cond.default_proj = max_proj; - res = new_rd_Proj(db, block, arg, mode_X, max_proj); + res = new_rd_Proj(db, arg, mode_X, max_proj); return res; } /* new_bd_defaultProj */ -static ir_node * -new_bd_Sel(dbg_info *db, ir_node *block, ir_node *store, ir_node *objptr, - int arity, ir_node **in, ir_entity *ent) { +static ir_node *new_bd_Sel(dbg_info *db, ir_node *block, ir_node *store, + ir_node *objptr, int arity, ir_node **in, + ir_entity *ent) +{ ir_node **r_in; ir_node *res; int r_arity; - ir_graph *irg = current_ir_graph; + ir_graph *irg = get_irn_irg(block); ir_mode *mode = is_Method_type(get_entity_type(ent)) ? mode_P_code : mode_P_data; assert(ent != NULL && is_entity(ent) && "entity expected in Sel construction"); @@ -286,14 +178,15 @@ new_bd_Sel(dbg_info *db, ir_node *block, ir_node *store, ir_node *objptr, res = new_ir_node(db, irg, block, op_Sel, mode, r_arity, r_in); res->attr.sel.entity = ent; res = optimize_node(res); - IRN_VRFY_IRG(res, irg); + IRN_VERIFY_IRG(res, irg); return res; } /* new_bd_Sel */ -static ir_node * -new_bd_SymConst_type(dbg_info *db, ir_node *block, ir_mode *mode, - symconst_symbol value,symconst_kind symkind, ir_type *tp) { - ir_graph *irg = current_ir_graph; +static ir_node *new_bd_SymConst_type(dbg_info *db, ir_node *block, + ir_mode *mode, symconst_symbol value, + symconst_kind symkind, ir_type *tp) +{ + ir_graph *irg = get_irn_irg(block); ir_node *res = new_ir_node(db, irg, block, op_SymConst, mode, 0, NULL); res->attr.symc.kind = symkind; @@ -301,63 +194,44 @@ new_bd_SymConst_type(dbg_info *db, ir_node *block, ir_mode *mode, res->attr.symc.tp = tp; res = optimize_node(res); - IRN_VRFY_IRG(res, irg); + IRN_VERIFY_IRG(res, irg); return res; } /* new_bd_SymConst_type */ -static ir_node * -new_bd_Sync(dbg_info *db, ir_node *block) { +static ir_node *new_bd_Sync(dbg_info *db, ir_node *block) +{ ir_node *res; - ir_graph *irg = current_ir_graph; + ir_graph *irg = get_irn_irg(block); res = new_ir_node(db, irg, block, op_Sync, mode_M, -1, NULL); /* no need to call optimize node here, Sync are always created with no predecessors */ - IRN_VRFY_IRG(res, irg); + IRN_VERIFY_IRG(res, irg); return res; } /* new_bd_Sync */ - -static ir_node * -new_bd_EndReg(dbg_info *db, ir_node *block) { - ir_node *res; - ir_graph *irg = current_ir_graph; - - res = new_ir_node(db, irg, block, op_EndReg, mode_T, -1, NULL); - set_irg_end_reg(irg, res); - IRN_VRFY_IRG(res, irg); - return res; -} /* new_bd_EndReg */ - -static ir_node * -new_bd_EndExcept(dbg_info *db, ir_node *block) { - ir_node *res; - ir_graph *irg = current_ir_graph; - - res = new_ir_node(db, irg, block, op_EndExcept, mode_T, -1, NULL); - set_irg_end_except(irg, res); - IRN_VRFY_IRG (res, irg); - return res; -} /* new_bd_EndExcept */ - -static ir_node * -new_bd_ASM(dbg_info *db, ir_node *block, int arity, ir_node *in[], ir_asm_constraint *inputs, - int n_outs, ir_asm_constraint *outputs, int n_clobber, ident *clobber[], ident *asm_text) { +static ir_node *new_bd_ASM(dbg_info *db, ir_node *block, int arity, + ir_node *in[], ir_asm_constraint *inputs, int n_outs, + ir_asm_constraint *outputs, int n_clobber, + ident *clobber[], ident *text) +{ ir_node *res; - ir_graph *irg = current_ir_graph; + ir_graph *irg = get_irn_irg(block); res = new_ir_node(db, irg, block, op_ASM, mode_T, arity, in); 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.asm_text = asm_text; + res->attr.assem.input_constraints + = NEW_ARR_D(ir_asm_constraint, irg->obst, arity); + res->attr.assem.output_constraints + = NEW_ARR_D(ir_asm_constraint, irg->obst, n_outs); + res->attr.assem.clobbers = NEW_ARR_D(ident *, irg->obst, n_clobber); + res->attr.assem.text = 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.input_constraints, inputs, sizeof(inputs[0]) * arity); + memcpy(res->attr.assem.output_constraints, outputs, sizeof(outputs[0]) * n_outs); + memcpy(res->attr.assem.clobbers, clobber, sizeof(clobber[0]) * n_clobber); res = optimize_node(res); - IRN_VRFY_IRG(res, irg); + IRN_VERIFY_IRG(res, irg); return res; } /* new_bd_ASM */ @@ -365,8 +239,8 @@ new_bd_ASM(dbg_info *db, ir_node *block, int arity, ir_node *in[], ir_asm_constr /* private interfaces, for professional use only */ /* --------------------------------------------- */ -ir_node * -new_rd_Start(dbg_info *db, ir_graph *irg, ir_node *block) { +ir_node *new_rd_Start(dbg_info *db, ir_graph *irg, ir_node *block) +{ ir_graph *rem = current_ir_graph; ir_node *res; @@ -377,8 +251,8 @@ new_rd_Start(dbg_info *db, ir_graph *irg, ir_node *block) { return res; } /* new_rd_Start */ -ir_node * -new_rd_End(dbg_info *db, ir_graph *irg, ir_node *block) { +ir_node *new_rd_End(dbg_info *db, ir_graph *irg, ir_node *block) +{ ir_node *res; ir_graph *rem = current_ir_graph; @@ -391,8 +265,8 @@ new_rd_End(dbg_info *db, ir_graph *irg, ir_node *block) { /* Creates a Phi node with all predecessors. Calling this constructor is only allowed if the corresponding block is mature. */ -ir_node * -new_rd_Phi(dbg_info *db, ir_node *block, int arity, ir_node **in, ir_mode *mode) { +ir_node *new_rd_Phi(dbg_info *db, ir_node *block, int arity, ir_node **in, ir_mode *mode) +{ ir_node *res; ir_graph *rem = current_ir_graph; @@ -403,8 +277,8 @@ new_rd_Phi(dbg_info *db, ir_node *block, int arity, ir_node **in, ir_mode *mode) return res; } /* new_rd_Phi */ -ir_node * -new_rd_Const_type(dbg_info *db, ir_graph *irg, tarval *con, ir_type *tp) { +ir_node *new_rd_Const_type(dbg_info *db, ir_graph *irg, tarval *con, ir_type *tp) +{ ir_node *res; ir_graph *rem = current_ir_graph; @@ -415,8 +289,8 @@ new_rd_Const_type(dbg_info *db, ir_graph *irg, tarval *con, ir_type *tp) { return res; } /* new_rd_Const_type */ -ir_node * -new_rd_Const(dbg_info *db, ir_graph *irg, tarval *con) { +ir_node *new_rd_Const(dbg_info *db, ir_graph *irg, tarval *con) +{ ir_node *res; //#ifdef USE_ORIGINAL ir_graph *rem = current_ir_graph; @@ -431,26 +305,19 @@ new_rd_Const(dbg_info *db, ir_graph *irg, tarval *con) { return res; } /* new_rd_Const */ -ir_node * -new_rd_Const_long(dbg_info *db, ir_graph *irg, ir_mode *mode, long value) { +ir_node *new_rd_Const_long(dbg_info *db, ir_graph *irg, ir_mode *mode, long value) +{ return new_rd_Const(db, irg, new_tarval_from_long(value, mode)); } /* new_rd_Const_long */ -ir_node * -new_rd_defaultProj(dbg_info *db, ir_node *block, ir_node *arg, long max_proj) { - ir_node *res; - ir_graph *rem = current_ir_graph; - - current_ir_graph = get_Block_irg(block); - res = new_bd_defaultProj(db, block, arg, max_proj); - current_ir_graph = rem; - - return res; +ir_node *new_rd_defaultProj(dbg_info *db, ir_node *arg, long max_proj) +{ + return new_bd_defaultProj(db, arg, max_proj); } /* new_rd_defaultProj */ -ir_node * -new_rd_simpleSel(dbg_info *db, ir_node *block, - ir_node *store, ir_node *objptr, ir_entity *ent) { +ir_node *new_rd_simpleSel(dbg_info *db, ir_node *block, ir_node *store, + ir_node *objptr, ir_entity *ent) +{ ir_node *res; ir_graph *rem = current_ir_graph; @@ -461,9 +328,10 @@ new_rd_simpleSel(dbg_info *db, ir_node *block, return res; } /* new_rd_simpleSel */ -ir_node * -new_rd_SymConst_type(dbg_info *db, ir_graph *irg, ir_mode *mode, - symconst_symbol value, symconst_kind symkind, ir_type *tp) { +ir_node *new_rd_SymConst_type(dbg_info *db, ir_graph *irg, ir_mode *mode, + symconst_symbol value, symconst_kind symkind, + ir_type *tp) +{ ir_node *res; ir_graph *rem = current_ir_graph; ir_node *block = get_irg_start_block(irg); @@ -475,50 +343,49 @@ new_rd_SymConst_type(dbg_info *db, ir_graph *irg, ir_mode *mode, return res; } /* new_rd_SymConst_type */ -ir_node * -new_rd_SymConst(dbg_info *db, ir_graph *irg, ir_mode *mode, - symconst_symbol value, symconst_kind symkind) { +ir_node *new_rd_SymConst(dbg_info *db, ir_graph *irg, ir_mode *mode, + symconst_symbol value, symconst_kind symkind) +{ return new_rd_SymConst_type(db, irg, mode, value, symkind, firm_unknown_type); } /* new_rd_SymConst */ - ir_node *new_rd_SymConst_addr_ent(dbg_info *db, ir_graph *irg, ir_mode *mode, ir_entity *symbol, ir_type *tp) { +ir_node *new_rd_SymConst_addr_ent(dbg_info *db, ir_graph *irg, ir_mode *mode, ir_entity *symbol, ir_type *tp) +{ symconst_symbol sym; sym.entity_p = symbol; return new_rd_SymConst_type(db, irg, mode, sym, symconst_addr_ent, tp); } /* new_rd_SymConst_addr_ent */ -ir_node *new_rd_SymConst_ofs_ent(dbg_info *db, ir_graph *irg, ir_mode *mode, ir_entity *symbol, ir_type *tp) { +ir_node *new_rd_SymConst_ofs_ent(dbg_info *db, ir_graph *irg, ir_mode *mode, ir_entity *symbol, ir_type *tp) +{ symconst_symbol sym; sym.entity_p = symbol; return new_rd_SymConst_type(db, irg, mode, sym, symconst_ofs_ent, tp); } /* new_rd_SymConst_ofs_ent */ -ir_node *new_rd_SymConst_addr_name(dbg_info *db, ir_graph *irg, ir_mode *mode, ident *symbol, ir_type *tp) { - symconst_symbol sym; - sym.ident_p = symbol; - return new_rd_SymConst_type(db, irg, mode, sym, symconst_addr_name, tp); -} /* new_rd_SymConst_addr_name */ - -ir_node *new_rd_SymConst_type_tag(dbg_info *db, ir_graph *irg, ir_mode *mode, ir_type *symbol, ir_type *tp) { +ir_node *new_rd_SymConst_type_tag(dbg_info *db, ir_graph *irg, ir_mode *mode, ir_type *symbol, ir_type *tp) +{ symconst_symbol sym; sym.type_p = symbol; return new_rd_SymConst_type(db, irg, mode, sym, symconst_type_tag, tp); } /* new_rd_SymConst_type_tag */ -ir_node *new_rd_SymConst_size(dbg_info *db, ir_graph *irg, ir_mode *mode, ir_type *symbol, ir_type *tp) { +ir_node *new_rd_SymConst_size(dbg_info *db, ir_graph *irg, ir_mode *mode, ir_type *symbol, ir_type *tp) +{ symconst_symbol sym; sym.type_p = symbol; return new_rd_SymConst_type(db, irg, mode, sym, symconst_type_size, tp); } /* new_rd_SymConst_size */ -ir_node *new_rd_SymConst_align(dbg_info *db, ir_graph *irg, ir_mode *mode, ir_type *symbol, ir_type *tp) { +ir_node *new_rd_SymConst_align(dbg_info *db, ir_graph *irg, ir_mode *mode, ir_type *symbol, ir_type *tp) +{ symconst_symbol sym; sym.type_p = symbol; return new_rd_SymConst_type(db, irg, mode, sym, symconst_type_align, tp); } /* new_rd_SymConst_align */ -ir_node * -new_rd_Sync(dbg_info *db, ir_node *block, int arity, ir_node *in[]) { +ir_node *new_rd_Sync(dbg_info *db, ir_node *block, int arity, ir_node *in[]) +{ ir_node *res; ir_graph *rem = current_ir_graph; int i; @@ -533,114 +400,102 @@ new_rd_Sync(dbg_info *db, ir_node *block, int arity, ir_node *in[]) { return res; } /* new_rd_Sync */ -ir_node * -new_rd_EndReg(dbg_info *db, ir_graph *irg, ir_node *block) { - ir_node *res; - - res = new_ir_node(db, irg, block, op_EndReg, mode_T, -1, NULL); - set_irg_end_reg(irg, res); - IRN_VRFY_IRG(res, irg); - return res; -} /* new_rd_EndReg */ - -ir_node * -new_rd_EndExcept(dbg_info *db, ir_graph *irg, ir_node *block) { - ir_node *res; - - res = new_ir_node(db, irg, block, op_EndExcept, mode_T, -1, NULL); - set_irg_end_except(irg, res); - IRN_VRFY_IRG (res, irg); - return res; -} /* new_rd_EndExcept */ - ir_node *new_rd_ASM(dbg_info *db, ir_node *block, int arity, ir_node *in[], ir_asm_constraint *inputs, int n_outs, ir_asm_constraint *outputs, - int n_clobber, ident *clobber[], ident *asm_text) { + int n_clobber, ident *clobber[], ident *text) +{ ir_node *res; ir_graph *rem = current_ir_graph; current_ir_graph = get_Block_irg(block); - res = new_bd_ASM(db, block, arity, in, inputs, n_outs, outputs, n_clobber, clobber, asm_text); + res = new_bd_ASM(db, block, arity, in, inputs, n_outs, outputs, n_clobber, clobber, text); current_ir_graph = rem; return res; } /* new_rd_ASM */ -ir_node *new_r_Start(ir_graph *irg, ir_node *block) { +ir_node *new_r_Start(ir_graph *irg, ir_node *block) +{ return new_rd_Start(NULL, irg, block); } -ir_node *new_r_End(ir_graph *irg, ir_node *block) { +ir_node *new_r_End(ir_graph *irg, ir_node *block) +{ return new_rd_End(NULL, irg, block); } -ir_node *new_r_Const(ir_graph *irg, tarval *con) { +ir_node *new_r_Const(ir_graph *irg, tarval *con) +{ return new_rd_Const(NULL, irg, con); } -ir_node *new_r_Const_long(ir_graph *irg, ir_mode *mode, long value) { +ir_node *new_r_Const_long(ir_graph *irg, ir_mode *mode, long value) +{ return new_rd_Const_long(NULL, irg, mode, value); } -ir_node *new_r_Const_type(ir_graph *irg, tarval *con, ir_type *tp) { +ir_node *new_r_Const_type(ir_graph *irg, tarval *con, ir_type *tp) +{ return new_rd_Const_type(NULL, irg, con, tp); } -ir_node *new_r_SymConst(ir_graph *irg, ir_mode *mode, - symconst_symbol value, symconst_kind symkind) { +ir_node *new_r_SymConst(ir_graph *irg, ir_mode *mode, symconst_symbol value, + symconst_kind symkind) +{ return new_rd_SymConst(NULL, irg, mode, value, symkind); } -ir_node *new_r_simpleSel(ir_node *block, ir_node *store, - ir_node *objptr, ir_entity *ent) { +ir_node *new_r_simpleSel(ir_node *block, ir_node *store, ir_node *objptr, + ir_entity *ent) +{ return new_rd_Sel(NULL, block, store, objptr, 0, NULL, ent); } -ir_node *new_r_Phi(ir_node *block, int arity, ir_node **in, ir_mode *mode) { +ir_node *new_r_Phi(ir_node *block, int arity, ir_node **in, ir_mode *mode) +{ return new_rd_Phi(NULL, block, arity, in, mode); } -ir_node *new_r_Sync(ir_node *block, int arity, ir_node *in[]) { +ir_node *new_r_Sync(ir_node *block, int arity, ir_node *in[]) +{ return new_rd_Sync(NULL, block, arity, in); } -ir_node *new_r_defaultProj(ir_node *block, ir_node *arg, long max_proj) { - return new_rd_defaultProj(NULL, block, arg, max_proj); +ir_node *new_r_defaultProj(ir_node *arg, long max_proj) +{ + return new_rd_defaultProj(NULL, arg, max_proj); } -ir_node *new_r_Bad(ir_graph *irg) { +ir_node *new_r_Bad(ir_graph *irg) +{ return get_irg_bad(irg); } -ir_node *new_r_EndReg(ir_graph *irg, ir_node *block) { - return new_rd_EndReg(NULL, irg, block); -} -ir_node *new_r_EndExcept(ir_graph *irg, ir_node *block) { - return new_rd_EndExcept(NULL, irg, block); -} -ir_node *new_r_NoMem(ir_graph *irg) { +ir_node *new_r_NoMem(ir_graph *irg) +{ return get_irg_no_mem(irg); } ir_node *new_r_ASM(ir_node *block, int arity, ir_node *in[], ir_asm_constraint *inputs, int n_outs, ir_asm_constraint *outputs, - int n_clobber, ident *clobber[], ident *asm_text) { - return new_rd_ASM(NULL, block, arity, in, inputs, n_outs, outputs, n_clobber, clobber, asm_text); + int n_clobber, ident *clobber[], ident *text) +{ + return new_rd_ASM(NULL, block, arity, in, inputs, n_outs, outputs, n_clobber, clobber, text); } /** ********************/ /** public interfaces */ /** construction tools */ -ir_node * -new_d_Start(dbg_info *db) { +ir_node *new_d_Start(dbg_info *db) +{ ir_node *res; res = new_ir_node(db, current_ir_graph, current_ir_graph->current_block, op_Start, mode_T, 0, NULL); res = optimize_node(res); - IRN_VRFY_IRG(res, current_ir_graph); + IRN_VERIFY_IRG(res, current_ir_graph); return res; } /* new_d_Start */ -ir_node * -new_d_End(dbg_info *db) { +ir_node *new_d_End(dbg_info *db) +{ ir_node *res; res = new_ir_node(db, current_ir_graph, current_ir_graph->current_block, op_End, mode_X, -1, NULL); res = optimize_node(res); - IRN_VRFY_IRG(res, current_ir_graph); + IRN_VERIFY_IRG(res, current_ir_graph); return res; } /* new_d_End */ @@ -672,12 +527,12 @@ new_d_End(dbg_info *db) { * *************************************************************************** */ /** Creates a Phi node with 0 predecessors. */ -static inline ir_node * -new_rd_Phi0(ir_graph *irg, ir_node *block, ir_mode *mode) { +static inline ir_node *new_rd_Phi0(ir_graph *irg, ir_node *block, ir_mode *mode) +{ ir_node *res; res = new_ir_node(NULL, irg, block, op_Phi, mode, 0, NULL); - IRN_VRFY_IRG(res, irg); + IRN_VERIFY_IRG(res, irg); return res; } /* new_rd_Phi0 */ @@ -693,9 +548,10 @@ new_rd_Phi0(ir_graph *irg, ir_node *block, ir_mode *mode) { * @param phi0 in non-NULL: the Phi0 node in the same block that represents * the value for which the new Phi is constructed */ -static inline ir_node * -new_rd_Phi_in(ir_graph *irg, ir_node *block, ir_mode *mode, - ir_node **in, int ins, ir_node *phi0) { +static inline ir_node *new_rd_Phi_in(ir_graph *irg, ir_node *block, + ir_mode *mode, ir_node **in, int ins, + ir_node *phi0) +{ int i; ir_node *res, *known; @@ -749,7 +605,7 @@ new_rd_Phi_in(ir_graph *irg, ir_node *block, ir_mode *mode, } } else { res = optimize_node(res); /* This is necessary to add the node to the hash table for cse. */ - IRN_VRFY_IRG(res, irg); + IRN_VERIFY_IRG(res, irg); /* Memory Phis in endless loops must be kept alive. As we can't distinguish these easily we keep all of them alive. */ if (is_Phi(res) && mode == mode_M) @@ -759,11 +615,9 @@ new_rd_Phi_in(ir_graph *irg, ir_node *block, ir_mode *mode, return res; } /* new_rd_Phi_in */ -static ir_node * -get_r_value_internal(ir_node *block, int pos, ir_mode *mode); +static ir_node *get_r_value_internal(ir_node *block, int pos, ir_mode *mode); -static ir_node * -phi_merge(ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins); +static ir_node *phi_merge(ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins); /** * Construct a new frag_array for node n. @@ -773,7 +627,8 @@ phi_merge(ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins); * Further the last entry in frag_arr of current block points to n. This * constructs a chain block->last_frag_op-> ... first_frag_op of all frag ops in the block. */ -static inline ir_node **new_frag_arr(ir_node *n) { +static inline ir_node **new_frag_arr(ir_node *n) +{ ir_node **arr; int opt; @@ -808,7 +663,8 @@ static inline ir_node **new_frag_arr(ir_node *n) { /** * Returns the frag_arr from a node. */ -static inline ir_node **get_frag_arr(ir_node *n) { +static inline ir_node **get_frag_arr(ir_node *n) +{ switch (get_irn_opcode(n)) { case iro_Call: return n->attr.call.exc.frag_arr; @@ -823,8 +679,8 @@ static inline ir_node **get_frag_arr(ir_node *n) { } } /* get_frag_arr */ -static void -set_frag_value(ir_node **frag_arr, int pos, ir_node *val) { +static void set_frag_value(ir_node **frag_arr, int pos, ir_node *val) +{ #ifdef DEBUG_libfirm int i; @@ -845,8 +701,9 @@ set_frag_value(ir_node **frag_arr, int pos, ir_node *val) { assert(!"potential endless recursion in set_frag_value"); } /* set_frag_value */ -static ir_node * -get_r_frag_value_internal(ir_node *block, ir_node *cfOp, int pos, ir_mode *mode) { +static ir_node *get_r_frag_value_internal(ir_node *block, ir_node *cfOp, + int pos, ir_mode *mode) +{ ir_node *res; ir_node **frag_arr; @@ -886,7 +743,8 @@ get_r_frag_value_internal(ir_node *block, ir_node *cfOp, int pos, ir_mode *mode) * @param cf_pred the control flow node * @param prev_cf_op if cf_pred is a Proj, the predecessor node, else equal to cf_pred */ -static int is_exception_flow(ir_node *cf_pred, ir_node *prev_cf_op) { +static int is_exception_flow(ir_node *cf_pred, ir_node *prev_cf_op) +{ /* * Note: all projections from a raise are "exceptional control flow" we we handle it * like a normal Jmp, because there is no "regular" one. @@ -902,8 +760,7 @@ static int is_exception_flow(ir_node *cf_pred, ir_node *prev_cf_op) { return 1; } /* Hmm, exception but not a Proj? */ - assert(!"unexpected condition: fragile op without a proj"); - return 1; + panic("unexpected condition: fragile op without a proj"); } return 0; } /* is_exception_flow */ @@ -914,8 +771,8 @@ static int is_exception_flow(ir_node *cf_pred, ir_node *prev_cf_op) { * node might optimize it away and return a real value. * This function must be called with an in-array of proper size. */ -static ir_node * -phi_merge(ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins) { +static ir_node *phi_merge(ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins) +{ ir_node *prevBlock, *res, *phi0, *phi0_all; int i; @@ -1032,8 +889,8 @@ phi_merge(ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins) { * @param pos the value number of the value searched * @param mode the mode of this value (needed for Phi construction) */ -static ir_node * -get_r_value_internal(ir_node *block, int pos, ir_mode *mode) { +static ir_node *get_r_value_internal(ir_node *block, int pos, ir_mode *mode) +{ ir_node *res; /* There are 4 cases to treat. @@ -1120,8 +977,8 @@ 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_immBlock(ir_node *block) { +void mature_immBlock(ir_node *block) +{ int ins; ir_node *n, **nin; ir_node *next; @@ -1155,36 +1012,35 @@ mature_immBlock(ir_node *block) { nodes refer to the unoptimized node. We can call optimize_in_place_2(), as global cse has no effect on blocks. */ block = optimize_in_place_2(block); - IRN_VRFY_IRG(block, irg); + IRN_VERIFY_IRG(block, irg); } } /* mature_immBlock */ -ir_node * -new_d_Phi(dbg_info *db, int arity, ir_node **in, ir_mode *mode) { +ir_node *new_d_Phi(dbg_info *db, int arity, ir_node **in, ir_mode *mode) +{ return new_bd_Phi(db, current_ir_graph->current_block, arity, in, mode); } /* new_d_Phi */ -ir_node * -new_d_Const(dbg_info *db, tarval *con) { +ir_node *new_d_Const(dbg_info *db, tarval *con) +{ return new_bd_Const(db, con); } /* new_d_Const */ -ir_node * -new_d_Const_long(dbg_info *db, ir_mode *mode, long value) { +ir_node *new_d_Const_long(dbg_info *db, ir_mode *mode, long value) +{ return new_bd_Const_long(db, mode, value); } /* new_d_Const_long */ -ir_node * -new_d_Const_type(dbg_info *db, tarval *con, ir_type *tp) { +ir_node *new_d_Const_type(dbg_info *db, tarval *con, ir_type *tp) +{ return new_bd_Const_type(db, con, tp); } /* new_d_Const_type */ -ir_node * -new_d_defaultProj(dbg_info *db, ir_node *arg, long max_proj) { +ir_node *new_d_defaultProj(dbg_info *db, ir_node *arg, long max_proj) +{ ir_node *res; assert(arg->op == op_Cond); - arg->attr.cond.kind = fragmentary; arg->attr.cond.default_proj = max_proj; res = new_d_Proj(db, arg, mode_X, max_proj); return res; @@ -1199,7 +1055,8 @@ new_d_defaultProj(dbg_info *db, ir_node *arg, long max_proj) { * @param frag_store the address of the frag store in irn attributes, if this * address contains a value != NULL, does nothing */ -void firm_alloc_frag_arr(ir_node *irn, 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(irn) == op) && /* Could be optimized away. */ @@ -1209,8 +1066,7 @@ void firm_alloc_frag_arr(ir_node *irn, ir_op *op, ir_node ***frag_store) { } } /* firm_alloc_frag_arr */ -ir_node * -new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr, ir_entity *ent) +ir_node *new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr, ir_entity *ent) /* GL: objptr was called frame before. Frame was a bad choice for the name as the operand could as well be a pointer to a dynamic object. */ { @@ -1218,39 +1074,28 @@ new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr, ir_entity *ent) store, objptr, 0, NULL, ent); } /* new_d_simpleSel */ -ir_node * -new_d_SymConst_type(dbg_info *db, ir_mode *mode, symconst_symbol value, symconst_kind kind, ir_type *tp) { +ir_node *new_d_SymConst_type(dbg_info *db, ir_mode *mode, symconst_symbol value, symconst_kind kind, ir_type *tp) +{ return new_bd_SymConst_type(db, get_irg_start_block(current_ir_graph), mode, value, kind, tp); } /* new_d_SymConst_type */ -ir_node * -new_d_SymConst(dbg_info *db, ir_mode *mode, symconst_symbol value, symconst_kind kind) { +ir_node *new_d_SymConst(dbg_info *db, ir_mode *mode, symconst_symbol value, symconst_kind kind) +{ return new_bd_SymConst_type(db, get_irg_start_block(current_ir_graph), mode, value, kind, firm_unknown_type); } /* new_d_SymConst */ -ir_node * -new_d_Sync(dbg_info *db, int arity, ir_node *in[]) { +ir_node *new_d_Sync(dbg_info *db, int arity, ir_node *in[]) +{ return new_rd_Sync(db, current_ir_graph->current_block, arity, in); } /* new_d_Sync */ -ir_node * -new_d_EndReg(dbg_info *db) { - return new_bd_EndReg(db, current_ir_graph->current_block); -} /* new_d_EndReg */ - -ir_node * -new_d_EndExcept(dbg_info *db) { - return new_bd_EndExcept(db, current_ir_graph->current_block); -} /* new_d_EndExcept */ - - -ir_node * -new_d_ASM(dbg_info *db, int arity, ir_node *in[], ir_asm_constraint *inputs, - int n_outs, ir_asm_constraint *outputs, - int n_clobber, ident *clobber[], ident *asm_text) { - return new_bd_ASM(db, current_ir_graph->current_block, arity, in, inputs, n_outs, outputs, n_clobber, clobber, asm_text); +ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[], ir_asm_constraint *inputs, + int n_outs, ir_asm_constraint *outputs, int n_clobber, + ident *clobber[], ident *text) +{ + return new_bd_ASM(db, current_ir_graph->current_block, arity, in, inputs, n_outs, outputs, n_clobber, clobber, text); } /* new_d_ASM */ /* ********************************************************************* */ @@ -1260,8 +1105,8 @@ new_d_ASM(dbg_info *db, int arity, ir_node *in[], ir_asm_constraint *inputs, /* Block construction */ /* immature Block without predecessors */ -ir_node * -new_d_immBlock(dbg_info *db) { +ir_node *new_d_immBlock(dbg_info *db) +{ ir_node *res; assert(get_irg_phase_state(current_ir_graph) == phase_building); @@ -1291,19 +1136,19 @@ new_d_immBlock(dbg_info *db) { memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc); /* Immature block may not be optimized! */ - IRN_VRFY_IRG(res, current_ir_graph); + IRN_VERIFY_IRG(res, current_ir_graph); return res; } /* new_d_immBlock */ -ir_node * -new_immBlock(void) { +ir_node *new_immBlock(void) +{ return new_d_immBlock(NULL); } /* new_immBlock */ /* immature PartBlock with its predecessors */ -ir_node * -new_d_immPartBlock(dbg_info *db, ir_node *pred_jmp) { +ir_node *new_d_immPartBlock(dbg_info *db, ir_node *pred_jmp) +{ ir_node *res = new_d_immBlock(db); ir_node *blk = get_nodes_block(pred_jmp); @@ -1317,16 +1162,17 @@ new_d_immPartBlock(dbg_info *db, ir_node *pred_jmp) { return res; } /* new_d_immPartBlock */ -ir_node * -new_immPartBlock(ir_node *pred_jmp) { +ir_node *new_immPartBlock(ir_node *pred_jmp) +{ return new_d_immPartBlock(NULL, pred_jmp); } /* new_immPartBlock */ /* add an edge to a jmp/control flow node */ -void -add_immBlock_pred(ir_node *block, ir_node *jmp) { +void add_immBlock_pred(ir_node *block, ir_node *jmp) +{ int n = ARR_LEN(block->in) - 1; + assert(is_Block(block) && "Error: Must be a Block"); assert(!block->attr.block.is_matured && "Error: Block already matured!\n"); assert(block->attr.block.is_mb_head && "Error: Cannot add a predecessor to a PartBlock"); assert(is_ir_node(jmp)); @@ -1337,8 +1183,8 @@ add_immBlock_pred(ir_node *block, ir_node *jmp) { } /* add_immBlock_pred */ /* changing the current block */ -void -set_cur_block(ir_node *target) { +void set_cur_block(ir_node *target) +{ current_ir_graph->current_block = target; } /* set_cur_block */ @@ -1346,8 +1192,8 @@ set_cur_block(ir_node *target) { /* parameter administration */ /* get a value from the parameter array from the current block by its index */ -ir_node * -get_d_value(dbg_info *db, int pos, ir_mode *mode) { +ir_node *get_d_value(dbg_info *db, int pos, ir_mode *mode) +{ ir_graph *irg = current_ir_graph; assert(get_irg_phase_state(irg) == phase_building); inc_irg_visited(irg); @@ -1359,14 +1205,65 @@ get_d_value(dbg_info *db, int pos, ir_mode *mode) { } /* get_d_value */ /* get a value from the parameter array from the current block by its index */ -ir_node * -get_value(int pos, ir_mode *mode) { +ir_node *get_value(int pos, ir_mode *mode) +{ return get_d_value(NULL, pos, mode); } /* get_value */ +/** + * helper function for guess_mode: recursively look for a definition for + * local variable @p pos, returns its mode if found. + */ +static ir_mode *guess_recursively(ir_node *block, int pos) +{ + ir_node *value; + int n_preds; + int i; + + if (irn_visited(block)) + return NULL; + mark_irn_visited(block); + + /* already have a defintion -> we can simply look at its mode */ + value = block->attr.block.graph_arr[pos]; + if (value != NULL) + return get_irn_mode(value); + + /* now we try to guess, by looking at the predecessor blocks */ + n_preds = get_irn_arity(block); + for (i = 0; i < n_preds; ++i) { + ir_node *pred_block = get_Block_cfgpred_block(block, i); + ir_mode *mode = guess_recursively(pred_block, pos); + if (mode != NULL) + return mode; + } + + /* no way to guess */ + return NULL; +} + +ir_mode *ir_guess_mode(int pos) +{ + ir_graph *irg = current_ir_graph; + ir_node *block = irg->current_block; + ir_node *value = block->attr.block.graph_arr[pos+1]; + ir_mode *mode; + + /* already have a defintion -> we can simply look at its mode */ + if (value != NULL) + return get_irn_mode(value); + + ir_reserve_resources(current_ir_graph, IR_RESOURCE_IRN_VISITED); + inc_irg_visited(current_ir_graph); + mode = guess_recursively(block, pos+1); + ir_free_resources(current_ir_graph, IR_RESOURCE_IRN_VISITED); + + return mode; +} + /* set a value at position pos in the parameter array from the current block */ -void -set_value(int pos, ir_node *value) { +void set_value(int pos, ir_node *value) +{ ir_graph *irg = current_ir_graph; assert(get_irg_phase_state(irg) == phase_building); assert(pos >= 0); @@ -1376,8 +1273,8 @@ set_value(int pos, ir_node *value) { } /* set_value */ /* Find the value number for a node in the current block.*/ -int -find_value(ir_node *value) { +int find_value(ir_node *value) +{ int i; ir_node *bl = current_ir_graph->current_block; @@ -1388,8 +1285,8 @@ find_value(ir_node *value) { } /* find_value */ /* get the current store */ -ir_node * -get_store(void) { +ir_node *get_store(void) +{ ir_graph *irg = current_ir_graph; assert(get_irg_phase_state(irg) == phase_building); @@ -1399,8 +1296,8 @@ get_store(void) { } /* get_store */ /* set the current store: handles automatic Sync construction for Load nodes */ -void -set_store(ir_node *store) { +void set_store(ir_node *store) +{ ir_node *load, *pload, *pred, *in[2]; assert(get_irg_phase_state(current_ir_graph) == phase_building); @@ -1437,20 +1334,22 @@ set_store(ir_node *store) { current_ir_graph->current_block->attr.block.graph_arr[0] = store; } /* set_store */ -void -keep_alive(ir_node *ka) { +void keep_alive(ir_node *ka) +{ add_End_keepalive(get_irg_end(current_ir_graph), ka); } /* keep_alive */ /* --- Useful access routines --- */ /* Returns the current block of the current graph. To set the current block use set_cur_block. */ -ir_node *get_cur_block(void) { +ir_node *get_cur_block(void) +{ return get_irg_current_block(current_ir_graph); } /* get_cur_block */ /* Returns the frame type of the current graph */ -ir_type *get_cur_frame_type(void) { +ir_type *get_cur_frame_type(void) +{ return get_irg_frame_type(current_ir_graph); } /* get_cur_frame_type */ @@ -1459,77 +1358,100 @@ ir_type *get_cur_frame_type(void) { /* initialize */ /* call once for each run of the library */ -void -firm_init_cons(uninitialized_local_variable_func_t *func) { +void ir_set_uninitialized_local_variable_func( + uninitialized_local_variable_func_t *func) +{ default_initialize_local_variable = func; -} /* firm_init_cons */ +} -void -irp_finalize_cons(void) { +void irg_finalize_cons(ir_graph *irg) +{ + set_irg_phase_state(irg, phase_high); +} + +void irp_finalize_cons(void) +{ int i; for (i = get_irp_n_irgs() - 1; i >= 0; --i) { irg_finalize_cons(get_irp_irg(i)); } irp->phase_state = phase_high; -} /* irp_finalize_cons */ +} -ir_node *new_Start(void) { +ir_node *new_Start(void) +{ return new_d_Start(NULL); } -ir_node *new_End(void) { +ir_node *new_End(void) +{ return new_d_End(NULL); } -ir_node *new_Const(tarval *con) { +ir_node *new_Const(tarval *con) +{ return new_d_Const(NULL, con); } -ir_node *new_Const_long(ir_mode *mode, long value) { +ir_node *new_Const_long(ir_mode *mode, long value) +{ return new_d_Const_long(NULL, mode, value); } -ir_node *new_Const_type(tarval *con, ir_type *tp) { +ir_node *new_Const_type(tarval *con, ir_type *tp) +{ return new_d_Const_type(NULL, con, tp); } -ir_node *new_SymConst_type(ir_mode *mode, symconst_symbol value, symconst_kind kind, ir_type *type) { +ir_node *new_SymConst_type(ir_mode *mode, symconst_symbol value, symconst_kind kind, ir_type *type) +{ return new_d_SymConst_type(NULL, mode, value, kind, type); } -ir_node *new_SymConst(ir_mode *mode, symconst_symbol value, symconst_kind kind) { +ir_node *new_SymConst(ir_mode *mode, symconst_symbol value, symconst_kind kind) +{ return new_d_SymConst(NULL, mode, value, kind); } -ir_node *new_simpleSel(ir_node *store, ir_node *objptr, ir_entity *ent) { +ir_node *new_simpleSel(ir_node *store, ir_node *objptr, ir_entity *ent) +{ return new_d_simpleSel(NULL, store, objptr, ent); } -ir_node *new_Phi(int arity, ir_node **in, ir_mode *mode) { +ir_node *new_Phi(int arity, ir_node **in, ir_mode *mode) +{ return new_d_Phi(NULL, arity, in, mode); } -ir_node *new_Sync(int arity, ir_node *in[]) { +ir_node *new_Sync(int arity, ir_node *in[]) +{ return new_d_Sync(NULL, arity, in); } -ir_node *new_defaultProj(ir_node *arg, long max_proj) { +ir_node *new_defaultProj(ir_node *arg, long max_proj) +{ return new_d_defaultProj(NULL, arg, max_proj); } -ir_node *new_Bad(void) { +ir_node *new_Bad(void) +{ return get_irg_bad(current_ir_graph); } -ir_node *new_EndReg(void) { - return new_d_EndReg(NULL); -} -ir_node *new_EndExcept(void) { - return new_d_EndExcept(NULL); -} -ir_node *new_NoMem(void) { +ir_node *new_NoMem(void) +{ return get_irg_no_mem(current_ir_graph); } ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs, int n_outs, ir_asm_constraint *outputs, - int n_clobber, ident *clobber[], ident *asm_text) { - return new_d_ASM(NULL, arity, in, inputs, n_outs, outputs, n_clobber, clobber, asm_text); + int n_clobber, ident *clobber[], ident *text) +{ + return new_d_ASM(NULL, arity, in, inputs, n_outs, outputs, n_clobber, clobber, text); } /* create a new anchor node */ -ir_node *new_Anchor(ir_graph *irg) { +ir_node *new_Anchor(ir_graph *irg) +{ ir_node *in[anchor_last]; + ir_node *res; memset(in, 0, sizeof(in)); - return new_ir_node(NULL, irg, NULL, op_Anchor, mode_ANY, anchor_last, in); + res = new_ir_node(NULL, irg, NULL, op_Anchor, mode_ANY, anchor_last, in); + + /* hack to get get_irn_irg working: set block to ourself and allow + * get_Block_irg for anchor */ + res->attr.irg.irg = irg; + res->in[0] = res; + + return res; }