softfloat: Implement float128_to_uint32
PATCH 1/1 softfloat: Implement float128_to_uint32
Handling it just like float128_to_uint32_round_to_zero, that hopefully is free of bugs :)
Documentation basically copied from float128_to_uint64
--- fpu/softfloat.c | 29 +++++++++++++++++++++++++++++ include/fpu/softfloat.h | 1 + 2 files changed, 30 insertions(+)
fpu/softfloat.c +29 -0
@@ -6792,6 +6792,35 @@ uint32_t float128_to_uint32_round_to_zero(float128 a, float_status *status)return res; } +/*---------------------------------------------------------------------------- +| Returns the result of converting the quadruple-precision floating-point value +| `a' to the 32-bit unsigned integer format. The conversion is +| performed according to the IEC/IEEE Standard for Binary Floating-Point +| Arithmetic---which means in particular that the conversion is rounded +| according to the current rounding mode. If `a' is a NaN, the largest +| positive integer is returned. If the conversion overflows, the +| largest unsigned integer is returned. If 'a' is negative, the value is +| rounded and zero is returned; negative values that do not round to zero +| will raise the inexact exception. +*----------------------------------------------------------------------------*/ + +uint32_t float128_to_uint32 (float128 a,float_status *status) +{ +uint64_t v; +uint32_t res; +int old_exc_flags =get_float_exception_flags (status); + + v =float128_to_uint64 (a, status); +if (v >0xffffffff ) { + res =0xffffffff ; + }else { +return v; + } +set_float_exception_flags (old_exc_flags, status); +float_raise (float_flag_invalid, status); +return res; +} +/*---------------------------------------------------------------------------- | Returns the result of converting the quadruple-precision floating-point | value `a' to the single-precision floating-point format. The conversion
include/fpu/softfloat.h +1 -0
@@ -878,6 +878,7 @@ int64_t float128_to_int64(float128, float_status *status);int64_t float128_to_int64_round_to_zero (float128 ,float_status *status);uint64_t float128_to_uint64 (float128 ,float_status *status);uint64_t float128_to_uint64_round_to_zero (float128 ,float_status *status); +uint32_t float128_to_uint32 (float128 ,float_status *status);uint32_t float128_to_uint32_round_to_zero (float128 ,float_status *status);float32 float128_to_float32 (float128 ,float_status *status);float64 float128_to_float64 (float128 ,float_status *status);
Signature · 1 line
2.17.2
Quoted 10 lines · David Hildenbrand
Handling it just like
float128_to_uint32_round_to_zero, that hopefully is free of bugs :)Documentation basically copied from
float128_to_uint64Signed-off-by David Hildenbrand <[email protected]>--- fpu/softfloat.c | 29 +++++++++++++++++++++++++++++ include/fpu/softfloat.h | 1 + 2 files changed, 30 insertions(+)
r~
Alex Bennée
AppliedQuoted 4 lines · David Hildenbrand
Handling it just like
float128_to_uint32_round_to_zero, that hopefully is free of bugs :)Documentation basically copied from
float128_to_uint64
Queued to fpu/next, thanks.
BTW to test:
tests/fp: add wrapping for f128_to_ui32
Needed to test: softfloat: add float128_is_{normal,denormal}
2 files changed, 3 insertions(+), 1 deletion(-)
tests/fp/fp-test.c | 3 ++-tests/fp/wrap.inc.c | 1 +
modified tests/fp/fp-test.c
@@ -622,7 +622,8 @@ static void do_testfloat(int op, int rmode, bool exact)
test_ab_extF80_z_bool(true_ab_extF80M_z_bool, subj_ab_extF80M_z_bool);
break;
case F128_TO_UI32:
- not_implemented();
+ test_a_f128_z_ui32_rx(slow_f128M_to_ui32, qemu_f128M_to_ui32, rmode,
+ exact);
break;
case F128_TO_UI64:
test_a_f128_z_ui64_rx(slow_f128M_to_ui64, qemu_f128M_to_ui64, rmode,modified tests/fp/wrap.inc.c
@@ -367,6 +367,7 @@ WRAP_80_TO_INT_MINMAG(qemu_extF80M_to_i64_r_minMag,
WRAP_128_TO_INT(qemu_f128M_to_i32, float128_to_int32, int_fast32_t) WRAP_128_TO_INT(qemu_f128M_to_i64, float128_to_int64, int_fast64_t)
+WRAP_128_TO_INT(qemu_f128M_to_ui32, float128_to_uint32, uint_fast32_t)
WRAP_128_TO_INT(qemu_f128M_to_ui64, float128_to_uint64, uint_fast64_t) #undef WRAP_128_TO_INT
--
Alex Bennée
Quoted 8 lines · Alex Bennée
Quoted 4 lines · David Hildenbrand
Handling it just like
float128_to_uint32_round_to_zero, that hopefully is free of bugs :)Documentation basically copied from
float128_to_uint64
Quoted 7 lines
Queued to fpu/next, thanks.
BTW to test:
tests/fp: add wrapping for
f128_to_ui32Needed to test: softfloat: add float128_is_{normal,denormal}
Thanks, was that supposed to be "softfloat: Implement float128_to_uint32" ?
Quoted 30 lines
Signed-off-by Alex Bennée <[email protected]>2 files changed, 3 insertions(+), 1 deletion(-)
tests/fp/fp-test.c| 3 ++-tests/fp/wrap.inc.c| 1 +modified
tests/fp/fp-test.c(quoted diff) +2
-1@@ -622,7 +622,8 @@ static void do_testfloat(int op, int rmode, bool exact) test_ab_extF80_z_bool(true_ab_extF80M_z_bool, subj_ab_extF80M_z_bool); break; case F128_TO_UI32: - not_implemented(); + test_a_f128_z_ui32_rx(slow_f128M_to_ui32, qemu_f128M_to_ui32, rmode, + exact); break; case F128_TO_UI64: test_a_f128_z_ui64_rx(slow_f128M_to_ui64, qemu_f128M_to_ui64, rmode,modified
tests/fp/wrap.inc.c(quoted diff) +1
-1@@ -367,6 +367,7 @@ WRAP_80_TO_INT_MINMAG(qemu_extF80M_to_i64_r_minMag, WRAP_128_TO_INT(qemu_f128M_to_i32, float128_to_int32, int_fast32_t) WRAP_128_TO_INT(qemu_f128M_to_i64, float128_to_int64, int_fast64_t) +WRAP_128_TO_INT(qemu_f128M_to_ui32, float128_to_uint32, uint_fast32_t) WRAP_128_TO_INT(qemu_f128M_to_ui64, float128_to_uint64, uint_fast64_t) #undef WRAP_128_TO_INT --Alex Bennée
Signature · 3 lines
Thanks, David / dhildenb
Quoted 11 lines · David Hildenbrand
Quoted 10 lines · Alex Bennée
Quoted 4 lines · David Hildenbrand
Handling it just like
float128_to_uint32_round_to_zero, that hopefully is free of bugs :)Documentation basically copied from
float128_to_uint64Queued to fpu/next, thanks.
Quoted 8 lines
Quoted 5 lines
BTW to test:
tests/fp: add wrapping for
f128_to_ui32Needed to test: softfloat: add float128_is_{normal,denormal}
Thanks, was that supposed to be "softfloat: Implement
float128_to_uint32" ?
Ahh yes... too liberal with my C&P ;-)
Thanks!
Quoted 24 lines
Quoted 24 lines
Signed-off-by Alex Bennée <[email protected]>2 files changed, 3 insertions(+), 1 deletion(-)
tests/fp/fp-test.c| 3 ++-tests/fp/wrap.inc.c| 1 +modified
tests/fp/fp-test.c(quoted diff) +2
-1@@ -622,7 +622,8 @@ static void do_testfloat(int op, int rmode, bool exact) test_ab_extF80_z_bool(true_ab_extF80M_z_bool, subj_ab_extF80M_z_bool); break; case F128_TO_UI32: - not_implemented(); + test_a_f128_z_ui32_rx(slow_f128M_to_ui32, qemu_f128M_to_ui32, rmode, + exact); break; case F128_TO_UI64: test_a_f128_z_ui64_rx(slow_f128M_to_ui64, qemu_f128M_to_ui64, rmode,modified
tests/fp/wrap.inc.c(quoted diff) +0
-0@@ -367,6 +367,7 @@ WRAP_80_TO_INT_MINMAG(qemu_extF80M_to_i64_r_minMag, WRAP_128_TO_INT(qemu_f128M_to_i32, float128_to_int32, int_fast32_t) WRAP_128_TO_INT(qemu_f128M_to_i64, float128_to_int64, int_fast64_t)
Quoted 7 lines
Quoted 7 lines
(quoted diff) +1
-1+WRAP_128_TO_INT(qemu_f128M_to_ui32, float128_to_uint32, uint_fast32_t) WRAP_128_TO_INT(qemu_f128M_to_ui64, float128_to_uint64, uint_fast64_t) #undef WRAP_128_TO_INT --Alex Bennée
--
Alex Bennée
Quoted 18 lines · Alex Bennée
Quoted 15 lines · David Hildenbrand
Quoted 14 lines · Alex Bennée
Quoted 4 lines · David Hildenbrand
Handling it just like
float128_to_uint32_round_to_zero, that hopefully is free of bugs :)Documentation basically copied from
float128_to_uint64Queued to fpu/next, thanks.
BTW to test:
tests/fp: add wrapping for
f128_to_ui32
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Needed to test: softfloat: add float128_is_{normal,denormal}
Thanks, was that supposed to be "softfloat: Implement
float128_to_uint32" ?Ahh yes... too liberal with my C&P ;-)
Thanks!
Hi Alex,
any chance we can get my two softfloat + richards float_to_odd patches upstream in the near future? I have quite some patches waiting for these three to be able to get picked up by Conny (and more to be sent by me).
Thanks!
Signature · 3 lines
Thanks, David / dhildenb