mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-fpu-20210603' into staging
Finish conversion of float128 and floatx80 to FloatParts.
Implement float128_muladd and float128_{min,max}*.
Optimize int-to-float conversion with hard-float.
# gpg: Signature made Thu 03 Jun 2021 22:13:10 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-gitlab/tags/pull-fpu-20210603: (29 commits)
softfloat: Use hard-float for {u}int64_to_float{32,64}
tests/fp: Enable more tests
softfloat: Convert modrem operations to FloatParts
softfloat: Move floatN_log2 to softfloat-parts.c.inc
softfloat: Convert float32_exp2 to FloatParts
softfloat: Convert floatx80 compare to FloatParts
softfloat: Convert floatx80_scalbn to FloatParts
softfloat: Convert floatx80 to integer to FloatParts
softfloat: Convert floatx80 float conversions to FloatParts
softfloat: Convert integer to floatx80 to FloatParts
softfloat: Convert floatx80_round_to_int to FloatParts
softfloat: Convert floatx80_round to FloatParts
softfloat: Convert floatx80_sqrt to FloatParts
softfloat: Convert floatx80_div to FloatParts
softfloat: Convert floatx80_mul to FloatParts
softfloat: Convert floatx80_add/sub to FloatParts
tests/fp/fp-test: Reverse order of floatx80 precision tests
softfloat: Adjust parts_uncanon_normal for floatx80
softfloat: Introduce Floatx80RoundPrec
softfloat: Reduce FloatFmt
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
+788
-115
File diff suppressed because it is too large
Load Diff
@@ -256,14 +256,6 @@ floatx80 floatx80_default_nan(float_status *status)
|
||||
const floatx80 floatx80_infinity
|
||||
= make_floatx80_init(floatx80_infinity_high, floatx80_infinity_low);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Internal canonical NaN format.
|
||||
*----------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
bool sign;
|
||||
uint64_t high, low;
|
||||
} commonNaNT;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns 1 if the half-precision floating-point value `a' is a quiet
|
||||
| NaN; otherwise returns 0.
|
||||
@@ -379,46 +371,6 @@ bool float32_is_signaling_nan(float32 a_, float_status *status)
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns the result of converting the single-precision floating-point NaN
|
||||
| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid
|
||||
| exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static commonNaNT float32ToCommonNaN(float32 a, float_status *status)
|
||||
{
|
||||
commonNaNT z;
|
||||
|
||||
if (float32_is_signaling_nan(a, status)) {
|
||||
float_raise(float_flag_invalid, status);
|
||||
}
|
||||
z.sign = float32_val(a) >> 31;
|
||||
z.low = 0;
|
||||
z.high = ((uint64_t)float32_val(a)) << 41;
|
||||
return z;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns the result of converting the canonical NaN `a' to the single-
|
||||
| precision floating-point format.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static float32 commonNaNToFloat32(commonNaNT a, float_status *status)
|
||||
{
|
||||
uint32_t mantissa = a.high >> 41;
|
||||
|
||||
if (status->default_nan_mode) {
|
||||
return float32_default_nan(status);
|
||||
}
|
||||
|
||||
if (mantissa) {
|
||||
return make_float32(
|
||||
(((uint32_t)a.sign) << 31) | 0x7F800000 | (a.high >> 41));
|
||||
} else {
|
||||
return float32_default_nan(status);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Select which NaN to propagate for a two-input operation.
|
||||
| IEEE754 doesn't specify all the details of this, so the
|
||||
@@ -689,62 +641,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
|
||||
#endif
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Takes two single-precision floating-point values `a' and `b', one of which
|
||||
| is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a
|
||||
| signaling NaN, the invalid exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static float32 propagateFloat32NaN(float32 a, float32 b, float_status *status)
|
||||
{
|
||||
bool aIsLargerSignificand;
|
||||
uint32_t av, bv;
|
||||
FloatClass a_cls, b_cls;
|
||||
|
||||
/* This is not complete, but is good enough for pickNaN. */
|
||||
a_cls = (!float32_is_any_nan(a)
|
||||
? float_class_normal
|
||||
: float32_is_signaling_nan(a, status)
|
||||
? float_class_snan
|
||||
: float_class_qnan);
|
||||
b_cls = (!float32_is_any_nan(b)
|
||||
? float_class_normal
|
||||
: float32_is_signaling_nan(b, status)
|
||||
? float_class_snan
|
||||
: float_class_qnan);
|
||||
|
||||
av = float32_val(a);
|
||||
bv = float32_val(b);
|
||||
|
||||
if (is_snan(a_cls) || is_snan(b_cls)) {
|
||||
float_raise(float_flag_invalid, status);
|
||||
}
|
||||
|
||||
if (status->default_nan_mode) {
|
||||
return float32_default_nan(status);
|
||||
}
|
||||
|
||||
if ((uint32_t)(av << 1) < (uint32_t)(bv << 1)) {
|
||||
aIsLargerSignificand = 0;
|
||||
} else if ((uint32_t)(bv << 1) < (uint32_t)(av << 1)) {
|
||||
aIsLargerSignificand = 1;
|
||||
} else {
|
||||
aIsLargerSignificand = (av < bv) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
|
||||
if (is_snan(b_cls)) {
|
||||
return float32_silence_nan(b, status);
|
||||
}
|
||||
return b;
|
||||
} else {
|
||||
if (is_snan(a_cls)) {
|
||||
return float32_silence_nan(a, status);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns 1 if the double-precision floating-point value `a' is a quiet
|
||||
| NaN; otherwise returns 0.
|
||||
@@ -785,104 +681,6 @@ bool float64_is_signaling_nan(float64 a_, float_status *status)
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns the result of converting the double-precision floating-point NaN
|
||||
| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid
|
||||
| exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static commonNaNT float64ToCommonNaN(float64 a, float_status *status)
|
||||
{
|
||||
commonNaNT z;
|
||||
|
||||
if (float64_is_signaling_nan(a, status)) {
|
||||
float_raise(float_flag_invalid, status);
|
||||
}
|
||||
z.sign = float64_val(a) >> 63;
|
||||
z.low = 0;
|
||||
z.high = float64_val(a) << 12;
|
||||
return z;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns the result of converting the canonical NaN `a' to the double-
|
||||
| precision floating-point format.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static float64 commonNaNToFloat64(commonNaNT a, float_status *status)
|
||||
{
|
||||
uint64_t mantissa = a.high >> 12;
|
||||
|
||||
if (status->default_nan_mode) {
|
||||
return float64_default_nan(status);
|
||||
}
|
||||
|
||||
if (mantissa) {
|
||||
return make_float64(
|
||||
(((uint64_t) a.sign) << 63)
|
||||
| UINT64_C(0x7FF0000000000000)
|
||||
| (a.high >> 12));
|
||||
} else {
|
||||
return float64_default_nan(status);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Takes two double-precision floating-point values `a' and `b', one of which
|
||||
| is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a
|
||||
| signaling NaN, the invalid exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static float64 propagateFloat64NaN(float64 a, float64 b, float_status *status)
|
||||
{
|
||||
bool aIsLargerSignificand;
|
||||
uint64_t av, bv;
|
||||
FloatClass a_cls, b_cls;
|
||||
|
||||
/* This is not complete, but is good enough for pickNaN. */
|
||||
a_cls = (!float64_is_any_nan(a)
|
||||
? float_class_normal
|
||||
: float64_is_signaling_nan(a, status)
|
||||
? float_class_snan
|
||||
: float_class_qnan);
|
||||
b_cls = (!float64_is_any_nan(b)
|
||||
? float_class_normal
|
||||
: float64_is_signaling_nan(b, status)
|
||||
? float_class_snan
|
||||
: float_class_qnan);
|
||||
|
||||
av = float64_val(a);
|
||||
bv = float64_val(b);
|
||||
|
||||
if (is_snan(a_cls) || is_snan(b_cls)) {
|
||||
float_raise(float_flag_invalid, status);
|
||||
}
|
||||
|
||||
if (status->default_nan_mode) {
|
||||
return float64_default_nan(status);
|
||||
}
|
||||
|
||||
if ((uint64_t)(av << 1) < (uint64_t)(bv << 1)) {
|
||||
aIsLargerSignificand = 0;
|
||||
} else if ((uint64_t)(bv << 1) < (uint64_t)(av << 1)) {
|
||||
aIsLargerSignificand = 1;
|
||||
} else {
|
||||
aIsLargerSignificand = (av < bv) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
|
||||
if (is_snan(b_cls)) {
|
||||
return float64_silence_nan(b, status);
|
||||
}
|
||||
return b;
|
||||
} else {
|
||||
if (is_snan(a_cls)) {
|
||||
return float64_silence_nan(a, status);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns 1 if the extended double-precision floating-point value `a' is a
|
||||
| quiet NaN; otherwise returns 0. This slightly differs from the same
|
||||
@@ -946,55 +744,6 @@ floatx80 floatx80_silence_nan(floatx80 a, float_status *status)
|
||||
return a;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns the result of converting the extended double-precision floating-
|
||||
| point NaN `a' to the canonical NaN format. If `a' is a signaling NaN, the
|
||||
| invalid exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static commonNaNT floatx80ToCommonNaN(floatx80 a, float_status *status)
|
||||
{
|
||||
floatx80 dflt;
|
||||
commonNaNT z;
|
||||
|
||||
if (floatx80_is_signaling_nan(a, status)) {
|
||||
float_raise(float_flag_invalid, status);
|
||||
}
|
||||
if (a.low >> 63) {
|
||||
z.sign = a.high >> 15;
|
||||
z.low = 0;
|
||||
z.high = a.low << 1;
|
||||
} else {
|
||||
dflt = floatx80_default_nan(status);
|
||||
z.sign = dflt.high >> 15;
|
||||
z.low = 0;
|
||||
z.high = dflt.low << 1;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns the result of converting the canonical NaN `a' to the extended
|
||||
| double-precision floating-point format.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static floatx80 commonNaNToFloatx80(commonNaNT a, float_status *status)
|
||||
{
|
||||
floatx80 z;
|
||||
|
||||
if (status->default_nan_mode) {
|
||||
return floatx80_default_nan(status);
|
||||
}
|
||||
|
||||
if (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);
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Takes two extended double-precision floating-point values `a' and `b', one
|
||||
| of which is a NaN, and returns the appropriate NaN result. If either `a' or
|
||||
@@ -1086,92 +835,3 @@ bool float128_is_signaling_nan(float128 a, float_status *status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns the result of converting the quadruple-precision floating-point NaN
|
||||
| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid
|
||||
| exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static commonNaNT float128ToCommonNaN(float128 a, float_status *status)
|
||||
{
|
||||
commonNaNT z;
|
||||
|
||||
if (float128_is_signaling_nan(a, status)) {
|
||||
float_raise(float_flag_invalid, status);
|
||||
}
|
||||
z.sign = a.high >> 63;
|
||||
shortShift128Left(a.high, a.low, 16, &z.high, &z.low);
|
||||
return z;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns the result of converting the canonical NaN `a' to the quadruple-
|
||||
| precision floating-point format.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static float128 commonNaNToFloat128(commonNaNT a, float_status *status)
|
||||
{
|
||||
float128 z;
|
||||
|
||||
if (status->default_nan_mode) {
|
||||
return float128_default_nan(status);
|
||||
}
|
||||
|
||||
shift128Right(a.high, a.low, 16, &z.high, &z.low);
|
||||
z.high |= (((uint64_t)a.sign) << 63) | UINT64_C(0x7FFF000000000000);
|
||||
return z;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Takes two quadruple-precision floating-point values `a' and `b', one of
|
||||
| which is a NaN, and returns the appropriate NaN result. If either `a' or
|
||||
| `b' is a signaling NaN, the invalid exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
static float128 propagateFloat128NaN(float128 a, float128 b,
|
||||
float_status *status)
|
||||
{
|
||||
bool aIsLargerSignificand;
|
||||
FloatClass a_cls, b_cls;
|
||||
|
||||
/* This is not complete, but is good enough for pickNaN. */
|
||||
a_cls = (!float128_is_any_nan(a)
|
||||
? float_class_normal
|
||||
: float128_is_signaling_nan(a, status)
|
||||
? float_class_snan
|
||||
: float_class_qnan);
|
||||
b_cls = (!float128_is_any_nan(b)
|
||||
? float_class_normal
|
||||
: float128_is_signaling_nan(b, status)
|
||||
? float_class_snan
|
||||
: float_class_qnan);
|
||||
|
||||
if (is_snan(a_cls) || is_snan(b_cls)) {
|
||||
float_raise(float_flag_invalid, status);
|
||||
}
|
||||
|
||||
if (status->default_nan_mode) {
|
||||
return float128_default_nan(status);
|
||||
}
|
||||
|
||||
if (lt128(a.high << 1, a.low, b.high << 1, b.low)) {
|
||||
aIsLargerSignificand = 0;
|
||||
} else if (lt128(b.high << 1, b.low, a.high << 1, a.low)) {
|
||||
aIsLargerSignificand = 1;
|
||||
} else {
|
||||
aIsLargerSignificand = (a.high < b.high) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
|
||||
if (is_snan(b_cls)) {
|
||||
return float128_silence_nan(b, status);
|
||||
}
|
||||
return b;
|
||||
} else {
|
||||
if (is_snan(a_cls)) {
|
||||
return float128_silence_nan(a, status);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
+1117
-3312
File diff suppressed because it is too large
Load Diff
@@ -69,7 +69,7 @@ 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,
|
||||
static inline void set_floatx80_rounding_precision(FloatX80RoundPrec val,
|
||||
float_status *status)
|
||||
{
|
||||
status->floatx80_rounding_precision = val;
|
||||
@@ -120,7 +120,8 @@ 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)
|
||||
static inline FloatX80RoundPrec
|
||||
get_floatx80_rounding_precision(float_status *status)
|
||||
{
|
||||
return status->floatx80_rounding_precision;
|
||||
}
|
||||
|
||||
@@ -745,4 +745,38 @@ static inline bool ne128(uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1)
|
||||
return a0 != b0 || a1 != b1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Similarly, comparisons of 192-bit values.
|
||||
*/
|
||||
|
||||
static inline bool eq192(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t b0, uint64_t b1, uint64_t b2)
|
||||
{
|
||||
return ((a0 ^ b0) | (a1 ^ b1) | (a2 ^ b2)) == 0;
|
||||
}
|
||||
|
||||
static inline bool le192(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t b0, uint64_t b1, uint64_t b2)
|
||||
{
|
||||
if (a0 != b0) {
|
||||
return a0 < b0;
|
||||
}
|
||||
if (a1 != b1) {
|
||||
return a1 < b1;
|
||||
}
|
||||
return a2 <= b2;
|
||||
}
|
||||
|
||||
static inline bool lt192(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t b0, uint64_t b1, uint64_t b2)
|
||||
{
|
||||
if (a0 != b0) {
|
||||
return a0 < b0;
|
||||
}
|
||||
if (a1 != b1) {
|
||||
return a1 < b1;
|
||||
}
|
||||
return a2 < b2;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -154,6 +154,14 @@ enum {
|
||||
float_flag_output_denormal = 128
|
||||
};
|
||||
|
||||
/*
|
||||
* Rounding precision for floatx80.
|
||||
*/
|
||||
typedef enum __attribute__((__packed__)) {
|
||||
floatx80_precision_x,
|
||||
floatx80_precision_d,
|
||||
floatx80_precision_s,
|
||||
} FloatX80RoundPrec;
|
||||
|
||||
/*
|
||||
* Floating Point Status. Individual architectures may maintain
|
||||
@@ -165,7 +173,7 @@ enum {
|
||||
typedef struct float_status {
|
||||
FloatRoundMode float_rounding_mode;
|
||||
uint8_t float_exception_flags;
|
||||
signed char floatx80_rounding_precision;
|
||||
FloatX80RoundPrec floatx80_rounding_precision;
|
||||
bool tininess_before_rounding;
|
||||
/* should denormalised results go to zero and set the inexact flag? */
|
||||
bool flush_to_zero;
|
||||
|
||||
@@ -1152,7 +1152,7 @@ floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status);
|
||||
| Floating-Point Arithmetic.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
floatx80 roundAndPackFloatx80(int8_t roundingPrecision, bool zSign,
|
||||
floatx80 roundAndPackFloatx80(FloatX80RoundPrec roundingPrecision, bool zSign,
|
||||
int32_t zExp, uint64_t zSig0, uint64_t zSig1,
|
||||
float_status *status);
|
||||
|
||||
@@ -1165,7 +1165,7 @@ floatx80 roundAndPackFloatx80(int8_t roundingPrecision, bool zSign,
|
||||
| normalized.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
floatx80 normalizeRoundAndPackFloatx80(int8_t roundingPrecision,
|
||||
floatx80 normalizeRoundAndPackFloatx80(FloatX80RoundPrec roundingPrecision,
|
||||
bool zSign, int32_t zExp,
|
||||
uint64_t zSig0, uint64_t zSig1,
|
||||
float_status *status);
|
||||
@@ -1204,6 +1204,12 @@ float128 float128_rem(float128, float128, float_status *status);
|
||||
float128 float128_sqrt(float128, float_status *status);
|
||||
FloatRelation float128_compare(float128, float128, float_status *status);
|
||||
FloatRelation float128_compare_quiet(float128, float128, float_status *status);
|
||||
float128 float128_min(float128, float128, float_status *status);
|
||||
float128 float128_max(float128, float128, float_status *status);
|
||||
float128 float128_minnum(float128, float128, float_status *status);
|
||||
float128 float128_maxnum(float128, float128, float_status *status);
|
||||
float128 float128_minnummag(float128, float128, float_status *status);
|
||||
float128 float128_maxnummag(float128, float128, float_status *status);
|
||||
bool float128_is_quiet_nan(float128, float_status *status);
|
||||
bool float128_is_signaling_nan(float128, float_status *status);
|
||||
float128 float128_silence_nan(float128, float_status *status);
|
||||
|
||||
@@ -97,37 +97,38 @@ void SetRoundingMode(const unsigned int opcode)
|
||||
|
||||
void SetRoundingPrecision(const unsigned int opcode)
|
||||
{
|
||||
int rounding_precision;
|
||||
FPA11 *fpa11 = GET_FPA11();
|
||||
FloatX80RoundPrec rounding_precision;
|
||||
FPA11 *fpa11 = GET_FPA11();
|
||||
#ifdef MAINTAIN_FPCR
|
||||
fpa11->fpcr &= ~MASK_ROUNDING_PRECISION;
|
||||
fpa11->fpcr &= ~MASK_ROUNDING_PRECISION;
|
||||
#endif
|
||||
switch (opcode & MASK_ROUNDING_PRECISION)
|
||||
{
|
||||
case ROUND_SINGLE:
|
||||
rounding_precision = 32;
|
||||
switch (opcode & MASK_ROUNDING_PRECISION) {
|
||||
case ROUND_SINGLE:
|
||||
rounding_precision = floatx80_precision_s;
|
||||
#ifdef MAINTAIN_FPCR
|
||||
fpa11->fpcr |= ROUND_SINGLE;
|
||||
fpa11->fpcr |= ROUND_SINGLE;
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
case ROUND_DOUBLE:
|
||||
rounding_precision = 64;
|
||||
case ROUND_DOUBLE:
|
||||
rounding_precision = floatx80_precision_d;
|
||||
#ifdef MAINTAIN_FPCR
|
||||
fpa11->fpcr |= ROUND_DOUBLE;
|
||||
fpa11->fpcr |= ROUND_DOUBLE;
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
case ROUND_EXTENDED:
|
||||
rounding_precision = 80;
|
||||
case ROUND_EXTENDED:
|
||||
rounding_precision = floatx80_precision_x;
|
||||
#ifdef MAINTAIN_FPCR
|
||||
fpa11->fpcr |= ROUND_EXTENDED;
|
||||
fpa11->fpcr |= ROUND_EXTENDED;
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
default: rounding_precision = 80;
|
||||
}
|
||||
set_floatx80_rounding_precision(rounding_precision, &fpa11->fp_status);
|
||||
default:
|
||||
rounding_precision = floatx80_precision_x;
|
||||
break;
|
||||
}
|
||||
set_floatx80_rounding_precision(rounding_precision, &fpa11->fp_status);
|
||||
}
|
||||
|
||||
/* Emulate the instruction in the opcode. */
|
||||
|
||||
@@ -673,38 +673,40 @@ uint32_t helper_fnstcw(CPUX86State *env)
|
||||
|
||||
void update_fp_status(CPUX86State *env)
|
||||
{
|
||||
int rnd_type;
|
||||
FloatRoundMode rnd_mode;
|
||||
FloatX80RoundPrec rnd_prec;
|
||||
|
||||
/* set rounding mode */
|
||||
switch (env->fpuc & FPU_RC_MASK) {
|
||||
default:
|
||||
case FPU_RC_NEAR:
|
||||
rnd_type = float_round_nearest_even;
|
||||
rnd_mode = float_round_nearest_even;
|
||||
break;
|
||||
case FPU_RC_DOWN:
|
||||
rnd_type = float_round_down;
|
||||
rnd_mode = float_round_down;
|
||||
break;
|
||||
case FPU_RC_UP:
|
||||
rnd_type = float_round_up;
|
||||
rnd_mode = float_round_up;
|
||||
break;
|
||||
case FPU_RC_CHOP:
|
||||
rnd_type = float_round_to_zero;
|
||||
rnd_mode = float_round_to_zero;
|
||||
break;
|
||||
}
|
||||
set_float_rounding_mode(rnd_type, &env->fp_status);
|
||||
set_float_rounding_mode(rnd_mode, &env->fp_status);
|
||||
|
||||
switch ((env->fpuc >> 8) & 3) {
|
||||
case 0:
|
||||
rnd_type = 32;
|
||||
rnd_prec = floatx80_precision_s;
|
||||
break;
|
||||
case 2:
|
||||
rnd_type = 64;
|
||||
rnd_prec = floatx80_precision_d;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
rnd_type = 80;
|
||||
rnd_prec = floatx80_precision_x;
|
||||
break;
|
||||
}
|
||||
set_floatx80_rounding_precision(rnd_type, &env->fp_status);
|
||||
set_floatx80_rounding_precision(rnd_prec, &env->fp_status);
|
||||
}
|
||||
|
||||
void helper_fldcw(CPUX86State *env, uint32_t val)
|
||||
@@ -1074,7 +1076,8 @@ void helper_f2xm1(CPUX86State *env)
|
||||
&sig2);
|
||||
/* This result is inexact. */
|
||||
sig1 |= 1;
|
||||
ST0 = normalizeRoundAndPackFloatx80(80, sign, exp, sig0, sig1,
|
||||
ST0 = normalizeRoundAndPackFloatx80(floatx80_precision_x,
|
||||
sign, exp, sig0, sig1,
|
||||
&env->fp_status);
|
||||
}
|
||||
} else {
|
||||
@@ -1083,9 +1086,10 @@ void helper_f2xm1(CPUX86State *env)
|
||||
int32_t n, aexp, bexp;
|
||||
uint64_t asig0, asig1, asig2, bsig0, bsig1;
|
||||
FloatRoundMode save_mode = env->fp_status.float_rounding_mode;
|
||||
signed char save_prec = env->fp_status.floatx80_rounding_precision;
|
||||
FloatX80RoundPrec save_prec =
|
||||
env->fp_status.floatx80_rounding_precision;
|
||||
env->fp_status.float_rounding_mode = float_round_nearest_even;
|
||||
env->fp_status.floatx80_rounding_precision = 80;
|
||||
env->fp_status.floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
/* Find the nearest multiple of 1/32 to the argument. */
|
||||
tmp = floatx80_scalbn(ST0, 5, &env->fp_status);
|
||||
@@ -1183,7 +1187,8 @@ void helper_f2xm1(CPUX86State *env)
|
||||
env->fp_status.float_rounding_mode = save_mode;
|
||||
/* This result is inexact. */
|
||||
asig1 |= 1;
|
||||
ST0 = normalizeRoundAndPackFloatx80(80, asign, aexp, asig0, asig1,
|
||||
ST0 = normalizeRoundAndPackFloatx80(floatx80_precision_x,
|
||||
asign, aexp, asig0, asig1,
|
||||
&env->fp_status);
|
||||
}
|
||||
|
||||
@@ -1301,8 +1306,9 @@ void helper_fpatan(CPUX86State *env)
|
||||
* division is exact, the result of fpatan is still inexact
|
||||
* (and underflowing where appropriate).
|
||||
*/
|
||||
signed char save_prec = env->fp_status.floatx80_rounding_precision;
|
||||
env->fp_status.floatx80_rounding_precision = 80;
|
||||
FloatX80RoundPrec save_prec =
|
||||
env->fp_status.floatx80_rounding_precision;
|
||||
env->fp_status.floatx80_rounding_precision = floatx80_precision_x;
|
||||
ST1 = floatx80_div(ST1, ST0, &env->fp_status);
|
||||
env->fp_status.floatx80_rounding_precision = save_prec;
|
||||
if (!floatx80_is_zero(ST1) &&
|
||||
@@ -1321,7 +1327,8 @@ void helper_fpatan(CPUX86State *env)
|
||||
if (exp == 0) {
|
||||
normalizeFloatx80Subnormal(sig, &exp, &sig);
|
||||
}
|
||||
ST1 = normalizeRoundAndPackFloatx80(80, sign, exp, sig - 1,
|
||||
ST1 = normalizeRoundAndPackFloatx80(floatx80_precision_x,
|
||||
sign, exp, sig - 1,
|
||||
-1, &env->fp_status);
|
||||
}
|
||||
} else {
|
||||
@@ -1377,9 +1384,10 @@ void helper_fpatan(CPUX86State *env)
|
||||
uint64_t azsig2, azsig3, axsig0, axsig1;
|
||||
floatx80 x8;
|
||||
FloatRoundMode save_mode = env->fp_status.float_rounding_mode;
|
||||
signed char save_prec = env->fp_status.floatx80_rounding_precision;
|
||||
FloatX80RoundPrec save_prec =
|
||||
env->fp_status.floatx80_rounding_precision;
|
||||
env->fp_status.float_rounding_mode = float_round_nearest_even;
|
||||
env->fp_status.floatx80_rounding_precision = 80;
|
||||
env->fp_status.floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
if (arg0_exp == 0) {
|
||||
normalizeFloatx80Subnormal(arg0_sig, &arg0_exp, &arg0_sig);
|
||||
@@ -1448,7 +1456,8 @@ void helper_fpatan(CPUX86State *env)
|
||||
* Split x as x = t + y, where t = n/8 is the nearest
|
||||
* multiple of 1/8 to x.
|
||||
*/
|
||||
x8 = normalizeRoundAndPackFloatx80(80, false, xexp + 3, xsig0,
|
||||
x8 = normalizeRoundAndPackFloatx80(floatx80_precision_x,
|
||||
false, xexp + 3, xsig0,
|
||||
xsig1, &env->fp_status);
|
||||
n = floatx80_to_int32(x8, &env->fp_status);
|
||||
if (n == 0) {
|
||||
@@ -1569,7 +1578,7 @@ void helper_fpatan(CPUX86State *env)
|
||||
/* Compute z^2. */
|
||||
mul128To256(zsig0, zsig1, zsig0, zsig1,
|
||||
&z2sig0, &z2sig1, &z2sig2, &z2sig3);
|
||||
z2 = normalizeRoundAndPackFloatx80(80, false,
|
||||
z2 = normalizeRoundAndPackFloatx80(floatx80_precision_x, false,
|
||||
zexp + zexp - 0x3ffe,
|
||||
z2sig0, z2sig1,
|
||||
&env->fp_status);
|
||||
@@ -1689,7 +1698,7 @@ void helper_fpatan(CPUX86State *env)
|
||||
}
|
||||
/* This result is inexact. */
|
||||
rsig1 |= 1;
|
||||
ST1 = normalizeRoundAndPackFloatx80(80, rsign, rexp,
|
||||
ST1 = normalizeRoundAndPackFloatx80(floatx80_precision_x, rsign, rexp,
|
||||
rsig0, rsig1, &env->fp_status);
|
||||
}
|
||||
|
||||
@@ -1890,7 +1899,8 @@ static void helper_fyl2x_common(CPUX86State *env, floatx80 arg, int32_t *exp,
|
||||
*/
|
||||
mul128To256(tsig0, tsig1, tsig0, tsig1,
|
||||
&t2sig0, &t2sig1, &t2sig2, &t2sig3);
|
||||
t2 = normalizeRoundAndPackFloatx80(80, false, texp + texp - 0x3ffe,
|
||||
t2 = normalizeRoundAndPackFloatx80(floatx80_precision_x, false,
|
||||
texp + texp - 0x3ffe,
|
||||
t2sig0, t2sig1, &env->fp_status);
|
||||
|
||||
/* Compute the lower parts of the polynomial expansion. */
|
||||
@@ -2004,15 +2014,17 @@ void helper_fyl2xp1(CPUX86State *env)
|
||||
exp += arg1_exp - 0x3ffe;
|
||||
/* This result is inexact. */
|
||||
sig1 |= 1;
|
||||
ST1 = normalizeRoundAndPackFloatx80(80, arg0_sign ^ arg1_sign, exp,
|
||||
ST1 = normalizeRoundAndPackFloatx80(floatx80_precision_x,
|
||||
arg0_sign ^ arg1_sign, exp,
|
||||
sig0, sig1, &env->fp_status);
|
||||
} else {
|
||||
int32_t aexp;
|
||||
uint64_t asig0, asig1, asig2;
|
||||
FloatRoundMode save_mode = env->fp_status.float_rounding_mode;
|
||||
signed char save_prec = env->fp_status.floatx80_rounding_precision;
|
||||
FloatX80RoundPrec save_prec =
|
||||
env->fp_status.floatx80_rounding_precision;
|
||||
env->fp_status.float_rounding_mode = float_round_nearest_even;
|
||||
env->fp_status.floatx80_rounding_precision = 80;
|
||||
env->fp_status.floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
helper_fyl2x_common(env, ST0, &aexp, &asig0, &asig1);
|
||||
/*
|
||||
@@ -2027,7 +2039,8 @@ void helper_fyl2xp1(CPUX86State *env)
|
||||
/* This result is inexact. */
|
||||
asig1 |= 1;
|
||||
env->fp_status.float_rounding_mode = save_mode;
|
||||
ST1 = normalizeRoundAndPackFloatx80(80, arg0_sign ^ arg1_sign, aexp,
|
||||
ST1 = normalizeRoundAndPackFloatx80(floatx80_precision_x,
|
||||
arg0_sign ^ arg1_sign, aexp,
|
||||
asig0, asig1, &env->fp_status);
|
||||
env->fp_status.floatx80_rounding_precision = save_prec;
|
||||
}
|
||||
@@ -2111,9 +2124,10 @@ void helper_fyl2x(CPUX86State *env)
|
||||
int32_t int_exp;
|
||||
floatx80 arg0_m1;
|
||||
FloatRoundMode save_mode = env->fp_status.float_rounding_mode;
|
||||
signed char save_prec = env->fp_status.floatx80_rounding_precision;
|
||||
FloatX80RoundPrec save_prec =
|
||||
env->fp_status.floatx80_rounding_precision;
|
||||
env->fp_status.float_rounding_mode = float_round_nearest_even;
|
||||
env->fp_status.floatx80_rounding_precision = 80;
|
||||
env->fp_status.floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
if (arg0_exp == 0) {
|
||||
normalizeFloatx80Subnormal(arg0_sig, &arg0_exp, &arg0_sig);
|
||||
@@ -2170,7 +2184,8 @@ void helper_fyl2x(CPUX86State *env)
|
||||
/* This result is inexact. */
|
||||
asig1 |= 1;
|
||||
env->fp_status.float_rounding_mode = save_mode;
|
||||
ST1 = normalizeRoundAndPackFloatx80(80, asign ^ arg1_sign, aexp,
|
||||
ST1 = normalizeRoundAndPackFloatx80(floatx80_precision_x,
|
||||
asign ^ arg1_sign, aexp,
|
||||
asig0, asig1, &env->fp_status);
|
||||
}
|
||||
|
||||
@@ -2252,12 +2267,12 @@ void helper_fscale(CPUX86State *env)
|
||||
}
|
||||
} else {
|
||||
int n;
|
||||
signed char save = env->fp_status.floatx80_rounding_precision;
|
||||
FloatX80RoundPrec save = env->fp_status.floatx80_rounding_precision;
|
||||
uint8_t save_flags = get_float_exception_flags(&env->fp_status);
|
||||
set_float_exception_flags(0, &env->fp_status);
|
||||
n = floatx80_to_int32_round_to_zero(ST1, &env->fp_status);
|
||||
set_float_exception_flags(save_flags, &env->fp_status);
|
||||
env->fp_status.floatx80_rounding_precision = 80;
|
||||
env->fp_status.floatx80_rounding_precision = floatx80_precision_x;
|
||||
ST0 = floatx80_scalbn(ST0, n, &env->fp_status);
|
||||
env->fp_status.floatx80_rounding_precision = save;
|
||||
}
|
||||
|
||||
+25
-25
@@ -94,13 +94,13 @@ static void m68k_restore_precision_mode(CPUM68KState *env)
|
||||
{
|
||||
switch (env->fpcr & FPCR_PREC_MASK) {
|
||||
case FPCR_PREC_X: /* extended */
|
||||
set_floatx80_rounding_precision(80, &env->fp_status);
|
||||
set_floatx80_rounding_precision(floatx80_precision_x, &env->fp_status);
|
||||
break;
|
||||
case FPCR_PREC_S: /* single */
|
||||
set_floatx80_rounding_precision(32, &env->fp_status);
|
||||
set_floatx80_rounding_precision(floatx80_precision_s, &env->fp_status);
|
||||
break;
|
||||
case FPCR_PREC_D: /* double */
|
||||
set_floatx80_rounding_precision(64, &env->fp_status);
|
||||
set_floatx80_rounding_precision(floatx80_precision_d, &env->fp_status);
|
||||
break;
|
||||
case FPCR_PREC_U: /* undefined */
|
||||
default:
|
||||
@@ -111,9 +111,9 @@ static void m68k_restore_precision_mode(CPUM68KState *env)
|
||||
static void cf_restore_precision_mode(CPUM68KState *env)
|
||||
{
|
||||
if (env->fpcr & FPCR_PREC_S) { /* single */
|
||||
set_floatx80_rounding_precision(32, &env->fp_status);
|
||||
set_floatx80_rounding_precision(floatx80_precision_s, &env->fp_status);
|
||||
} else { /* double */
|
||||
set_floatx80_rounding_precision(64, &env->fp_status);
|
||||
set_floatx80_rounding_precision(floatx80_precision_d, &env->fp_status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,8 +166,8 @@ void HELPER(set_fpcr)(CPUM68KState *env, uint32_t val)
|
||||
|
||||
#define PREC_BEGIN(prec) \
|
||||
do { \
|
||||
int old; \
|
||||
old = get_floatx80_rounding_precision(&env->fp_status); \
|
||||
FloatX80RoundPrec old = \
|
||||
get_floatx80_rounding_precision(&env->fp_status); \
|
||||
set_floatx80_rounding_precision(prec, &env->fp_status) \
|
||||
|
||||
#define PREC_END() \
|
||||
@@ -176,14 +176,14 @@ void HELPER(set_fpcr)(CPUM68KState *env, uint32_t val)
|
||||
|
||||
void HELPER(fsround)(CPUM68KState *env, FPReg *res, FPReg *val)
|
||||
{
|
||||
PREC_BEGIN(32);
|
||||
PREC_BEGIN(floatx80_precision_s);
|
||||
res->d = floatx80_round(val->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
|
||||
void HELPER(fdround)(CPUM68KState *env, FPReg *res, FPReg *val)
|
||||
{
|
||||
PREC_BEGIN(64);
|
||||
PREC_BEGIN(floatx80_precision_d);
|
||||
res->d = floatx80_round(val->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
@@ -195,14 +195,14 @@ void HELPER(fsqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
|
||||
|
||||
void HELPER(fssqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
|
||||
{
|
||||
PREC_BEGIN(32);
|
||||
PREC_BEGIN(floatx80_precision_s);
|
||||
res->d = floatx80_sqrt(val->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
|
||||
void HELPER(fdsqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
|
||||
{
|
||||
PREC_BEGIN(64);
|
||||
PREC_BEGIN(floatx80_precision_d);
|
||||
res->d = floatx80_sqrt(val->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
@@ -214,14 +214,14 @@ void HELPER(fabs)(CPUM68KState *env, FPReg *res, FPReg *val)
|
||||
|
||||
void HELPER(fsabs)(CPUM68KState *env, FPReg *res, FPReg *val)
|
||||
{
|
||||
PREC_BEGIN(32);
|
||||
PREC_BEGIN(floatx80_precision_s);
|
||||
res->d = floatx80_round(floatx80_abs(val->d), &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
|
||||
void HELPER(fdabs)(CPUM68KState *env, FPReg *res, FPReg *val)
|
||||
{
|
||||
PREC_BEGIN(64);
|
||||
PREC_BEGIN(floatx80_precision_d);
|
||||
res->d = floatx80_round(floatx80_abs(val->d), &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
@@ -233,14 +233,14 @@ void HELPER(fneg)(CPUM68KState *env, FPReg *res, FPReg *val)
|
||||
|
||||
void HELPER(fsneg)(CPUM68KState *env, FPReg *res, FPReg *val)
|
||||
{
|
||||
PREC_BEGIN(32);
|
||||
PREC_BEGIN(floatx80_precision_s);
|
||||
res->d = floatx80_round(floatx80_chs(val->d), &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
|
||||
void HELPER(fdneg)(CPUM68KState *env, FPReg *res, FPReg *val)
|
||||
{
|
||||
PREC_BEGIN(64);
|
||||
PREC_BEGIN(floatx80_precision_d);
|
||||
res->d = floatx80_round(floatx80_chs(val->d), &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
@@ -252,14 +252,14 @@ void HELPER(fadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
|
||||
void HELPER(fsadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
{
|
||||
PREC_BEGIN(32);
|
||||
PREC_BEGIN(floatx80_precision_s);
|
||||
res->d = floatx80_add(val0->d, val1->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
|
||||
void HELPER(fdadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
{
|
||||
PREC_BEGIN(64);
|
||||
PREC_BEGIN(floatx80_precision_d);
|
||||
res->d = floatx80_add(val0->d, val1->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
@@ -271,14 +271,14 @@ void HELPER(fsub)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
|
||||
void HELPER(fssub)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
{
|
||||
PREC_BEGIN(32);
|
||||
PREC_BEGIN(floatx80_precision_s);
|
||||
res->d = floatx80_sub(val1->d, val0->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
|
||||
void HELPER(fdsub)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
{
|
||||
PREC_BEGIN(64);
|
||||
PREC_BEGIN(floatx80_precision_d);
|
||||
res->d = floatx80_sub(val1->d, val0->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
@@ -290,14 +290,14 @@ void HELPER(fmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
|
||||
void HELPER(fsmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
{
|
||||
PREC_BEGIN(32);
|
||||
PREC_BEGIN(floatx80_precision_s);
|
||||
res->d = floatx80_mul(val0->d, val1->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
|
||||
void HELPER(fdmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
{
|
||||
PREC_BEGIN(64);
|
||||
PREC_BEGIN(floatx80_precision_d);
|
||||
res->d = floatx80_mul(val0->d, val1->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
@@ -307,7 +307,7 @@ void HELPER(fsglmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
FloatRoundMode rounding_mode = get_float_rounding_mode(&env->fp_status);
|
||||
floatx80 a, b;
|
||||
|
||||
PREC_BEGIN(32);
|
||||
PREC_BEGIN(floatx80_precision_s);
|
||||
set_float_rounding_mode(float_round_to_zero, &env->fp_status);
|
||||
a = floatx80_round(val0->d, &env->fp_status);
|
||||
b = floatx80_round(val1->d, &env->fp_status);
|
||||
@@ -323,14 +323,14 @@ void HELPER(fdiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
|
||||
void HELPER(fsdiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
{
|
||||
PREC_BEGIN(32);
|
||||
PREC_BEGIN(floatx80_precision_s);
|
||||
res->d = floatx80_div(val1->d, val0->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
|
||||
void HELPER(fddiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
{
|
||||
PREC_BEGIN(64);
|
||||
PREC_BEGIN(floatx80_precision_d);
|
||||
res->d = floatx80_div(val1->d, val0->d, &env->fp_status);
|
||||
PREC_END();
|
||||
}
|
||||
@@ -340,7 +340,7 @@ void HELPER(fsgldiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
|
||||
FloatRoundMode rounding_mode = get_float_rounding_mode(&env->fp_status);
|
||||
floatx80 a, b;
|
||||
|
||||
PREC_BEGIN(32);
|
||||
PREC_BEGIN(floatx80_precision_s);
|
||||
set_float_rounding_mode(float_round_to_zero, &env->fp_status);
|
||||
a = floatx80_round(val1->d, &env->fp_status);
|
||||
b = floatx80_round(val0->d, &env->fp_status);
|
||||
|
||||
+54
-36
@@ -227,7 +227,8 @@ floatx80 floatx80_lognp1(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig, fSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact, j, k;
|
||||
floatx80 fp0, fp1, fp2, fp3, f, logof2, klog2, saveu;
|
||||
@@ -270,7 +271,7 @@ floatx80 floatx80_lognp1(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
compact = floatx80_make_compact(aExp, aSig);
|
||||
|
||||
@@ -426,7 +427,8 @@ floatx80 floatx80_logn(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig, fSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact, j, k, adjk;
|
||||
floatx80 fp0, fp1, fp2, fp3, f, logof2, klog2, saveu;
|
||||
@@ -469,7 +471,7 @@ floatx80 floatx80_logn(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
compact = floatx80_make_compact(aExp, aSig);
|
||||
|
||||
@@ -594,7 +596,8 @@ floatx80 floatx80_log10(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
floatx80 fp0, fp1;
|
||||
|
||||
@@ -626,7 +629,7 @@ floatx80 floatx80_log10(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
fp0 = floatx80_logn(a, status);
|
||||
fp1 = packFloatx80(0, 0x3FFD, UINT64_C(0xDE5BD8A937287195)); /* INV_L10 */
|
||||
@@ -651,7 +654,8 @@ floatx80 floatx80_log2(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
floatx80 fp0, fp1;
|
||||
|
||||
@@ -686,7 +690,7 @@ floatx80 floatx80_log2(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
if (aSig == one_sig) { /* X is 2^k */
|
||||
status->float_rounding_mode = user_rnd_mode;
|
||||
@@ -718,7 +722,8 @@ floatx80 floatx80_etox(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact, n, j, k, m, m1;
|
||||
floatx80 fp0, fp1, fp2, fp3, l2, scale, adjscale;
|
||||
@@ -746,7 +751,7 @@ floatx80 floatx80_etox(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
adjflag = 0;
|
||||
|
||||
@@ -902,7 +907,8 @@ floatx80 floatx80_twotox(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact, n, j, l, m, m1;
|
||||
floatx80 fp0, fp1, fp2, fp3, adjfact, fact1, fact2;
|
||||
@@ -929,7 +935,7 @@ floatx80 floatx80_twotox(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
fp0 = a;
|
||||
|
||||
@@ -1052,7 +1058,8 @@ floatx80 floatx80_tentox(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact, n, j, l, m, m1;
|
||||
floatx80 fp0, fp1, fp2, fp3, adjfact, fact1, fact2;
|
||||
@@ -1079,7 +1086,7 @@ floatx80 floatx80_tentox(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
fp0 = a;
|
||||
|
||||
@@ -1207,7 +1214,8 @@ floatx80 floatx80_tan(floatx80 a, float_status *status)
|
||||
int32_t aExp, xExp;
|
||||
uint64_t aSig, xSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact, l, n, j;
|
||||
floatx80 fp0, fp1, fp2, fp3, fp4, fp5, invtwopi, twopi1, twopi2;
|
||||
@@ -1233,7 +1241,7 @@ floatx80 floatx80_tan(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
compact = floatx80_make_compact(aExp, aSig);
|
||||
|
||||
@@ -1417,7 +1425,8 @@ floatx80 floatx80_sin(floatx80 a, float_status *status)
|
||||
int32_t aExp, xExp;
|
||||
uint64_t aSig, xSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact, l, n, j;
|
||||
floatx80 fp0, fp1, fp2, fp3, fp4, fp5, x, invtwopi, twopi1, twopi2;
|
||||
@@ -1443,7 +1452,7 @@ floatx80 floatx80_sin(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
compact = floatx80_make_compact(aExp, aSig);
|
||||
|
||||
@@ -1656,7 +1665,8 @@ floatx80 floatx80_cos(floatx80 a, float_status *status)
|
||||
int32_t aExp, xExp;
|
||||
uint64_t aSig, xSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact, l, n, j;
|
||||
floatx80 fp0, fp1, fp2, fp3, fp4, fp5, x, invtwopi, twopi1, twopi2;
|
||||
@@ -1682,7 +1692,7 @@ floatx80 floatx80_cos(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
compact = floatx80_make_compact(aExp, aSig);
|
||||
|
||||
@@ -1893,7 +1903,8 @@ floatx80 floatx80_atan(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact, tbl_index;
|
||||
floatx80 fp0, fp1, fp2, fp3, xsave;
|
||||
@@ -1920,7 +1931,7 @@ floatx80 floatx80_atan(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
if (compact < 0x3FFB8000 || compact > 0x4002FFFF) {
|
||||
/* |X| >= 16 or |X| < 1/16 */
|
||||
@@ -2090,7 +2101,8 @@ floatx80 floatx80_asin(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact;
|
||||
floatx80 fp0, fp1, fp2, one;
|
||||
@@ -2124,7 +2136,7 @@ floatx80 floatx80_asin(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
one = packFloatx80(0, one_exp, one_sig);
|
||||
fp0 = a;
|
||||
@@ -2155,7 +2167,8 @@ floatx80 floatx80_acos(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact;
|
||||
floatx80 fp0, fp1, one;
|
||||
@@ -2193,7 +2206,7 @@ floatx80 floatx80_acos(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
one = packFloatx80(0, one_exp, one_sig);
|
||||
fp0 = a;
|
||||
@@ -2224,7 +2237,8 @@ floatx80 floatx80_atanh(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact;
|
||||
floatx80 fp0, fp1, fp2, one;
|
||||
@@ -2257,7 +2271,7 @@ floatx80 floatx80_atanh(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
one = packFloatx80(0, one_exp, one_sig);
|
||||
fp2 = packFloatx80(aSign, 0x3FFE, one_sig); /* SIGN(X) * (1/2) */
|
||||
@@ -2289,7 +2303,8 @@ floatx80 floatx80_etoxm1(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact, n, j, m, m1;
|
||||
floatx80 fp0, fp1, fp2, fp3, l2, sc, onebysc;
|
||||
@@ -2316,7 +2331,7 @@ floatx80 floatx80_etoxm1(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
if (aExp >= 0x3FFD) { /* |X| >= 1/4 */
|
||||
compact = floatx80_make_compact(aExp, aSig);
|
||||
@@ -2541,7 +2556,8 @@ floatx80 floatx80_tanh(floatx80 a, float_status *status)
|
||||
int32_t aExp, vExp;
|
||||
uint64_t aSig, vSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact;
|
||||
floatx80 fp0, fp1;
|
||||
@@ -2565,7 +2581,7 @@ floatx80 floatx80_tanh(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
compact = floatx80_make_compact(aExp, aSig);
|
||||
|
||||
@@ -2656,7 +2672,8 @@ floatx80 floatx80_sinh(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact;
|
||||
floatx80 fp0, fp1, fp2;
|
||||
@@ -2681,7 +2698,7 @@ floatx80 floatx80_sinh(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
compact = floatx80_make_compact(aExp, aSig);
|
||||
|
||||
@@ -2744,7 +2761,8 @@ floatx80 floatx80_cosh(floatx80 a, float_status *status)
|
||||
int32_t aExp;
|
||||
uint64_t aSig;
|
||||
|
||||
int8_t user_rnd_mode, user_rnd_prec;
|
||||
FloatRoundMode user_rnd_mode;
|
||||
FloatX80RoundPrec user_rnd_prec;
|
||||
|
||||
int32_t compact;
|
||||
floatx80 fp0, fp1;
|
||||
@@ -2767,7 +2785,7 @@ floatx80 floatx80_cosh(floatx80 a, float_status *status)
|
||||
user_rnd_mode = status->float_rounding_mode;
|
||||
user_rnd_prec = status->floatx80_rounding_precision;
|
||||
status->float_rounding_mode = float_round_nearest_even;
|
||||
status->floatx80_rounding_precision = 80;
|
||||
status->floatx80_rounding_precision = floatx80_precision_x;
|
||||
|
||||
compact = floatx80_make_compact(aExp, aSig);
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* fp-test-log2.c - test QEMU's softfloat log2
|
||||
*
|
||||
* Copyright (C) 2020, Linaro, Ltd.
|
||||
*
|
||||
* License: GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
#ifndef HW_POISON_H
|
||||
#error Must define HW_POISON_H to work around TARGET_* poisoning
|
||||
#endif
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include <math.h>
|
||||
#include "fpu/softfloat.h"
|
||||
|
||||
typedef union {
|
||||
double d;
|
||||
float64 i;
|
||||
} ufloat64;
|
||||
|
||||
static int errors;
|
||||
|
||||
static void compare(ufloat64 test, ufloat64 real, ufloat64 soft, bool exact)
|
||||
{
|
||||
int msb;
|
||||
uint64_t ulp = UINT64_MAX;
|
||||
|
||||
if (real.i == soft.i) {
|
||||
return;
|
||||
}
|
||||
msb = 63 - __builtin_clzll(real.i ^ soft.i);
|
||||
|
||||
if (msb < 52) {
|
||||
if (real.i > soft.i) {
|
||||
ulp = real.i - soft.i;
|
||||
} else {
|
||||
ulp = soft.i - real.i;
|
||||
}
|
||||
}
|
||||
|
||||
/* glibc allows 3 ulp error in its libm-test-ulps; allow 4 here */
|
||||
if (!exact && ulp <= 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf("test: %016" PRIx64 " %+.13a\n"
|
||||
" sf: %016" PRIx64 " %+.13a\n"
|
||||
"libm: %016" PRIx64 " %+.13a\n",
|
||||
test.i, test.d, soft.i, soft.d, real.i, real.d);
|
||||
|
||||
if (msb == 63) {
|
||||
printf("Error in sign!\n\n");
|
||||
} else if (msb >= 52) {
|
||||
printf("Error in exponent: %d\n\n",
|
||||
(int)(soft.i >> 52) - (int)(real.i >> 52));
|
||||
} else {
|
||||
printf("Error in fraction: %" PRIu64 " ulp\n\n", ulp);
|
||||
}
|
||||
|
||||
if (++errors == 20) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
ufloat64 test, real, soft;
|
||||
float_status qsf = {0};
|
||||
int i;
|
||||
|
||||
set_float_rounding_mode(float_round_nearest_even, &qsf);
|
||||
|
||||
test.d = 0.0;
|
||||
real.d = -__builtin_inf();
|
||||
soft.i = float64_log2(test.i, &qsf);
|
||||
compare(test, real, soft, true);
|
||||
|
||||
test.d = 1.0;
|
||||
real.d = 0.0;
|
||||
soft.i = float64_log2(test.i, &qsf);
|
||||
compare(test, real, soft, true);
|
||||
|
||||
test.d = 2.0;
|
||||
real.d = 1.0;
|
||||
soft.i = float64_log2(test.i, &qsf);
|
||||
compare(test, real, soft, true);
|
||||
|
||||
test.d = 4.0;
|
||||
real.d = 2.0;
|
||||
soft.i = float64_log2(test.i, &qsf);
|
||||
compare(test, real, soft, true);
|
||||
|
||||
test.d = 0x1p64;
|
||||
real.d = 64.0;
|
||||
soft.i = float64_log2(test.i, &qsf);
|
||||
compare(test, real, soft, true);
|
||||
|
||||
test.d = __builtin_inf();
|
||||
real.d = __builtin_inf();
|
||||
soft.i = float64_log2(test.i, &qsf);
|
||||
compare(test, real, soft, true);
|
||||
|
||||
for (i = 0; i < 10000; ++i) {
|
||||
test.d = drand48() + 1.0; /* [1.0, 2.0) */
|
||||
real.d = log2(test.d);
|
||||
soft.i = float64_log2(test.i, &qsf);
|
||||
compare(test, real, soft, false);
|
||||
|
||||
test.d = drand48() * 100; /* [0.0, 100) */
|
||||
real.d = log2(test.d);
|
||||
soft.i = float64_log2(test.i, &qsf);
|
||||
compare(test, real, soft, false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+6
-3
@@ -963,18 +963,21 @@ static void QEMU_NORETURN run_test(void)
|
||||
verCases_usesExact = !!(attrs & FUNC_ARG_EXACT);
|
||||
|
||||
for (k = 0; k < 3; k++) {
|
||||
int prec80 = 32;
|
||||
FloatX80RoundPrec qsf_prec80 = floatx80_precision_x;
|
||||
int prec80 = 80;
|
||||
int l;
|
||||
|
||||
if (k == 1) {
|
||||
prec80 = 64;
|
||||
qsf_prec80 = floatx80_precision_d;
|
||||
} else if (k == 2) {
|
||||
prec80 = 80;
|
||||
prec80 = 32;
|
||||
qsf_prec80 = floatx80_precision_s;
|
||||
}
|
||||
|
||||
verCases_roundingPrecision = 0;
|
||||
slow_extF80_roundingPrecision = prec80;
|
||||
qsf.floatx80_rounding_precision = prec80;
|
||||
qsf.floatx80_rounding_precision = qsf_prec80;
|
||||
|
||||
if (attrs & FUNC_EFF_ROUNDINGPRECISION) {
|
||||
verCases_roundingPrecision = prec80;
|
||||
|
||||
+18
-9
@@ -556,7 +556,9 @@ softfloat_conv_tests = {
|
||||
'extF80_to_f64 extF80_to_f128 ' +
|
||||
'f128_to_f16',
|
||||
'int-to-float': 'i32_to_f16 i64_to_f16 i32_to_f32 i64_to_f32 ' +
|
||||
'i32_to_f64 i64_to_f64 i32_to_f128 i64_to_f128',
|
||||
'i32_to_f64 i64_to_f64 ' +
|
||||
'i32_to_extF80 i64_to_extF80 ' +
|
||||
'i32_to_f128 i64_to_f128',
|
||||
'uint-to-float': 'ui32_to_f16 ui64_to_f16 ui32_to_f32 ui64_to_f32 ' +
|
||||
'ui32_to_f64 ui64_to_f64 ui64_to_f128 ' +
|
||||
'ui32_to_extF80 ui64_to_extF80',
|
||||
@@ -581,7 +583,7 @@ softfloat_conv_tests = {
|
||||
'extF80_to_ui64 extF80_to_ui64_r_minMag ' +
|
||||
'f128_to_ui64 f128_to_ui64_r_minMag',
|
||||
'round-to-integer': 'f16_roundToInt f32_roundToInt ' +
|
||||
'f64_roundToInt f128_roundToInt'
|
||||
'f64_roundToInt extF80_roundToInt f128_roundToInt'
|
||||
}
|
||||
softfloat_tests = {
|
||||
'eq_signaling' : 'compare',
|
||||
@@ -602,24 +604,20 @@ fptest_args = ['-s', '-l', '1']
|
||||
fptest_rounding_args = ['-r', 'all']
|
||||
|
||||
# Conversion Routines:
|
||||
# FIXME: i32_to_extF80 (broken), i64_to_extF80 (broken)
|
||||
# extF80_roundToInt (broken)
|
||||
foreach k, v : softfloat_conv_tests
|
||||
test('fp-test-' + k, fptest,
|
||||
args: fptest_args + fptest_rounding_args + v.split(),
|
||||
suite: ['softfloat', 'softfloat-conv'])
|
||||
endforeach
|
||||
|
||||
# FIXME: extF80_{lt_quiet, rem} (broken),
|
||||
# extF80_{mulAdd} (missing)
|
||||
foreach k, v : softfloat_tests
|
||||
extF80_broken = ['lt_quiet', 'rem'].contains(k)
|
||||
test('fp-test-' + k, fptest,
|
||||
args: fptest_args + fptest_rounding_args +
|
||||
['f16_' + k, 'f32_' + k, 'f64_' + k, 'f128_' + k] +
|
||||
(extF80_broken ? [] : ['extF80_' + k]),
|
||||
['f16_' + k, 'f32_' + k, 'f64_' + k, 'f128_' + k, 'extF80_' + k],
|
||||
suite: ['softfloat', 'softfloat-' + v])
|
||||
endforeach
|
||||
|
||||
# FIXME: extF80_{mulAdd} (missing)
|
||||
test('fp-test-mulAdd', fptest,
|
||||
# no fptest_rounding_args
|
||||
args: fptest_args +
|
||||
@@ -634,3 +632,14 @@ fpbench = executable(
|
||||
include_directories: [sfinc, include_directories(tfdir)],
|
||||
c_args: fpcflags,
|
||||
)
|
||||
|
||||
fptestlog2 = executable(
|
||||
'fp-test-log2',
|
||||
['fp-test-log2.c', '../../fpu/softfloat.c'],
|
||||
link_with: [libsoftfloat],
|
||||
dependencies: [qemuutil],
|
||||
include_directories: [sfinc],
|
||||
c_args: fpcflags,
|
||||
)
|
||||
test('fp-test-log2', fptestlog2,
|
||||
suite: ['softfloat', 'softfloat-ops'])
|
||||
|
||||
+1
-1
@@ -643,7 +643,7 @@ WRAP_CMP80(qemu_extF80M_eq, floatx80_eq_quiet)
|
||||
WRAP_CMP80(qemu_extF80M_le, floatx80_le)
|
||||
WRAP_CMP80(qemu_extF80M_lt, floatx80_lt)
|
||||
WRAP_CMP80(qemu_extF80M_le_quiet, floatx80_le_quiet)
|
||||
WRAP_CMP80(qemu_extF80M_lt_quiet, floatx80_le_quiet)
|
||||
WRAP_CMP80(qemu_extF80M_lt_quiet, floatx80_lt_quiet)
|
||||
#undef WRAP_CMP80
|
||||
|
||||
#define WRAP_CMP128(name, func) \
|
||||
|
||||
Reference in New Issue
Block a user