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