qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: Leon Alrae <leon.alrae@imgtec.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Aurelien Jarno <aurelien@aurel32.net>,
	Thomas Schwinge <thomas@codesourcery.com>
Subject: Re: [Qemu-devel] [PATCH v2 6/7] softfloat: Add SoftFloat status `nan2008_mode' flag
Date: Thu, 5 Feb 2015 17:00:57 +0000	[thread overview]
Message-ID: <CAFEAcA-T-unNUrRa7EUER4zdZgNk3+aETb0Jbhnf7m-w91UOOA@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.10.1412121932590.19155@tp.orcam.me.uk>

On 12 December 2014 at 19:35, Maciej W. Rozycki <macro@codesourcery.com> wrote:
> Add support for switching between legacy NaN and IEEE 754-2008 NaN modes
> where required, currently for the MIPS target only.  Also handle the
> saving and restoration of the `nan2008_mode' status flag.
>
> Use qNaN bit patterns for the 2008 NaN mode as from revision 5.00 [1][2]
> of the MIPS Architecture, updated from revision 3.50 that used a
> different choice.
>
> References:
>
> [1] "MIPS Architecture For Programmers, Volume I-A: Introduction to the
>     MIPS32 Architecture", MIPS Technologies, Inc., Document Number:
>     MD00082, Revision 5.02, April 30, 2013, Table 5.3 "Value Supplied
>     When a New Quiet NaN Is Created", p. 73
>
> [2] "MIPS Architecture For Programmers, Volume I-A: Introduction to the
>     MIPS64 Architecture", MIPS Technologies, Inc., Document Number:
>     MD00083, Revision 5.01, December 15, 2012, Table 5.3 "Value Supplied
>     When a New Quiet NaN Is Created", p. 73
>
> Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
> Signed-off-by: Maciej W. Rozycki <macro@codesourcery.com>
> ---
> Changes from v1:
>
> - regenerate on top of the SoftFloat relicensing patch set.
>
> qemu-softfloat-nan2008.diff
> Index: qemu-git-trunk/fpu/softfloat-specialize.h
> ===================================================================
> --- qemu-git-trunk.orig/fpu/softfloat-specialize.h      2014-12-11 22:42:41.128934304 +0000
> +++ qemu-git-trunk/fpu/softfloat-specialize.h   2014-12-11 22:43:02.128938514 +0000
> @@ -83,10 +83,16 @@ this code that are retained.
>   * by setting the most significant bit of the mantissa for a signaling NaN?
>   * (The more common choice is to have it be zero for SNaN and one for QNaN.)
>   */
> -#if defined(TARGET_MIPS) || defined(TARGET_SH4) || defined(TARGET_UNICORE32)
> -#define SNAN_BIT_IS_ONE 1
> +#if defined(TARGET_MIPS)
> +/* Has to be decided dynamically.  */
> +#define SNAN_BIT_IS_VARIABLE   1
> +#define SNAN_BIT_IS_ONE        0
> +#elif defined(TARGET_SH4) || defined(TARGET_UNICORE32)
> +#define SNAN_BIT_IS_VARIABLE   0
> +#define SNAN_BIT_IS_ONE        1
>  #else
> -#define SNAN_BIT_IS_ONE 0
> +#define SNAN_BIT_IS_VARIABLE   0
> +#define SNAN_BIT_IS_ONE        0
>  #endif
>
>  #if defined(TARGET_XTENSA)
> @@ -103,6 +109,10 @@ inline float16 float16_default_nan(STATU
>  {
>  #if defined(TARGET_ARM)
>      return const_float16(0x7E00);
> +#elif SNAN_BIT_IS_VARIABLE
> +    return STATUS(nan2008_mode)
> +           ? const_float16(0x7E00)
> +           : const_float16(0x7DFF);
>  #elif SNAN_BIT_IS_ONE
>      return const_float16(0x7DFF);
>  #else

Ah, I see now what the previous patch was in aid of.

(I hadn't realised that the 2008 rev of IEEE754 nailed down
the SNaN/QNaN bit sense. That was always a dumb thing to have
left impdef, so good news I guess.)

Can we get the ifdefs out of these functions entirely, by
something like

#if defined(TARGET_SH4) || etc
#define SNAN_BIT_IS_ONE(status) 1
#elif defined(TARGET_MIPS)
#define SNAN_BIT_IS_ONE(status) (status->nan2008_mode)
#else
#define SNAN_BIT_IS_ONE(status) 0

and then just have all the conversion functions do
   return SNAN_BIT_IS_ONE(status) ? x : y;

(that should also eliminate the need to mark x and y
as unused I think).

NB: you probably want to do that on top of my series
for getting rid of the STATUS macros.

> Index: qemu-git-trunk/include/fpu/softfloat.h
> ===================================================================
> --- qemu-git-trunk.orig/include/fpu/softfloat.h 2014-12-11 22:42:41.128934304 +0000
> +++ qemu-git-trunk/include/fpu/softfloat.h      2014-12-11 22:43:02.128938514 +0000
> @@ -223,6 +223,7 @@ typedef struct float_status {
>      /* should denormalised inputs go to zero and set the input_denormal flag? */
>      flag flush_inputs_to_zero;
>      flag default_nan_mode;

This could use a comment about what the semantics of the new flag are...

> +    flag nan2008_mode;
>  } float_status;
>
> Index: qemu-git-trunk/target-mips/cpu.h
> ===================================================================
> --- qemu-git-trunk.orig/target-mips/cpu.h       2014-12-11 22:42:41.128934304 +0000
> +++ qemu-git-trunk/target-mips/cpu.h    2014-12-11 22:43:02.128938514 +0000
> @@ -615,7 +615,11 @@ void mips_cpu_list (FILE *f, fprintf_fun
>  extern void cpu_wrdsp(uint32_t rs, uint32_t mask_num, CPUMIPSState *env);
>  extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env);
>
> -#define CPU_SAVE_VERSION 7
> +#define CPU_SAVE_VERSION 8
> +/* We preserve compatibility with rev. 7 images.  */
> +#define CPU_SAVE_VERSION_OLDEST_SUPPORTED 7
> +/* Rev. 8 added 2008 NaN support.  */
> +#define CPU_SAVE_VERSION_2008_NAN 8

It would be nicer to split this into two patches: one adding
the new features to softfloat, and one using them in the MIPS
target.

thanks
-- PMM

  reply	other threads:[~2015-02-05 17:01 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-09  1:54 [Qemu-devel] [PATCH 0/7] MIPS: IEEE 754-2008 features support Maciej W. Rozycki
2014-12-09  1:54 ` [Qemu-devel] [PATCH 1/7] softfloat: Fix sNaN handling in FP conversion operations Maciej W. Rozycki
2015-01-29 14:51   ` Leon Alrae
2015-02-05 16:37   ` Peter Maydell
2015-02-05 16:38     ` Peter Maydell
2015-02-06 14:37     ` Maciej W. Rozycki
2015-02-06 14:45       ` Peter Maydell
2015-02-06 19:35         ` Maciej W. Rozycki
2015-02-08 12:12           ` Maciej W. Rozycki
2014-12-09  1:54 ` [Qemu-devel] [PATCH 2/7] softfloat: Simplify `floatx80ToCommonNaN' function Maciej W. Rozycki
2015-01-28 16:15   ` Leon Alrae
2014-12-09  1:55 ` [Qemu-devel] [PATCH 3/7] softfloat: Convert `*_default_nan' variables into inline functions Maciej W. Rozycki
2014-12-12 19:34   ` [Qemu-devel] [PATCH v2 " Maciej W. Rozycki
2015-01-30 14:09     ` Leon Alrae
2015-01-30 16:02       ` Maciej W. Rozycki
2015-01-30 16:55         ` Peter Maydell
2015-01-31 11:56           ` Maciej W. Rozycki
2015-01-31 12:52             ` Peter Maydell
2015-01-31 14:58               ` Maciej W. Rozycki
2015-02-03 15:43         ` Richard Henderson
2014-12-09  1:55 ` [Qemu-devel] [PATCH 4/7] softfloat: Add SoftFloat status parameter to `*_nan' functions Maciej W. Rozycki
2014-12-09  1:55 ` [Qemu-devel] [PATCH 5/7] softfloat: Rework `*_is_*_nan' functions Maciej W. Rozycki
2014-12-12 19:35   ` [Qemu-devel] [PATCH v2 " Maciej W. Rozycki
2015-02-05 16:42     ` Peter Maydell
2014-12-09  1:55 ` [Qemu-devel] [PATCH 6/7] softfloat: Add SoftFloat status `nan2008_mode' flag Maciej W. Rozycki
2014-12-12 19:35   ` [Qemu-devel] [PATCH v2 " Maciej W. Rozycki
2015-02-05 17:00     ` Peter Maydell [this message]
2015-02-05 19:07       ` Maciej W. Rozycki
2014-12-09  1:56 ` [Qemu-devel] [PATCH 7/7] target-mips: Add IEEE 754-2008 features support Maciej W. Rozycki
2015-02-09 17:10   ` Leon Alrae
2015-02-09 20:55     ` Maciej W. Rozycki
2015-02-10 10:44       ` Leon Alrae
2015-02-10 14:30         ` Maciej W. Rozycki
2015-02-10 17:21           ` Leon Alrae
2015-02-17 13:55   ` Maciej W. Rozycki
2014-12-09  9:20 ` [Qemu-devel] [PATCH 0/7] MIPS: " Peter Maydell
2014-12-09 12:28   ` Maciej W. Rozycki
2014-12-09 12:41     ` Peter Maydell
2014-12-09 18:16       ` Maciej W. Rozycki
2015-01-30 11:59 ` Peter Maydell
2015-01-30 13:47   ` Maciej W. Rozycki
     [not found]     ` <54CE9614.2060805@codesourcery.com>
2015-02-03 16:28       ` Thomas Schwinge
2015-02-03 22:30         ` Maciej W. Rozycki

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=CAFEAcA-T-unNUrRa7EUER4zdZgNk3+aETb0Jbhnf7m-w91UOOA@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=leon.alrae@imgtec.com \
    --cc=macro@linux-mips.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thomas@codesourcery.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).