Commit 956ae3e9 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/rth/tags/pull-fpu-20200519' into staging



Misc cleanups

# gpg: Signature made Tue 19 May 2020 16:51:38 BST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth/tags/pull-fpu-20200519:
  softfloat: Return bool from all classification predicates
  softfloat: Inline floatx80 compare specializations
  softfloat: Inline float128 compare specializations
  softfloat: Inline float64 compare specializations
  softfloat: Inline float32 compare specializations
  softfloat: Name compare relation enum
  softfloat: Name rounding mode enum
  softfloat: Change tininess_before_rounding to bool
  softfloat: Replace flag with bool
  softfloat: Use post test for floatN_mul

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents f2465433 150c7a91
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ this code that are retained.
 * 2008 revision and backward compatibility with their original choice.
 * Thus for MIPS we must make the choice at runtime.
 */
static inline flag snan_bit_is_one(float_status *status)
static inline bool snan_bit_is_one(float_status *status)
{
#if defined(TARGET_MIPS)
    return status->snan_bit_is_one;
@@ -114,7 +114,7 @@ static bool parts_is_snan_frac(uint64_t frac, float_status *status)
#ifdef NO_SIGNALING_NANS
    return false;
#else
    flag msb = extract64(frac, DECOMPOSED_BINARY_POINT - 1, 1);
    bool msb = extract64(frac, DECOMPOSED_BINARY_POINT - 1, 1);
    return msb == snan_bit_is_one(status);
#endif
}
@@ -236,7 +236,7 @@ void float_raise(uint8_t flags, float_status *status)
| Internal canonical NaN format.
*----------------------------------------------------------------------------*/
typedef struct {
    flag sign;
    bool sign;
    uint64_t high, low;
} commonNaNT;

@@ -245,7 +245,7 @@ typedef struct {
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int float16_is_quiet_nan(float16 a_, float_status *status)
bool float16_is_quiet_nan(float16 a_, float_status *status)
{
#ifdef NO_SIGNALING_NANS
    return float16_is_any_nan(a_);
@@ -264,7 +264,7 @@ int float16_is_quiet_nan(float16 a_, float_status *status)
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int float16_is_signaling_nan(float16 a_, float_status *status)
bool float16_is_signaling_nan(float16 a_, float_status *status)
{
#ifdef NO_SIGNALING_NANS
    return 0;
@@ -283,7 +283,7 @@ int float16_is_signaling_nan(float16 a_, float_status *status)
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int float32_is_quiet_nan(float32 a_, float_status *status)
bool float32_is_quiet_nan(float32 a_, float_status *status)
{
#ifdef NO_SIGNALING_NANS
    return float32_is_any_nan(a_);
@@ -302,7 +302,7 @@ int float32_is_quiet_nan(float32 a_, float_status *status)
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int float32_is_signaling_nan(float32 a_, float_status *status)
bool float32_is_signaling_nan(float32 a_, float_status *status)
{
#ifdef NO_SIGNALING_NANS
    return 0;
@@ -374,7 +374,7 @@ static float32 commonNaNToFloat32(commonNaNT a, float_status *status)
*----------------------------------------------------------------------------*/

static int pickNaN(FloatClass a_cls, FloatClass b_cls,
                   flag aIsLargerSignificand)
                   bool aIsLargerSignificand)
{
#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_HPPA)
    /* ARM mandated NaN propagation rules (see FPProcessNaNs()), take
@@ -584,7 +584,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,

static float32 propagateFloat32NaN(float32 a, float32 b, float_status *status)
{
    flag aIsLargerSignificand;
    bool aIsLargerSignificand;
    uint32_t av, bv;
    FloatClass a_cls, b_cls;

@@ -637,7 +637,7 @@ static float32 propagateFloat32NaN(float32 a, float32 b, float_status *status)
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int float64_is_quiet_nan(float64 a_, float_status *status)
bool float64_is_quiet_nan(float64 a_, float_status *status)
{
#ifdef NO_SIGNALING_NANS
    return float64_is_any_nan(a_);
@@ -657,7 +657,7 @@ int float64_is_quiet_nan(float64 a_, float_status *status)
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int float64_is_signaling_nan(float64 a_, float_status *status)
bool float64_is_signaling_nan(float64 a_, float_status *status)
{
#ifdef NO_SIGNALING_NANS
    return 0;
@@ -722,7 +722,7 @@ static float64 commonNaNToFloat64(commonNaNT a, float_status *status)

static float64 propagateFloat64NaN(float64 a, float64 b, float_status *status)
{
    flag aIsLargerSignificand;
    bool aIsLargerSignificand;
    uint64_t av, bv;
    FloatClass a_cls, b_cls;

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

floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status)
{
    flag aIsLargerSignificand;
    bool aIsLargerSignificand;
    FloatClass a_cls, b_cls;

    /* This is not complete, but is good enough for pickNaN.  */
@@ -939,7 +939,7 @@ floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status)
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int float128_is_quiet_nan(float128 a, float_status *status)
bool float128_is_quiet_nan(float128 a, float_status *status)
{
#ifdef NO_SIGNALING_NANS
    return float128_is_any_nan(a);
@@ -959,7 +959,7 @@ int float128_is_quiet_nan(float128 a, float_status *status)
| signaling NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int float128_is_signaling_nan(float128 a, float_status *status)
bool float128_is_signaling_nan(float128 a, float_status *status)
{
#ifdef NO_SIGNALING_NANS
    return 0;
@@ -1038,7 +1038,7 @@ static float128 commonNaNToFloat128(commonNaNT a, float_status *status)
static float128 propagateFloat128NaN(float128 a, float128 b,
                                     float_status *status)
{
    flag aIsLargerSignificand;
    bool aIsLargerSignificand;
    FloatClass a_cls, b_cls;

    /* This is not complete, but is good enough for pickNaN.  */
+257 −1226

File changed.

Preview size limit exceeded, changes collapsed.

+14 −13
Original line number Diff line number Diff line
@@ -53,12 +53,13 @@ this code that are retained.

#include "fpu/softfloat-types.h"

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

static inline void set_float_rounding_mode(int val, float_status *status)
static inline void set_float_rounding_mode(FloatRoundMode val,
                                           float_status *status)
{
    status->float_rounding_mode = val;
}
@@ -74,32 +75,32 @@ static inline void set_floatx80_rounding_precision(int val,
    status->floatx80_rounding_precision = val;
}

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

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

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

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

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

static inline int get_float_rounding_mode(float_status *status)
static inline FloatRoundMode get_float_rounding_mode(float_status *status)
{
    return status->float_rounding_mode;
}
@@ -114,17 +115,17 @@ 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)
static inline bool get_flush_to_zero(float_status *status)
{
    return status->flush_to_zero;
}

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

static inline flag get_default_nan_mode(float_status *status)
static inline bool get_default_nan_mode(float_status *status)
{
    return status->default_nan_mode;
}
+8 −16
Original line number Diff line number Diff line
@@ -756,11 +756,9 @@ static inline uint32_t estimateSqrt32(int aExp, uint32_t a)
| Otherwise, returns 0.
*----------------------------------------------------------------------------*/

static inline flag eq128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
static inline bool eq128(uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1)
{

    return ( a0 == b0 ) && ( a1 == b1 );

    return a0 == b0 && a1 == b1;
}

/*----------------------------------------------------------------------------
@@ -769,11 +767,9 @@ static inline flag eq128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
| Otherwise, returns 0.
*----------------------------------------------------------------------------*/

static inline flag le128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
static inline bool le128(uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1)
{

    return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 <= b1 ) );

    return a0 < b0 || (a0 == b0 && a1 <= b1);
}

/*----------------------------------------------------------------------------
@@ -782,11 +778,9 @@ static inline flag le128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
| returns 0.
*----------------------------------------------------------------------------*/

static inline flag lt128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
static inline bool lt128(uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1)
{

    return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 < b1 ) );

    return a0 < b0 || (a0 == b0 && a1 < b1);
}

/*----------------------------------------------------------------------------
@@ -795,11 +789,9 @@ static inline flag lt128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
| Otherwise, returns 0.
*----------------------------------------------------------------------------*/

static inline flag ne128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
static inline bool ne128(uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1)
{

    return ( a0 != b0 ) || ( a1 != b1 );

    return a0 != b0 || a1 != b1;
}

#endif
+10 −18
Original line number Diff line number Diff line
@@ -80,12 +80,6 @@ this code that are retained.
#ifndef SOFTFLOAT_TYPES_H
#define SOFTFLOAT_TYPES_H

/* This 'flag' type must be able to hold at least 0 and 1. It should
 * probably be replaced with 'bool' but the uses would need to be audited
 * to check that they weren't accidentally relying on it being a larger type.
 */
typedef uint8_t flag;

/*
 * Software IEC/IEEE floating-point types.
 */
@@ -122,16 +116,14 @@ typedef struct {
 * Software IEC/IEEE floating-point underflow tininess-detection mode.
 */

enum {
    float_tininess_after_rounding  = 0,
    float_tininess_before_rounding = 1
};
#define float_tininess_after_rounding  false
#define float_tininess_before_rounding true

/*
 *Software IEC/IEEE floating-point rounding mode.
 */

enum {
typedef enum __attribute__((__packed__)) {
    float_round_nearest_even = 0,
    float_round_down         = 1,
    float_round_up           = 2,
@@ -139,7 +131,7 @@ enum {
    float_round_ties_away    = 4,
    /* Not an IEEE rounding mode: round to the closest odd mantissa value */
    float_round_to_odd       = 5,
};
} FloatRoundMode;

/*
 * Software IEC/IEEE floating-point exception flags.
@@ -164,17 +156,17 @@ enum {
 */

typedef struct float_status {
    signed char float_detect_tininess;
    signed char float_rounding_mode;
    FloatRoundMode float_rounding_mode;
    uint8_t     float_exception_flags;
    signed char floatx80_rounding_precision;
    bool tininess_before_rounding;
    /* should denormalised results go to zero and set the inexact flag? */
    flag flush_to_zero;
    bool flush_to_zero;
    /* should denormalised inputs go to zero and set the input_denormal flag? */
    flag flush_inputs_to_zero;
    flag default_nan_mode;
    bool flush_inputs_to_zero;
    bool default_nan_mode;
    /* not always used -- see snan_bit_is_one() in softfloat-specialize.h */
    flag snan_bit_is_one;
    bool snan_bit_is_one;
} float_status;

#endif /* SOFTFLOAT_TYPES_H */
Loading