* [Qemu-devel] [PATCH v1] softfloat: Implement float128_to_uint32
@ 2019-02-06 10:53 David Hildenbrand
2019-02-06 11:03 ` Richard Henderson
2019-02-06 15:12 ` Alex Bennée
0 siblings, 2 replies; 6+ messages in thread
From: David Hildenbrand @ 2019-02-06 10:53 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Peter Maydell, Aurelien Jarno,
Alex Bennée, 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
Signed-off-by: David Hildenbrand <david@redhat.com>
---
fpu/softfloat.c | 29 +++++++++++++++++++++++++++++
include/fpu/softfloat.h | 1 +
2 files changed, 30 insertions(+)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 9132d7a0b0..c69cd6b5d1 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -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
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 3ff5215b81..3ff3fa5224 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -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);
--
2.17.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v1] softfloat: Implement float128_to_uint32
2019-02-06 10:53 [Qemu-devel] [PATCH v1] softfloat: Implement float128_to_uint32 David Hildenbrand
@ 2019-02-06 11:03 ` Richard Henderson
2019-02-06 15:12 ` Alex Bennée
1 sibling, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2019-02-06 11:03 UTC (permalink / raw)
To: David Hildenbrand, qemu-devel
Cc: Peter Maydell, Aurelien Jarno, Alex Bennée
On 2/6/19 10:53 AM, David Hildenbrand wrote:
> Handling it just like float128_to_uint32_round_to_zero, that hopefully
> is free of bugs :)
>
> Documentation basically copied from float128_to_uint64
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> fpu/softfloat.c | 29 +++++++++++++++++++++++++++++
> include/fpu/softfloat.h | 1 +
> 2 files changed, 30 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v1] softfloat: Implement float128_to_uint32
2019-02-06 10:53 [Qemu-devel] [PATCH v1] softfloat: Implement float128_to_uint32 David Hildenbrand
2019-02-06 11:03 ` Richard Henderson
@ 2019-02-06 15:12 ` Alex Bennée
2019-02-06 15:22 ` David Hildenbrand
1 sibling, 1 reply; 6+ messages in thread
From: Alex Bennée @ 2019-02-06 15:12 UTC (permalink / raw)
To: David Hildenbrand
Cc: qemu-devel, Richard Henderson, Peter Maydell, Aurelien Jarno
David Hildenbrand <david@redhat.com> writes:
> 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}
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v1] softfloat: Implement float128_to_uint32
2019-02-06 15:12 ` Alex Bennée
@ 2019-02-06 15:22 ` David Hildenbrand
2019-02-06 15:42 ` Alex Bennée
0 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand @ 2019-02-06 15:22 UTC (permalink / raw)
To: Alex Bennée
Cc: qemu-devel, Richard Henderson, Peter Maydell, Aurelien Jarno
On 06.02.19 16:12, Alex Bennée wrote:
>
> David Hildenbrand <david@redhat.com> writes:
>
>> 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}
Thanks, was that supposed to be "softfloat: Implement float128_to_uint32" ?
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>
> 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
>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v1] softfloat: Implement float128_to_uint32
2019-02-06 15:22 ` David Hildenbrand
@ 2019-02-06 15:42 ` Alex Bennée
2019-02-22 15:29 ` David Hildenbrand
0 siblings, 1 reply; 6+ messages in thread
From: Alex Bennée @ 2019-02-06 15:42 UTC (permalink / raw)
To: David Hildenbrand
Cc: qemu-devel, Richard Henderson, Peter Maydell, Aurelien Jarno
David Hildenbrand <david@redhat.com> writes:
> On 06.02.19 16:12, Alex Bennée wrote:
>>
>> David Hildenbrand <david@redhat.com> writes:
>>
>>> 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}
>
> Thanks, was that supposed to be "softfloat: Implement
> float128_to_uint32" ?
Ahh yes... too liberal with my C&P ;-)
Thanks!
>
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>
>> 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
>>
--
Alex Bennée
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v1] softfloat: Implement float128_to_uint32
2019-02-06 15:42 ` Alex Bennée
@ 2019-02-22 15:29 ` David Hildenbrand
0 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand @ 2019-02-22 15:29 UTC (permalink / raw)
To: Alex Bennée
Cc: qemu-devel, Richard Henderson, Peter Maydell, Aurelien Jarno,
Cornelia Huck
On 06.02.19 16:42, Alex Bennée wrote:
>
> David Hildenbrand <david@redhat.com> writes:
>
>> On 06.02.19 16:12, Alex Bennée wrote:
>>>
>>> David Hildenbrand <david@redhat.com> writes:
>>>
>>>> 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}
>>
>> 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!
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-02-22 15:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06 10:53 [Qemu-devel] [PATCH v1] softfloat: Implement float128_to_uint32 David Hildenbrand
2019-02-06 11:03 ` Richard Henderson
2019-02-06 15:12 ` Alex Bennée
2019-02-06 15:22 ` David Hildenbrand
2019-02-06 15:42 ` Alex Bennée
2019-02-22 15:29 ` David Hildenbrand
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.