mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 00:25:27 +00:00
softfloat: pass float_status pointer to pickNaN
Pass float_status structure pointer to the pickNaN so that machine-specific settings are available to NaN selection code. Add use_first_nan property to float_status and use it in Xtensa-specific pickNaN. Backports commit 913602e3ffe6bf50b869a14028a55cb267645ba3
This commit is contained in:
parent
db780eff66
commit
fee4c62fe4
|
@ -380,7 +380,7 @@ static float32 commonNaNToFloat32(commonNaNT a, float_status *status)
|
|||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static int pickNaN(FloatClass a_cls, FloatClass b_cls,
|
||||
bool aIsLargerSignificand)
|
||||
bool aIsLargerSignificand, float_status *status)
|
||||
{
|
||||
#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_HPPA)
|
||||
/* ARM mandated NaN propagation rules (see FPProcessNaNs()), take
|
||||
|
@ -413,7 +413,7 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
|
|||
} else {
|
||||
return 1;
|
||||
}
|
||||
#elif defined(TARGET_PPC) || defined(TARGET_XTENSA) || defined(TARGET_M68K)
|
||||
#elif defined(TARGET_PPC) || defined(TARGET_M68K)
|
||||
/* PowerPC propagation rules:
|
||||
* 1. A if it sNaN or qNaN
|
||||
* 2. B if it sNaN or qNaN
|
||||
|
@ -438,6 +438,24 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
|
|||
} else {
|
||||
return 1;
|
||||
}
|
||||
#elif defined(TARGET_XTENSA)
|
||||
/*
|
||||
* Xtensa has two NaN propagation modes.
|
||||
* Which one is active is controlled by float_status::use_first_nan.
|
||||
*/
|
||||
if (status->use_first_nan) {
|
||||
if (is_nan(a_cls)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (is_nan(b_cls)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* This implements x87 NaN propagation rules:
|
||||
* SNaN + QNaN => return the QNaN
|
||||
|
@ -617,7 +635,7 @@ static float32 propagateFloat32NaN(float32 a, float32 b, float_status *status)
|
|||
aIsLargerSignificand = (av < bv) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) {
|
||||
if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
|
||||
if (is_snan(b_cls)) {
|
||||
return float32_silence_nan(b, status);
|
||||
}
|
||||
|
@ -755,7 +773,7 @@ static float64 propagateFloat64NaN(float64 a, float64 b, float_status *status)
|
|||
aIsLargerSignificand = (av < bv) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) {
|
||||
if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
|
||||
if (is_snan(b_cls)) {
|
||||
return float64_silence_nan(b, status);
|
||||
}
|
||||
|
@ -919,7 +937,7 @@ floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status)
|
|||
aIsLargerSignificand = (a.high < b.high) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) {
|
||||
if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
|
||||
if (is_snan(b_cls)) {
|
||||
return floatx80_silence_nan(b, status);
|
||||
}
|
||||
|
@ -1067,7 +1085,7 @@ static float128 propagateFloat128NaN(float128 a, float128 b,
|
|||
aIsLargerSignificand = (a.high < b.high) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) {
|
||||
if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
|
||||
if (is_snan(b_cls)) {
|
||||
return float128_silence_nan(b, status);
|
||||
}
|
||||
|
|
|
@ -882,7 +882,7 @@ static FloatParts pick_nan(FloatParts a, FloatParts b, float_status *s)
|
|||
} else {
|
||||
if (pickNaN(a.cls, b.cls,
|
||||
a.frac > b.frac ||
|
||||
(a.frac == b.frac && a.sign < b.sign))) {
|
||||
(a.frac == b.frac && a.sign < b.sign), s)) {
|
||||
a = b;
|
||||
}
|
||||
if (is_snan(a.cls)) {
|
||||
|
|
|
@ -95,6 +95,11 @@ static inline void set_snan_bit_is_one(bool val, float_status *status)
|
|||
status->snan_bit_is_one = val;
|
||||
}
|
||||
|
||||
static inline void set_use_first_nan(bool val, float_status *status)
|
||||
{
|
||||
status->use_first_nan = val;
|
||||
}
|
||||
|
||||
static inline void set_no_signaling_nans(bool val, float_status *status)
|
||||
{
|
||||
status->no_signaling_nans = val;
|
||||
|
|
|
@ -171,6 +171,7 @@ typedef struct float_status {
|
|||
* softfloat-specialize.inc.c)
|
||||
*/
|
||||
bool snan_bit_is_one;
|
||||
bool use_first_nan;
|
||||
bool no_signaling_nans;
|
||||
} float_status;
|
||||
|
||||
|
|
Loading…
Reference in a new issue