Add back IPI support
[riscv-isa-sim.git] / softfloat / f32_classify.c
1
2 #include <stdbool.h>
3 #include <stdint.h>
4 #include "platform.h"
5 #include "internals.h"
6 #include "specialize.h"
7 #include "softfloat.h"
8
9 uint_fast16_t f32_classify( float32_t a )
10 {
11 union ui32_f32 uA;
12 uint_fast32_t uiA;
13
14 uA.f = a;
15 uiA = uA.ui;
16
17 uint_fast16_t infOrNaN = expF32UI( uiA ) == 0xFF;
18 uint_fast16_t subnormalOrZero = expF32UI( uiA ) == 0;
19 bool sign = signF32UI( uiA );
20
21 return
22 ( sign && infOrNaN && fracF32UI( uiA ) == 0 ) << 0 |
23 ( sign && !infOrNaN && !subnormalOrZero ) << 1 |
24 ( sign && subnormalOrZero && fracF32UI( uiA ) ) << 2 |
25 ( sign && subnormalOrZero && fracF32UI( uiA ) == 0 ) << 3 |
26 ( !sign && infOrNaN && fracF32UI( uiA ) == 0 ) << 7 |
27 ( !sign && !infOrNaN && !subnormalOrZero ) << 6 |
28 ( !sign && subnormalOrZero && fracF32UI( uiA ) ) << 5 |
29 ( !sign && subnormalOrZero && fracF32UI( uiA ) == 0 ) << 4 |
30 ( isNaNF32UI( uiA ) && softfloat_isSigNaNF32UI( uiA )) << 8 |
31 ( isNaNF32UI( uiA ) && !softfloat_isSigNaNF32UI( uiA )) << 9;
32 }
33