-/**
- * Language dependent variable initialization callback.
- */
-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.res_mode = 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); \
-}
-
-
-/**
- * Constructs a Block with a fixed number of predecessors.
- * Does not set current_block. Cannot be used with automatic
- * Phi node construction.
- */
-static ir_node *
-new_bd_Block(dbg_info *db, int arity, ir_node **in) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, NULL, op_Block, mode_BB, arity, in);
-
- /* macroblock header */
- res->in[0] = res;
-
- res->attr.block.is_dead = 0;
- res->attr.block.is_mb_head = 1;
- res->attr.block.has_label = 0;
- res->attr.block.irg = irg;
- 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;
- res->attr.block.mb_depth = 0;
- res->attr.block.label = 0;
-
- set_Block_matured(res, 1);
- set_Block_block_visited(res, 0);
-
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Block */
-
-static ir_node *
-new_bd_Start(dbg_info *db, ir_node *block) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, block, op_Start, mode_T, 0, NULL);
-
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Start */
-
-static ir_node *
-new_bd_End(dbg_info *db, ir_node *block) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, block, op_End, mode_X, -1, NULL);
-
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_End */
-
-/**
- * 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) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
- int i;
- int has_unknown = 0;
-
- /* Don't assert that block matured: the use of this constructor is strongly
- restricted ... */
- if (get_Block_matured(block))
- assert(get_irn_arity(block) == arity);
-
- res = new_ir_node(db, irg, block, op_Phi, mode, arity, in);
-
- 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) {
- has_unknown = 1;
- break;
- }
-
- if (!has_unknown) res = optimize_node(res);
- IRN_VRFY_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 ((res->op == op_Phi) && (mode == mode_M))
- add_End_keepalive(get_irg_end(irg), res);
- return res;
-} /* new_bd_Phi */
-
-static ir_node *
-new_bd_Const_type(dbg_info *db, ir_node *block, ir_mode *mode, tarval *con, ir_type *tp) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
- (void) block;
-
- res = new_ir_node(db, irg, get_irg_start_block(irg), op_Const, mode, 0, NULL);
- res->attr.con.tv = 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);
-
- return res;
-} /* new_bd_Const_type */
-
-static ir_node *
-new_bd_Const(dbg_info *db, ir_node *block, ir_mode *mode, tarval *con) {
- ir_graph *irg = current_ir_graph;
-
- return new_rd_Const_type (db, irg, block, mode, con, firm_unknown_type);
-} /* new_bd_Const */
-
-static ir_node *
-new_bd_Const_long(dbg_info *db, ir_node *block, ir_mode *mode, long value) {
- ir_graph *irg = current_ir_graph;
-
- return new_rd_Const(db, irg, block, mode, new_tarval_from_long(value, mode));
-} /* new_bd_Const_long */
-
-static ir_node *
-new_bd_Id(dbg_info *db, ir_node *block, ir_node *val, ir_mode *mode) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, block, op_Id, mode, 1, &val);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Id */
-
-static ir_node *
-new_bd_Proj(dbg_info *db, ir_node *block, ir_node *arg, ir_mode *mode,
- long proj) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node (db, irg, block, op_Proj, mode, 1, &arg);
- res->attr.proj = proj;
-
- assert(res);
- assert(get_Proj_pred(res));
- assert(get_nodes_block(get_Proj_pred(res)));
-
- res = optimize_node(res);
-
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Proj */
-
-static ir_node *
-new_bd_defaultProj(dbg_info *db, ir_node *block, ir_node *arg,
- long max_proj) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- assert(arg->op == op_Cond);
- arg->attr.cond.kind = fragmentary;
- arg->attr.cond.default_proj = max_proj;
- res = new_rd_Proj (db, irg, block, arg, mode_X, max_proj);
- return res;
-} /* new_bd_defaultProj */
-
-static ir_node *
-new_bd_Conv(dbg_info *db, ir_node *block, ir_node *op, ir_mode *mode, int strict_flag) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, block, op_Conv, mode, 1, &op);
- res->attr.conv.strict = strict_flag;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Conv */
-
-static ir_node *
-new_bd_Cast(dbg_info *db, ir_node *block, ir_node *op, ir_type *to_tp) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- assert(is_atomic_type(to_tp));
-
- res = new_ir_node(db, irg, block, op_Cast, get_irn_mode(op), 1, &op);
- res->attr.cast.totype = to_tp;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Cast */
-
-static ir_node *
-new_bd_Tuple(dbg_info *db, ir_node *block, int arity, ir_node **in) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, block, op_Tuple, mode_T, arity, in);
- res = optimize_node (res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Tuple */
-
-NEW_BD_BINOP(Add)
-NEW_BD_BINOP(Sub)
-NEW_BD_UNOP(Minus)
-NEW_BD_BINOP(Mul)
-NEW_BD_BINOP(Mulh)
-NEW_BD_DIVOP(Quot)
-NEW_BD_DIVOP(DivMod)
-NEW_BD_DIVOP(Div)
-NEW_BD_DIVOP(Mod)
-NEW_BD_BINOP(And)
-NEW_BD_BINOP(Or)
-NEW_BD_BINOP(Eor)
-NEW_BD_UNOP(Not)
-NEW_BD_BINOP(Shl)
-NEW_BD_BINOP(Shr)
-NEW_BD_BINOP(Shrs)
-NEW_BD_BINOP(Rot)
-NEW_BD_UNOP(Abs)
-NEW_BD_BINOP(Carry)
-NEW_BD_BINOP(Borrow)
-
-/** Creates a remainderless Div node. */
-static ir_node *new_bd_DivRL(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_Div, mode_T, 3, in);
- res->attr.divmod.exc.pin_state = state;
- res->attr.divmod.res_mode = mode;
- res->attr.divmod.no_remainder = 1;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_Cmp(dbg_info *db, ir_node *block, ir_node *op1, ir_node *op2) {
- 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_Cmp, mode_T, 2, in);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Cmp */
-
-static ir_node *
-new_bd_Jmp(dbg_info *db, ir_node *block) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, block, op_Jmp, mode_X, 0, NULL);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Jmp */
-
-static ir_node *
-new_bd_IJmp(dbg_info *db, ir_node *block, ir_node *tgt) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, block, op_IJmp, mode_X, 1, &tgt);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_IJmp */
-
-static ir_node *
-new_bd_Cond(dbg_info *db, ir_node *block, ir_node *c) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, block, op_Cond, mode_T, 1, &c);
- res->attr.cond.kind = dense;
- res->attr.cond.default_proj = 0;
- res->attr.cond.pred = COND_JMP_PRED_NONE;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Cond */
-
-static ir_node *
-new_bd_Call(dbg_info *db, ir_node *block, ir_node *store,
- ir_node *callee, int arity, ir_node **in, ir_type *tp) {
- ir_node **r_in;
- ir_node *res;
- int r_arity;
- ir_graph *irg = current_ir_graph;
-
- r_arity = arity+2;
- NEW_ARR_A(ir_node *, r_in, r_arity);
- r_in[0] = store;
- r_in[1] = callee;
- memcpy(&r_in[2], in, sizeof(ir_node *) * arity);
-
- res = new_ir_node(db, irg, block, op_Call, mode_T, r_arity, r_in);
-
- 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;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Call */
-
-static ir_node *
-new_bd_Return(dbg_info *db, ir_node *block,
- ir_node *store, int arity, ir_node **in) {
- ir_node **r_in;
- ir_node *res;
- int r_arity;
- ir_graph *irg = current_ir_graph;
-
- r_arity = arity+1;
- NEW_ARR_A (ir_node *, r_in, r_arity);
- r_in[0] = store;
- memcpy(&r_in[1], in, sizeof(ir_node *) * arity);
- res = new_ir_node(db, irg, block, op_Return, mode_X, r_arity, r_in);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Return */
-
-static ir_node *
-new_bd_Load(dbg_info *db, ir_node *block,
- ir_node *store, ir_node *adr, ir_mode *mode) {
- ir_node *in[2];
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- in[0] = store;
- in[1] = adr;
- res = new_ir_node(db, irg, block, op_Load, mode_T, 2, in);
- res->attr.load.exc.pin_state = op_pin_state_pinned;
- res->attr.load.load_mode = mode;
- res->attr.load.volatility = volatility_non_volatile;
- res->attr.load.aligned = align_is_aligned;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Load */
-
-static ir_node *
-new_bd_Store(dbg_info *db, ir_node *block,
- ir_node *store, ir_node *adr, ir_node *val) {
- ir_node *in[3];
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- in[0] = store;
- in[1] = adr;
- in[2] = val;
- res = new_ir_node(db, irg, block, op_Store, mode_T, 3, in);
- res->attr.store.exc.pin_state = op_pin_state_pinned;
- res->attr.store.volatility = volatility_non_volatile;
- res->attr.store.aligned = align_is_aligned;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Store */
-
-static ir_node *
-new_bd_Alloc(dbg_info *db, ir_node *block, ir_node *store,
- ir_node *size, ir_type *alloc_type, ir_where_alloc where) {
- ir_node *in[2];
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- in[0] = store;
- in[1] = size;
- res = new_ir_node(db, irg, block, op_Alloc, mode_T, 2, in);
- res->attr.alloc.exc.pin_state = op_pin_state_pinned;
- res->attr.alloc.where = where;
- res->attr.alloc.type = alloc_type;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Alloc */
-
-static ir_node *
-new_bd_Free(dbg_info *db, ir_node *block, ir_node *store,
- ir_node *ptr, ir_node *size, ir_type *free_type, ir_where_alloc where) {
- ir_node *in[3];
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- in[0] = store;
- in[1] = ptr;
- in[2] = size;
- res = new_ir_node (db, irg, block, op_Free, mode_M, 3, in);
- res->attr.free.where = where;
- res->attr.free.type = free_type;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Free */
-
-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_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");
-
- r_arity = arity + 2;
- NEW_ARR_A(ir_node *, r_in, r_arity); /* uses alloca */
- r_in[0] = store;
- r_in[1] = objptr;
- memcpy(&r_in[2], in, sizeof(ir_node *) * arity);
- /*
- * Sel's can select functions which should be of mode mode_P_code.
- */
- res = new_ir_node(db, irg, block, op_Sel, mode, r_arity, r_in);
- res->attr.sel.ent = ent;
- res = optimize_node(res);
- IRN_VRFY_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;
- 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 = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_SymConst_type */
-
-static ir_node *
-new_bd_Sync(dbg_info *db, ir_node *block) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- 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);
- return res;
-} /* new_bd_Sync */
-
-static ir_node *
-new_bd_Confirm(dbg_info *db, ir_node *block, ir_node *val, ir_node *bound, pn_Cmp cmp) {
- ir_node *in[2], *res;
- ir_graph *irg = current_ir_graph;
-
- in[0] = val;
- in[1] = bound;
- res = new_ir_node(db, irg, block, op_Confirm, get_irn_mode(val), 2, in);
- res->attr.confirm.cmp = cmp;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Confirm */
-
-static ir_node *
-new_bd_Unknown(ir_mode *m) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(NULL, irg, get_irg_start_block(irg), op_Unknown, m, 0, NULL);
- res = optimize_node(res);
- return res;
-} /* new_bd_Unknown */
-
-static ir_node *
-new_bd_CallBegin(dbg_info *db, ir_node *block, ir_node *call) {
- ir_node *in[1];
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- in[0] = get_Call_ptr(call);
- res = new_ir_node(db, irg, block, op_CallBegin, mode_T, 1, in);
- /* res->attr.callbegin.irg = irg; */
- res->attr.callbegin.call = call;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_CallBegin */
-
-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_Break(dbg_info *db, ir_node *block) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, block, op_Break, mode_X, 0, NULL);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Break */
-
-static ir_node *
-new_bd_Filter(dbg_info *db, ir_node *block, ir_node *arg, ir_mode *mode,
- long proj) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, block, op_Filter, mode, 1, &arg);
- res->attr.filter.proj = proj;
- res->attr.filter.in_cg = NULL;
- res->attr.filter.backedge = NULL;
-
- assert(res);
- assert(get_Proj_pred(res));
- assert(get_nodes_block(get_Proj_pred(res)));
-
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Filter */
-
-static ir_node *
-new_bd_Mux(dbg_info *db, ir_node *block,
- ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode) {
- ir_node *in[3];
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- 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;
-} /* 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) {
- ir_node *in[3];
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- in[0] = store;
- in[1] = dst;
- in[2] = src;
-
- res = new_ir_node(db, irg, block, op_CopyB, mode_T, 3, in);
-
- res->attr.copyb.exc.pin_state = op_pin_state_pinned;
- res->attr.copyb.data_type = data_type;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_CopyB */
-
-static ir_node *
-new_bd_InstOf(dbg_info *db, ir_node *block, ir_node *store,
- ir_node *objptr, ir_type *type) {
- ir_node *in[2];
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- in[0] = store;
- in[1] = objptr;
- res = new_ir_node(db, irg, block, op_Sel, mode_T, 2, in);
- res->attr.instof.type = type;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_InstOf */
-
-static ir_node *
-new_bd_Raise(dbg_info *db, ir_node *block, ir_node *store, ir_node *obj) {
- ir_node *in[2];
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- in[0] = store;
- in[1] = obj;
- res = new_ir_node(db, irg, block, op_Raise, mode_T, 2, in);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Raise */
-
-static ir_node *
-new_bd_Bound(dbg_info *db, ir_node *block,
- ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper) {
- ir_node *in[4];
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- in[0] = store;
- in[1] = idx;
- in[2] = lower;
- in[3] = upper;
- res = new_ir_node(db, irg, block, op_Bound, mode_T, 4, in);
- res->attr.bound.exc.pin_state = op_pin_state_pinned;
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Bound */
-
-static ir_node *
-new_bd_Pin(dbg_info *db, ir_node *block, ir_node *node) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- res = new_ir_node(db, irg, block, op_Pin, get_irn_mode(node), 1, &node);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-} /* new_bd_Pin */
-
-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) {
- ir_node *res;
- ir_graph *irg = current_ir_graph;
- (void) clobber;
-
- 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;
-
- 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);
- return res;
-} /* new_bd_ASM */
-
-/* --------------------------------------------- */
-/* private interfaces, for professional use only */
-/* --------------------------------------------- */
-
-/* Constructs a Block with a fixed number of predecessors.
- Does not set current_block. Can not be used with automatic
- Phi node construction. */
-ir_node *
-new_rd_Block(dbg_info *db, ir_graph *irg, int arity, ir_node **in) {
- ir_graph *rem = current_ir_graph;
- ir_node *res;
-
- current_ir_graph = irg;
- res = new_bd_Block(db, arity, in);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Block */
-
-ir_node *
-new_rd_Start(dbg_info *db, ir_graph *irg, ir_node *block) {
- ir_graph *rem = current_ir_graph;
- ir_node *res;
-
- current_ir_graph = irg;
- res = new_bd_Start(db, block);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Start */
-
-ir_node *
-new_rd_End(dbg_info *db, ir_graph *irg, ir_node *block) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_End(db, block);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_End */
-
-/* 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_graph *irg, ir_node *block, int arity, ir_node **in, ir_mode *mode) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Phi(db, block,arity, in, mode);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Phi */
-
-ir_node *
-new_rd_Const_type(dbg_info *db, ir_graph *irg, ir_node *block, ir_mode *mode, tarval *con, ir_type *tp) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Const_type(db, block, mode, con, tp);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Const_type */
-
-ir_node *
-new_rd_Const(dbg_info *db, ir_graph *irg, ir_node *block, ir_mode *mode, tarval *con) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Const_type(db, block, mode, con, firm_unknown_type);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Const */
-
-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));
-} /* new_rd_Const_long */
-
-ir_node *
-new_rd_Id(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *val, ir_mode *mode) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Id(db, block, val, mode);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Id */
-
-ir_node *
-new_rd_Proj(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg, ir_mode *mode,
- long proj) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Proj(db, block, arg, mode, proj);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Proj */
-
-ir_node *
-new_rd_defaultProj(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
- long max_proj) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_defaultProj(db, block, arg, max_proj);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_defaultProj */
-
-ir_node *
-new_rd_Conv(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_Conv(db, block, op, mode, 0);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Conv */
-
-ir_node *
-new_rd_Cast(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *op, ir_type *to_tp) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Cast(db, block, op, to_tp);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Cast */
-
-ir_node *
-new_rd_Tuple(dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node **in) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Tuple(db, block, arity, in);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Tuple */
-
-NEW_RD_BINOP(Add)
-NEW_RD_BINOP(Sub)
-NEW_RD_UNOP(Minus)
-NEW_RD_BINOP(Mul)
-NEW_RD_BINOP(Mulh)
-NEW_RD_DIVOP(Quot)
-NEW_RD_DIVOP(DivMod)
-NEW_RD_DIVOP(Div)
-NEW_RD_DIVOP(Mod)
-NEW_RD_BINOP(And)
-NEW_RD_BINOP(Or)
-NEW_RD_BINOP(Eor)
-NEW_RD_UNOP(Not)
-NEW_RD_BINOP(Shl)
-NEW_RD_BINOP(Shr)
-NEW_RD_BINOP(Shrs)
-NEW_RD_BINOP(Rot)
-NEW_RD_UNOP(Abs)
-NEW_RD_BINOP(Carry)
-NEW_RD_BINOP(Borrow)
-
-/* creates a rd constructor for an divRL */
-ir_node *new_rd_DivRL(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_DivRL(db, block, memop, op1, op2, mode, state);
- current_ir_graph = rem;
- return res;
-}
-
-ir_node *
-new_rd_Cmp(dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Cmp(db, block, op1, op2);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Cmp */
-
-ir_node *
-new_rd_Jmp(dbg_info *db, ir_graph *irg, ir_node *block) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Jmp(db, block);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Jmp */
-
-ir_node *
-new_rd_IJmp(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *tgt) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_IJmp(db, block, tgt);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_IJmp */
-
-ir_node *
-new_rd_Cond(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Cond(db, block, c);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Cond */
-
-ir_node *
-new_rd_Call(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *callee, int arity, ir_node **in, ir_type *tp) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Call(db, block, store, callee, arity, in, tp);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Call */
-
-ir_node *
-new_rd_Return(dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, int arity, ir_node **in) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Return(db, block, store, arity, in);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Return */
-
-ir_node *
-new_rd_Load(dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *adr, ir_mode *mode) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Load(db, block, store, adr, mode);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Load */
-
-ir_node *
-new_rd_Store(dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *adr, ir_node *val) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Store(db, block, store, adr, val);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Store */
-
-ir_node *
-new_rd_Alloc(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *size, ir_type *alloc_type, ir_where_alloc where) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Alloc(db, block, store, size, alloc_type, where);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Alloc */
-
-ir_node *
-new_rd_Free(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *ptr, ir_node *size, ir_type *free_type, ir_where_alloc where) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Free(db, block, store, ptr, size, free_type, where);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Free */
-
-ir_node *
-new_rd_simpleSel(dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *objptr, ir_entity *ent) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Sel(db, block, store, objptr, 0, NULL, ent);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_simpleSel */
-
-ir_node *
-new_rd_Sel(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store, ir_node *objptr,
- int arity, ir_node **in, ir_entity *ent) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Sel(db, block, store, objptr, arity, in, ent);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_Sel */
-
-ir_node *
-new_rd_SymConst_type(dbg_info *db, ir_graph *irg, ir_node *block, ir_mode *mode,
- symconst_symbol value, symconst_kind symkind, ir_type *tp) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_SymConst_type(db, block, mode, value, symkind, tp);
- current_ir_graph = rem;
-
- return res;
-} /* new_rd_SymConst_type */
-
-ir_node *
-new_rd_SymConst(dbg_info *db, ir_graph *irg, ir_node *block, ir_mode *mode,
- symconst_symbol value, symconst_kind symkind) {
- return new_rd_SymConst_type(db, irg, block, 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) {
- symconst_symbol sym;
- sym.entity_p = symbol;
- return new_rd_SymConst_type(db, irg, get_irg_start_block(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) {
- symconst_symbol sym;
- sym.entity_p = symbol;
- return new_rd_SymConst_type(db, irg, get_irg_start_block(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, get_irg_start_block(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) {
- symconst_symbol sym;
- sym.type_p = symbol;
- return new_rd_SymConst_type(db, irg, get_irg_start_block(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) {
- symconst_symbol sym;
- sym.type_p = symbol;
- return new_rd_SymConst_type(db, irg, get_irg_start_block(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) {
- symconst_symbol sym;
- sym.type_p = symbol;
- return new_rd_SymConst_type(db, irg, get_irg_start_block(irg), mode, sym, symconst_type_align, tp);
-} /* new_rd_SymConst_align */
-
-ir_node *
-new_rd_Sync(dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node *in[]) {
- ir_node *res;
- ir_graph *rem = current_ir_graph;
- int i;
-
- current_ir_graph = irg;
- res = new_bd_Sync(db, block);
- current_ir_graph = rem;
-
- for (i = 0; i < arity; ++i)
- add_Sync_pred(res, in[i]);
-
- return res;
-} /* new_rd_Sync */
-
-ir_node *
-new_rd_Bad(ir_graph *irg) {
- return get_irg_bad(irg);
-} /* new_rd_Bad */
-
-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 *res;
- ir_graph *rem = current_ir_graph;
-
- current_ir_graph = irg;
- res = new_bd_Confirm(db, block, val, bound, cmp);
- current_ir_graph = rem;