#include "irhooks.h"
#include "irarch.h"
#include "hashptr.h"
-#include "archop.h"
#include "opt_confirms.h"
#include "opt_polymorphy.h"
#include "irtools.h"
ir_node *oldn = n;
int n_preds;
- /* don't optimize dead blocks */
- if (is_Block_dead(n))
+ /* don't optimize dead or labeled blocks */
+ if (is_Block_dead(n) || has_Block_label(n))
return n;
n_preds = get_Block_n_cfgpreds(n);
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_AND);
return n;
}
- /* constants are cormalized to right, check this site first */
+ /* constants are normalized to right, check this site first */
tv = value_of(b);
if (tarval_is_all_one(tv)) {
n = a;
DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_AND);
return n;
}
+ if (tv != get_tarval_bad()) {
+ ir_mode *mode = get_irn_mode(n);
+ if (!mode_is_signed(mode) && is_Conv(a)) {
+ ir_node *convop = get_Conv_op(a);
+ ir_mode *convopmode = get_irn_mode(convop);
+ if (!mode_is_signed(convopmode)) {
+ if (tarval_is_all_one(tarval_convert_to(tv, convopmode))) {
+ /* Conv(X) & all_one(mode(X)) = Conv(X) */
+ n = a;
+ DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_AND);
+ return n;
+ }
+ }
+ }
+ }
tv = value_of(a);
if (tarval_is_all_one(tv)) {
n = b;
irg = current_ir_graph;
for (i = 0; i < n; ++i) {
pred = get_irn_n(phi, i);
- res[i] = new_r_Const_type(irg, mode, res[i], get_Const_type(pred));
+ res[i] = new_r_Const_type(irg, res[i], get_Const_type(pred));
}
return new_r_Phi(irg, get_nodes_block(phi), n, (ir_node **)res, mode);
} /* apply_binop_on_phi */
irg = current_ir_graph;
for (i = 0; i < n; ++i) {
pred = get_irn_n(a, i);
- res[i] = new_r_Const_type(irg, mode, res[i], get_Const_type(pred));
+ res[i] = new_r_Const_type(irg, res[i], get_Const_type(pred));
}
return new_r_Phi(irg, get_nodes_block(a), n, (ir_node **)res, mode);
} /* apply_binop_on_2_phis */
irg = current_ir_graph;
for (i = 0; i < n; ++i) {
pred = get_irn_n(phi, i);
- res[i] = new_r_Const_type(irg, mode, res[i], get_Const_type(pred));
+ res[i] = new_r_Const_type(irg, res[i], get_Const_type(pred));
}
return new_r_Phi(irg, get_nodes_block(phi), n, (ir_node **)res, mode);
} /* apply_unop_on_phi */
irg = current_ir_graph;
for (i = 0; i < n; ++i) {
pred = get_irn_n(phi, i);
- res[i] = new_r_Const_type(irg, mode, res[i], get_Const_type(pred));
+ res[i] = new_r_Const_type(irg, res[i], get_Const_type(pred));
}
return new_r_Phi(irg, get_nodes_block(phi), n, (ir_node **)res, mode);
} /* apply_conv_on_phi */
current_ir_graph,
block,
a,
- new_r_Const_long(current_ir_graph, mode, 2),
+ new_Const_long(mode, 2),
mode);
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_A_A);
return n;
}
if (op == b) {
/* ~x + x = -1 */
- n = new_Const(mode, get_mode_minus_one(mode));
+ n = new_Const(get_mode_minus_one(mode));
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_X_NOT_X);
return n;
}
if (op == a) {
/* x + ~x = -1 */
- n = new_Const(mode, get_mode_minus_one(mode));
+ n = new_Const(get_mode_minus_one(mode));
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_X_NOT_X);
return n;
}
tarval *tv = tarval_neg(get_Const_tarval(cnst));
dbg_info *dbgi = get_irn_dbg_info(cnst);
ir_graph *irg = get_irn_irg(cnst);
- ir_mode *mode = get_irn_mode(cnst);
if (tv == tarval_bad) return NULL;
- return new_rd_Const(dbgi, irg, mode, tv);
+ return new_rd_Const(dbgi, irg, tv);
}
/**
if (mode_is_float(mode) && (get_irg_fp_model(current_ir_graph) & fp_strict_algebraic))
return n;
- if (is_Const(b) && get_irn_mode(b) != mode_P) {
+ if (is_Const(b) && !mode_is_reference(get_irn_mode(b))) {
/* a - C -> a + (-C) */
ir_node *cnst = const_negate(b);
if (cnst != NULL) {
ir_node *s_left = get_Sub_left(b);
ir_node *s_right = get_Sub_right(b);
ir_mode *s_mode = get_irn_mode(b);
- if (s_mode == mode_P) {
+ if (mode_is_reference(s_mode)) {
ir_node *sub = new_rd_Sub(s_dbg, irg, s_block, a, s_left, mode);
dbg_info *a_dbg = get_irn_dbg_info(n);
ir_node *a_block = get_nodes_block(n);
get_irn_dbg_info(n),
current_ir_graph, blk,
mb,
- new_r_Const_long(current_ir_graph, mode, 1),
+ new_Const_long(mode, 1),
mode),
mode);
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_SUB_MUL_A_X_A);
get_irn_dbg_info(n),
current_ir_graph, blk,
ma,
- new_r_Const_long(current_ir_graph, mode, 1),
+ new_Const_long(mode, 1),
mode),
mode);
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_SUB_MUL_A_X_A);
tv = tarval_add(tv, get_mode_one(mode));
if (tv != tarval_bad) {
ir_node *blk = get_nodes_block(n);
- ir_node *c = new_Const(mode, tv);
+ ir_node *c = new_Const(tv);
n = new_rd_Add(get_irn_dbg_info(n), current_ir_graph, blk, get_Not_op(b), c, mode);
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_SUB_C_NOT_X);
return n;
value = n;
tv = value_of(n);
if (tv != tarval_bad) {
- value = new_Const(get_tarval_mode(tv), tv);
+ value = new_Const(tv);
DBG_OPT_CSTEVAL(n, value);
goto make_tuple;
if (a == b && value_not_zero(a, &dummy)) {
/* BEWARE: we can optimize a/a to 1 only if this cannot cause a exception */
- value = new_Const(mode, get_mode_one(mode));
+ value = new_Const(get_mode_one(mode));
DBG_OPT_CSTEVAL(n, value);
goto make_tuple;
} else {
value = n;
tv = value_of(n);
if (tv != tarval_bad) {
- value = new_Const(get_tarval_mode(tv), tv);
+ value = new_Const(tv);
DBG_OPT_CSTEVAL(n, value);
goto make_tuple;
if (a == b && value_not_zero(a, &dummy)) {
/* BEWARE: we can optimize a%a to 0 only if this cannot cause a exception */
- value = new_Const(mode, get_mode_null(mode));
+ value = new_Const(get_mode_null(mode));
DBG_OPT_CSTEVAL(n, value);
goto make_tuple;
} else {
if (tv == get_mode_minus_one(mode)) {
/* a % -1 = 0 */
- value = new_Const(mode, get_mode_null(mode));
+ value = new_Const(get_mode_null(mode));
DBG_OPT_CSTEVAL(n, value);
goto make_tuple;
}
if (tb != tarval_bad) {
if (tb == get_mode_one(get_tarval_mode(tb))) {
va = a;
- vb = new_Const(mode, get_mode_null(mode));
+ vb = new_Const(get_mode_null(mode));
DBG_OPT_CSTEVAL(n, vb);
goto make_tuple;
} else if (ta != tarval_bad) {
Jmp for X result!? */
resb = tarval_mod(ta, tb);
if (resb == tarval_bad) return n; /* Causes exception! */
- va = new_Const(mode, resa);
- vb = new_Const(mode, resb);
+ va = new_Const(resa);
+ vb = new_Const(resb);
DBG_OPT_CSTEVAL(n, va);
DBG_OPT_CSTEVAL(n, vb);
goto make_tuple;
} else if (mode_is_signed(mode) && tb == get_mode_minus_one(mode)) {
va = new_rd_Minus(get_irn_dbg_info(n), current_ir_graph, get_nodes_block(n), a, mode);
- vb = new_Const(mode, get_mode_null(mode));
+ vb = new_Const(get_mode_null(mode));
DBG_OPT_CSTEVAL(n, va);
DBG_OPT_CSTEVAL(n, vb);
goto make_tuple;
} else if (a == b) {
if (value_not_zero(a, &dummy)) {
/* a/a && a != 0 */
- va = new_Const(mode, get_mode_one(mode));
- vb = new_Const(mode, get_mode_null(mode));
+ va = new_Const(get_mode_one(mode));
+ vb = new_Const(get_mode_null(mode));
DBG_OPT_CSTEVAL(n, va);
DBG_OPT_CSTEVAL(n, vb);
goto make_tuple;
tarval *tv = value_of(b);
if (tv != tarval_bad) {
- int rem;
+ int rem = tarval_fp_ops_enabled();
/*
* Floating point constant folding might be disabled here to
* However, as we check for exact result, doing it is safe.
* Switch it on.
*/
- rem = tarval_enable_fp_ops(1);
+ tarval_enable_fp_ops(1);
tv = tarval_quo(get_mode_one(mode), tv);
- (void)tarval_enable_fp_ops(rem);
+ tarval_enable_fp_ops(rem);
/* Do the transformation if the result is either exact or we are not
using strict rules. */
if (tv != tarval_bad &&
(tarval_ieee754_get_exact() || (get_irg_fp_model(current_ir_graph) & fp_strict_algebraic) == 0)) {
ir_node *blk = get_nodes_block(n);
- ir_node *c = new_Const(mode, tv);
+ ir_node *c = new_Const(tv);
ir_node *a = get_Quot_left(n);
ir_node *m = new_rd_Mul(get_irn_dbg_info(n), current_ir_graph, blk, a, c, mode);
ir_node *mem = get_Quot_mem(n);
if (a == b) {
/* a ^ a = 0 */
n = new_rd_Const(get_irn_dbg_info(n), current_ir_graph,
- mode, get_mode_null(mode));
+ get_mode_null(mode));
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_EOR_A_A);
} else if (mode == mode_b &&
is_Proj(a) &&
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_EOR_TO_NOT_BOOL);
} else if (is_Const(b)) {
if (is_Not(a)) { /* ~x ^ const -> x ^ ~const */
- ir_node *cnst = new_Const(mode, tarval_not(get_Const_tarval(b)));
+ ir_node *cnst = new_Const(tarval_not(get_Const_tarval(b)));
ir_node *not_op = get_Not_op(a);
dbg_info *dbg = get_irn_dbg_info(n);
ir_graph *irg = current_ir_graph;
if (is_Eor(a)) {
ir_node *eor_b = get_Eor_right(a);
if (is_Const(eor_b)) { /* ~(x ^ const) -> x ^ ~const */
- ir_node *cnst = new_Const(mode, tarval_not(get_Const_tarval(eor_b)));
+ ir_node *cnst = new_Const(tarval_not(get_Const_tarval(eor_b)));
ir_node *eor_a = get_Eor_left(a);
dbg_info *dbg = get_irn_dbg_info(n);
ir_graph *irg = current_ir_graph;
ir_graph *irg = current_ir_graph;
ir_node *block = get_nodes_block(n);
ir_node *add_l = get_Minus_op(a);
- ir_node *add_r = new_rd_Const(dbg, irg, mode, get_mode_minus_one(mode));
+ ir_node *add_r = new_rd_Const(dbg, irg, get_mode_minus_one(mode));
n = new_rd_Add(dbg, irg, block, add_l, add_r, mode);
} else if (is_Add(a)) {
ir_node *add_r = get_Add_right(a);
ir_node *op = get_Not_op(a);
tarval *tv = get_mode_one(mode);
ir_node *blk = get_nodes_block(n);
- ir_node *c = new_Const(mode, tv);
+ ir_node *c = new_Const(tv);
n = new_rd_Add(get_irn_dbg_info(n), current_ir_graph, blk, op, c, mode);
DBG_OPT_ALGSIM2(oldn, a, n, FS_OPT_MINUS_NOT);
return n;
if (tv != tarval_bad) {
tv = tarval_neg(tv);
if (tv != tarval_bad) {
- ir_node *cnst = new_Const(mode, tv);
+ ir_node *cnst = new_Const(tv);
dbg_info *dbg = get_irn_dbg_info(a);
ir_graph *irg = current_ir_graph;
ir_node *block = get_nodes_block(a);
ir_type *tp = get_irn_type(n);
if (is_Const(pred) && get_Const_type(pred) != tp) {
- n = new_rd_Const_type(NULL, current_ir_graph, get_irn_mode(pred),
- get_Const_tarval(pred), tp);
+ n = new_rd_Const_type(NULL, current_ir_graph, get_Const_tarval(pred), tp);
DBG_OPT_CSTEVAL(oldn, n);
} else if (is_SymConst(pred) && get_SymConst_value_type(pred) != tp) {
n = new_rd_SymConst_type(NULL, current_ir_graph, get_irn_n(pred, -1), get_irn_mode(pred),
if (get_Mod_left(mod) == b) {
/* a % a = 0 if a != 0 */
ir_mode *mode = get_irn_mode(proj);
- ir_node *res = new_Const(mode, get_mode_null(mode));
+ ir_node *res = new_Const(get_mode_null(mode));
DBG_OPT_CSTEVAL(mod, res);
return res;
if (get_DivMod_left(divmod) == b) {
/* a % a = 0 if a != 0 */
ir_mode *mode = get_irn_mode(proj);
- ir_node *res = new_Const(mode, get_mode_null(mode));
+ ir_node *res = new_Const(get_mode_null(mode));
DBG_OPT_CSTEVAL(divmod, res);
return res;
/* we have a constant switch */
long num = get_Proj_proj(proj);
- if (num != get_Cond_defaultProj(n)) { /* we cannot optimize default Proj's yet */
+ if (num != get_Cond_default_proj(n)) { /* we cannot optimize default Proj's yet */
if (get_tarval_long(tb) == num) {
/* Do NOT create a jump here, or we will have 2 control flow ops
* in a block. This case is optimized away in optimize_cf(). */
*/
static ir_node *create_zero_const(ir_mode *mode) {
tarval *tv = get_mode_null(mode);
- ir_node *cnst = new_Const(mode, tv);
+ ir_node *cnst = new_Const(tv);
return cnst;
}
/* we can evaluate some cases directly */
switch (proj_nr) {
case pn_Cmp_False:
- return new_Const(mode_b, get_tarval_b_false());
+ return new_Const(get_tarval_b_false());
case pn_Cmp_True:
- return new_Const(mode_b, get_tarval_b_true());
+ return new_Const(get_tarval_b_true());
case pn_Cmp_Leg:
if (!mode_is_float(get_irn_mode(left)))
- return new_Const(mode_b, get_tarval_b_true());
+ return new_Const(get_tarval_b_true());
break;
default:
break;
tarval *mask = tarval_shl(c2, c1);
tarval *value = tarval_shl(c3, c1);
- left = new_rd_And(dbg, irg, block, get_Shr_left(ll), new_Const(mode, mask), mode);
- right = new_Const(mode, value);
+ left = new_rd_And(dbg, irg, block, get_Shr_left(ll), new_Const(mask), mode);
+ right = new_Const(value);
changed |= 1;
}
}
if (mask != tv) {
/* TODO: move to constant evaluation */
tv = proj_nr == pn_Cmp_Eq ? get_tarval_b_false() : get_tarval_b_true();
- c1 = new_Const(mode_b, tv);
+ c1 = new_Const(tv);
DBG_OPT_CSTEVAL(proj, c1);
return c1;
}
if (! tarval_is_null(get_Const_tarval(c1))) {
/* TODO: move to constant evaluation */
tv = proj_nr == pn_Cmp_Eq ? get_tarval_b_false() : get_tarval_b_true();
- c1 = new_Const(mode_b, tv);
+ c1 = new_Const(tv);
DBG_OPT_CSTEVAL(proj, c1);
return c1;
}
if (tarval_and(tv, cmask) != tv) {
/* condition not met */
tv = proj_nr == pn_Cmp_Eq ? get_tarval_b_false() : get_tarval_b_true();
- c1 = new_Const(mode_b, tv);
+ c1 = new_Const(tv);
DBG_OPT_CSTEVAL(proj, c1);
return c1;
}
sl = get_Shl_left(left);
blk = get_nodes_block(n);
- left = new_rd_And(get_irn_dbg_info(left), current_ir_graph, blk, sl, new_Const(mode, amask), mode);
+ left = new_rd_And(get_irn_dbg_info(left), current_ir_graph, blk, sl, new_Const(amask), mode);
tv = tarval_shr(tv, tv1);
changed |= 2;
DBG_OPT_ALGSIM0(n, n, FS_OPT_CMP_SHF_TO_AND);
if (tarval_and(tv, cmask) != tv) {
/* condition not met */
tv = proj_nr == pn_Cmp_Eq ? get_tarval_b_false() : get_tarval_b_true();
- c1 = new_Const(mode_b, tv);
+ c1 = new_Const(tv);
DBG_OPT_CSTEVAL(proj, c1);
return c1;
}
sl = get_Shr_left(left);
blk = get_nodes_block(n);
- left = new_rd_And(get_irn_dbg_info(left), current_ir_graph, blk, sl, new_Const(mode, amask), mode);
+ left = new_rd_And(get_irn_dbg_info(left), current_ir_graph, blk, sl, new_Const(amask), mode);
tv = tarval_shl(tv, tv1);
changed |= 2;
DBG_OPT_ALGSIM0(n, n, FS_OPT_CMP_SHF_TO_AND);
if (!tarval_is_all_one(cond) && !tarval_is_null(cond)) {
/* condition not met */
tv = proj_nr == pn_Cmp_Eq ? get_tarval_b_false() : get_tarval_b_true();
- c1 = new_Const(mode_b, tv);
+ c1 = new_Const(tv);
DBG_OPT_CSTEVAL(proj, c1);
return c1;
}
sl = get_Shrs_left(left);
blk = get_nodes_block(n);
- left = new_rd_And(get_irn_dbg_info(left), current_ir_graph, blk, sl, new_Const(mode, amask), mode);
+ left = new_rd_And(get_irn_dbg_info(left), current_ir_graph, blk, sl, new_Const(amask), mode);
tv = tarval_shl(tv, tv1);
changed |= 2;
DBG_OPT_ALGSIM0(n, n, FS_OPT_CMP_SHF_TO_AND);
}
if (changed & 2) /* need a new Const */
- right = new_Const(mode, tv);
+ right = new_Const(tv);
if ((proj_nr == pn_Cmp_Eq || proj_nr == pn_Cmp_Lg) && is_Const(right) && is_Const_null(right) && is_Proj(left)) {
ir_node *op = get_Proj_pred(left);
ir_mode *mode = get_irn_mode(v);
tv = tarval_sub(tv, get_mode_one(mode), NULL);
- left = new_rd_And(get_irn_dbg_info(op), current_ir_graph, blk, v, new_Const(mode, tv), mode);
+ left = new_rd_And(get_irn_dbg_info(op), current_ir_graph, blk, v, new_Const(tv), mode);
changed |= 1;
DBG_OPT_ALGSIM0(n, n, FS_OPT_CMP_MOD_TO_AND);
}
block = get_irn_n(or, -1);
new_and = new_r_And(current_ir_graph, block,
- value, new_Const(mode, tarval_and(tv4, tv2)), mode);
+ value, new_Const(tarval_and(tv4, tv2)), mode);
- new_const = new_Const(mode, tarval_or(tv3, tv1));
+ new_const = new_Const(tarval_or(tv3, tv1));
set_Or_left(or, new_and);
set_Or_right(or, new_const);
ir_node *block = get_nodes_block(n);
dbg_info *dbgi = get_irn_dbg_info(n);
ir_mode *smode = get_irn_mode(right);
- ir_node *cnst = new_Const(smode, new_tarval_from_long(get_mode_size_bits(mode) - 1, smode));
+ ir_node *cnst = new_Const_long(smode, get_mode_size_bits(mode) - 1);
return new_rd_Shrs(dbgi, irg, block, get_binop_left(left),
cnst, mode);
}
- return new_Const(mode, get_mode_null(mode));
+ return new_Const(get_mode_null(mode));
}
}
} else {
block = get_nodes_block(n);
in[0] = get_binop_left(left);
- in[1] = new_Const(get_tarval_mode(res), res);
+ in[1] = new_Const(res);
irn = new_ir_node(NULL, current_ir_graph, block, get_irn_op(n), mode, 2, in);
}
assert(get_tarval_mode(tv_shift) == mode);
- new_const = new_Const(mode, tv_shift);
+ new_const = new_Const(tv_shift);
if (op_left == op_And) {
new_bitop = new_rd_And(dbgi, irg, block, new_shift, new_const, mode);
pnc = tarval_cmp(tv_shl, tv_shr);
if (pnc == pn_Cmp_Lt || pnc == pn_Cmp_Eq) {
tv_shift = tarval_sub(tv_shr, tv_shl, NULL);
- new_const = new_Const(get_tarval_mode(tv_shift), tv_shift);
+ new_const = new_Const(tv_shift);
if (need_shrs) {
new_shift = new_rd_Shrs(dbgi, irg, block, x, new_const, mode);
} else {
} else {
assert(pnc == pn_Cmp_Gt);
tv_shift = tarval_sub(tv_shl, tv_shr, NULL);
- new_const = new_Const(get_tarval_mode(tv_shift), tv_shift);
+ new_const = new_Const(tv_shift);
new_shift = new_rd_Shl(dbgi, irg, block, x, new_const, mode);
}
- new_const = new_Const(mode, tv_mask);
+ new_const = new_Const(tv_mask);
new_and = new_rd_And(dbgi, irg, block, new_shift, new_const, mode);
return new_and;
dbg_info *dbg = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
ir_graph *irg = current_ir_graph;
- ir_node *t = new_Const(mode, tarval_sub(a, min, NULL));
- ir_node *f = new_Const(mode, tarval_sub(b, min, NULL));
+ ir_node *t = new_Const(tarval_sub(a, min, NULL));
+ ir_node *f = new_Const(tarval_sub(b, min, NULL));
n = new_rd_Mux(dbg, irg, block, sel, f, t, mode);
- n = new_rd_Add(dbg, irg, block, n, new_Const(mode, min), mode);
+ n = new_rd_Add(dbg, irg, block, n, new_Const(min), mode);
return n;
}
}
}
}
}
- return arch_transform_node_Mux(n);
+
+ return n;
} /* transform_node_Mux */
/**
add_identities(current_ir_graph->value_table, n);
return n;
-}
+} /* transform_node_Sync */
+
+/**
+ * optimize a trampoline Call into a direct Call
+ */
+static ir_node *transform_node_Call(ir_node *call) {
+ ir_node *callee = get_Call_ptr(call);
+ ir_node *adr, *mem, *res, *bl, **in;
+ ir_type *ctp, *mtp, *tp;
+ ident *id;
+ dbg_info *db;
+ int i, n_res, n_param;
+ ir_variadicity var;
+
+ if (! is_Proj(callee))
+ return call;
+ callee = get_Proj_pred(callee);
+ if (! is_Builtin(callee))
+ return call;
+ if (get_Builtin_kind(callee) != ir_bk_inner_trampoline)
+ return call;
+
+ mem = get_Call_mem(call);
+
+ if (skip_Proj(mem) == callee) {
+ /* memory is routed to the trampoline, skip */
+ mem = get_Builtin_mem(callee);
+ }
+
+ /* build a new call type */
+ mtp = get_Call_type(call);
+ id = get_type_ident(mtp);
+ id = id_mangle(new_id_from_chars("T_", 2), id);
+ db = get_type_dbg_info(mtp);
+
+ n_res = get_method_n_ress(mtp);
+ n_param = get_method_n_params(mtp);
+ ctp = new_d_type_method(id, n_param + 1, n_res, db);
+
+ for (i = 0; i < n_res; ++i)
+ set_method_res_type(ctp, i, get_method_res_type(mtp, i));
+
+ NEW_ARR_A(ir_node *, in, n_param + 1);
+
+ /* FIXME: we don't need a new pointer type in every step */
+ tp = get_irg_frame_type(current_ir_graph);
+ id = id_mangle(get_type_ident(tp), new_id_from_chars("_ptr", 4));
+ tp = new_type_pointer(id, tp, mode_P_data);
+ set_method_param_type(ctp, 0, tp);
+
+ in[0] = get_Builtin_param(callee, 2);
+ for (i = 0; i < n_param; ++i) {
+ set_method_param_type(ctp, i + 1, get_method_param_type(mtp, i));
+ in[i + 1] = get_Call_param(call, i);
+ }
+ var = get_method_variadicity(mtp);
+ set_method_variadicity(ctp, var);
+ if (var == variadicity_variadic) {
+ set_method_first_variadic_param_index(ctp, get_method_first_variadic_param_index(mtp) + 1);
+ }
+ /* When we resolve a trampoline, the function must be called by a this-call */
+ set_method_calling_convention(ctp, get_method_calling_convention(mtp) | cc_this_call);
+ set_method_additional_properties(ctp, get_method_additional_properties(mtp));
+
+ adr = get_Builtin_param(callee, 1);
+
+ db = get_irn_dbg_info(call);
+ bl = get_nodes_block(call);
+
+ res = new_rd_Call(db, current_ir_graph, bl, mem, adr, n_param + 1, in, ctp);
+ if (get_irn_pinned(call) == op_pin_state_floats)
+ set_irn_pinned(res, op_pin_state_floats);
+ return res;
+} /* transform_node_Call */
/**
* Tries several [inplace] [optimizing] transformations and returns an
CASE(End);
CASE(Mux);
CASE(Sync);
+ CASE(Call);
default:
/* leave NULL */;
}
const divmod_attr *ma = get_irn_divmod_attr(a);
const divmod_attr *mb = get_irn_divmod_attr(b);
return ma->exc.pin_state != mb->exc.pin_state ||
- ma->res_mode != mb->res_mode ||
+ ma->resmode != mb->resmode ||
ma->no_remainder != mb->no_remainder;
} /* node_cmp_attr_Div */
const divmod_attr *ma = get_irn_divmod_attr(a);
const divmod_attr *mb = get_irn_divmod_attr(b);
return ma->exc.pin_state != mb->exc.pin_state ||
- ma->res_mode != mb->res_mode;
+ ma->resmode != mb->resmode;
} /* node_cmp_attr_DivMod */
/** Compares the attributes of two Mod nodes. */
const divmod_attr *ma = get_irn_divmod_attr(a);
const divmod_attr *mb = get_irn_divmod_attr(b);
return ma->exc.pin_state != mb->exc.pin_state ||
- ma->res_mode != mb->res_mode;
+ ma->resmode != mb->resmode;
} /* node_cmp_attr_Mod */
/** Compares the attributes of two Quot nodes. */
const divmod_attr *ma = get_irn_divmod_attr(a);
const divmod_attr *mb = get_irn_divmod_attr(b);
return ma->exc.pin_state != mb->exc.pin_state ||
- ma->res_mode != mb->res_mode;
+ ma->resmode != mb->resmode;
} /* node_cmp_attr_Quot */
/** Compares the attributes of two Confirm nodes. */
static int node_cmp_attr_Confirm(ir_node *a, ir_node *b) {
+ /* no need to compare the bound, as this is a input */
return (get_Confirm_cmp(a) != get_Confirm_cmp(b));
} /* node_cmp_attr_Confirm */
+/** Compares the attributes of two Builtin nodes. */
+static int node_cmp_attr_Builtin(ir_node *a, ir_node *b) {
+ const builtin_attr *ma = get_irn_builtin_attr(a);
+ const builtin_attr *mb = get_irn_builtin_attr(b);
+
+ /* no need to compare the type, equal kind means equal type */
+ return ma->kind != mb->kind;
+} /* node_cmp_attr_Builtin */
+
/** Compares the attributes of two ASM nodes. */
static int node_cmp_attr_ASM(ir_node *a, ir_node *b) {
int i, n;
return 0;
} /* node_cmp_attr_ASM */
+/** Compares the inexistent attributes of two Dummy nodes. */
+static int node_cmp_attr_Dummy(ir_node *a, ir_node *b)
+{
+ (void) a;
+ (void) b;
+ return 1;
+}
+
/**
* Set the default node attribute compare operation for an ir_op_ops.
*
CASE(Mod);
CASE(Quot);
CASE(Bound);
+ CASE(Builtin);
+ CASE(Dummy);
/* FIXME CopyB */
default:
/* leave NULL */;
/* neither constants nor Tuple values can be evaluated */
if (iro != iro_Const && (get_irn_mode(n) != mode_T)) {
unsigned fp_model = get_irg_fp_model(current_ir_graph);
- int old_fp_mode = tarval_enable_fp_ops((fp_model & fp_strict_algebraic) == 0);
+ int old_fp_mode = tarval_fp_ops_enabled();
+
+ tarval_enable_fp_ops(! (fp_model & fp_no_float_fold));
+
/* try to evaluate */
tv = computed_value(n);
if (tv != tarval_bad) {
/* evaluation was successful -- replace the node. */
irg_kill_node(current_ir_graph, n);
- nw = new_Const(get_tarval_mode(tv), tv);
+ nw = new_Const(tv);
if (old_tp && get_type_mode(old_tp) == get_tarval_mode(tv))
set_Const_type(nw, old_tp);
/* neither constants nor Tuple values can be evaluated */
if (iro != iro_Const && get_irn_mode(n) != mode_T) {
unsigned fp_model = get_irg_fp_model(current_ir_graph);
- int old_fp_mode = tarval_enable_fp_ops((fp_model & fp_strict_algebraic) == 0);
+ int old_fp_mode = tarval_fp_ops_enabled();
+
+ tarval_enable_fp_ops((fp_model & fp_strict_algebraic) == 0);
/* try to evaluate */
tv = computed_value(n);
if (tv != tarval_bad) {
for (i = 0; i < arity && !old_tp; ++i)
old_tp = get_irn_type(get_irn_n(n, i));
- n = new_Const(get_tarval_mode(tv), tv);
+ n = new_Const(tv);
if (old_tp && get_type_mode(old_tp) == get_tarval_mode(tv))
set_Const_type(n, old_tp);