Commit c71c24a2 authored by Matthias Braun's avatar Matthias Braun
Browse files

fix unittests for missing get_mode_minus_one, fix bad max initialisation for float modes

parent d41b8b3a
......@@ -509,6 +509,8 @@ void init_mode_values(ir_mode* mode)
mode->nan = get_tarval(buf, buflen, mode);
fc_get_max(desc, buf, true); // min = negative maximum
mode->min = get_tarval(buf, buflen, mode);
fc_get_max(desc, buf, false);
mode->max = get_tarval(buf, buflen, mode);
mode->null = new_tarval_from_double(0.0, mode);
mode->one = new_tarval_from_double(1.0, mode);
break;
......
......@@ -17,6 +17,11 @@ static void test_tv(ir_tarval *tv)
}
}
static ir_tarval *get_mode_minus_one(ir_mode *mode)
{
return tarval_neg(get_mode_one(mode));
}
static void test_mode(ir_mode *mode)
{
test_tv(get_mode_null(mode));
......
......@@ -39,7 +39,7 @@ int main(void)
test_float(0, get_mode_null(mode_F));
test_float(1, get_mode_one(mode_F));
test_float(-1, get_mode_minus_one(mode_F));
test_float(-1, tarval_neg(get_mode_one(mode_F)));
test_float(FLT_MAX, get_mode_max(mode_F));
test_float(-FLT_MAX, get_mode_min(mode_F));
test_float(FLT_EPSILON, NULL);
......@@ -53,7 +53,7 @@ int main(void)
test_double(0, get_mode_null(mode_D));
test_double(1, get_mode_one(mode_D));
test_double(-1, get_mode_minus_one(mode_D));
test_double(-1, tarval_neg(get_mode_one(mode_D)));
test_double(DBL_MAX, get_mode_max(mode_D));
test_double(-DBL_MAX, get_mode_min(mode_D));
test_double(DBL_EPSILON, NULL);
......@@ -77,7 +77,7 @@ int main(void)
test_ldouble(0, get_mode_null(mode_E));
test_ldouble(1, get_mode_one(mode_E));
test_ldouble(-1, get_mode_minus_one(mode_E));
test_ldouble(-1, tarval_neg(get_mode_one(mode_E)));
test_ldouble(LDBL_MAX, get_mode_max(mode_E));
test_ldouble(-LDBL_MAX, get_mode_min(mode_E));
test_ldouble(LDBL_EPSILON, NULL);
......
......@@ -10,7 +10,7 @@ static void check_mode(ir_mode *mode)
{
ir_tarval *zero = get_mode_null(mode);
ir_tarval *one = get_mode_one(mode);
ir_tarval *minus_one = get_mode_minus_one(mode);
ir_tarval *minus_one = tarval_neg(one);
ir_tarval *minus_zero = tarval_neg(zero);
ir_tarval *two = new_tarval_from_str("2", 1, mode);
ir_tarval *half = new_tarval_from_str("0.5", 3, mode);
......@@ -124,7 +124,7 @@ static void check_mode(ir_mode *mode)
ir_tarval *int_zero = get_mode_null(mode_Is);
ir_tarval *int_one = get_mode_one(mode_Is);
ir_tarval *int_minus_one = get_mode_minus_one(mode_Is);
ir_tarval *int_minus_one = get_mode_all_one(mode_Is);
ir_tarval *int_min = get_mode_min(mode_Is);
ir_tarval *int_max = get_mode_max(mode_Is);
assert(tarval_convert_to(zero, mode_Is) == int_zero);
......
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