All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH 01/19] fpu/softfloat: Merge NO_SIGNALING_NANS definitions
Date: Fri, 11 May 2018 07:44:30 +0100	[thread overview]
Message-ID: <87h8nevghd.fsf@linaro.org> (raw)
In-Reply-To: <20180511004345.26708-2-richard.henderson@linaro.org>


Richard Henderson <richard.henderson@linaro.org> writes:

> Move the ifdef inside the relevant functions instead of
> duplicating the function declarations.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  fpu/softfloat-specialize.h | 100 +++++++++++++++----------------------
>  1 file changed, 40 insertions(+), 60 deletions(-)
>
> diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h
> index a20b440159..8bd553abd2 100644
> --- a/fpu/softfloat-specialize.h
> +++ b/fpu/softfloat-specialize.h
> @@ -233,17 +233,6 @@ typedef struct {
>      uint64_t high, low;
>  } commonNaNT;
>
> -#ifdef NO_SIGNALING_NANS
> -int float16_is_quiet_nan(float16 a_, float_status *status)
> -{
> -    return float16_is_any_nan(a_);
> -}
> -
> -int float16_is_signaling_nan(float16 a_, float_status *status)
> -{
> -    return 0;
> -}
> -#else
>  /*----------------------------------------------------------------------------
>  | Returns 1 if the half-precision floating-point value `a' is a quiet
>  | NaN; otherwise returns 0.
> @@ -251,12 +240,16 @@ int float16_is_signaling_nan(float16 a_, float_status *status)
>
>  int float16_is_quiet_nan(float16 a_, float_status *status)
>  {
> +#ifdef NO_SIGNALING_NANS
> +    return float16_is_any_nan(a_);
> +#else
>      uint16_t a = float16_val(a_);
>      if (status->snan_bit_is_one) {
>          return (((a >> 9) & 0x3F) == 0x3E) && (a & 0x1FF);
>      } else {
>          return ((a & ~0x8000) >= 0x7C80);
>      }
> +#endif
>  }
>
>  /*----------------------------------------------------------------------------
> @@ -266,14 +259,17 @@ int float16_is_quiet_nan(float16 a_, float_status *status)
>
>  int float16_is_signaling_nan(float16 a_, float_status *status)
>  {
> +#ifdef NO_SIGNALING_NANS
> +    return 0;
> +#else
>      uint16_t a = float16_val(a_);
>      if (status->snan_bit_is_one) {
>          return ((a & ~0x8000) >= 0x7C80);
>      } else {
>          return (((a >> 9) & 0x3F) == 0x3E) && (a & 0x1FF);
>      }
> -}
>  #endif
> +}
>
>  /*----------------------------------------------------------------------------
>  | Returns a quiet NaN if the half-precision floating point value `a' is a
> @@ -293,17 +289,6 @@ float16 float16_maybe_silence_nan(float16 a_, float_status *status)
>      return a_;
>  }
>
> -#ifdef NO_SIGNALING_NANS
> -int float32_is_quiet_nan(float32 a_, float_status *status)
> -{
> -    return float32_is_any_nan(a_);
> -}
> -
> -int float32_is_signaling_nan(float32 a_, float_status *status)
> -{
> -    return 0;
> -}
> -#else
>  /*----------------------------------------------------------------------------
>  | Returns 1 if the single-precision floating-point value `a' is a quiet
>  | NaN; otherwise returns 0.
> @@ -311,12 +296,16 @@ int float32_is_signaling_nan(float32 a_, float_status *status)
>
>  int float32_is_quiet_nan(float32 a_, float_status *status)
>  {
> +#ifdef NO_SIGNALING_NANS
> +    return float32_is_any_nan(a_);
> +#else
>      uint32_t a = float32_val(a_);
>      if (status->snan_bit_is_one) {
>          return (((a >> 22) & 0x1FF) == 0x1FE) && (a & 0x003FFFFF);
>      } else {
>          return ((uint32_t)(a << 1) >= 0xFF800000);
>      }
> +#endif
>  }
>
>  /*----------------------------------------------------------------------------
> @@ -326,14 +315,17 @@ int float32_is_quiet_nan(float32 a_, float_status *status)
>
>  int float32_is_signaling_nan(float32 a_, float_status *status)
>  {
> +#ifdef NO_SIGNALING_NANS
> +    return 0;
> +#else
>      uint32_t a = float32_val(a_);
>      if (status->snan_bit_is_one) {
>          return ((uint32_t)(a << 1) >= 0xFF800000);
>      } else {
>          return (((a >> 22) & 0x1FF) == 0x1FE) && (a & 0x003FFFFF);
>      }
> -}
>  #endif
> +}
>
>  /*----------------------------------------------------------------------------
>  | Returns a quiet NaN if the single-precision floating point value `a' is a
> @@ -704,17 +696,6 @@ static float32 propagateFloat32NaN(float32 a, float32 b, float_status *status)
>      }
>  }
>
> -#ifdef NO_SIGNALING_NANS
> -int float64_is_quiet_nan(float64 a_, float_status *status)
> -{
> -    return float64_is_any_nan(a_);
> -}
> -
> -int float64_is_signaling_nan(float64 a_, float_status *status)
> -{
> -    return 0;
> -}
> -#else
>  /*----------------------------------------------------------------------------
>  | Returns 1 if the double-precision floating-point value `a' is a quiet
>  | NaN; otherwise returns 0.
> @@ -722,6 +703,9 @@ int float64_is_signaling_nan(float64 a_, float_status *status)
>
>  int float64_is_quiet_nan(float64 a_, float_status *status)
>  {
> +#ifdef NO_SIGNALING_NANS
> +    return float64_is_any_nan(a_);
> +#else
>      uint64_t a = float64_val(a_);
>      if (status->snan_bit_is_one) {
>          return (((a >> 51) & 0xFFF) == 0xFFE)
> @@ -729,6 +713,7 @@ int float64_is_quiet_nan(float64 a_, float_status *status)
>      } else {
>          return ((a << 1) >= 0xFFF0000000000000ULL);
>      }
> +#endif
>  }
>
>  /*----------------------------------------------------------------------------
> @@ -738,6 +723,9 @@ int float64_is_quiet_nan(float64 a_, float_status *status)
>
>  int float64_is_signaling_nan(float64 a_, float_status *status)
>  {
> +#ifdef NO_SIGNALING_NANS
> +    return 0;
> +#else
>      uint64_t a = float64_val(a_);
>      if (status->snan_bit_is_one) {
>          return ((a << 1) >= 0xFFF0000000000000ULL);
> @@ -745,8 +733,8 @@ int float64_is_signaling_nan(float64 a_, float_status *status)
>          return (((a >> 51) & 0xFFF) == 0xFFE)
>              && (a & LIT64(0x0007FFFFFFFFFFFF));
>      }
> -}
>  #endif
> +}
>
>  /*----------------------------------------------------------------------------
>  | Returns a quiet NaN if the double-precision floating point value `a' is a
> @@ -859,17 +847,6 @@ static float64 propagateFloat64NaN(float64 a, float64 b, float_status *status)
>      }
>  }
>
> -#ifdef NO_SIGNALING_NANS
> -int floatx80_is_quiet_nan(floatx80 a_, float_status *status)
> -{
> -    return floatx80_is_any_nan(a_);
> -}
> -
> -int floatx80_is_signaling_nan(floatx80 a_, float_status *status)
> -{
> -    return 0;
> -}
> -#else
>  /*----------------------------------------------------------------------------
>  | Returns 1 if the extended double-precision floating-point value `a' is a
>  | quiet NaN; otherwise returns 0. This slightly differs from the same
> @@ -878,6 +855,9 @@ int floatx80_is_signaling_nan(floatx80 a_, float_status *status)
>
>  int floatx80_is_quiet_nan(floatx80 a, float_status *status)
>  {
> +#ifdef NO_SIGNALING_NANS
> +    return floatx80_is_any_nan(a);
> +#else
>      if (status->snan_bit_is_one) {
>          uint64_t aLow;
>
> @@ -889,6 +869,7 @@ int floatx80_is_quiet_nan(floatx80 a, float_status *status)
>          return ((a.high & 0x7FFF) == 0x7FFF)
>              && (LIT64(0x8000000000000000) <= ((uint64_t)(a.low << 1)));
>      }
> +#endif
>  }
>
>  /*----------------------------------------------------------------------------
> @@ -899,6 +880,9 @@ int floatx80_is_quiet_nan(floatx80 a, float_status *status)
>
>  int floatx80_is_signaling_nan(floatx80 a, float_status *status)
>  {
> +#ifdef NO_SIGNALING_NANS
> +    return 0;
> +#else
>      if (status->snan_bit_is_one) {
>          return ((a.high & 0x7FFF) == 0x7FFF)
>              && ((a.low << 1) >= 0x8000000000000000ULL);
> @@ -910,8 +894,8 @@ int floatx80_is_signaling_nan(floatx80 a, float_status *status)
>              && (uint64_t)(aLow << 1)
>              && (a.low == aLow);
>      }
> -}
>  #endif
> +}
>
>  /*----------------------------------------------------------------------------
>  | Returns a quiet NaN if the extended double-precision floating point value
> @@ -1020,17 +1004,6 @@ floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status)
>      }
>  }
>
> -#ifdef NO_SIGNALING_NANS
> -int float128_is_quiet_nan(float128 a_, float_status *status)
> -{
> -    return float128_is_any_nan(a_);
> -}
> -
> -int float128_is_signaling_nan(float128 a_, float_status *status)
> -{
> -    return 0;
> -}
> -#else
>  /*----------------------------------------------------------------------------
>  | Returns 1 if the quadruple-precision floating-point value `a' is a quiet
>  | NaN; otherwise returns 0.
> @@ -1038,6 +1011,9 @@ int float128_is_signaling_nan(float128 a_, float_status *status)
>
>  int float128_is_quiet_nan(float128 a, float_status *status)
>  {
> +#ifdef NO_SIGNALING_NANS
> +    return float128_is_any_nan(a);
> +#else
>      if (status->snan_bit_is_one) {
>          return (((a.high >> 47) & 0xFFFF) == 0xFFFE)
>              && (a.low || (a.high & 0x00007FFFFFFFFFFFULL));
> @@ -1045,6 +1021,7 @@ int float128_is_quiet_nan(float128 a, float_status *status)
>          return ((a.high << 1) >= 0xFFFF000000000000ULL)
>              && (a.low || (a.high & 0x0000FFFFFFFFFFFFULL));
>      }
> +#endif
>  }
>
>  /*----------------------------------------------------------------------------
> @@ -1054,6 +1031,9 @@ int float128_is_quiet_nan(float128 a, float_status *status)
>
>  int float128_is_signaling_nan(float128 a, float_status *status)
>  {
> +#ifdef NO_SIGNALING_NANS
> +    return 0;
> +#else
>      if (status->snan_bit_is_one) {
>          return ((a.high << 1) >= 0xFFFF000000000000ULL)
>              && (a.low || (a.high & 0x0000FFFFFFFFFFFFULL));
> @@ -1061,8 +1041,8 @@ int float128_is_signaling_nan(float128 a, float_status *status)
>          return (((a.high >> 47) & 0xFFFF) == 0xFFFE)
>              && (a.low || (a.high & LIT64(0x00007FFFFFFFFFFF)));
>      }
> -}
>  #endif
> +}
>
>  /*----------------------------------------------------------------------------
>  | Returns a quiet NaN if the quadruple-precision floating point value `a' is


--
Alex Bennée

  reply	other threads:[~2018-05-11  6:44 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-11  0:43 [Qemu-devel] [PATCH 00/19] softfloat: Clean up NaN handling Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 01/19] fpu/softfloat: Merge NO_SIGNALING_NANS definitions Richard Henderson
2018-05-11  6:44   ` Alex Bennée [this message]
2018-05-11  0:43 ` [Qemu-devel] [PATCH 02/19] fpu/softfloat: Split floatXX_silence_nan from floatXX_maybe_silence_nan Richard Henderson
2018-05-11  7:47   ` Alex Bennée
2018-05-11 15:06     ` Alex Bennée
2018-05-11 15:16       ` Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 03/19] fpu/softfloat: Move softfloat-specialize.h below FloatParts definition Richard Henderson
2018-05-11  7:48   ` Alex Bennée
2018-05-11  0:43 ` [Qemu-devel] [PATCH 04/19] fpu/softfloat: Canonicalize NaN fraction Richard Henderson
2018-05-11 16:26   ` Alex Bennée
2018-05-11 16:46     ` Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 05/19] fpu/softfloat: Introduce parts_is_snan_frac Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 06/19] fpu/softfloat: Replace float_class_dnan with parts_default_nan Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 07/19] fpu/softfloat: Replace float_class_msnan with parts_silence_nan Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 08/19] target/arm: Use floatX_silence_nan when we have already checked for SNaN Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 09/19] target/arm: Remove floatX_maybe_silence_nan from conversions Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 10/19] target/hppa: " Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 11/19] target/m68k: Use floatX_silence_nan when we have already checked for SNaN Richard Henderson
2018-05-11 10:11   ` Laurent Vivier
2018-05-11  0:43 ` [Qemu-devel] [PATCH 12/19] target/mips: Remove floatX_maybe_silence_nan from conversions Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 13/19] target/riscv: " Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 14/19] target/s390x: " Richard Henderson
2018-05-11  6:47   ` David Hildenbrand
2018-05-11  0:43 ` [Qemu-devel] [PATCH 15/19] fpu/softfloat: Use float*_silence_nan in propagateFloat*NaN Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 16/19] fpu/softfloat: Remove floatX_maybe_silence_nan Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 17/19] fpu/softfloat: Introduce SNAN_BIT_IS_ONE Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 18/19] fpu/softfloat: Pass FloatClass to pickNaN Richard Henderson
2018-05-11  0:43 ` [Qemu-devel] [PATCH 19/19] fpu/softfloat: Pass FloatClass to pickNaNMulAdd Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h8nevghd.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.