Commit 50d69ee0 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/stsquad/tags/pull-softfloat-headers-190819-1' into staging



Softfloat updates

  - minor refactoring of constants
  - drop LIT64 macro
  - re-organise header inclusion

# gpg: Signature made Mon 19 Aug 2019 12:08:37 BST
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-softfloat-headers-190819-1:
  targets (various): use softfloat-helpers.h where we can
  target/riscv: rationalise softfloat includes
  target/mips: rationalise softfloat includes
  fpu: rename softfloat-specialize.h -> .inc.c
  fpu: make softfloat-macros "self-contained"
  fpu: move inline helpers into a separate header
  fpu: remove the LIT64 macro
  target/m68k: replace LIT64 with UINT64_C macros
  fpu: replace LIT64 with UINT64_C macros
  fpu: use min/max values from stdint.h for integral overflow
  fpu: convert float[16/32/64]_squash_denormal to new modern style
  fpu: replace LIT64 usage with UINT64_C for specialize constants

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 3fbd3405 5f8ab000
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -196,11 +196,11 @@ floatx80 floatx80_default_nan(float_status *status)
    /* None of the targets that have snan_bit_is_one use floatx80.  */
    assert(!snan_bit_is_one(status));
#if defined(TARGET_M68K)
    r.low = LIT64(0xFFFFFFFFFFFFFFFF);
    r.low = UINT64_C(0xFFFFFFFFFFFFFFFF);
    r.high = 0x7FFF;
#else
    /* X86 */
    r.low = LIT64(0xC000000000000000);
    r.low = UINT64_C(0xC000000000000000);
    r.high = 0xFFFF;
#endif
    return r;
@@ -212,9 +212,9 @@ floatx80 floatx80_default_nan(float_status *status)

#define floatx80_infinity_high 0x7FFF
#if defined(TARGET_M68K)
#define floatx80_infinity_low  LIT64(0x0000000000000000)
#define floatx80_infinity_low  UINT64_C(0x0000000000000000)
#else
#define floatx80_infinity_low  LIT64(0x8000000000000000)
#define floatx80_infinity_low  UINT64_C(0x8000000000000000)
#endif

const floatx80 floatx80_infinity
@@ -667,7 +667,7 @@ int float64_is_signaling_nan(float64 a_, float_status *status)
        return ((a << 1) >= 0xFFF0000000000000ULL);
    } else {
        return (((a >> 51) & 0xFFF) == 0xFFE)
            && (a & LIT64(0x0007FFFFFFFFFFFF));
            && (a & UINT64_C(0x0007FFFFFFFFFFFF));
    }
#endif
}
@@ -707,7 +707,7 @@ static float64 commonNaNToFloat64(commonNaNT a, float_status *status)
    if (mantissa) {
        return make_float64(
              (((uint64_t) a.sign) << 63)
            | LIT64(0x7FF0000000000000)
            | UINT64_C(0x7FF0000000000000)
            | (a.high >> 12));
    } else {
        return float64_default_nan(status);
@@ -790,7 +790,7 @@ int floatx80_is_quiet_nan(floatx80 a, float_status *status)
            && (a.low == aLow);
    } else {
        return ((a.high & 0x7FFF) == 0x7FFF)
            && (LIT64(0x8000000000000000) <= ((uint64_t)(a.low << 1)));
            && (UINT64_C(0x8000000000000000) <= ((uint64_t)(a.low << 1)));
    }
#endif
}
@@ -812,7 +812,7 @@ int floatx80_is_signaling_nan(floatx80 a, float_status *status)
    } else {
        uint64_t aLow;

        aLow = a.low & ~LIT64(0x4000000000000000);
        aLow = a.low & ~UINT64_C(0x4000000000000000);
        return ((a.high & 0x7FFF) == 0x7FFF)
            && (uint64_t)(aLow << 1)
            && (a.low == aLow);
@@ -829,7 +829,7 @@ floatx80 floatx80_silence_nan(floatx80 a, float_status *status)
{
    /* None of the targets that have snan_bit_is_one use floatx80.  */
    assert(!snan_bit_is_one(status));
    a.low |= LIT64(0xC000000000000000);
    a.low |= UINT64_C(0xC000000000000000);
    return a;
}

@@ -874,7 +874,7 @@ static floatx80 commonNaNToFloatx80(commonNaNT a, float_status *status)
    }

    if (a.high >> 1) {
        z.low = LIT64(0x8000000000000000) | a.high >> 1;
        z.low = UINT64_C(0x8000000000000000) | a.high >> 1;
        z.high = (((uint16_t)a.sign) << 15) | 0x7FFF;
    } else {
        z = floatx80_default_nan(status);
@@ -969,7 +969,7 @@ int float128_is_signaling_nan(float128 a, float_status *status)
            && (a.low || (a.high & 0x0000FFFFFFFFFFFFULL));
    } else {
        return (((a.high >> 47) & 0xFFFF) == 0xFFFE)
            && (a.low || (a.high & LIT64(0x00007FFFFFFFFFFF)));
            && (a.low || (a.high & UINT64_C(0x00007FFFFFFFFFFF)));
    }
#endif
}
@@ -987,7 +987,7 @@ float128 float128_silence_nan(float128 a, float_status *status)
    if (snan_bit_is_one(status)) {
        return float128_default_nan(status);
    } else {
        a.high |= LIT64(0x0000800000000000);
        a.high |= UINT64_C(0x0000800000000000);
        return a;
    }
#endif
@@ -1025,7 +1025,7 @@ static float128 commonNaNToFloat128(commonNaNT a, float_status *status)
    }

    shift128Right(a.high, a.low, 16, &z.high, &z.low);
    z.high |= (((uint64_t)a.sign) << 63) | LIT64(0x7FFF000000000000);
    z.high |= (((uint64_t)a.sign) << 63) | UINT64_C(0x7FFF000000000000);
    return z;
}

+124 −140

File changed.

Preview size limit exceeded, changes collapsed.

+132 −0
Original line number Diff line number Diff line
/*
 * QEMU float support - standalone helpers
 *
 * This is provided for files that don't need the access to the full
 * set of softfloat functions. Typically this is cpu initialisation
 * code which wants to set default rounding and exceptions modes.
 *
 * The code in this source file is derived from release 2a of the SoftFloat
 * IEC/IEEE Floating-point Arithmetic Package. Those parts of the code (and
 * some later contributions) are provided under that license, as detailed below.
 * It has subsequently been modified by contributors to the QEMU Project,
 * so some portions are provided under:
 *  the SoftFloat-2a license
 *  the BSD license
 *  GPL-v2-or-later
 *
 * Any future contributions to this file after December 1st 2014 will be
 * taken to be licensed under the Softfloat-2a license unless specifically
 * indicated otherwise.
 */

/*
===============================================================================
This C header file is part of the SoftFloat IEC/IEEE Floating-point
Arithmetic Package, Release 2a.

Written by John R. Hauser.  This work was made possible in part by the
International Computer Science Institute, located at Suite 600, 1947 Center
Street, Berkeley, California 94704.  Funding was partially provided by the
National Science Foundation under grant MIP-9311980.  The original version
of this code was written as part of a project to build a fixed-point vector
processor in collaboration with the University of California at Berkeley,
overseen by Profs. Nelson Morgan and John Wawrzynek.  More information
is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
arithmetic/SoftFloat.html'.

THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.

Derivative works are acceptable, even for commercial purposes, so long as
(1) they include prominent notice that the work is derivative, and (2) they
include prominent notice akin to these four paragraphs for those parts of
this code that are retained.

===============================================================================
*/

#ifndef _SOFTFLOAT_HELPERS_H_
#define _SOFTFLOAT_HELPERS_H_

#include "fpu/softfloat-types.h"

static inline void set_float_detect_tininess(int val, float_status *status)
{
    status->float_detect_tininess = val;
}

static inline void set_float_rounding_mode(int val, float_status *status)
{
    status->float_rounding_mode = val;
}

static inline void set_float_exception_flags(int val, float_status *status)
{
    status->float_exception_flags = val;
}

static inline void set_floatx80_rounding_precision(int val,
                                                   float_status *status)
{
    status->floatx80_rounding_precision = val;
}

static inline void set_flush_to_zero(flag val, float_status *status)
{
    status->flush_to_zero = val;
}

static inline void set_flush_inputs_to_zero(flag val, float_status *status)
{
    status->flush_inputs_to_zero = val;
}

static inline void set_default_nan_mode(flag val, float_status *status)
{
    status->default_nan_mode = val;
}

static inline void set_snan_bit_is_one(flag val, float_status *status)
{
    status->snan_bit_is_one = val;
}

static inline int get_float_detect_tininess(float_status *status)
{
    return status->float_detect_tininess;
}

static inline int get_float_rounding_mode(float_status *status)
{
    return status->float_rounding_mode;
}

static inline int get_float_exception_flags(float_status *status)
{
    return status->float_exception_flags;
}

static inline int get_floatx80_rounding_precision(float_status *status)
{
    return status->floatx80_rounding_precision;
}

static inline flag get_flush_to_zero(float_status *status)
{
    return status->flush_to_zero;
}

static inline flag get_flush_inputs_to_zero(float_status *status)
{
    return status->flush_inputs_to_zero;
}

static inline flag get_default_nan_mode(float_status *status)
{
    return status->default_nan_mode;
}

#endif /* _SOFTFLOAT_HELPERS_H_ */
+4 −4
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ this code that are retained.
#ifndef FPU_SOFTFLOAT_MACROS_H
#define FPU_SOFTFLOAT_MACROS_H

#include "fpu/softfloat.h"
#include "fpu/softfloat-types.h"

/*----------------------------------------------------------------------------
| Shifts `a' right by the number of bits given in `count'.  If any nonzero
@@ -618,13 +618,13 @@ static inline uint64_t estimateDiv128To64(uint64_t a0, uint64_t a1, uint64_t b)
    uint64_t rem0, rem1, term0, term1;
    uint64_t z;

    if ( b <= a0 ) return LIT64( 0xFFFFFFFFFFFFFFFF );
    if ( b <= a0 ) return UINT64_C(0xFFFFFFFFFFFFFFFF);
    b0 = b>>32;
    z = ( b0<<32 <= a0 ) ? LIT64( 0xFFFFFFFF00000000 ) : ( a0 / b0 )<<32;
    z = ( b0<<32 <= a0 ) ? UINT64_C(0xFFFFFFFF00000000) : ( a0 / b0 )<<32;
    mul64To128( b, z, &term0, &term1 );
    sub128( a0, a1, term0, term1, &rem0, &rem1 );
    while ( ( (int64_t) rem0 ) < 0 ) {
        z -= LIT64( 0x100000000 );
        z -= UINT64_C(0x100000000);
        b1 = b<<32;
        add128( rem0, rem1, b0, b1, &rem0, &rem1 );
    }
+1 −64
Original line number Diff line number Diff line
@@ -82,8 +82,6 @@ this code that are retained.
#ifndef SOFTFLOAT_H
#define SOFTFLOAT_H

#define LIT64( a ) a##LL

/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point ordering relations
*----------------------------------------------------------------------------*/
@@ -95,68 +93,7 @@ enum {
};

#include "fpu/softfloat-types.h"

static inline void set_float_detect_tininess(int val, float_status *status)
{
    status->float_detect_tininess = val;
}
static inline void set_float_rounding_mode(int val, float_status *status)
{
    status->float_rounding_mode = val;
}
static inline void set_float_exception_flags(int val, float_status *status)
{
    status->float_exception_flags = val;
}
static inline void set_floatx80_rounding_precision(int val,
                                                   float_status *status)
{
    status->floatx80_rounding_precision = val;
}
static inline void set_flush_to_zero(flag val, float_status *status)
{
    status->flush_to_zero = val;
}
static inline void set_flush_inputs_to_zero(flag val, float_status *status)
{
    status->flush_inputs_to_zero = val;
}
static inline void set_default_nan_mode(flag val, float_status *status)
{
    status->default_nan_mode = val;
}
static inline void set_snan_bit_is_one(flag val, float_status *status)
{
    status->snan_bit_is_one = val;
}
static inline int get_float_detect_tininess(float_status *status)
{
    return status->float_detect_tininess;
}
static inline int get_float_rounding_mode(float_status *status)
{
    return status->float_rounding_mode;
}
static inline int get_float_exception_flags(float_status *status)
{
    return status->float_exception_flags;
}
static inline int get_floatx80_rounding_precision(float_status *status)
{
    return status->floatx80_rounding_precision;
}
static inline flag get_flush_to_zero(float_status *status)
{
    return status->flush_to_zero;
}
static inline flag get_flush_inputs_to_zero(float_status *status)
{
    return status->flush_inputs_to_zero;
}
static inline flag get_default_nan_mode(float_status *status)
{
    return status->default_nan_mode;
}
#include "fpu/softfloat-helpers.h"

/*----------------------------------------------------------------------------
| Routine to raise any or all of the software IEC/IEEE floating-point
Loading