qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 13/20] fpu/softfloat: re-factor div


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v2 13/20] fpu/softfloat: re-factor div
Date: Fri, 12 Jan 2018 16:22:19 +0000

On 9 January 2018 at 12:22, Alex Bennée <address@hidden> wrote:
> We can now add float16_div and use the common decompose and
> canonicalize functions to have a single implementation for
> float16/32/64 versions.
>
> Signed-off-by: Alex Bennée <address@hidden>
> Signed-off-by: Richard Henderson <address@hidden>
> ---
>  fpu/softfloat-macros.h  |  44 +++++++++
>  fpu/softfloat.c         | 235 
> ++++++++++++++++++------------------------------
>  include/fpu/softfloat.h |   1 +
>  3 files changed, 134 insertions(+), 146 deletions(-)
>
> diff --git a/fpu/softfloat-macros.h b/fpu/softfloat-macros.h
> index 9cc6158cb4..980be2c051 100644
> --- a/fpu/softfloat-macros.h
> +++ b/fpu/softfloat-macros.h
> @@ -625,6 +625,50 @@ static uint64_t estimateDiv128To64( uint64_t a0, 
> uint64_t a1, uint64_t b )
>
>  }
>
> +/* Nicked from gmp longlong.h __udiv_qrnnd */

Can we have a copyright/license attribution for code we nick
from other projects, please? :-)

> +static uint64_t div128To64(uint64_t n0, uint64_t n1, uint64_t d)
> +{
> +    uint64_t d0, d1, q0, q1, r1, r0, m;
> +
> +    d0 = (uint32_t)d;
> +    d1 = d >> 32;
> +
> +    r1 = n1 % d1;
> +    q1 = n1 / d1;
> +    m = q1 * d0;
> +    r1 = (r1 << 32) | (n0 >> 32);
> +    if (r1 < m) {
> +        q1 -= 1;
> +        r1 += d;
> +        if (r1 >= d) {
> +            if (r1 < m) {
> +                q1 -= 1;
> +                r1 += d;
> +            }
> +        }
> +    }
> +    r1 -= m;
> +
> +    r0 = r1 % d1;
> +    q0 = r1 / d1;
> +    m = q0 * d0;
> +    r0 = (r0 << 32) | (uint32_t)n0;
> +    if (r0 < m) {
> +        q0 -= 1;
> +        r0 += d;
> +        if (r0 >= d) {
> +            if (r0 < m) {
> +                q0 -= 1;
> +                r0 += d;
> +            }
> +        }
> +    }
> +    r0 -= m;
> +
> +    /* Return remainder in LSB */
> +    return (q1 << 32) | q0 | (r0 != 0);
> +}

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]