]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/compiler-rt/lib/i386/floatdidf.S
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / compiler-rt / lib / i386 / floatdidf.S
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 // double __floatundidf(du_int a);
7
8 #ifdef __i386__
9
10 #ifndef __ELF__
11 .const
12 #endif
13 .align 4
14 twop52: .quad 0x4330000000000000
15 twop32: .quad 0x41f0000000000000
16
17 #define REL_ADDR(_a)    (_a)-0b(%eax)
18
19 .text
20 .align 4
21 DEFINE_COMPILERRT_FUNCTION(__floatdidf)
22         cvtsi2sd        8(%esp),                        %xmm1
23         movss           4(%esp),                        %xmm0 // low 32 bits of a
24         calll           0f
25 0:      popl            %eax
26         mulsd           REL_ADDR(twop32),       %xmm1 // a_hi as a double (without rounding)
27         movsd           REL_ADDR(twop52),       %xmm2 // 0x1.0p52
28         subsd           %xmm2,                          %xmm1 // a_hi - 0x1p52 (no rounding occurs)
29         orpd            %xmm2,                          %xmm0 // 0x1p52 + a_lo (no rounding occurs)
30         addsd           %xmm1,                          %xmm0 // a_hi + a_lo   (round happens here)
31         movsd           %xmm0,                     4(%esp)
32         fldl       4(%esp)
33         ret
34         
35 #endif // __i386__