-/* 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_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(irg->end, res);
- return res;
-}
-
-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;
-
- res = new_ir_node (db, irg, irg->start_block, 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;
-}
-
-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);
-}
-
-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));
-}
-
-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;
-}
-
-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;
-
-}
-
-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.c.kind = fragmentary;
- arg->attr.c.default_proj = max_proj;
- res = new_rd_Proj (db, irg, block, arg, mode_X, max_proj);
- return res;
-}
-
-static ir_node *
-new_bd_Conv (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_Conv, mode, 1, &op);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-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;
-}
-
-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;
-}
-
-static ir_node *
-new_bd_Add (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_Add, mode, 2, in);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_Sub (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_Sub, mode, 2, in);
- res = optimize_node (res);
- IRN_VRFY_IRG(res, irg);
-
- return res;
-}
-
-static ir_node *
-new_bd_Minus (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_Minus, mode, 1, &op);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_Mul (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_Mul, mode, 2, in);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_Quot (dbg_info *db, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2)
-{
- 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_Quot, mode_T, 3, in);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_DivMod (dbg_info *db, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2)
-{
- 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_DivMod, mode_T, 3, in);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_Div (dbg_info *db, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2)
-{
- 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 = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_Mod (dbg_info *db, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2)
-{
- 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_Mod, mode_T, 3, in);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_And (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_And, mode, 2, in);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_Or (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_Or, mode, 2, in);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_Eor (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_Eor, mode, 2, in);
- res = optimize_node (res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_Not (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_Not, mode, 1, &op);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}
-
-static ir_node *
-new_bd_Shl (dbg_info *db, ir_node *block,
- ir_node *op, ir_node *k, ir_mode *mode)
-{
- ir_node *in[2];
- ir_node *res;
- ir_graph *irg = current_ir_graph;
-
- in[0] = op;
- in[1] = k;
- res = new_ir_node(db, irg, block, op_Shl, mode, 2, in);
- res = optimize_node(res);
- IRN_VRFY_IRG(res, irg);
- return res;
-}