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