qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v1 16/19] fpu/softfloat: re-factor int/uint to f


From: Alex Bennée
Subject: Re: [Qemu-devel] [PATCH v1 16/19] fpu/softfloat: re-factor int/uint to float
Date: Tue, 12 Dec 2017 17:21:45 +0000
User-agent: mu4e 1.0-alpha2; emacs 26.0.90

Alex Bennée <address@hidden> writes:

> These are considerably simpler as the lower order integers can just
> use the higher order conversion function. As the decomposed fractional
> part is a full 64 bit rounding and inexact handling comes from the
> pack functions.
<snip>
>
> +/*
> + * Integer to float conversions
> + *
> + * Returns the result of converting the two's complement integer `a'
> + * to the floating-point format. The conversion is performed according
> + * to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
> + */
> +
> +static decomposed_parts int_to_float(int64_t a, float_status *status)
> +{
> +    decomposed_parts r;
> +    if (a == 0) {
> +        r.cls = float_class_zero;
> +    } else if (a == (1ULL << 63)) {

As the re-pack code can handle -0 we need to explicitly set it here as
we are building decomposed_parts from scratch:

    if (a == 0) {
        r.cls = float_class_zero;
        r.sign = false;
    } else if (a == (1ULL << 63)) {

And also at:
> +
> +/*
> + * Unsigned Integer to float conversions
> + *
> + * Returns the result of converting the unsigned integer `a' to the
> + * floating-point format. The conversion is performed according to the
> + * IEC/IEEE Standard for Binary Floating-Point Arithmetic.
> + */
> +
> +static decomposed_parts uint_to_float(uint64_t a, float_status *status)
> +{
> +    decomposed_parts r;
> +    if (a == 0) {
> +        r.cls = float_class_zero;
> +    } else {

Now reads:

    decomposed_parts r = { .sign = false};

    if (a == 0) {
        r.cls = float_class_zero;
    } else {
        int spare_bits = clz64(a) - 1;
        r.cls = float_class_normal;


--
Alex Bennée



reply via email to

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