qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Laurent Vivier <laurent@vivier.eu>, qemu-devel@nongnu.org
Cc: Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [Qemu-devel] [PATCH v3 06/16] target-m68k: add FPCR and FPSR
Date: Thu, 16 Feb 2017 12:10:11 +1100	[thread overview]
Message-ID: <a9741f4b-fccf-1f99-b490-3359e187adf1@twiddle.net> (raw)
In-Reply-To: <20170207005930.28327-7-laurent@vivier.eu>

On 02/07/2017 11:59 AM, Laurent Vivier wrote:
>  void HELPER(itrunc_FP0)(CPUM68KState *env)
>  {
>      floatx80 res;
>
> +    set_float_rounding_mode(float_round_to_zero, &env->fp_status);
>      res = floatx80_round_to_int(FP0_to_floatx80(env), &env->fp_status);
> +    restore_rounding_mode(env);

It would be better to save/restore the current rounding mode as opposed to 
recomputing from the fpcr.

>  void HELPER(cmp_FP0_FP1)(CPUM68KState *env)
>  {
>      floatx80 fp0 = FP0_to_floatx80(env);
>      floatx80 fp1 = FP1_to_floatx80(env);
> -    floatx80 res;
> +    int float_compare;
>
> -    res = floatx80_sub(fp0, fp1, &env->fp_status);
> -    if (floatx80_is_quiet_nan(res, &env->fp_status)) {
> -        /* +/-inf compares equal against itself, but sub returns nan.  */
> -        if (!floatx80_is_quiet_nan(fp0, &env->fp_status)
> -            && !floatx80_is_quiet_nan(fp1, &env->fp_status)) {
> -            res = floatx80_zero;
> -            if (floatx80_lt_quiet(fp0, res, &env->fp_status)) {
> -                res = floatx80_chs(res);
> -            }
> -        }
> -    }
> -
> -    floatx80_to_FP0(env, res);
> +    float_compare = floatx80_compare(fp1, fp0, &env->fp_status);
> +    env->fpsr = (env->fpsr & ~FPSR_CC_MASK) | float_comp_to_cc(float_compare);
>  }
>
> -uint32_t HELPER(compare_FP0)(CPUM68KState *env)
> +void HELPER(tst_FP0)(CPUM68KState *env)
>  {
> -    floatx80 fp0 = FP0_to_floatx80(env);
> -    return floatx80_compare_quiet(fp0, floatx80_zero, &env->fp_status);
> +    uint32_t fpsr = 0;
> +    floatx80 val = FP0_to_floatx80(env);
> +
> +    if (floatx80_is_neg(val)) {
> +        fpsr |= FPSR_CC_N;
> +    }
> +
> +    if (floatx80_is_any_nan(val)) {
> +        fpsr |= FPSR_CC_A;
> +    } else if (floatx80_is_infinity(val)) {
> +        fpsr |= FPSR_CC_I;
> +    } else if (floatx80_is_zero(val)) {
> +        fpsr |= FPSR_CC_Z;
> +    }
> +    env->fpsr = (env->fpsr & ~FPSR_CC_MASK) | fpsr;
>  }

It would be better to pass in the old FPSR value, returning the new FPSR value, 
so that the helper can be marked TCG_CALL_NO_RWG -- not reading or modifying 
TCG globals.

> +        gen_helper_tst_FP0(cpu_env);

Making this, e.g. gen_helper_tst_FP0(QREG_FPSR, cpu_env).  Which will also 
happen to leave the FPSR in a host register where it can be used if the next 
insn is a fp branch.


r~

  reply	other threads:[~2017-02-16  1:10 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-07  0:59 [Qemu-devel] [PATCH v3 00/16] target-m68k: implement 680x0 FPU Laurent Vivier
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 01/16] softfloat: define 680x0 specific values Laurent Vivier
2017-02-08 21:30   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 02/16] softloat: disable floatx80_invalid_encoding() for m68k Laurent Vivier
2017-02-08 21:32   ` Richard Henderson
2017-02-08 22:58   ` Peter Maydell
2017-02-09  8:07     ` Laurent Vivier
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 03/16] target-m68k: move FPU helpers to fpu_helper.c Laurent Vivier
2017-02-08 21:33   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 04/16] target-m68k: define ext_opsize Laurent Vivier
2017-02-08 21:33   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 05/16] target-m68k: use floatx80 internally Laurent Vivier
2017-02-15 22:59   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 06/16] target-m68k: add FPCR and FPSR Laurent Vivier
2017-02-16  1:10   ` Richard Henderson [this message]
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 07/16] target-m68k: manage FPU exceptions Laurent Vivier
2017-02-16  1:16   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 08/16] target-m68k: define 96bit FP registers for gdb on 680x0 Laurent Vivier
2017-02-16  1:17   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 09/16] target-m68k: add fmovem Laurent Vivier
2017-02-16  1:22   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 10/16] target-m68k: add fscc Laurent Vivier
2017-02-16  1:27   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 11/16] target-m68k: add fmovecr Laurent Vivier
2017-02-16  1:28   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 12/16] target-m68k: add fscale, fgetman, fgetexp and fmod Laurent Vivier
2017-02-16  1:34   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 13/16] target-m68k: add fsglmul and fsgldiv Laurent Vivier
2017-02-16  1:36   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 14/16] target-m68k: add explicit single and double precision operations Laurent Vivier
2017-02-16  1:41   ` Richard Henderson
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 15/16] target-m68k: add more FPU instructions Laurent Vivier
2017-02-16  1:46   ` Richard Henderson
2017-02-16 10:18     ` Andreas Schwab
2017-02-16 21:01       ` Richard Henderson
2017-02-17  9:06         ` Andreas Schwab
2017-02-07  0:59 ` [Qemu-devel] [PATCH v3 16/16] target-m68k: add fsincos Laurent Vivier
2017-02-07  1:25 ` [Qemu-devel] [PATCH v3 00/16] target-m68k: implement 680x0 FPU no-reply

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=a9741f4b-fccf-1f99-b490-3359e187adf1@twiddle.net \
    --to=rth@twiddle.net \
    --cc=aurelien@aurel32.net \
    --cc=laurent@vivier.eu \
    --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).