| Daniel Dunbar | 51c80cc | 2009-10-27 17:49:19 +0000 | [diff] [blame] | 1 | //===-- floatundidf.S - Implement __floatundidf for i386 ------------------===// | 
| Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 2 | // | 
 | 3 | //                     The LLVM Compiler Infrastructure | 
 | 4 | // | 
| Howard Hinnant | 9ad441f | 2010-11-16 22:13:33 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open | 
 | 6 | // Source Licenses. See LICENSE.TXT for details. | 
| Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 7 | // | 
 | 8 | //===----------------------------------------------------------------------===// | 
 | 9 | // | 
 | 10 | // This file implements __floatundidf for the compiler_rt library. | 
 | 11 | // | 
 | 12 | //===----------------------------------------------------------------------===// | 
 | 13 |  | 
| Daniel Dunbar | 19336a2 | 2009-10-27 17:49:50 +0000 | [diff] [blame] | 14 | #include "../assembly.h" | 
 | 15 |  | 
| Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 16 | // double __floatundidf(du_int a); | 
 | 17 |  | 
 | 18 | #ifdef __i386__ | 
 | 19 |  | 
| Edward O'Callaghan | eed1300 | 2009-11-04 23:52:51 +0000 | [diff] [blame] | 20 | #ifndef __ELF__ | 
| Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 21 | .const | 
| Edward O'Callaghan | eed1300 | 2009-11-04 23:52:51 +0000 | [diff] [blame] | 22 | #endif | 
| Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 23 | .align 4 | 
 | 24 | twop52: .quad 0x4330000000000000 | 
 | 25 | twop84_plus_twop52: | 
 | 26 | 		.quad 0x4530000000100000 | 
 | 27 | twop84: .quad 0x4530000000000000 | 
 | 28 |  | 
 | 29 | #define REL_ADDR(_a)	(_a)-0b(%eax) | 
 | 30 |  | 
 | 31 | .text | 
 | 32 | .align 4 | 
| Daniel Dunbar | b4b1e8c | 2009-10-27 17:50:21 +0000 | [diff] [blame] | 33 | DEFINE_COMPILERRT_FUNCTION(__floatundidf) | 
| Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 34 | 	movss	8(%esp),						%xmm1 // high 32 bits of a | 
 | 35 | 	movss	4(%esp),						%xmm0 // low 32 bits of a | 
 | 36 | 	calll	0f | 
 | 37 | 0:	popl	%eax | 
 | 38 | 	orpd	REL_ADDR(twop84),				%xmm1 // 0x1p84 + a_hi (no rounding occurs) | 
 | 39 | 	subsd	REL_ADDR(twop84_plus_twop52),	%xmm1 // a_hi - 0x1p52 (no rounding occurs) | 
 | 40 | 	orpd	REL_ADDR(twop52),				%xmm0 // 0x1p52 + a_lo (no rounding occurs) | 
 | 41 | 	addsd	%xmm1,							%xmm0 // a_hi + a_lo   (round happens here) | 
 | 42 | 	movsd	%xmm0,						   4(%esp) | 
 | 43 | 	fldl   4(%esp) | 
 | 44 | 	ret | 
 | 45 | 	 | 
 | 46 | #endif // __i386__ |