temporary undoing of renaming
[riscv-isa-sim.git] / softfloat / i64_to_f32.c
1
2 #include <stdbool.h>
3 #include <stdint.h>
4 #include "platform.h"
5 #include "primitives.h"
6 #include "internals.h"
7 #include "softfloat.h"
8
9 float32_t i64_to_f32( int_fast64_t a )
10 {
11 bool sign;
12 uint_fast64_t absA;
13 int shiftCount;
14 union ui32_f32 u;
15 uint_fast32_t sig;
16
17 sign = ( a < 0 );
18 absA = sign ? - (uint_fast64_t) a : a;
19 shiftCount = softfloat_countLeadingZeros64( absA ) - 40;
20 if ( 0 <= shiftCount ) {
21 u.ui =
22 a ? packToF32UI(
23 sign, 0x95 - shiftCount, (uint_fast32_t) absA<<shiftCount )
24 : 0;
25 return u.f;
26 } else {
27 shiftCount += 7;
28 sig =
29 ( shiftCount < 0 )
30 ? softfloat_shortShift64RightJam( absA, - shiftCount )
31 : (uint_fast32_t) absA<<shiftCount;
32 return softfloat_roundPackToF32( sign, 0x9C - shiftCount, sig );
33 }
34
35 }
36