Commit 2f089f0b authored by Matthias Braun's avatar Matthias Braun
Browse files

remove get_mode_minus_one() there is still get_mode_all_one() for two complement modes

parent be5da877
......@@ -187,18 +187,11 @@ FIRM_API ir_tarval *get_mode_null(const ir_mode *mode);
*/
FIRM_API ir_tarval *get_mode_one(const ir_mode *mode);
/**
* Returns the value Minus One, represented in this mode.
*
* Minus One is defined only for modes allowing
* multiplication with signed values, i.e. signed ints and floats.
*/
FIRM_API ir_tarval *get_mode_minus_one(const ir_mode *mode);
/**
* Returns the value where all bits are One, represented in this mode.
*
* All One is defined only for modes integer, reference and boolean modes
* This represents the value -1 for signed modes with irma_twos_complement.
*/
FIRM_API ir_tarval *get_mode_all_one(const ir_mode *mode);
......
......@@ -254,14 +254,8 @@ FIRM_API int tarval_is_null(const ir_tarval *tv);
FIRM_API int tarval_is_one(const ir_tarval *tv);
/**
* Returns 1 if tv is the "minus one"
*
* @param tv the tarval
*/
FIRM_API int tarval_is_minus_one(const ir_tarval *tv);
/**
* returns non-zero if all bits in the tarval are set
* returns non-zero if all bits in the tarval are set.
* This means the value is -1 for signed modes with irma_twos_complement.
*/
FIRM_API int tarval_is_all_one(const ir_tarval *tv);
......
......@@ -3164,7 +3164,7 @@ static void find_const_transform(x86_condition_code_t cc,
return;
}
if (tarval_is_minus_one(t)) {
if (tarval_is_all_one(t)) {
res->steps[step].transform = SETCC_TR_NEG;
++step;
res->steps[step].transform = SETCC_TR_SET;
......
......@@ -298,13 +298,6 @@ ir_tarval *get_mode_one(const ir_mode *mode)
return mode->one;
}
ir_tarval *get_mode_minus_one(const ir_mode *mode)
{
assert(mode_is_data(mode));
return mode->minus_one;
}
ir_tarval *get_mode_all_one(const ir_mode *mode)
{
assert(mode_is_data(mode) || mode == mode_b);
......
......@@ -2426,11 +2426,11 @@ static ir_node *transform_node_Or_(ir_node *n)
const bitinfo *const ba = get_bitinfo(a);
ir_tarval * mask;
if (ba) {
ir_tarval *const z = ba->z;
ir_tarval *const minus_one = get_mode_minus_one(mode);
ir_tarval *const z = ba->z;
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_add(z, minus_one));
mask = tarval_eor(z, tarval_sub(z, one, mode));
} else {
mask = get_mode_one(mode);
}
......@@ -2787,9 +2787,9 @@ static ir_node *transform_node_Add(ir_node *n)
ir_node *op = get_Not_op(a);
if (is_Const(b)) {
ir_tarval *const tv = get_Const_tarval(b);
ir_tarval *const minus_one = get_mode_minus_one(mode);
ir_tarval *const add = tarval_add(tv, minus_one);
ir_tarval *const tv = get_Const_tarval(b);
ir_tarval *const one = get_mode_one(mode);
ir_tarval *const add = tarval_sub(tv, one, mode);
if (tarval_is_constant(add)) {
/* ~x + C = (C - 1) - x */
......@@ -2906,7 +2906,7 @@ static ir_node *transform_node_Sub(ir_node *n)
if (mode == lmode &&
get_mode_arithmetic(mode) == irma_twos_complement &&
is_Const(a) &&
tarval_is_minus_one(get_Const_tarval(a))) {
tarval_is_all_one(get_Const_tarval(a))) {
/* -1 - x -> ~x */
dbg_info *dbg = get_irn_dbg_info(n);
n = new_rd_Not(dbg, get_nodes_block(n), b, mode);
......@@ -3347,9 +3347,9 @@ static ir_node *transform_node_Mul(ir_node *n)
}
/* x*-1 => -x */
if (tarval_is_minus_one(c1) ||
(get_mode_arithmetic(mode) == irma_twos_complement
&& tarval_is_all_one(c1))) {
if ((get_mode_arithmetic(mode) == irma_twos_complement
&& tarval_is_all_one(c1))
|| (mode_is_float(mode) && tarval_is_minus_one(c1))) {
dbg_info *dbgi = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
return new_rd_Minus(dbgi, block, a, mode);
......@@ -3473,7 +3473,7 @@ static ir_node *transform_node_Div(ir_node *n)
if (mode_is_signed(mode) && is_Const(b)) {
ir_tarval *tv = get_Const_tarval(b);
if (tarval_is_minus_one(tv)) {
if (tarval_is_all_one(tv)) {
/* a / -1 */
value = new_rd_Minus(get_irn_dbg_info(n), get_nodes_block(n), a, mode);
DBG_OPT_CSTEVAL(n, value);
......@@ -3586,7 +3586,7 @@ static ir_node *transform_node_Mod(ir_node *n)
if (mode_is_signed(mode) && is_Const(b)) {
ir_tarval *tv = get_Const_tarval(b);
if (tarval_is_minus_one(tv)) {
if (tarval_is_all_one(tv)) {
/* a % -1 = 0 */
value = new_r_Const_null(irg, mode);
DBG_OPT_CSTEVAL(n, value);
......@@ -3972,11 +3972,11 @@ absorb:;
const bitinfo *const ba = get_bitinfo(a);
ir_tarval * mask;
if (ba) {
ir_tarval *const z = ba->z;
ir_tarval *const minus_one = get_mode_minus_one(mode);
ir_tarval *const z = ba->z;
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_add(z, minus_one));
mask = tarval_eor(z, tarval_sub(z, one, mode));
} else {
mask = get_mode_one(mode);
}
......@@ -4079,7 +4079,7 @@ static ir_node *transform_node_Not(ir_node *n)
ir_graph *irg = get_irn_irg(n);
ir_node *block = get_nodes_block(n);
ir_node *add_l = get_Minus_op(a);
ir_node *add_r = new_rd_Const(dbg, irg, get_mode_minus_one(mode));
ir_node *add_r = new_rd_Const(dbg, irg, get_mode_all_one(mode));
return new_rd_Add(dbg, block, add_l, add_r, mode);
}
if (is_Add(a) || is_Or_Eor_Add(a)) {
......
......@@ -161,7 +161,6 @@ struct ir_mode {
ir_tarval *max; /**< the maximum value that can be expressed */
ir_tarval *null; /**< the value 0 */
ir_tarval *one; /**< the value 1 */
ir_tarval *minus_one; /**< the value -1 */
ir_tarval *all_one; /**< the value ~0 */
ir_tarval *infinity; /**< the infinity value */
ir_tarval *nan; /** the not a number (NaN) value */
......
......@@ -27,6 +27,7 @@
#include "be.h"
#include "util.h"
#include "firmstat_t.h"
#include "tv_t.h"
/** Walker environment. */
struct ir_intrinsics_map {
......@@ -263,7 +264,7 @@ int i_mapper_cbrt(ir_node *call)
return 0;
tv = get_Const_tarval(op);
if (! tarval_is_null(tv) && !tarval_is_one(tv) && !tarval_is_minus_one(tv))
if (!tarval_is_null(tv) && !tarval_is_one(tv) && !tarval_is_minus_one(tv))
return 0;
mem = get_Call_mem(call);
......
......@@ -511,8 +511,6 @@ void init_mode_values(ir_mode* mode)
mode->min = get_tarval(buf, buflen, mode);
mode->null = new_tarval_from_double(0.0, mode);
mode->one = new_tarval_from_double(1.0, mode);
mode->minus_one = mode_is_signed(mode)
? new_tarval_from_double(-1.0, mode) : tarval_bad;
break;
}
......@@ -524,7 +522,6 @@ void init_mode_values(ir_mode* mode)
mode->max = tarval_b_true;
mode->null = tarval_b_false;
mode->one = tarval_b_true;
mode->minus_one = tarval_bad;
break;
case irms_reference:
......@@ -545,12 +542,6 @@ void init_mode_values(ir_mode* mode)
mode->null = get_tarval(buf, buflen, mode);
sc_set_bit_at(buf, 0);
mode->one = get_tarval(buf, buflen, mode);
if (sign) {
sc_neg(buf, buf);
mode->minus_one = get_tarval(buf, buflen, mode);
} else {
mode->minus_one = tarval_bad;
}
break;
}
......@@ -561,7 +552,6 @@ void init_mode_values(ir_mode* mode)
mode->max = tarval_bad;
mode->null = tarval_bad;
mode->one = tarval_bad;
mode->minus_one = tarval_bad;
mode->infinity = tarval_bad;
mode->nan = tarval_bad;
break;
......@@ -596,26 +586,26 @@ int tarval_is_negative(const ir_tarval *a)
int tarval_is_null(const ir_tarval *tv)
{
return tv != tarval_unknown && tv != tarval_bad
&& tv == get_mode_null(get_tarval_mode(tv));
return tv == get_tarval_mode(tv)->null && tv != tarval_bad;
}
int tarval_is_one(const ir_tarval *tv)
{
return tv != tarval_unknown && tv != tarval_bad
&& tv == get_mode_one(get_tarval_mode(tv));
return tv == get_tarval_mode(tv)->one && tv != tarval_bad;
}
int tarval_is_all_one(const ir_tarval *tv)
{
return tv != tarval_unknown && tv != tarval_bad
&& tv == get_mode_all_one(get_tarval_mode(tv));
return tv == get_tarval_mode(tv)->all_one && tv != tarval_bad;
}
int tarval_is_minus_one(const ir_tarval *tv)
bool tarval_is_minus_one(const ir_tarval *tv)
{
return tv != tarval_unknown && tv != tarval_bad
&& tv == get_mode_minus_one(get_tarval_mode(tv));
ir_mode *mode = get_tarval_mode(tv);
assert(mode_is_float(mode));
const fp_value *val = (const fp_value*)tv->value;
return fc_is_negative(val) && fc_zero_mantissa(val)
&& fc_get_exponent(val) == 0 && !fc_is_inf(val) && !fc_is_nan(val);
}
ir_relation tarval_cmp(const ir_tarval *a, const ir_tarval *b)
......
......@@ -125,6 +125,8 @@ uint64_t get_tarval_uint64(const ir_tarval *tv);
bool tarval_is_uint64(const ir_tarval *tv);
bool tarval_is_minus_one(const ir_tarval *tv);
ir_tarval *get_tarval_small(ir_mode *mode);
ir_tarval *get_tarval_epsilon(ir_mode *mode);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment