Commit 9b02a9db authored by Matthias Braun's avatar Matthias Braun
Browse files

tv: Remove mode parameter from tarval_sub

We can get a proper mode for pointer-pointer from
get_reference_offset_mode().
parent d013e557
......@@ -414,11 +414,10 @@ FIRM_API ir_tarval *tarval_add(ir_tarval *a, ir_tarval *b);
*
* @param a the first tarval
* @param b the second tarval
* @param dst_mode the mode of the result, needed for mode_P - mode_P, else NULL
*
* @return a - b or tarval_bad
*/
FIRM_API ir_tarval *tarval_sub(ir_tarval *a, ir_tarval *b, ir_mode *dst_mode);
FIRM_API ir_tarval *tarval_sub(ir_tarval *a, ir_tarval *b);
/**
* Multiplication of tarvals.
......
......@@ -378,8 +378,8 @@ undefined:
const long modulo_shift = get_mode_modulo_shift(m);
ir_mode *const rmode = get_irn_mode(right);
ir_tarval *const rone = get_mode_one(rmode);
ir_tarval *const size_mask = tarval_sub(new_tarval_from_long(size_bits, rmode), rone, NULL);
ir_tarval *const modulo_mask = tarval_sub(new_tarval_from_long(modulo_shift, rmode), rone, NULL);
ir_tarval *const size_mask = tarval_sub(new_tarval_from_long(size_bits, rmode), rone);
ir_tarval *const modulo_mask = tarval_sub(new_tarval_from_long(modulo_shift, rmode), rone);
ir_tarval *const zero = get_mode_null(m);
ir_tarval *const all_one = get_mode_all_one(m);
ir_tarval *const oversize_mask = tarval_andnot(modulo_mask, size_mask);
......@@ -422,8 +422,8 @@ undefined:
const long modulo_shift = get_mode_modulo_shift(m);
ir_mode *const rmode = get_irn_mode(right);
ir_tarval *const rone = get_mode_one(rmode);
ir_tarval *const size_mask = tarval_sub(new_tarval_from_long(size_bits, rmode), rone, NULL);
ir_tarval *const modulo_mask = tarval_sub(new_tarval_from_long(modulo_shift, rmode), rone, NULL);
ir_tarval *const size_mask = tarval_sub(new_tarval_from_long(size_bits, rmode), rone);
ir_tarval *const modulo_mask = tarval_sub(new_tarval_from_long(modulo_shift, rmode), rone);
ir_tarval *const zero = get_mode_null(m);
ir_tarval *const all_one = get_mode_all_one(m);
ir_tarval *const oversize_mask = tarval_andnot(modulo_mask, size_mask);
......@@ -466,8 +466,8 @@ undefined:
const long modulo_shift = get_mode_modulo_shift(m);
ir_mode *const rmode = get_irn_mode(right);
ir_tarval *const rone = get_mode_one(rmode);
ir_tarval *const size_mask = tarval_sub(new_tarval_from_long(size_bits, rmode), rone, NULL);
ir_tarval *const modulo_mask = tarval_sub(new_tarval_from_long(modulo_shift, rmode), rone, NULL);
ir_tarval *const size_mask = tarval_sub(new_tarval_from_long(size_bits, rmode), rone);
ir_tarval *const modulo_mask = tarval_sub(new_tarval_from_long(modulo_shift, rmode), rone);
ir_tarval *const zero = get_mode_null(m);
ir_tarval *const all_one = get_mode_all_one(m);
ir_tarval *const oversize_mask = tarval_andnot(modulo_mask, size_mask);
......@@ -523,8 +523,8 @@ undefined:
ir_tarval *const lo = l->o;
ir_tarval *const rz = r->z;
ir_tarval *const ro = r->o;
ir_tarval *const vz = tarval_sub(lo, rz, m);
ir_tarval *const vo = tarval_sub(lz, ro, m);
ir_tarval *const vz = tarval_sub(lo, rz);
ir_tarval *const vo = tarval_sub(lz, ro);
ir_tarval *const lnc = tarval_eor(lz, lo);
ir_tarval *const rnc = tarval_eor(rz, ro);
ir_tarval *const vnc = tarval_eor(vz, vo);
......
......@@ -287,8 +287,8 @@ static void dca_transfer(ir_node *irn)
const long modulo_shift = get_mode_modulo_shift(mode);
ir_mode *const rmode = get_irn_mode(right);
ir_tarval *const rone = get_mode_one(rmode);
ir_tarval *const size_mask = tarval_sub(new_tarval_from_long(size_bits, rmode), rone, NULL);
ir_tarval *const modulo_mask = tarval_sub(new_tarval_from_long(modulo_shift, rmode), rone, NULL);
ir_tarval *const size_mask = tarval_sub(new_tarval_from_long(size_bits, rmode), rone);
ir_tarval *const modulo_mask = tarval_sub(new_tarval_from_long(modulo_shift, rmode), rone);
ir_tarval *const oversize_mask = tarval_andnot(modulo_mask, size_mask);
ir_tarval *const ro = br->o;
ir_tarval *const rz = br->z;
......@@ -337,8 +337,8 @@ static void dca_transfer(ir_node *irn)
const long modulo_shift = get_mode_modulo_shift(mode);
ir_mode *const rmode = get_irn_mode(right);
ir_tarval *const rone = get_mode_one(rmode);
ir_tarval *const size_mask = tarval_sub(new_tarval_from_long(size_bits, rmode), rone, NULL);
ir_tarval *const modulo_mask = tarval_sub(new_tarval_from_long(modulo_shift, rmode), rone, NULL);
ir_tarval *const size_mask = tarval_sub(new_tarval_from_long(size_bits, rmode), rone);
ir_tarval *const modulo_mask = tarval_sub(new_tarval_from_long(modulo_shift, rmode), rone);
ir_tarval *const oversize_mask = tarval_andnot(modulo_mask, size_mask);
ir_tarval *const ro = br->o;
ir_tarval *const rz = br->z;
......
......@@ -152,8 +152,8 @@ static int vrp_update_node(ir_vrp_info *info, ir_node *node)
&& vrp_right->range_type == VRP_RANGE) {
int old_wrap_on_overflow = tarval_get_wrap_on_overflow();
tarval_set_wrap_on_overflow(false);
ir_tarval *new_top = tarval_sub(vrp_left->range_top, vrp_right->range_bottom, NULL);
ir_tarval *new_bottom = tarval_sub(vrp_left->range_bottom, vrp_right->range_top, NULL);
ir_tarval *new_top = tarval_sub(vrp_left->range_top, vrp_right->range_bottom);
ir_tarval *new_bottom = tarval_sub(vrp_left->range_bottom, vrp_right->range_top);
tarval_set_wrap_on_overflow(old_wrap_on_overflow);
if (new_top != tarval_bad && new_bottom != tarval_bad) {
......
......@@ -113,9 +113,9 @@ static carry_result lower_sub_borrow(ir_node *left, ir_node *right, ir_mode *mod
int old_wrap_on_overflow = tarval_get_wrap_on_overflow();
tarval_set_wrap_on_overflow(false);
if (tarval_sub(lmin, rmax, NULL) == tarval_bad) {
if (tarval_sub(lmin, rmax) == tarval_bad) {
result = can_carry;
if (tarval_sub(lmax, rmin, NULL) == tarval_bad) {
if (tarval_sub(lmax, rmin) == tarval_bad) {
result = must_carry;
}
}
......
......@@ -3428,7 +3428,7 @@ static void find_const_transform(x86_condition_code_t cc,
res->steps[step].transform = SETCC_TR_OR;
} else {
/* Normalize f to zero. */
ir_tarval *t_sub = tarval_sub(t, f, NULL);
ir_tarval *t_sub = tarval_sub(t, f);
t = t_sub;
res->steps[step].transform = SETCC_TR_ADD;
......@@ -3442,7 +3442,7 @@ static void find_const_transform(x86_condition_code_t cc,
res->steps[step].val = get_tarval_long(f);
++step;
f = tarval_sub(f, f, NULL);
f = tarval_sub(f, f);
assert(tarval_is_null(f));
}
......
......@@ -598,7 +598,7 @@ static int tv_ld2(ir_tarval *tv, int bits)
#define SHL(a, b) tarval_shl_unsigned(a, b)
#define SHR(a, b) tarval_shr_unsigned(a, b)
#define ADD(a, b) tarval_add(a, b)
#define SUB(a, b) tarval_sub(a, b, NULL)
#define SUB(a, b) tarval_sub(a, b)
#define MUL(a, b) tarval_mul(a, b)
#define DIV(a, b) tarval_div(a, b)
#define MOD(a, b) tarval_mod(a, b)
......
......@@ -132,22 +132,16 @@ static bool check_mode_same_input(const ir_node *n, int input,
return true;
}
static bool check_mode_same_size_input(const ir_node *n, int input,
const char *inputname)
static bool check_mode_ptrdiff_input(const ir_node *n, int input,
const char *inputname)
{
ir_mode *mode = get_irn_mode(n);
unsigned mode_size = get_mode_size_bits(mode);
ir_node *in = get_irn_n(n, input);
ir_mode *in_mode = get_irn_mode(in);
unsigned in_mode_size = get_mode_size_bits(in_mode);
if (mode_size != in_mode_size) {
char num[16];
if (inputname == NULL) {
snprintf(num, sizeof(num), "input %d", input);
inputname = num;
}
warn(n, "mode size of input '%s' different from output mode size",
inputname);
ir_mode *expected = get_reference_offset_mode(in_mode);
ir_mode *mode = get_irn_mode(n);
if (mode != expected) {
warn(n, "Sub with mode %+F at input %s expected mode %+F but has %+F",
in_mode, inputname, expected, mode);
return false;
}
return true;
......@@ -683,8 +677,8 @@ static int verify_node_Sub(const ir_node *n)
if (mode_is_reference(mode_left)) {
fine &= check_input_func(n, n_Sub_left, "left", mode_is_reference, "reference");
fine &= check_input_func(n, n_Sub_right, "right", mode_is_reference, "reference");
fine &= check_mode_same_size_input(n, n_Sub_left, "left");
fine &= check_mode_same_size_input(n, n_Sub_right, "right");
fine &= check_mode_ptrdiff_input(n, n_Sub_left, "left");
fine &= check_mode_ptrdiff_input(n, n_Sub_right, "right");
} else {
fine &= check_mode_same_input(n, n_Sub_left, "left");
fine &= check_mode_same_input(n, n_Sub_right, "right");
......
......@@ -675,7 +675,7 @@ static ir_node *eval_strcmp(ir_graph *irg, ir_entity *left, ir_entity *right,
ir_mode *const res_mode = get_type_mode(res_tp);
ir_tarval *const res_l = tarval_convert_to(tv_l, res_mode);
ir_tarval *const res_r = tarval_convert_to(tv_r, res_mode);
ir_tarval *const tv = tarval_sub(res_l, res_r, res_mode);
ir_tarval *const tv = tarval_sub(res_l, res_r);
return new_r_Const(irg, tv);
}
......
......@@ -148,7 +148,7 @@ static void normalize_table(ir_node *switchn, ir_mode *new_mode,
ir_tarval *min = entry->min;
min = tarval_convert_to(min, new_mode);
if (delta != NULL)
min = tarval_sub(min, delta, NULL);
min = tarval_sub(min, delta);
if (entry->min == entry->max) {
entry->min = min;
......@@ -157,7 +157,7 @@ static void normalize_table(ir_node *switchn, ir_mode *new_mode,
ir_tarval *max = entry->max;
max = tarval_convert_to(max, new_mode);
if (delta != NULL)
max = tarval_sub(max, delta, NULL);
max = tarval_sub(max, delta);
entry->min = min;
entry->max = max;
}
......@@ -245,7 +245,7 @@ static bool normalize_switch(switch_info_t *info, ir_mode *selector_mode)
dbg_info *dbgi = get_irn_dbg_info(switchn);
selector = new_rd_Sub(dbgi, block, selector, min_const, mode);
info->switch_max = tarval_sub(info->switch_max, min, mode);
info->switch_max = tarval_sub(info->switch_max, min);
info->switch_min = get_mode_null(mode);
delta = min;
}
......@@ -285,7 +285,7 @@ static ir_node *create_case_cond(const ir_switch_table_entry *entry,
if (entry->min == entry->max) {
cmp = new_rd_Cmp(dbgi, block, selector, minconst, ir_relation_equal);
} else {
ir_tarval *adjusted_max = tarval_sub(entry->max, entry->min, NULL);
ir_tarval *adjusted_max = tarval_sub(entry->max, entry->min);
ir_node *sub = new_rd_Sub(dbgi, block, selector, minconst,
get_tarval_mode(adjusted_max));
ir_node *maxconst = new_r_Const(irg, adjusted_max);
......@@ -404,12 +404,12 @@ static void find_switch_nodes(ir_node *block, void *ctx)
* We do an if-cascade if there are too many spare numbers.
*/
ir_mode *selector_mode = get_irn_mode(get_Switch_selector(switchn));
ir_tarval *spare = tarval_sub(info.switch_max, info.switch_min, selector_mode);
ir_tarval *spare = tarval_sub(info.switch_max, info.switch_min);
ir_mode *mode = find_unsigned_mode(selector_mode);
spare = tarval_convert_to(spare, mode);
ir_tarval *num_cases_minus_one
= new_tarval_from_long(info.num_cases-1, mode);
spare = tarval_sub(spare, num_cases_minus_one, mode);
spare = tarval_sub(spare, num_cases_minus_one);
ir_tarval *spare_size = new_tarval_from_long(env->spare_size, mode);
bool lower_switch = info.num_cases <= env->small_switch
|| (tarval_cmp(spare, spare_size) & ir_relation_greater_equal);
......
......@@ -173,7 +173,7 @@ static ir_node *bool_and(cond_pair* const cpair, ir_node *dst_block)
(rel_hi == ir_relation_equal || rel_hi == ir_relation_greater_equal || rel_hi == ir_relation_greater)) {
/* x >=|>|!= lo && x ==|>=|> hi ==> x ==|>=|> hi */
return cmp_hi;
} else if (tarval_is_one(tarval_sub(tv_hi, tv_lo, NULL))) { /* lo + 1 == hi */
} else if (tarval_is_one(tarval_sub(tv_hi, tv_lo))) { /* lo + 1 == hi */
if (rel_lo == ir_relation_greater_equal && rel_hi == ir_relation_less) {
/* x >= c && x < c + 1 ==> x == c */
return make_Cmp(dst_block, cmp_lo, ir_relation_equal);
......@@ -228,7 +228,7 @@ static ir_node *bool_and(cond_pair* const cpair, ir_node *dst_block)
}
c = new_r_Const(irg, tv_lo);
sub = new_r_Sub(block, x, c, mode);
subc = new_r_Const(irg, tarval_sub(tv_hi, tv_lo, NULL));
subc = new_r_Const(irg, tarval_sub(tv_hi, tv_lo));
cmp = new_r_Cmp(block, sub, subc, rel_hi);
return cmp;
}
......@@ -299,7 +299,7 @@ static ir_node *bool_or(cond_pair *const cpair, ir_node *dst_block)
(rel_hi == ir_relation_equal || rel_hi == ir_relation_greater_equal || rel_hi == ir_relation_greater)) {
/* x >=|>|!= lo || x ==|>=|> hi ==> x >=|>|!= lo */
return cmp_lo;
} else if (tarval_is_one(tarval_sub(tv_hi, tv_lo, NULL))) { /* lo + 1 == hi */
} else if (tarval_is_one(tarval_sub(tv_hi, tv_lo))) { /* lo + 1 == hi */
if (rel_lo == ir_relation_less && rel_hi == ir_relation_greater_equal) {
/* x < c || x >= c + 1 ==> x != c */
return make_Cmp(dst_block, cmp_lo, ir_relation_less_greater);
......@@ -354,7 +354,7 @@ static ir_node *bool_or(cond_pair *const cpair, ir_node *dst_block)
}
c = new_r_Const(irg, tv_lo);
sub = new_r_Sub(block, x, c, mode);
subc = new_r_Const(irg, tarval_sub(tv_hi, tv_lo, NULL));
subc = new_r_Const(irg, tarval_sub(tv_hi, tv_lo));
cmp = new_r_Cmp(block, sub, subc, rel_hi);
return cmp;
}
......
......@@ -2026,7 +2026,7 @@ static void compute_Sub(node_t *node)
node->type.tv = tarval_bottom;
} else if (is_con(a) && is_con(b)) {
if (is_tarval(a.tv) && is_tarval(b.tv)) {
node->type.tv = tarval_sub(a.tv, b.tv, get_irn_mode(sub));
node->type.tv = tarval_sub(a.tv, b.tv);
} else if (is_tarval(b.tv) && tarval_is_null(b.tv)) {
node->type = a;
} else {
......
......@@ -340,7 +340,7 @@ static ir_tarval *computed_value_Sub(const ir_node *n)
ir_tarval *ta = value_of(a);
ir_tarval *tb = value_of(b);
if (ta != tarval_unknown && tb != tarval_unknown)
return tarval_sub(ta, tb, mode);
return tarval_sub(ta, tb);
return tarval_unknown;
}
......@@ -1719,31 +1719,8 @@ static int is_const_Mux(ir_node *n)
is_Const(get_Mux_true(n));
}
typedef ir_tarval *(*tarval_sub_type)(ir_tarval *a, ir_tarval *b, ir_mode *mode);
typedef ir_tarval *(*tarval_binop_type)(ir_tarval *a, ir_tarval *b);
/**
* in reality eval_func should be tarval (*eval_func)() but incomplete
* declarations are bad style and generate noisy warnings
*/
typedef void (*eval_func)(void);
/**
* Wrapper for the tarval binop evaluation, tarval_sub has one more parameter.
*/
static ir_tarval *do_eval(eval_func eval, ir_tarval *a, ir_tarval *b, ir_mode *mode)
{
if (eval == (eval_func) tarval_sub) {
tarval_sub_type func = (tarval_sub_type)eval;
return func(a, b, mode);
} else {
tarval_binop_type func = (tarval_binop_type)eval;
return func(a, b);
}
}
/**
* Apply an evaluator on a binop with a constant operators (and one Phi).
*
......@@ -1755,14 +1732,14 @@ static ir_tarval *do_eval(eval_func eval, ir_tarval *a, ir_tarval *b, ir_mode *m
*
* @return a new Phi node if the conversion was successful, NULL else
*/
static ir_node *apply_binop_on_phi(ir_node *phi, ir_tarval *other, eval_func eval, ir_mode *mode, bool left)
static ir_node *apply_binop_on_phi(ir_node *phi, ir_tarval *other, tarval_binop_type eval, ir_mode *mode, bool left)
{
int n = get_irn_arity(phi);
ir_tarval **tvs = ALLOCAN(ir_tarval*, n);
if (left) {
foreach_irn_in(phi, i, pred) {
ir_tarval *tv = get_Const_tarval(pred);
ir_tarval *evaluated = do_eval(eval, other, tv, mode);
ir_tarval *evaluated = eval(other, tv);
if (!tarval_is_constant(evaluated)) {
/* folding failed, abort */
......@@ -1773,7 +1750,7 @@ static ir_node *apply_binop_on_phi(ir_node *phi, ir_tarval *other, eval_func eva
} else {
foreach_irn_in(phi, i, pred) {
ir_tarval *tv = get_Const_tarval(pred);
ir_tarval *evaluated = do_eval(eval, tv, other, mode);
ir_tarval *evaluated = eval(tv, other);
if (!tarval_is_constant(evaluated)) {
/* folding failed, abort */
......@@ -1801,7 +1778,7 @@ static ir_node *apply_binop_on_phi(ir_node *phi, ir_tarval *other, eval_func eva
*
* @return a new Phi node if the conversion was successful, NULL else
*/
static ir_node *apply_binop_on_2_phis(ir_node *a, ir_node *b, eval_func eval, ir_mode *mode)
static ir_node *apply_binop_on_2_phis(ir_node *a, ir_node *b, tarval_binop_type eval, ir_mode *mode)
{
if (get_nodes_block(a) != get_nodes_block(b))
return NULL;
......@@ -1813,7 +1790,7 @@ static ir_node *apply_binop_on_2_phis(ir_node *a, ir_node *b, eval_func eval, ir
ir_tarval *tv_l = get_Const_tarval(pred_a);
const ir_node *pred_b = get_irn_n(b, i);
ir_tarval *tv_r = get_Const_tarval(pred_b);
ir_tarval *tv = do_eval(eval, tv_l, tv_r, mode);
ir_tarval *tv = eval(tv_l, tv_r);
if (!tarval_is_constant(tv)) {
/* folding failed, bad */
......@@ -1903,7 +1880,7 @@ static ir_node *apply_conv_on_phi(ir_node *phi, ir_mode *mode)
*
* @return a new Mux node if the conversion was successful, NULL else
*/
static ir_node *apply_binop_on_mux(ir_node *mux, ir_tarval *other, eval_func eval, ir_mode *mode, bool left)
static ir_node *apply_binop_on_mux(ir_node *mux, ir_tarval *other, tarval_binop_type eval, ir_mode *mode, bool left)
{
if (!only_one_user(mux)) {
return NULL;
......@@ -1914,11 +1891,11 @@ static ir_node *apply_binop_on_mux(ir_node *mux, ir_tarval *other, eval_func eva
ir_tarval *new_true, *new_false;
if (left) {
new_true = do_eval(eval, other, true_val, mode);
new_false = do_eval(eval, other, false_val, mode);
new_true = eval(other, true_val);
new_false = eval(other, false_val);
} else {
new_true = do_eval(eval, true_val, other, mode);
new_false = do_eval(eval, false_val, other, mode);
new_true = eval(true_val, other);
new_false = eval(false_val, other);
}
if (!tarval_is_constant(new_true) || !tarval_is_constant(new_false)) {
......@@ -1943,7 +1920,7 @@ static ir_node *apply_binop_on_mux(ir_node *mux, ir_tarval *other, eval_func eva
*
* @return a new Mux node if the conversion was successful, NULL else
*/
static ir_node *apply_binop_on_2_muxs(ir_node *a, ir_node *b, eval_func eval, ir_mode *mode)
static ir_node *apply_binop_on_2_muxs(ir_node *a, ir_node *b, tarval_binop_type eval, ir_mode *mode)
{
if (!only_one_user(a) || !only_one_user(b)) {
return NULL;
......@@ -1964,8 +1941,8 @@ static ir_node *apply_binop_on_2_muxs(ir_node *a, ir_node *b, eval_func eval, ir
ir_tarval *true_a = get_Const_tarval(get_Mux_true(a));
ir_tarval *true_b = get_Const_tarval(get_Mux_true(b));
ir_tarval *new_false = do_eval(eval, false_a, false_b, mode);
ir_tarval *new_true = do_eval(eval, true_a, true_b, mode);
ir_tarval *new_false = eval(false_a, false_b);
ir_tarval *new_true = eval(true_a, true_b);
if (!tarval_is_constant(new_true) || !tarval_is_constant(new_false)) {
return NULL;
......@@ -2556,7 +2533,7 @@ static ir_node *transform_node_Or_(ir_node *n)
ir_tarval *const one = get_mode_one(mode);
/* Create mask for rightmost may-1-bit and the trailing 0's. */
mask = tarval_eor(z, tarval_sub(z, one, NULL));
mask = tarval_eor(z, tarval_sub(z, one));
} else {
mask = get_mode_one(mode);
}
......@@ -2674,7 +2651,7 @@ static ir_node *transform_node_Or_(ir_node *n)
}
ir_node *c;
HANDLE_BINOP_CHOICE((eval_func) tarval_or, a, b, c, mode);
HANDLE_BINOP_CHOICE(tarval_or, a, b, c, mode);
n = transform_bitop_chain(n);
if (n != oldn)
......@@ -2734,7 +2711,7 @@ static ir_node *transform_node_Eor_(ir_node *n)
}
ir_node *c;
HANDLE_BINOP_CHOICE((eval_func) tarval_eor, a, b, c, mode);
HANDLE_BINOP_CHOICE(tarval_eor, a, b, c, mode);
/* normalize not nodes... ~a ^ b <=> a ^ ~b */
if (is_Not(a) && only_one_user(a) &&
......@@ -2781,7 +2758,7 @@ static ir_node *transform_node_Eor_(ir_node *n)
ir_node *block = get_nodes_block(n);
ir_node *aa = get_Add_left(a);
ir_tarval *tab = get_Const_tarval(ab);
ir_tarval *tc = tarval_sub(tb, tab, NULL);
ir_tarval *tc = tarval_sub(tb, tab);
ir_node *c = new_rd_Const(dbgi, irg, tc);
return new_rd_Sub(dbgi, block, c, aa, mode);
}
......@@ -2794,7 +2771,7 @@ static ir_node *transform_node_Eor_(ir_node *n)
ir_node *block = get_nodes_block(n);
ir_node *ab = get_Sub_right(a);
ir_tarval *taa = get_Const_tarval(aa);
ir_tarval *tc = tarval_sub(tb, taa, NULL);
ir_tarval *tc = tarval_sub(tb, taa);
ir_node *c = new_rd_Const(dbgi, irg, tc);
return new_rd_Add(dbgi, block, ab, c, mode);
}
......@@ -3044,7 +3021,7 @@ static ir_node *transform_node_Add(ir_node *n)
}
ir_node *c;
HANDLE_BINOP_CHOICE((eval_func) tarval_add, a, b, c, mode);
HANDLE_BINOP_CHOICE(tarval_add, a, b, c, mode);
/* these optimizations are imprecise for floating-point ops */
if (mode_is_float(mode) && !ir_imprecise_float_transforms_allowed())
......@@ -3094,7 +3071,7 @@ static ir_node *transform_node_Add(ir_node *n)
if (is_Const(b)) {
ir_tarval *const tv = get_Const_tarval(b);
ir_tarval *const one = get_mode_one(mode);
ir_tarval *const add = tarval_sub(tv, one, NULL);
ir_tarval *const add = tarval_sub(tv, one);
if (tarval_is_constant(add)) {
/* ~x + C = (C - 1) - x */
......@@ -3248,7 +3225,7 @@ static ir_node *transform_node_Sub(ir_node *n)
}
ir_node *c;
HANDLE_BINOP_CHOICE((eval_func) tarval_sub, a, b, c, mode);
HANDLE_BINOP_CHOICE(tarval_sub, a, b, c, mode);
/* these optimizations are imprecise for floating-point ops */
if (mode_is_float(mode) && !ir_imprecise_float_transforms_allowed())
......@@ -3273,7 +3250,7 @@ static ir_node *transform_node_Sub(ir_node *n)
if (tarval_is_constant(tr)) {
ir_tarval *ta = get_Const_tarval(a);
ir_tarval *tv = tarval_sub(ta, tr, NULL);
ir_tarval *tv = tarval_sub(ta, tr);
if (tarval_is_constant(tv)) {
/* C1 - (x + C2) = (C1 - C2) - x*/
......@@ -3650,7 +3627,7 @@ static ir_node *transform_node_Mul(ir_node *n)
ir_node *a = get_Mul_left(n);
ir_node *b = get_Mul_right(n);
ir_node *c;
HANDLE_BINOP_CHOICE((eval_func) tarval_mul, a, b, c, mode);
HANDLE_BINOP_CHOICE(tarval_mul, a, b, c, mode);
ir_mode_arithmetic arith = get_mode_arithmetic(mode);
if (is_Const(b)) {
......@@ -3840,21 +3817,21 @@ static ir_node *transform_node_Div(ir_node *n)
if (mode_is_int(mode)) {
if (is_Const(b) && is_const_Phi(a)) {
/* check for Div(Phi, Const) */
value = apply_binop_on_phi(a, get_Const_tarval(b), (eval_func) tarval_div, mode, 0);
value = apply_binop_on_phi(a, get_Const_tarval(b), tarval_div, mode, 0);
if (value) {
DBG_OPT_ALGSIM0(n, value);
goto make_tuple;
}
} else if (is_Const(a) && is_const_Phi(b)) {
/* check for Div(Const, Phi) */
value = apply_binop_on_phi(b, get_Const_tarval(a), (eval_func) tarval_div, mode, 1);
value = apply_binop_on_phi(b, get_Const_tarval(a), tarval_div, mode, 1);
if (value) {
DBG_OPT_ALGSIM0(n, value);
goto make_tuple;
}
} else if (is_const_Phi(a) && is_const_Phi(b)) {
/* check for Div(Phi, Phi) */
value = apply_binop_on_2_phis(a, b, (eval_func) tarval_div, mode);
value = apply_binop_on_2_phis(a, b, tarval_div, mode);
if (value) {
DBG_OPT_ALGSIM0(n, value);
goto make_tuple;
......@@ -3944,21 +3921,21 @@ static ir_node *transform_node_Mod(ir_node *n)
if (is_Const(b) && is_const_Phi(a)) {
/* check for Div(Phi, Const) */
value = apply_binop_on_phi(a, get_Const_tarval(b), (eval_func) tarval_mod, mode, 0);
value = apply_binop_on_phi(a, get_Const_tarval(b), tarval_mod, mode, 0);
if (value) {
DBG_OPT_ALGSIM0(n, value);
goto make_tuple;
}
} else if (is_Const(a) && is_const_Phi(b)) {
/* check for Div(Const, Phi) */
value = apply_binop_on_phi(b, get_Const_tarval(a), (eval_func) tarval_mod, mode, 1);
value = apply_binop_on_phi(b, get_Const_tarval(a), tarval_mod, mode, 1);
if (value) {
DBG_OPT_ALGSIM0(n, value);
goto make_tuple;
}
} else if (is_const_Phi(a) && is_const_Phi(b)) {
/* check for Div(Phi, Phi) */
value = apply_binop_on_2_phis(a, b, (eval_func) tarval_mod, mode);
value = apply_binop_on_2_phis(a, b, tarval_mod, mode);
if (value) {
DBG_OPT_ALGSIM0(n, value);
goto make_tuple;
......@@ -4301,7 +4278,7 @@ static ir_node *transform_node_And(ir_node *n)
ir_node *c;
ir_mode *mode = get_irn_mode(n);
HANDLE_BINOP_CHOICE((eval_func) tarval_and, a, b, c, mode);
HANDLE_BINOP_CHOICE(tarval_and, a, b, c, mode);
if (is_Or(a) || is_Or_Eor_Add(a)) {
ir_node *or_left = get_binop_left(a);
......@@ -4408,7 +4385,7 @@ absorb:;
ir_tarval *const one = get_mode_one(mode);
/* Create mask for rightmost may-1-bit and the trailing 0's. */
mask = tarval_eor(z, tarval_sub(z, one, NULL));
mask = tarval_eor(z, tarval_sub(z, one));
} else {
mask = get_mode_one(mode);
}
......@@ -5098,7 +5075,7 @@ cmp_x_eq_0:
if (tarval_is_null(tarval_and(tarval_or(leq, req), min))) {
ir_tarval *const c = get_Const_tarval(lr);
ir_tarval *const one = get_mode_one(mode);
ir_tarval *const mask = tarval_sub(tarval_shl(one, c), one, NULL);
ir_tarval *const mask = tarval_sub(tarval_shl(one, c), one);
ir_tarval *const lmask = tarval_and(leq, mask);
ir_tarval *const rmask = tarval_and(req, mask);
if (tarval_is_null(tarval_or(lmask, rmask)) &&
......@@ -5169,7 +5146,7 @@ cmp_x_eq_0:
ir_node *blk = get_nodes_block(op);
ir_mode *mode = get_irn_mode(v);
tv = tarval_sub(tv, get_mode_one(mode), NULL);
tv = tarval_sub(tv, get_mode_one(mode));
left = new_rd_And(get_irn_dbg_info(op), blk, v, new_r_Const(irg, tv), mode);
changed = true;
DBG_OPT_ALGSIM0(n, n);
......@@ -5387,14 +5364,14 @@ cmp_x_eq_0:
* which converges in O(2**n). */
ir_tarval *const one = get_mode_one(mode);
ir_tarval *const hibit = tarval_shl_unsigned(one, hi);
ir_tarval *const mask = tarval_sub(hibit, one, NULL);
tv = tarval_or(tarval_andnot(tarval_sub(tv, hibit, NULL), mask), tarval_and(bl->z, mask));
ir_tarval *const mask = tarval_sub(hibit, one);
tv = tarval_or(tarval_andnot(tarval_sub(tv, hibit), mask), tarval_and(bl->z, mask));
goto reduced_tv;
}
}
/* c > 0 : a < c ==> a <= (c - 1) a >= c ==> a > (c - 1) */
tv = tarval_sub(tv, get_mode_one(mode), NULL);
tv = tarval_sub(tv, get_mode_one(mode));
goto reduced_tv;
} else if ((relation == ir_relation_greater || relation == ir_relation_less_equal) &&
tarval_cmp(tv, get_mode_null(mode)) == ir_relation_less) {
......@@ -5412,7 +5389,7 @@ cmp_x_eq_0:
* which converges in O(2**n). */
ir_tarval *const one = get_mode_one(mode);
ir_tarval *const hibit = tarval_shl_unsigned(one, hi);
ir_tarval *const mask = tarval_sub(hibit, one, NULL);
ir_tarval *const mask = tarval_sub(hibit, one);
tv = tarval_or(tarval_andnot(tarval_add(tv, hibit), mask), tarval_and(bl->o, mask));