qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Aurelien Jarno <aurelien@aurel32.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 9/9] target-i386: add support for FPU exceptions
Date: Tue, 24 May 2011 16:55:51 +0100	[thread overview]
Message-ID: <BANLkTimH7mXrQ+bQWEyksEbk4xjixzAyVQ@mail.gmail.com> (raw)
In-Reply-To: <1306186971-9528-10-git-send-email-aurelien@aurel32.net>

On 23 May 2011 22:42, Aurelien Jarno <aurelien@aurel32.net> wrote:
> This patch adds support for FPU exceptions. It keeps the exception in
> the softfloat status, and copy them back to env->fpus when needed by
> oring them. When loading a new value to env->fpus, it starts with a
> clean softfloat status.
>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

gdbstub.c still looks at env->fpus directly without calling
cpu_x86_update_fpus() first; it should probably go through
helper_fnstsw() now (or if you like a utility function that does what
helper_fnstsw() does now).

Similarly the code in helper_fstenv() and cpu_pre_save() that does:
    cpu_x86_update_fpus(env);
    SOMETHING = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11;

could be usefully abstracted away into a call to this utility fn.

For the rest, it looks OK, but the cpu_x86_update_fpus() and
cpu_x86_set_fpus() functions feel a bit like they're only half
an abstraction layer -- so sometimes it's OK to tweak env->fpus
directly and sometimes you need to use the functions. That means
it's tricky to tell from eyeballing or grepping the code whether an
update_fpus() call got missed out. Maybe it would be better to have
a set of functions such that you could mandate that all env->fpus
accesses went via the functions?

A random nitpick:

> @@ -4208,7 +4200,13 @@ void helper_fscale(void)
>     if (floatx80_is_any_nan(ST1)) {
>         ST0 = ST1;
>     } else {
> -        int n = floatx80_to_int32_round_to_zero(ST1, &env->fp_status);
> +        int n, x;
> +
> +        /* The float to int conversion should not generate any exception. */
> +        x = get_float_exception_flags(&env->fp_status);
> +        n = floatx80_to_int32_round_to_zero(ST1, &env->fp_status);
> +        set_float_exception_flags(x, &env->fp_status);
> +
>         ST0 = floatx80_scalbn(ST0, n, &env->fp_status);
>     }
>  }

...doesn't this mean you won't set the #D flag if ST1 is denormal?

I'm unconvinced about scalbn as a softfloat primitive. It gets used:
 * by ARM for the VCVT fixed-point conversions, as a combination of
   scalbn + float-to-int or int-to-float + scalbn
 * by PPC for the same reason (vctuxs, vctsxs, vcfux, vcfsx)
 * by x86 here as a float-to-int + scalbn, for FSCALE

and I think that in all three cases the attempt to implement a floating
point op by composing two softfloat primitives causes problems with
getting the floating point exception flags right. (In the fixedpoint
conversion case the issue is that for instance if the input is a
negative number we should only set InvalidOp but the scalbn is likely
to result in our also setting Inexact. But if you don't let the
scalbn set any flags at all then you have to special case when the
input is a NaN or denormal, which is equally awkward.)

-- PMM

      reply	other threads:[~2011-05-24 15:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-23 21:42 [Qemu-devel] [PATCH v2 0/9] softfloat-native removal and i386 improvement Aurelien Jarno
2011-05-23 21:42 ` [Qemu-devel] [PATCH v2 1/9] target-ppc: remove old CONFIG_SOFTFLOAT #ifdef Aurelien Jarno
2011-05-29 10:58   ` Andreas Färber
2011-05-23 21:42 ` [Qemu-devel] [PATCH v2 2/9] target-mips/gdbstub: remove old CONFIG_SOFTFLOAT #ifndef Aurelien Jarno
2011-05-23 22:09   ` Peter Maydell
2011-05-29 11:01   ` Andreas Färber
2011-05-23 21:42 ` [Qemu-devel] [PATCH v2 3/9] target-i386: remove old code handling float64 Aurelien Jarno
2011-05-24 15:12   ` Peter Maydell
2011-05-23 21:42 ` [Qemu-devel] [PATCH v2 4/9] softfloat-native: remove Aurelien Jarno
2011-05-23 21:42 ` [Qemu-devel] [PATCH v2 5/9] softfloat: always enable floatx80 and float128 support Aurelien Jarno
2011-05-23 21:42 ` [Qemu-devel] [PATCH v2 6/9] target-i386: use floatx80 constants in helper_fld*_ST0() Aurelien Jarno
2011-05-23 22:11   ` Peter Maydell
2011-05-29 10:38   ` Andreas Färber
2011-05-23 21:42 ` [Qemu-devel] [PATCH v2 7/9] softfloat: add float*_is_zero_or_denormal() Aurelien Jarno
2011-05-23 21:42 ` [Qemu-devel] [PATCH v2 8/9] target-i386: cleanup helper_fxam_ST0() Aurelien Jarno
2011-05-23 22:02   ` Peter Maydell
2011-05-23 21:42 ` [Qemu-devel] [PATCH v2 9/9] target-i386: add support for FPU exceptions Aurelien Jarno
2011-05-24 15:55   ` Peter Maydell [this message]

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=BANLkTimH7mXrQ+bQWEyksEbk4xjixzAyVQ@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.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 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).