qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: matheus.ferst@eldorado.org.br, qemu-devel@nongnu.org,
	qemu-ppc@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	danielhb413@gmail.com, groug@kaod.org, clg@kaod.org,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	david@gibson.dropbear.id.au
Subject: Re: [RFC PATCH 2/6] softfloat: add int128_to_float* conversion methods
Date: Tue, 29 Mar 2022 05:40:52 -0600	[thread overview]
Message-ID: <31afd7fc-9ecd-959f-5a80-18a6707061a8@linaro.org> (raw)
In-Reply-To: <20220328201442.175206-3-matheus.ferst@eldorado.org.br>

On 3/28/22 14:14, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst <matheus.ferst@eldorado.org.br>
> 
> Based on parts_sint_to_float, implements parts_sint_to_float2 that
> receives a 128-bit signed integer via int64_t and uint64_t arguments.
> 
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
>   fpu/softfloat-parts.c.inc | 37 +++++++++++++++++++++++++++++++++++++
>   fpu/softfloat.c           | 30 ++++++++++++++++++++++++++++++
>   include/fpu/softfloat.h   |  3 +++
>   3 files changed, 70 insertions(+)
> 
> diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
> index 0bbecf835f..5f7f107a0d 100644
> --- a/fpu/softfloat-parts.c.inc
> +++ b/fpu/softfloat-parts.c.inc
> @@ -1196,6 +1196,43 @@ static void partsN(sint_to_float)(FloatPartsN *p, int64_t a,
>       p->frac_hi = f << shift;
>   }
>   
> +static void partsN(sint_to_float2)(FloatPartsN *p, int64_t hi, uint64_t lo,
> +                                   int scale, float_status *status)
> +{
> +    uint64_t f = hi;
> +    int shift;
> +
> +    if (hi == 0) {
> +        parts_uint_to_float(p, lo, scale, status);
> +    } else {

We should also defer "small" negative numbers.

        if (hi == -1) {
            parts_uint_to_float(p, -lo, scale, status);
            p->sign = true;
            return;
        }

That should ensure...

> +        memset(p, 0, sizeof(*p));
> +        p->cls = float_class_normal;
> +        if (hi < 0) {
> +            lo = -lo;
> +            f = ~f + !lo;
> +            p->sign = true;
> +        }
> +        if (f != 0) {
> +            shift = clz64(f);
> +        } else {
> +            shift = 64 + clz64(lo);
> +        }

this case

> +        scale = MIN(MAX(scale, -0x10000), 0x10000);
> +
> +        p->exp = 127 - shift + scale;
> +
> +        if (shift >= 64) {
> +            f = lo;
> +            lo = 0;
> +            shift -= 64;
> +        }

and this case don't happen.

> +        p->frac_hi = shl_double(f, lo, shift);
> +        if (N > 64) {
> +            p->frac_lo = shl_double(lo, 0, shift);

Same comment about shl_double w/ 0.

Alternately, rewrite the whole thing in terms of uint_to_float2:

     if (hi >= 0) {
         uint_to_float2(p, hi, lo, scale, status);
     } else {
         lo = -lo;
         hi = ~hi + !lo;
         uint_to_float2(p, hi, lo, scale, status);
         p->sign = true;
     }


r~


  reply	other threads:[~2022-03-29 11:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28 20:14 [RFC PATCH 0/6] softfloat 128-bit integer support matheus.ferst
2022-03-28 20:14 ` [RFC PATCH 1/6] softfloat: add uint128_to_float* conversion methods matheus.ferst
2022-03-29 11:28   ` Richard Henderson
2022-03-28 20:14 ` [RFC PATCH 2/6] softfloat: add int128_to_float* " matheus.ferst
2022-03-29 11:40   ` Richard Henderson [this message]
2022-03-28 20:14 ` [RFC PATCH 3/6] softfloat: add float*_to_uint128 " matheus.ferst
2022-03-29 11:48   ` Richard Henderson
2022-03-28 20:14 ` [RFC PATCH 4/6] softfloat: add float*_to_int128 " matheus.ferst
2022-03-29 12:10   ` Richard Henderson
2022-03-28 20:14 ` [RFC PATCH 5/6] target/ppc: implement xscv[su]qqp matheus.ferst
2022-03-29 12:16   ` Richard Henderson
2022-03-28 20:14 ` [RFC PATCH 6/6] target/ppc: implement xscvqp[su]qz matheus.ferst
2022-03-29 12:18   ` Richard Henderson
2022-03-29  3:38 ` [RFC PATCH 0/6] softfloat 128-bit integer support Richard Henderson
2022-03-30 17:59   ` Matheus K. Ferst

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=31afd7fc-9ecd-959f-5a80-18a6707061a8@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --cc=matheus.ferst@eldorado.org.br \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).