1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2 // See https://llvm.org/LICENSE.txt for license information.
3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 #include "../assembly.h"
7 // xf_float __floatundixf(du_int a);
15 .quad 0x43f0000000000000
17 #define REL_ADDR(_a) (_a)(%rip)
22 DEFINE_COMPILERRT_FUNCTION(__floatundixf)
28 1: faddl REL_ADDR(twop64)
30 END_COMPILERRT_FUNCTION(__floatundixf)
35 /* Branch-free implementation is ever so slightly slower, but more beautiful.
36 It is likely superior for inlining, so I kept it around for future reference.
44 .quad 0x4330000000000000
45 twop84_plus_twop52_neg:
46 .quad 0xc530000000100000
48 .quad 0x4530000000000000
50 #define REL_ADDR(_a) (_a)(%rip)
54 DEFINE_COMPILERRT_FUNCTION(__floatundixf)
55 movl %edi, %esi // low 32 bits of input
56 shrq $32, %rdi // hi 32 bits of input
57 orq REL_ADDR(twop84), %rdi // 2^84 + hi (as a double)
58 orq REL_ADDR(twop52), %rsi // 2^52 + lo (as a double)
61 fldl REL_ADDR(twop84_plus_twop52_neg)
62 faddl -8(%rsp) // hi - 2^52 (as double extended, no rounding occurs)
63 faddl -16(%rsp) // hi + lo (as double extended)
65 END_COMPILERRT_FUNCTION(__floatundixf)
71 NO_EXEC_STACK_DIRECTIVE