[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 03/28] softfloat: Move uint_to_float to softfloat-parts.c.
From: |
Alex Bennée |
Subject: |
Re: [PATCH v2 03/28] softfloat: Move uint_to_float to softfloat-parts.c.inc |
Date: |
Wed, 02 Jun 2021 12:31:51 +0100 |
User-agent: |
mu4e 1.5.13; emacs 28.0.50 |
Richard Henderson <richard.henderson@linaro.org> writes:
> Rename to parts$N_uint_to_float.
> Reimplement uint64_to_float128 with FloatParts128.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> fpu/softfloat.c | 83 ++++++++++++++++-----------------------
> fpu/softfloat-parts.c.inc | 23 +++++++++++
> 2 files changed, 56 insertions(+), 50 deletions(-)
>
> diff --git a/fpu/softfloat.c b/fpu/softfloat.c
> index 6404a2997f..db14bd09aa 100644
> --- a/fpu/softfloat.c
> +++ b/fpu/softfloat.c
> @@ -857,6 +857,14 @@ static void parts128_sint_to_float(FloatParts128 *p,
> int64_t a,
> #define parts_sint_to_float(P, I, Z, S) \
> PARTS_GENERIC_64_128(sint_to_float, P)(P, I, Z, S)
>
> +static void parts64_uint_to_float(FloatParts64 *p, uint64_t a,
> + int scale, float_status *s);
> +static void parts128_uint_to_float(FloatParts128 *p, uint64_t a,
> + int scale, float_status *s);
> +
> +#define parts_uint_to_float(P, I, Z, S) \
> + PARTS_GENERIC_64_128(uint_to_float, P)(P, I, Z, S)
> +
> /*
> * Helper functions for softfloat-parts.c.inc, per-size operations.
> */
> @@ -3102,35 +3110,15 @@ float128 int32_to_float128(int32_t a, float_status
> *status)
> }
>
> /*
> - * Unsigned Integer to float conversions
> - *
> - * Returns the result of converting the unsigned integer `a' to the
> - * floating-point format. The conversion is performed according to the
> - * IEC/IEEE Standard for Binary Floating-Point Arithmetic.
> + * Unsigned Integer to floating-point conversions
> */
>
> -static FloatParts64 uint_to_float(uint64_t a, int scale, float_status
> *status)
> -{
> - FloatParts64 r = { .sign = false };
> - int shift;
> -
> - if (a == 0) {
> - r.cls = float_class_zero;
> - } else {
> - scale = MIN(MAX(scale, -0x10000), 0x10000);
I realise this is translated to:
> +
> +/*
> + * Unsigned Integer to float conversions
> + *
> + * Returns the result of converting the unsigned integer `a' to the
> + * floating-point format. The conversion is performed according to the
> + * IEC/IEEE Standard for Binary Floating-Point Arithmetic.
> + */
> +static void partsN(uint_to_float)(FloatPartsN *p, uint64_t a,
> + int scale, float_status *status)
> +{
> + memset(p, 0, sizeof(*p));
> +
> + if (a == 0) {
> + p->cls = float_class_zero;
> + } else {
> + int shift = clz64(a);
> + scale = MIN(MAX(scale, -0x10000), 0x10000);
here but it does seem weird to have an arbitrary limit here
> + p->cls = float_class_normal;
> + p->exp = DECOMPOSED_BINARY_POINT - shift + scale;
where it's really a limit on fmt->exp_max. Are we just limiting it to
something sane and relying on the eventual repack to detect and overflow
condition?
> + p->frac_hi = a << shift;
> + }
> +}
Otherwise:
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
- Re: [PATCH v2 03/28] softfloat: Move uint_to_float to softfloat-parts.c.inc,
Alex Bennée <=