diff options
author | Andrew Waterman <waterman@eecs.berkeley.edu> | 2014-03-06 18:49:41 -0800 |
---|---|---|
committer | Andrew Waterman <waterman@eecs.berkeley.edu> | 2014-03-06 18:49:41 -0800 |
commit | a43d87cf0ae16acff8763130f0c7e40014616cff (patch) | |
tree | 44cf0b2086be058f1d5eb0c6167adaab851bae9b /softfloat/f64_classify.c | |
parent | 07599f5833dcce1cf154b543da0cec46a0953c45 (diff) | |
download | pk-a43d87cf0ae16acff8763130f0c7e40014616cff.zip pk-a43d87cf0ae16acff8763130f0c7e40014616cff.tar.gz pk-a43d87cf0ae16acff8763130f0c7e40014616cff.tar.bz2 |
Add fclass.{s|d} instructions
Diffstat (limited to 'softfloat/f64_classify.c')
-rwxr-xr-x | softfloat/f64_classify.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/softfloat/f64_classify.c b/softfloat/f64_classify.c new file mode 100755 index 0000000..2ec124b --- /dev/null +++ b/softfloat/f64_classify.c @@ -0,0 +1,33 @@ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "internals.h" +#include "specialize.h" +#include "softfloat.h" + +uint_fast16_t f64_classify( float64_t a ) +{ + union ui64_f64 uA; + uint_fast64_t uiA; + + uA.f = a; + uiA = uA.ui; + + uint_fast16_t infOrNaN = expF64UI( uiA ) == 0x7FF; + uint_fast16_t subnormalOrZero = expF64UI( uiA ) == 0; + bool sign = signF64UI( uiA ); + + return + ( sign && infOrNaN && fracF64UI( uiA ) == 0 ) << 0 | + ( sign && !infOrNaN && !subnormalOrZero ) << 1 | + ( sign && subnormalOrZero && fracF64UI( uiA ) ) << 2 | + ( sign && subnormalOrZero && fracF64UI( uiA ) == 0 ) << 3 | + ( !sign && infOrNaN && fracF64UI( uiA ) == 0 ) << 7 | + ( !sign && !infOrNaN && !subnormalOrZero ) << 6 | + ( !sign && subnormalOrZero && fracF64UI( uiA ) ) << 5 | + ( !sign && subnormalOrZero && fracF64UI( uiA ) == 0 ) << 4 | + ( isNaNF64UI( uiA ) && softfloat_isSigNaNF64UI( uiA )) << 8 | + ( isNaNF64UI( uiA ) && !softfloat_isSigNaNF64UI( uiA )) << 9; +} + |