1 // This file is dual licensed under the MIT and the University of Illinois Open
2 // Source Licenses. See LICENSE.TXT for details.
4 #include "../assembly.h"
6 // long double __floatundixf(du_int a);
10 #if defined(__APPLE__)
12 #elif defined(__ELF__)
20 .quad 0x43f0000000000000
22 #define REL_ADDR(_a) (_a)(%rip)
27 DEFINE_COMPILERRT_FUNCTION(__floatundixf)
33 1: faddl REL_ADDR(twop64)
35 END_COMPILERRT_FUNCTION(__floatundixf)
40 /* Branch-free implementation is ever so slightly slower, but more beautiful.
41 It is likely superior for inlining, so I kept it around for future reference.
45 #if defined(__APPLE__)
47 #elif defined(__ELF__)
54 .quad 0x4330000000000000
55 twop84_plus_twop52_neg:
56 .quad 0xc530000000100000
58 .quad 0x4530000000000000
60 #define REL_ADDR(_a) (_a)(%rip)
64 DEFINE_COMPILERRT_FUNCTION(__floatundixf)
65 movl %edi, %esi // low 32 bits of input
66 shrq $32, %rdi // hi 32 bits of input
67 orq REL_ADDR(twop84), %rdi // 2^84 + hi (as a double)
68 orq REL_ADDR(twop52), %rsi // 2^52 + lo (as a double)
71 fldl REL_ADDR(twop84_plus_twop52_neg)
72 faddl -8(%rsp) // hi - 2^52 (as double extended, no rounding occurs)
73 faddl -16(%rsp) // hi + lo (as double extended)
75 END_COMPILERRT_FUNCTION(__floatundixf)