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);
14 .quad 0x43f0000000000000
16 #define REL_ADDR(_a) (_a)(%rip)
21 DEFINE_COMPILERRT_FUNCTION(__floatundixf)
27 1: faddl REL_ADDR(twop64)
29 END_COMPILERRT_FUNCTION(__floatundixf)
34 /* Branch-free implementation is ever so slightly slower, but more beautiful.
35 It is likely superior for inlining, so I kept it around for future reference.
43 .quad 0x4330000000000000
44 twop84_plus_twop52_neg:
45 .quad 0xc530000000100000
47 .quad 0x4530000000000000
49 #define REL_ADDR(_a) (_a)(%rip)
53 DEFINE_COMPILERRT_FUNCTION(__floatundixf)
54 movl %edi, %esi // low 32 bits of input
55 shrq $32, %rdi // hi 32 bits of input
56 orq REL_ADDR(twop84), %rdi // 2^84 + hi (as a double)
57 orq REL_ADDR(twop52), %rsi // 2^52 + lo (as a double)
60 fldl REL_ADDR(twop84_plus_twop52_neg)
61 faddl -8(%rsp) // hi - 2^52 (as double extended, no rounding occurs)
62 faddl -16(%rsp) // hi + lo (as double extended)
64 END_COMPILERRT_FUNCTION(__floatundixf)