added functions to softfloat for future fpu implementation

This commit is contained in:
Stanislav Shwartsman 2004-02-17 21:59:24 +00:00
parent 97476a00e1
commit c3066a44bb
4 changed files with 42 additions and 16 deletions

View File

@ -30,12 +30,12 @@
//
struct i387_t
{
Bit32u cwd; // control word
Bit32u swd; // status word
Bit32u twd; // tag word
Bit32u cwd; // control word
Bit32u swd; // status word
Bit32u twd; // tag word
Bit32u fip;
Bit32u fcs;
Bit32u foo;
Bit32u foo; // last instruction opcode
Bit32u fos;
unsigned char tos;

View File

@ -435,10 +435,8 @@ BX_CPP_INLINE int floatx80_is_nan(floatx80 a)
BX_CPP_INLINE int floatx80_is_signaling_nan(floatx80 a)
{
Bit64s aLow = a.fraction & ~BX_CONST64(0x4000000000000000);
return
((a.exp & 0x7FFF) == 0x7FFF)
&& (Bit64s) (aLow<<1)
&& (a.fraction == aLow);
return ((a.exp & 0x7FFF) == 0x7FFF) &&
(Bit64s) (aLow<<1) && (a.fraction == aLow);
}
/*----------------------------------------------------------------------------

View File

@ -159,16 +159,16 @@ float_class_t float32_class(float32 a)
flag aSign = extractFloat32Sign(a);
if(aExp == 0xFF) {
if (aSig == 0) {
if (aSig == 0)
return (aSign) ? float_negative_inf : float_positive_inf;
}
return float_NaN;
}
if(aExp == 0) {
if (aSig == 0) {
if (aSig == 0)
return (aSign) ? float_negative_zero : float_positive_zero;
}
return float_denormal;
}
@ -296,16 +296,16 @@ float_class_t float64_class(float64 a)
flag aSign = extractFloat64Sign(a);
if(aExp == 0x7FF) {
if (aSig == 0) {
if (aSig == 0)
return (aSign) ? float_negative_inf : float_positive_inf;
}
return float_NaN;
}
if(aExp == 0) {
if (aSig == 0) {
if (aSig == 0)
return (aSign) ? float_negative_zero : float_positive_zero;
}
return float_denormal;
}
@ -2525,6 +2525,33 @@ static void
*zExpPtr = 1 - shiftCount;
}
/*----------------------------------------------------------------------------
| Determine extended-precision floating-point number class
*----------------------------------------------------------------------------*/
float_class_t floatx80_class(float64 a)
{
Bit32s aExp = extractFloatx80Exp(a);
Bit64u aSig = extractFloatx80Frac(a);
flag aSign = extractFloatx80Sign(a);
if(aExp == 0x7fff) {
if (aSig == 0)
return (aSign) ? float_negative_inf : float_positive_inf;
return float_NaN;
}
if(aExp == 0) {
if (aSig == 0)
return (aSign) ? float_negative_zero : float_positive_zero;
return float_denormal;
}
return float_normalized;
}
/*----------------------------------------------------------------------------
| Packs the sign `zSign', exponent `zExp', and significand `zSig' into an
| extended double-precision floating-point value, returning the result.

View File

@ -270,6 +270,7 @@ int floatx80_eq_signaling(floatx80, floatx80, float_status_t &status);
int floatx80_le_quiet(floatx80, floatx80, float_status_t &status);
int floatx80_lt_quiet(floatx80, floatx80, float_status_t &status);
float_class_t floatx80_class(floatx80);
int floatx80_is_signaling_nan(floatx80);
#endif