| Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame^] | 1 | //===-- floatundidf.s - Implement __floatundidf for i386 ------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements __floatundidf for the compiler_rt library. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | // double __floatundidf(du_int a); |
| 15 | |
| 16 | #ifdef __i386__ |
| 17 | |
| 18 | .const |
| 19 | .align 4 |
| 20 | twop52: .quad 0x4330000000000000 |
| 21 | twop84_plus_twop52: |
| 22 | .quad 0x4530000000100000 |
| 23 | twop84: .quad 0x4530000000000000 |
| 24 | |
| 25 | #define REL_ADDR(_a) (_a)-0b(%eax) |
| 26 | |
| 27 | .text |
| 28 | .align 4 |
| 29 | .globl ___floatundidf |
| 30 | ___floatundidf: |
| 31 | movss 8(%esp), %xmm1 // high 32 bits of a |
| 32 | movss 4(%esp), %xmm0 // low 32 bits of a |
| 33 | calll 0f |
| 34 | 0: popl %eax |
| 35 | orpd REL_ADDR(twop84), %xmm1 // 0x1p84 + a_hi (no rounding occurs) |
| 36 | subsd REL_ADDR(twop84_plus_twop52), %xmm1 // a_hi - 0x1p52 (no rounding occurs) |
| 37 | orpd REL_ADDR(twop52), %xmm0 // 0x1p52 + a_lo (no rounding occurs) |
| 38 | addsd %xmm1, %xmm0 // a_hi + a_lo (round happens here) |
| 39 | movsd %xmm0, 4(%esp) |
| 40 | fldl 4(%esp) |
| 41 | ret |
| 42 | |
| 43 | #endif // __i386__ |