1// This file is dual licensed under the MIT and the University of Illinois Open 2// Source Licenses. See LICENSE.TXT for details. 3 4#include "../assembly.h" 5 6// long double __floatundixf(du_int a); 7 8#ifdef __x86_64__ 9 10CONST_SECTION 11 12 .balign 16 13twop64: 14 .quad 0x43f0000000000000 15 16#define REL_ADDR(_a) (_a)(%rip) 17 18 .text 19 20 .balign 4 21DEFINE_COMPILERRT_FUNCTION(__floatundixf) 22 movq %rdi, -8(%rsp) 23 fildq -8(%rsp) 24 test %rdi, %rdi 25 js 1f 26 ret 271: faddl REL_ADDR(twop64) 28 ret 29END_COMPILERRT_FUNCTION(__floatundixf) 30 31#endif // __x86_64__ 32 33 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. 36 37#ifdef __x86_64__ 38 39CONST_SECTION 40 41 .balign 4 42twop52: 43 .quad 0x4330000000000000 44twop84_plus_twop52_neg: 45 .quad 0xc530000000100000 46twop84: 47 .quad 0x4530000000000000 48 49#define REL_ADDR(_a) (_a)(%rip) 50 51.text 52.balign 4 53DEFINE_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) 58 movq %rdi, -8(%rsp) 59 movq %rsi, -16(%rsp) 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) 63 ret 64END_COMPILERRT_FUNCTION(__floatundixf) 65 66#endif // __x86_64__ 67 68*/ 69 70NO_EXEC_STACK_DIRECTIVE 71 72