+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_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)
+
+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, 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, 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, symconst_symbol value,
+ symconst_kind symkind, ir_type *tp) {
+ ir_node *res;
+ ir_mode *mode;
+ ir_graph *irg = current_ir_graph;
+
+ if ((symkind == symconst_addr_name) || (symkind == symconst_addr_ent))
+ mode = mode_P_data; /* FIXME: can be mode_P_code */
+ else
+ mode = mode_Iu;
+
+ 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 */