X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Fircons.c;h=a9f161dc872390bd74a6d4d3c7a00d441fa30b93;hb=637542932dc27dcdfc7def09b58d9d5d4c34fb77;hp=dd9388fb706635218138cf851d421a061aea2001;hpb=9fe9c20a1570729f1bdd21a6f174ec045d2ff986;p=libfirm diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index dd9388fb7..a9f161dc8 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -25,6 +25,7 @@ #include #endif +# include "irprog_t.h" # include "irgraph_t.h" # include "irnode_t.h" # include "irmode_t.h" @@ -37,6 +38,7 @@ # include "array.h" # include "irbackedge_t.h" # include "irflag_t.h" +# include "iredges_t.h" #if USE_EXPLICIT_PHI_IN_STACK /* A stack needed for the automatic Phi node construction in constructor @@ -58,7 +60,7 @@ typedef struct Phi_in_stack Phi_in_stack; /* * language dependant initialization variable */ -static default_initialize_local_variable_func_t *default_initialize_local_variable = NULL; +static uninitialized_local_variable_func_t *default_initialize_local_variable = NULL; /* -------------------------------------------- */ /* privat interfaces, for professional use only */ @@ -67,7 +69,7 @@ static default_initialize_local_variable_func_t *default_initialize_local_variab /* Constructs a Block with a fixed number of predecessors. Does not set current_block. Can not be used with automatic Phi node construction. */ -INLINE ir_node * +ir_node * new_rd_Block (dbg_info* db, ir_graph *irg, int arity, ir_node **in) { ir_node *res; @@ -83,12 +85,13 @@ new_rd_Block (dbg_info* db, ir_graph *irg, int arity, ir_node **in) res->attr.block.backedge = new_backedge_arr(irg->obst, arity); res->attr.block.in_cg = NULL; res->attr.block.cg_backedge = NULL; + res->attr.block.extblk = NULL; IRN_VRFY_IRG(res, irg); return res; } -INLINE ir_node * +ir_node * new_rd_Start (dbg_info* db, ir_graph *irg, ir_node *block) { ir_node *res; @@ -100,7 +103,7 @@ new_rd_Start (dbg_info* db, ir_graph *irg, ir_node *block) return res; } -INLINE ir_node * +ir_node * new_rd_End (dbg_info* db, ir_graph *irg, ir_node *block) { ir_node *res; @@ -113,7 +116,7 @@ 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. */ -INLINE ir_node * +ir_node * new_rd_Phi (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node **in, ir_mode *mode) { ir_node *res; @@ -145,7 +148,7 @@ new_rd_Phi (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node **in return res; } -INLINE ir_node * +ir_node * new_rd_Const_type (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, tarval *con, type *tp) { ir_node *res; @@ -160,15 +163,19 @@ new_rd_Const_type (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, t return res; } -INLINE ir_node * +ir_node * new_rd_Const (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, tarval *con) { - type *tp = unknown_type; - /* removing this somehow causes errors in jack. */ - return new_rd_Const_type (db, irg, block, mode, con, tp); + return new_rd_Const_type (db, irg, block, mode, con, firm_unknown_type); } -INLINE ir_node * +ir_node * +new_rd_Const_long (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, long value) +{ + return new_rd_Const(db, irg, block, mode, new_tarval_from_long(value, mode)); +} + +ir_node * new_rd_Id (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *val, ir_mode *mode) { ir_node *res; @@ -179,7 +186,7 @@ new_rd_Id (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *val, ir_mode *m return res; } -INLINE ir_node * +ir_node * new_rd_Proj (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *arg, ir_mode *mode, long proj) { @@ -199,7 +206,7 @@ new_rd_Proj (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *arg, ir_mode } -INLINE ir_node * +ir_node * new_rd_defaultProj (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *arg, long max_proj) { @@ -211,7 +218,7 @@ new_rd_defaultProj (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *arg, return res; } -INLINE ir_node * +ir_node * new_rd_Conv (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, ir_mode *mode) { ir_node *res; @@ -222,7 +229,7 @@ new_rd_Conv (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, ir_mode * return res; } -INLINE ir_node * +ir_node * new_rd_Cast (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, type *to_tp) { ir_node *res; @@ -236,7 +243,7 @@ new_rd_Cast (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, type *to_ return res; } -INLINE ir_node * +ir_node * new_rd_Tuple (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node **in) { ir_node *res; @@ -247,7 +254,7 @@ new_rd_Tuple (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node ** return res; } -INLINE ir_node * +ir_node * new_rd_Add (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { @@ -262,7 +269,7 @@ new_rd_Add (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Sub (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { @@ -277,9 +284,9 @@ new_rd_Sub (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Minus (dbg_info* db, ir_graph *irg, ir_node *block, - ir_node *op, ir_mode *mode) + ir_node *op, ir_mode *mode) { ir_node *res; @@ -289,7 +296,7 @@ new_rd_Minus (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Mul (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { @@ -304,7 +311,7 @@ new_rd_Mul (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Quot (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *memop, ir_node *op1, ir_node *op2) { @@ -320,7 +327,7 @@ new_rd_Quot (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_DivMod (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *memop, ir_node *op1, ir_node *op2) { @@ -336,7 +343,7 @@ new_rd_DivMod (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Div (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *memop, ir_node *op1, ir_node *op2) { @@ -352,7 +359,7 @@ new_rd_Div (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Mod (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *memop, ir_node *op1, ir_node *op2) { @@ -368,7 +375,7 @@ new_rd_Mod (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_And (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { @@ -383,7 +390,7 @@ new_rd_And (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Or (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { @@ -398,7 +405,7 @@ new_rd_Or (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Eor (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { @@ -413,7 +420,7 @@ new_rd_Eor (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Not (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, ir_mode *mode) { @@ -425,7 +432,7 @@ new_rd_Not (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Shl (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, ir_node *k, ir_mode *mode) { @@ -440,7 +447,7 @@ new_rd_Shl (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Shr (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, ir_node *k, ir_mode *mode) { @@ -455,7 +462,7 @@ new_rd_Shr (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Shrs (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, ir_node *k, ir_mode *mode) { @@ -470,7 +477,7 @@ new_rd_Shrs (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Rot (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, ir_node *k, ir_mode *mode) { @@ -485,7 +492,7 @@ new_rd_Rot (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Abs (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, ir_mode *mode) { @@ -497,7 +504,7 @@ new_rd_Abs (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Cmp (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2) { @@ -512,7 +519,7 @@ new_rd_Cmp (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Jmp (dbg_info* db, ir_graph *irg, ir_node *block) { ir_node *res; @@ -523,7 +530,7 @@ new_rd_Jmp (dbg_info* db, ir_graph *irg, ir_node *block) return res; } -INLINE ir_node * +ir_node * new_rd_Cond (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *c) { ir_node *res; @@ -552,7 +559,7 @@ new_rd_Call (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, res = new_ir_node(db, irg, block, op_Call, mode_T, r_arity, r_in); - assert((get_unknown_type() == tp) || is_method_type(tp)); + assert((get_unknown_type() == tp) || is_Method_type(tp)); set_Call_type(res, tp); res->attr.call.exc.pin_state = op_pin_state_pinned; res->attr.call.callee_arr = NULL; @@ -579,7 +586,7 @@ new_rd_Return (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Raise (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, ir_node *obj) { ir_node *in[2]; @@ -593,7 +600,7 @@ new_rd_Raise (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, ir_no return res; } -INLINE ir_node * +ir_node * new_rd_Load (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, ir_node *adr, ir_mode *mode) { @@ -611,7 +618,7 @@ new_rd_Load (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Store (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, ir_node *adr, ir_node *val) { @@ -629,7 +636,7 @@ new_rd_Store (dbg_info* db, ir_graph *irg, ir_node *block, return res; } -INLINE ir_node * +ir_node * new_rd_Alloc (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, ir_node *size, type *alloc_type, where_alloc where) { @@ -647,9 +654,9 @@ new_rd_Alloc (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, return res; } -INLINE ir_node * +ir_node * new_rd_Free (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, - ir_node *ptr, ir_node *size, type *free_type) + ir_node *ptr, ir_node *size, type *free_type, where_alloc where) { ir_node *in[3]; ir_node *res; @@ -657,8 +664,9 @@ new_rd_Free (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, in[0] = store; in[1] = ptr; in[2] = size; - res = new_ir_node (db, irg, block, op_Free, mode_T, 3, in); - res->attr.f = free_type; + res = new_ir_node (db, irg, block, op_Free, mode_M, 3, in); + res->attr.f.where = where; + res->attr.f.type = free_type; res = optimize_node(res); IRN_VRFY_IRG(res, irg); return res; @@ -707,9 +715,9 @@ new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store, return res; } -INLINE ir_node * +ir_node * new_rd_SymConst_type (dbg_info* db, ir_graph *irg, ir_node *block, symconst_symbol value, - symconst_kind symkind, type *tp) { + symconst_kind symkind, type *tp) { ir_node *res; ir_mode *mode; @@ -729,11 +737,11 @@ new_rd_SymConst_type (dbg_info* db, ir_graph *irg, ir_node *block, symconst_symb return res; } -INLINE ir_node * +ir_node * new_rd_SymConst (dbg_info* db, ir_graph *irg, ir_node *block, symconst_symbol value, - symconst_kind symkind) + symconst_kind symkind) { - ir_node *res = new_rd_SymConst_type(db, irg, block, value, symkind, unknown_type); + ir_node *res = new_rd_SymConst_type(db, irg, block, value, symkind, firm_unknown_type); return res; } @@ -757,7 +765,7 @@ ir_node *new_rd_SymConst_size (dbg_info *db, ir_graph *irg, type *symbol, type * return new_rd_SymConst_type(db, irg, irg->start_block, sym, symconst_size, tp); } -INLINE ir_node * +ir_node * new_rd_Sync (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node **in) { ir_node *res; @@ -768,13 +776,13 @@ new_rd_Sync (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node **i return res; } -INLINE ir_node * +ir_node * new_rd_Bad (ir_graph *irg) { return irg->bad; } -INLINE ir_node * +ir_node * new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *val, ir_node *bound, pn_Cmp cmp) { ir_node *in[2], *res; @@ -788,13 +796,13 @@ new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *val, ir_no return res; } -INLINE ir_node * +ir_node * new_rd_Unknown (ir_graph *irg, ir_mode *m) { return new_ir_node(NULL, irg, irg->start_block, op_Unknown, m, 0, NULL); } -INLINE ir_node * +ir_node * new_rd_CallBegin (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *call) { ir_node *in[1]; @@ -809,7 +817,7 @@ new_rd_CallBegin (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *call) return res; } -INLINE ir_node * +ir_node * new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block) { ir_node *res; @@ -820,7 +828,7 @@ new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block) return res; } -INLINE ir_node * +ir_node * new_rd_EndExcept (dbg_info *db, ir_graph *irg, ir_node *block) { ir_node *res; @@ -831,7 +839,7 @@ new_rd_EndExcept (dbg_info *db, ir_graph *irg, ir_node *block) return res; } -INLINE ir_node * +ir_node * new_rd_Break (dbg_info *db, ir_graph *irg, ir_node *block) { ir_node *res; @@ -842,7 +850,7 @@ new_rd_Break (dbg_info *db, ir_graph *irg, ir_node *block) return res; } -INLINE ir_node * +ir_node * new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg, ir_mode *mode, long proj) { @@ -860,207 +868,235 @@ new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg, ir_mod res = optimize_node(res); IRN_VRFY_IRG(res, irg); return res; +} +ir_node * +new_rd_NoMem (ir_graph *irg) { + return irg->no_mem; } -INLINE ir_node * -new_rd_NoMem (ir_graph *irg) +ir_node * +new_rd_Mux (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode) { - return irg->no_mem; + ir_node *in[3]; + ir_node *res; + + in[0] = sel; + in[1] = ir_false; + in[2] = ir_true; + + res = new_ir_node(db, irg, block, op_Mux, mode, 3, in); + assert(res); + + res = optimize_node(res); + IRN_VRFY_IRG(res, irg); + return res; } -INLINE ir_node *new_r_Block (ir_graph *irg, int arity, ir_node **in) { +ir_node *new_r_Block (ir_graph *irg, int arity, ir_node **in) { return new_rd_Block(NULL, irg, arity, in); } -INLINE 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); } -INLINE 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); } -INLINE ir_node *new_r_Jmp (ir_graph *irg, ir_node *block) { +ir_node *new_r_Jmp (ir_graph *irg, ir_node *block) { return new_rd_Jmp(NULL, irg, block); } -INLINE ir_node *new_r_Cond (ir_graph *irg, ir_node *block, ir_node *c) { +ir_node *new_r_Cond (ir_graph *irg, ir_node *block, ir_node *c) { return new_rd_Cond(NULL, irg, block, c); } -INLINE ir_node *new_r_Return (ir_graph *irg, ir_node *block, +ir_node *new_r_Return (ir_graph *irg, ir_node *block, ir_node *store, int arity, ir_node **in) { return new_rd_Return(NULL, irg, block, store, arity, in); } -INLINE ir_node *new_r_Raise (ir_graph *irg, ir_node *block, +ir_node *new_r_Raise (ir_graph *irg, ir_node *block, ir_node *store, ir_node *obj) { return new_rd_Raise(NULL, irg, block, store, obj); } -INLINE ir_node *new_r_Const (ir_graph *irg, ir_node *block, +ir_node *new_r_Const (ir_graph *irg, ir_node *block, ir_mode *mode, tarval *con) { return new_rd_Const(NULL, irg, block, mode, con); } -INLINE ir_node *new_r_SymConst (ir_graph *irg, ir_node *block, + +ir_node *new_r_Const_long(ir_graph *irg, ir_node *block, + ir_mode *mode, long value) { + return new_rd_Const_long(NULL, irg, block, mode, value); +} + + +ir_node *new_r_SymConst (ir_graph *irg, ir_node *block, symconst_symbol value, symconst_kind symkind) { return new_rd_SymConst(NULL, irg, block, value, symkind); } -INLINE ir_node *new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store, +ir_node *new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store, ir_node *objptr, int n_index, ir_node **index, entity *ent) { return new_rd_Sel(NULL, irg, block, store, objptr, n_index, index, ent); } -INLINE ir_node *new_r_InstOf (ir_graph *irg, ir_node *block, ir_node *store, ir_node *objptr, +ir_node *new_r_InstOf (ir_graph *irg, ir_node *block, ir_node *store, ir_node *objptr, type *ent) { return (new_rd_InstOf (NULL, irg, block, store, objptr, ent)); } -INLINE ir_node *new_r_Call (ir_graph *irg, ir_node *block, ir_node *store, +ir_node *new_r_Call (ir_graph *irg, ir_node *block, ir_node *store, ir_node *callee, int arity, ir_node **in, type *tp) { return new_rd_Call(NULL, irg, block, store, callee, arity, in, tp); } -INLINE ir_node *new_r_Add (ir_graph *irg, ir_node *block, +ir_node *new_r_Add (ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { return new_rd_Add(NULL, irg, block, op1, op2, mode); } -INLINE ir_node *new_r_Sub (ir_graph *irg, ir_node *block, +ir_node *new_r_Sub (ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { return new_rd_Sub(NULL, irg, block, op1, op2, mode); } -INLINE ir_node *new_r_Minus (ir_graph *irg, ir_node *block, +ir_node *new_r_Minus (ir_graph *irg, ir_node *block, ir_node *op, ir_mode *mode) { return new_rd_Minus(NULL, irg, block, op, mode); } -INLINE ir_node *new_r_Mul (ir_graph *irg, ir_node *block, +ir_node *new_r_Mul (ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { return new_rd_Mul(NULL, irg, block, op1, op2, mode); } -INLINE ir_node *new_r_Quot (ir_graph *irg, ir_node *block, +ir_node *new_r_Quot (ir_graph *irg, ir_node *block, ir_node *memop, ir_node *op1, ir_node *op2) { return new_rd_Quot(NULL, irg, block, memop, op1, op2); } -INLINE ir_node *new_r_DivMod (ir_graph *irg, ir_node *block, +ir_node *new_r_DivMod (ir_graph *irg, ir_node *block, ir_node *memop, ir_node *op1, ir_node *op2) { return new_rd_DivMod(NULL, irg, block, memop, op1, op2); } -INLINE ir_node *new_r_Div (ir_graph *irg, ir_node *block, +ir_node *new_r_Div (ir_graph *irg, ir_node *block, ir_node *memop, ir_node *op1, ir_node *op2) { return new_rd_Div(NULL, irg, block, memop, op1, op2); } -INLINE ir_node *new_r_Mod (ir_graph *irg, ir_node *block, +ir_node *new_r_Mod (ir_graph *irg, ir_node *block, ir_node *memop, ir_node *op1, ir_node *op2) { return new_rd_Mod(NULL, irg, block, memop, op1, op2); } -INLINE ir_node *new_r_Abs (ir_graph *irg, ir_node *block, +ir_node *new_r_Abs (ir_graph *irg, ir_node *block, ir_node *op, ir_mode *mode) { return new_rd_Abs(NULL, irg, block, op, mode); } -INLINE ir_node *new_r_And (ir_graph *irg, ir_node *block, +ir_node *new_r_And (ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { return new_rd_And(NULL, irg, block, op1, op2, mode); } -INLINE ir_node *new_r_Or (ir_graph *irg, ir_node *block, +ir_node *new_r_Or (ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { return new_rd_Or(NULL, irg, block, op1, op2, mode); } -INLINE ir_node *new_r_Eor (ir_graph *irg, ir_node *block, +ir_node *new_r_Eor (ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2, ir_mode *mode) { return new_rd_Eor(NULL, irg, block, op1, op2, mode); } -INLINE ir_node *new_r_Not (ir_graph *irg, ir_node *block, +ir_node *new_r_Not (ir_graph *irg, ir_node *block, ir_node *op, ir_mode *mode) { return new_rd_Not(NULL, irg, block, op, mode); } -INLINE ir_node *new_r_Cmp (ir_graph *irg, ir_node *block, +ir_node *new_r_Cmp (ir_graph *irg, ir_node *block, ir_node *op1, ir_node *op2) { return new_rd_Cmp(NULL, irg, block, op1, op2); } -INLINE ir_node *new_r_Shl (ir_graph *irg, ir_node *block, +ir_node *new_r_Shl (ir_graph *irg, ir_node *block, ir_node *op, ir_node *k, ir_mode *mode) { return new_rd_Shl(NULL, irg, block, op, k, mode); } -INLINE ir_node *new_r_Shr (ir_graph *irg, ir_node *block, +ir_node *new_r_Shr (ir_graph *irg, ir_node *block, ir_node *op, ir_node *k, ir_mode *mode) { return new_rd_Shr(NULL, irg, block, op, k, mode); } -INLINE ir_node *new_r_Shrs (ir_graph *irg, ir_node *block, +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); } -INLINE ir_node *new_r_Rot (ir_graph *irg, ir_node *block, +ir_node *new_r_Rot (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); } -INLINE ir_node *new_r_Conv (ir_graph *irg, ir_node *block, +ir_node *new_r_Conv (ir_graph *irg, ir_node *block, ir_node *op, ir_mode *mode) { return new_rd_Conv(NULL, irg, block, op, mode); } -INLINE ir_node *new_r_Cast (ir_graph *irg, ir_node *block, ir_node *op, type *to_tp) { +ir_node *new_r_Cast (ir_graph *irg, ir_node *block, ir_node *op, type *to_tp) { return new_rd_Cast(NULL, irg, block, op, to_tp); } -INLINE ir_node *new_r_Phi (ir_graph *irg, ir_node *block, int arity, +ir_node *new_r_Phi (ir_graph *irg, ir_node *block, int arity, ir_node **in, ir_mode *mode) { return new_rd_Phi(NULL, irg, block, arity, in, mode); } -INLINE ir_node *new_r_Load (ir_graph *irg, ir_node *block, +ir_node *new_r_Load (ir_graph *irg, ir_node *block, 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 *new_r_Store (ir_graph *irg, ir_node *block, ir_node *store, ir_node *adr, ir_node *val) { return new_rd_Store(NULL, irg, block, store, adr, val); } -INLINE ir_node *new_r_Alloc (ir_graph *irg, ir_node *block, ir_node *store, +ir_node *new_r_Alloc (ir_graph *irg, ir_node *block, ir_node *store, ir_node *size, type *alloc_type, where_alloc where) { return new_rd_Alloc(NULL, irg, block, store, size, alloc_type, where); } -INLINE ir_node *new_r_Free (ir_graph *irg, ir_node *block, ir_node *store, - ir_node *ptr, ir_node *size, type *free_type) { - return new_rd_Free(NULL, irg, block, store, ptr, size, free_type); +ir_node *new_r_Free (ir_graph *irg, ir_node *block, ir_node *store, + ir_node *ptr, ir_node *size, type *free_type, where_alloc where) { + return new_rd_Free(NULL, irg, block, store, ptr, size, free_type, where); } -INLINE ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node **in) { +ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node **in) { return new_rd_Sync(NULL, irg, block, arity, in); } -INLINE ir_node *new_r_Proj (ir_graph *irg, ir_node *block, ir_node *arg, +ir_node *new_r_Proj (ir_graph *irg, ir_node *block, ir_node *arg, ir_mode *mode, long proj) { return new_rd_Proj(NULL, irg, block, arg, mode, proj); } -INLINE ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg, +ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg, long max_proj) { return new_rd_defaultProj(NULL, irg, block, arg, max_proj); } -INLINE ir_node *new_r_Tuple (ir_graph *irg, ir_node *block, +ir_node *new_r_Tuple (ir_graph *irg, ir_node *block, int arity, ir_node **in) { return new_rd_Tuple(NULL, irg, block, arity, in ); } -INLINE ir_node *new_r_Id (ir_graph *irg, ir_node *block, +ir_node *new_r_Id (ir_graph *irg, ir_node *block, ir_node *val, ir_mode *mode) { return new_rd_Id(NULL, irg, block, val, mode); } -INLINE ir_node *new_r_Bad (ir_graph *irg) { +ir_node *new_r_Bad (ir_graph *irg) { return new_rd_Bad(irg); } -INLINE ir_node *new_r_Confirm (ir_graph *irg, ir_node *block, ir_node *val, ir_node *bound, pn_Cmp cmp) { +ir_node *new_r_Confirm (ir_graph *irg, ir_node *block, ir_node *val, ir_node *bound, pn_Cmp cmp) { return new_rd_Confirm (NULL, irg, block, val, bound, cmp); } -INLINE ir_node *new_r_Unknown (ir_graph *irg, ir_mode *m) { +ir_node *new_r_Unknown (ir_graph *irg, ir_mode *m) { return new_rd_Unknown(irg, m); } -INLINE ir_node *new_r_CallBegin (ir_graph *irg, ir_node *block, ir_node *callee) { +ir_node *new_r_CallBegin (ir_graph *irg, ir_node *block, ir_node *callee) { return new_rd_CallBegin(NULL, irg, block, callee); } -INLINE ir_node *new_r_EndReg (ir_graph *irg, ir_node *block) { +ir_node *new_r_EndReg (ir_graph *irg, ir_node *block) { return new_rd_EndReg(NULL, irg, block); } -INLINE ir_node *new_r_EndExcept (ir_graph *irg, ir_node *block) { +ir_node *new_r_EndExcept (ir_graph *irg, ir_node *block) { return new_rd_EndExcept(NULL, irg, block); } -INLINE ir_node *new_r_Break (ir_graph *irg, ir_node *block) { +ir_node *new_r_Break (ir_graph *irg, ir_node *block) { return new_rd_Break(NULL, irg, block); } -INLINE ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg, +ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg, ir_mode *mode, long proj) { return new_rd_Filter(NULL, irg, block, arg, mode, proj); } -INLINE ir_node *new_r_NoMem (ir_graph *irg) { +ir_node *new_r_NoMem (ir_graph *irg) { return new_rd_NoMem(irg); } +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); +} /** ********************/ @@ -1116,7 +1152,7 @@ new_d_Block (dbg_info* db, int arity, ir_node **in) /* Create and initialize array for Phi-node construction. */ 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); + current_ir_graph->n_loc); memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc); } @@ -1184,7 +1220,7 @@ new_rd_Phi0 (ir_graph *irg, ir_node *block, ir_mode *mode) to model this stack, now it is explicit. This reduces side effects. */ #if USE_EXPLICIT_PHI_IN_STACK -INLINE Phi_in_stack * +Phi_in_stack * new_Phi_in_stack(void) { Phi_in_stack *res; @@ -1196,7 +1232,7 @@ new_Phi_in_stack(void) { return res; } -INLINE void +void free_Phi_in_stack(Phi_in_stack *s) { DEL_ARR_F(s->stack); free(s); @@ -1296,9 +1332,9 @@ new_rd_Phi_in (ir_graph *irg, ir_node *block, ir_mode *mode, ir_node **in, int i If so, it is a real Phi node and we break the loop. Else the Phi node merges the same definition on several paths and therefore is not needed. */ - for (i = 0; i < ins; ++i) - { - if (in[i] == res || in[i] == known) continue; + for (i = 0; i < ins; ++i) { + if (in[i] == res || in[i] == known) + continue; if (known == res) known = in[i]; @@ -1311,7 +1347,8 @@ new_rd_Phi_in (ir_graph *irg, ir_node *block, ir_mode *mode, ir_node **in, int i #if USE_EXPLICIT_PHI_IN_STACK free_to_Phi_in_stack(res); #else - obstack_free (current_ir_graph->obst, res); + edges_node_deleted(res, current_ir_graph); + obstack_free(current_ir_graph->obst, res); #endif res = known; } else { @@ -1492,13 +1529,13 @@ get_r_value_internal (ir_node *block, int pos, ir_mode *mode) #if USE_EXPLICIT_PHI_IN_STACK /* Just dummies */ -INLINE Phi_in_stack * new_Phi_in_stack() { return NULL; } -INLINE void free_Phi_in_stack(Phi_in_stack *s) { } +Phi_in_stack * new_Phi_in_stack() { return NULL; } +void free_Phi_in_stack(Phi_in_stack *s) { } #endif 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) + ir_node **in, int ins, ir_node *phi0) { int i; ir_node *res, *known; @@ -1534,15 +1571,18 @@ new_rd_Phi_in (ir_graph *irg, ir_node *block, ir_mode *mode, /* i==ins: there is at most one predecessor, we don't need a phi node. */ if (i == ins) { if (res != known) { + edges_node_deleted(res, current_ir_graph); obstack_free (current_ir_graph->obst, res); if (is_Phi(known)) { - /* If pred is a phi node we want to optmize it: If loops are matured in a bad - order, an enclosing Phi know may get superfluous. */ - res = optimize_in_place_2(known); - if (res != known) { exchange(known, res); } - } else { - res = known; + /* If pred is a phi node we want to optimize it: If loops are matured in a bad + order, an enclosing Phi know may get superfluous. */ + res = optimize_in_place_2(known); + if (res != known) + exchange(known, res); + } + else + res = known; } else { /* A undefined value, e.g., in unreachable code. */ res = new_Bad(); @@ -1590,11 +1630,11 @@ static INLINE ir_node ** new_frag_arr (ir_node *n) arr[0] = new_Proj(n, mode_M, pn_Call_M_except); else { assert((pn_Quot_M == pn_DivMod_M) && - (pn_Quot_M == pn_Div_M) && - (pn_Quot_M == pn_Mod_M) && - (pn_Quot_M == pn_Load_M) && - (pn_Quot_M == pn_Store_M) && - (pn_Quot_M == pn_Alloc_M) ); + (pn_Quot_M == pn_Div_M) && + (pn_Quot_M == pn_Mod_M) && + (pn_Quot_M == pn_Load_M) && + (pn_Quot_M == pn_Store_M) && + (pn_Quot_M == pn_Alloc_M) ); arr[0] = new_Proj(n, mode_M, pn_Alloc_M); } set_optimize(opt); @@ -1717,21 +1757,21 @@ phi_merge (ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins) before recuring. */ if (default_initialize_local_variable) - block->attr.block.graph_arr[pos] = default_initialize_local_variable(mode, pos - 1); + block->attr.block.graph_arr[pos] = default_initialize_local_variable(current_ir_graph, mode, pos - 1); else block->attr.block.graph_arr[pos] = new_Const(mode, tarval_bad); /* We don't need to care about exception ops in the start block. - There are none by definition. */ + There are none by definition. */ return block->attr.block.graph_arr[pos]; } else { phi0 = new_rd_Phi0(current_ir_graph, block, mode); block->attr.block.graph_arr[pos] = phi0; #if PRECISE_EXC_CONTEXT if (get_opt_precise_exc_context()) { - /* Set graph_arr for fragile ops. Also here we should break recursion. - We could choose a cyclic path through an cfop. But the recursion would - break at some point. */ - set_frag_value(block->attr.block.graph_arr, pos, phi0); + /* Set graph_arr for fragile ops. Also here we should break recursion. + We could choose a cyclic path through an cfop. But the recursion would + break at some point. */ + set_frag_value(block->attr.block.graph_arr, pos, phi0); } #endif } @@ -1754,9 +1794,9 @@ phi_merge (ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins) if (!is_Bad(prevBlock)) { #if PRECISE_EXC_CONTEXT if (get_opt_precise_exc_context() && - is_fragile_op(prevCfOp) && (get_irn_op (prevCfOp) != op_Bad)) { - assert(get_r_frag_value_internal (prevBlock, prevCfOp, pos, mode)); - nin[i-1] = get_r_frag_value_internal (prevBlock, prevCfOp, pos, mode); + is_fragile_op(prevCfOp) && (get_irn_op (prevCfOp) != op_Bad)) { + assert(get_r_frag_value_internal (prevBlock, prevCfOp, pos, mode)); + nin[i-1] = get_r_frag_value_internal (prevBlock, prevCfOp, pos, mode); } else #endif nin[i-1] = get_r_value_internal (prevBlock, pos, mode); @@ -1773,8 +1813,8 @@ phi_merge (ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins) if (!phi0) { phi0_all = block->attr.block.graph_arr[pos]; if (!((get_irn_op(phi0_all) == op_Phi) && - (get_irn_arity(phi0_all) == 0) && - (get_nodes_block(phi0_all) == block))) + (get_irn_arity(phi0_all) == 0) && + (get_nodes_block(phi0_all) == block))) phi0_all = NULL; } else { phi0_all = phi0; @@ -1882,7 +1922,7 @@ get_r_value_internal (ir_node *block, int pos, ir_mode *mode) printf("Error: no value set. Use of undefined variable. Initializing to zero.\n"); assert (mode->code >= irm_F && mode->code <= irm_P); res = new_rd_Const (NULL, current_ir_graph, block, mode, - get_mode_null(mode)); + get_mode_null(mode)); } /* The local valid value is available now. */ @@ -1954,6 +1994,12 @@ new_d_Const (dbg_info* db, ir_mode *mode, tarval *con) } ir_node * +new_d_Const_long(dbg_info* db, ir_mode *mode, long value) +{ + return new_rd_Const_long(db, current_ir_graph, current_ir_graph->start_block, mode, value); +} + + ir_node * new_d_Const_type (dbg_info* db, ir_mode *mode, tarval *con, type *tp) { return new_rd_Const_type(db, current_ir_graph, current_ir_graph->start_block, @@ -2041,8 +2087,8 @@ new_d_Mul (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode) static void allocate_frag_arr(ir_node *res, 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. */ - !*frag_store) /* Could be a cse where the arr is already set. */ { + (get_irn_op(res) == op) && /* Could be optimized away. */ + !*frag_store) /* Could be a cse where the arr is already set. */ { *frag_store = new_frag_arr(res); } } @@ -2256,10 +2302,11 @@ new_d_Alloc (dbg_info* db, ir_node *store, ir_node *size, type *alloc_type, } ir_node * -new_d_Free (dbg_info* db, ir_node *store, ir_node *ptr, ir_node *size, type *free_type) +new_d_Free (dbg_info* db, ir_node *store, ir_node *ptr, + ir_node *size, type *free_type, where_alloc where) { return new_rd_Free (db, current_ir_graph, current_ir_graph->current_block, - store, ptr, size, free_type); + store, ptr, size, free_type, where); } ir_node * @@ -2310,7 +2357,7 @@ new_d_Sync (dbg_info* db, int arity, ir_node** in) ir_node * (new_d_Bad)(void) { - return __new_d_Bad(); + return _new_d_Bad(); } ir_node * @@ -2366,7 +2413,14 @@ new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj) ir_node * (new_d_NoMem)(void) { - return __new_d_NoMem(); + return _new_d_NoMem(); +} + +ir_node * +new_d_Mux (dbg_info *db, ir_node *sel, ir_node *ir_false, + ir_node *ir_true, ir_mode *mode) { + return new_rd_Mux (db, current_ir_graph, current_ir_graph->current_block, + sel, ir_false, ir_true, mode); } /* ********************************************************************* */ @@ -2404,7 +2458,7 @@ ir_node *new_d_immBlock (dbg_info* db) { return res; } -INLINE ir_node * +ir_node * new_immBlock (void) { return new_d_immBlock(NULL); } @@ -2442,14 +2496,14 @@ get_d_value (dbg_info* db, int pos, ir_mode *mode) return get_r_value_internal (current_ir_graph->current_block, pos + 1, mode); } /* get a value from the parameter array from the current block by its index */ -INLINE ir_node * +ir_node * get_value (int pos, ir_mode *mode) { return get_d_value(NULL, pos, mode); } /* set a value at position pos in the parameter array from the current block */ -INLINE void +void set_value (int pos, ir_node *value) { assert(get_irg_phase_state (current_ir_graph) == phase_building); @@ -2458,7 +2512,7 @@ set_value (int pos, ir_node *value) } /* get the current store */ -INLINE ir_node * +ir_node * get_store (void) { assert(get_irg_phase_state (current_ir_graph) == phase_building); @@ -2468,7 +2522,7 @@ get_store (void) } /* set the current store */ -INLINE void +void set_store (ir_node *store) { /* GL: one could call set_value instead */ @@ -2500,17 +2554,28 @@ type *get_cur_frame_type() { /* call once for each run of the library */ void -init_cons (default_initialize_local_variable_func_t *func) +init_cons(uninitialized_local_variable_func_t *func) { default_initialize_local_variable = func; } /* call for each graph */ void -finalize_cons (ir_graph *irg) { +irg_finalize_cons (ir_graph *irg) { irg->phase_state = phase_high; } +void +irp_finalize_cons (void) { + int i, n_irgs = get_irp_n_irgs(); + for (i = 0; i < n_irgs; i++) { + irg_finalize_cons(get_irp_irg(i)); + } + irp->phase_state = phase_high;\ +} + + + ir_node *new_Block(int arity, ir_node **in) { return new_d_Block(NULL, arity, in); @@ -2537,6 +2602,11 @@ ir_node *new_Const (ir_mode *mode, tarval *con) { return new_d_Const(NULL, mode, con); } +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, type *tp) { return new_d_Const_type(NULL, get_type_mode(tp), con, tp); } @@ -2633,8 +2703,8 @@ ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type, return new_d_Alloc(NULL, store, size, alloc_type, where); } ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, - type *free_type) { - return new_d_Free(NULL, store, ptr, size, free_type); + type *free_type, where_alloc where) { + return new_d_Free(NULL, store, ptr, size, free_type, where); } ir_node *new_Sync (int arity, ir_node **in) { return new_d_Sync(NULL, arity, in); @@ -2678,3 +2748,6 @@ ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj) { ir_node *new_NoMem (void) { return new_d_NoMem(); } +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); +}