| 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 |
| 4 | |
| 5 | #include "../assembly.h" |
| 6 | |
| 7 | // xf_float __floatundixf(du_int a);16 |
| 8 | |
| 9 | #ifdef __i386__ |
| 10 | |
| 11 | CONST_SECTION |
| 12 | |
| 13 | .balign 16 |
| 14 | twop52: |
| 15 | .quad 0x4330000000000000 |
| 16 | |
| 17 | .balign 16 |
| 18 | twop84_plus_twop52_neg: |
| 19 | .quad 0xc530000000100000 |
| 20 | |
| 21 | .balign 16 |
| 22 | twop84: |
| 23 | .quad 0x4530000000000000 |
| 24 | |
| 25 | #define REL_ADDR(_a) (_a)-0b(%eax) |
| 26 | |
| 27 | .text |
| 28 | .balign 4 |
| 29 | DEFINE_COMPILERRT_FUNCTION(__floatundixf) |
| 30 | calll 0f |
| 31 | 0: popl %eax |
| 32 | movss 8(%esp), %xmm0 // hi 32 bits of input |
| 33 | movss 4(%esp), %xmm1 // lo 32 bits of input |
| 34 | orpd REL_ADDR(twop84), %xmm0 // 2^84 + hi (as a double) |
| 35 | orpd REL_ADDR(twop52), %xmm1 // 2^52 + lo (as a double) |
| 36 | addsd REL_ADDR(twop84_plus_twop52_neg), %xmm0 // hi - 2^52 (no rounding occurs) |
| 37 | movsd %xmm1, 4(%esp) |
| 38 | fldl 4(%esp) |
| 39 | movsd %xmm0, 4(%esp) |
| 40 | faddl 4(%esp) |
| 41 | ret |
| 42 | END_COMPILERRT_FUNCTION(__floatundixf) |
| 43 | |
| 44 | #endif // __i386__ |
| 45 | |
| 46 | NO_EXEC_STACK_DIRECTIVE |
| 47 | |
| 48 | |