remove SOFTFLOAT_ROUND_ODD rounding mode which not needed for x86 emu

This commit is contained in:
Stanislav Shwartsman 2024-03-10 20:36:18 +02:00
parent f31b115e20
commit 5a7224fc9f
18 changed files with 5 additions and 134 deletions

View File

@ -8,7 +8,7 @@ Detailed change log :
- CPU
- Integrated softfloat3e library replacing older softfloat2a fpu-emulation code
- Implemented AVX512_FP16 Intel instruction sets based on softfloat3e library (enabled in Xeon Sapphire Rapids CPU definition)
- Implemented AVX512_FP16 Intel instruction set based on softfloat3e library (enabled in Xeon Sapphire Rapids CPU definition)
- I/O Devices
- USB

View File

@ -110,10 +110,6 @@ extFloat80_t
case softfloat_round_max:
if (!signUI64) goto mag1;
break;
#ifdef SOFTFLOAT_ROUND_ODD
case softfloat_round_odd:
goto mag1;
#endif
}
uiZ64 = signUI64;
sigZ = 0;
@ -143,9 +139,6 @@ extFloat80_t
sigZ = UINT64_C(0x8000000000000000);
}
if (sigZ != sigA) {
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) sigZ |= lastBitMask;
#endif
if (exact) softfloat_raiseFlags(status, softfloat_flag_inexact);
}
uiZ:

View File

@ -115,11 +115,6 @@ float128_t
case softfloat_round_max:
if (!uiZ.v64) uiZ.v64 = packToF128UI64(0, 0x3FFF, 0);
break;
#ifdef SOFTFLOAT_ROUND_ODD
case softfloat_round_odd:
uiZ.v64 |= packToF128UI64(0, 0x3FFF, 0);
break;
#endif
}
goto uiZ;
}
@ -143,12 +138,6 @@ float128_t
lastBitMask0 = 0;
}
if ((uiZ.v64 != uiA64) || (uiZ.v0 != uiA0)) {
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) {
uiZ.v64 |= lastBitMask64;
uiZ.v0 |= lastBitMask0;
}
#endif
if (exact) softfloat_raiseFlags(status, softfloat_flag_inexact);
}
uiZ:

View File

@ -88,11 +88,6 @@ float16_t f16_roundToInt(float16_t a, uint8_t scale, uint8_t roundingMode, bool
case softfloat_round_max:
if (!uiZ) uiZ = packToF16UI(0, 0xF - scale, 0);
break;
#ifdef SOFTFLOAT_ROUND_ODD
case softfloat_round_odd:
uiZ |= packToF16UI(0, 0xF - scale, 0);
break;
#endif
}
return uiZ;
}
@ -111,9 +106,6 @@ float16_t f16_roundToInt(float16_t a, uint8_t scale, uint8_t roundingMode, bool
}
uiZ &= ~roundBitsMask;
if (uiZ != a) {
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) uiZ |= lastBitMask;
#endif
if (exact) softfloat_raiseFlags(status, softfloat_flag_inexact);
}
return uiZ;

View File

@ -88,11 +88,6 @@ float32_t f32_roundToInt(float32_t a, uint8_t scale, uint8_t roundingMode, bool
case softfloat_round_max:
if (!uiZ) uiZ = packToF32UI(0, 0x7F - scale, 0);
break;
#ifdef SOFTFLOAT_ROUND_ODD
case softfloat_round_odd:
uiZ |= packToF32UI(0, 0x7F - scale, 0);
break;
#endif
}
return uiZ;
}
@ -111,9 +106,6 @@ float32_t f32_roundToInt(float32_t a, uint8_t scale, uint8_t roundingMode, bool
}
uiZ &= ~roundBitsMask;
if (uiZ != a) {
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) uiZ |= lastBitMask;
#endif
if (exact) softfloat_raiseFlags(status, softfloat_flag_inexact);
}
return uiZ;

View File

@ -88,11 +88,6 @@ float64_t f64_roundToInt(float64_t a, uint8_t scale, uint8_t roundingMode, bool
case softfloat_round_max:
if (!uiZ) uiZ = packToF64UI(0, 0x3FF - scale, 0);
break;
#ifdef SOFTFLOAT_ROUND_ODD
case softfloat_round_odd:
uiZ |= packToF64UI(0, 0x3FF - scale, 0);
break;
#endif
}
return uiZ;
}
@ -111,9 +106,6 @@ float64_t f64_roundToInt(float64_t a, uint8_t scale, uint8_t roundingMode, bool
}
uiZ &= ~roundBitsMask;
if (uiZ != a) {
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) uiZ |= lastBitMask;
#endif
if (exact) softfloat_raiseFlags(status, softfloat_flag_inexact);
}
return uiZ;

View File

@ -78,8 +78,7 @@ struct softfloat_status_t
typedef struct softfloat_status_t float_status_t;
/*----------------------------------------------------------------------------
| Software floating-point rounding mode. (Mode "odd" is supported only if
| SoftFloat is compiled with macro 'SOFTFLOAT_ROUND_ODD' defined.)
| Software floating-point rounding mode.
*----------------------------------------------------------------------------*/
enum {
softfloat_round_near_even = 0,
@ -89,8 +88,7 @@ enum {
softfloat_round_up = softfloat_round_max,
softfloat_round_minMag = 3,
softfloat_round_to_zero = softfloat_round_minMag,
softfloat_round_near_maxMag = 4,
softfloat_round_odd = 6
softfloat_round_near_maxMag = 4
};
/*----------------------------------------------------------------------------

View File

@ -182,11 +182,6 @@ float16_t softfloat_addMagsF16(uint16_t uiA, uint16_t uiB, struct softfloat_stat
softfloat_raiseFlags(status, softfloat_flag_overflow | softfloat_flag_inexact);
}
}
#ifdef SOFTFLOAT_ROUND_ODD
else if (roundingMode == softfloat_round_odd) {
uiZ |= 1;
}
#endif
}
softfloat_raiseFlags(status, softfloat_flag_inexact);
return uiZ;

View File

@ -80,11 +80,6 @@ extFloat80_t
if (roundBits) {
if (isTiny) softfloat_raiseFlags(status, softfloat_flag_underflow);
softfloat_raiseFlags(status, softfloat_flag_inexact);
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) {
sig |= roundMask + 1;
}
#endif
}
sig += roundIncrement;
exp = ((sig & UINT64_C(0x8000000000000000)) != 0);
@ -103,12 +98,6 @@ extFloat80_t
*------------------------------------------------------------------------*/
if (roundBits) {
softfloat_raiseFlags(status, softfloat_flag_inexact);
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) {
sig = (sig & ~roundMask) | (roundMask + 1);
goto packReturn;
}
#endif
}
sig = (uint64_t) (sig + roundIncrement);
if (sig < roundIncrement) {
@ -143,12 +132,6 @@ extFloat80_t
if (sigExtra) {
if (isTiny) softfloat_raiseFlags(status, softfloat_flag_underflow);
softfloat_raiseFlags(status, softfloat_flag_inexact);
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) {
sig |= 1;
goto packReturn;
}
#endif
}
doIncrement = (UINT64_C(0x8000000000000000) <= sigExtra);
if (! roundNearEven && (roundingMode != softfloat_round_near_maxMag)) {
@ -185,12 +168,6 @@ extFloat80_t
*------------------------------------------------------------------------*/
if (sigExtra) {
softfloat_raiseFlags(status, softfloat_flag_inexact);
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) {
sig |= 1;
goto packReturn;
}
#endif
}
if (doIncrement) {
++sig;

View File

@ -111,12 +111,6 @@ float128_t
*------------------------------------------------------------------------*/
if (sigExtra) {
softfloat_raiseFlags(status, softfloat_flag_inexact);
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) {
sig0 |= 1;
goto packReturn;
}
#endif
}
if (doIncrement) {
sig128 = softfloat_add128(sig64, sig0, 0, 1);

View File

@ -92,12 +92,6 @@ float16_t
sig = (sig + roundIncrement)>>4;
if (roundBits) {
softfloat_raiseFlags(status, softfloat_flag_inexact);
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) {
sig |= 1;
goto packReturn;
}
#endif
}
sig &= ~(uint16_t) (! (roundBits ^ 8) & roundNearEven);
if (! sig) exp = 0;

View File

@ -96,12 +96,6 @@ float32_t
sig = (sig + roundIncrement)>>7;
if (roundBits) {
softfloat_raiseFlags(status, softfloat_flag_inexact);
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) {
sig |= 1;
goto packReturn;
}
#endif
}
sig &= ~(uint32_t) (! (roundBits ^ 0x40) & roundNearEven);
if (! sig) exp = 0;

View File

@ -96,12 +96,6 @@ float64_t
sig = (sig + roundIncrement)>>10;
if (roundBits) {
softfloat_raiseFlags(status, softfloat_flag_inexact);
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) {
sig |= 1;
goto packReturn;
}
#endif
}
sig &= ~(uint64_t) (! (roundBits ^ 0x200) & roundNearEven);
if (! sig) exp = 0;

View File

@ -51,12 +51,7 @@ int32_t softfloat_roundToI32(bool sign, uint64_t sig, uint8_t roundingMode, bool
roundIncrement = 0x800;
if ((roundingMode != softfloat_round_near_maxMag) && (roundingMode != softfloat_round_near_even)) {
roundIncrement = 0;
if (sign ? (roundingMode == softfloat_round_min)
#ifdef SOFTFLOAT_ROUND_ODD
|| (roundingMode == softfloat_round_odd)
#endif
: (roundingMode == softfloat_round_max)
) {
if (sign ? (roundingMode == softfloat_round_min) : (roundingMode == softfloat_round_max)) {
roundIncrement = 0xFFF;
}
}
@ -71,9 +66,6 @@ int32_t softfloat_roundToI32(bool sign, uint64_t sig, uint8_t roundingMode, bool
z = uZ.i;
if (z && ((z < 0) ^ sign)) goto invalid;
if (roundBits) {
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) z |= 1;
#endif
if (exact) softfloat_raiseFlags(status, softfloat_flag_inexact);
}
return z;

View File

@ -57,12 +57,7 @@ int64_t
if (UINT64_C(0x8000000000000000) <= sigExtra) goto increment;
} else {
if (sigExtra
&& (sign ? (roundingMode == softfloat_round_min)
#ifdef SOFTFLOAT_ROUND_ODD
|| (roundingMode == softfloat_round_odd)
#endif
: (roundingMode == softfloat_round_max))
) {
&& (sign ? (roundingMode == softfloat_round_min) : (roundingMode == softfloat_round_max))) {
increment:
++sig;
if (!sig) goto invalid;
@ -75,9 +70,6 @@ int64_t
z = uZ.i;
if (z && ((z < 0) ^ sign)) goto invalid;
if (sigExtra) {
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) z |= 1;
#endif
if (exact) softfloat_raiseFlags(status, softfloat_flag_inexact);
}
return z;

View File

@ -53,9 +53,6 @@ uint32_t
if (sign) {
if (!sig) return 0;
if (roundingMode == softfloat_round_min) goto invalid;
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) goto invalid;
#endif
} else {
if (roundingMode == softfloat_round_max) roundIncrement = 0xFFF;
}
@ -69,9 +66,6 @@ uint32_t
}
if (sign && z) goto invalid;
if (roundBits) {
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) z |= 1;
#endif
if (exact) softfloat_raiseFlags(status, softfloat_flag_inexact);
}
return z;

View File

@ -56,9 +56,6 @@ uint64_t
if (sign) {
if (!(sig | sigExtra)) return 0;
if (roundingMode == softfloat_round_min) goto invalid;
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) goto invalid;
#endif
} else {
if ((roundingMode == softfloat_round_max) && sigExtra) {
increment:
@ -72,9 +69,6 @@ uint64_t
}
if (sign && sig) goto invalid;
if (sigExtra) {
#ifdef SOFTFLOAT_ROUND_ODD
if (roundingMode == softfloat_round_odd) sig |= 1;
#endif
if (exact) softfloat_raiseFlags(status, softfloat_flag_inexact);
}
return sig;

View File

@ -180,11 +180,6 @@ float16_t softfloat_subMagsF16(uint16_t uiA, uint16_t uiB, struct softfloat_stat
|| (roundingMode == (signF16UI(uiZ) ? softfloat_round_max : softfloat_round_min))) {
--uiZ;
}
#ifdef SOFTFLOAT_ROUND_ODD
else if (roundingMode == softfloat_round_odd) {
uiZ = (uiZ - 1) | 1;
}
#endif
}
softfloat_raiseFlags(status, softfloat_flag_inexact);
return uiZ;