blob: 8bf9f0dfc50cf6b9c800981d16b830c7c4b900d3 [file] [log] [blame]
Daniel Dunbarb3a69012009-06-26 16:47:03 +00001// This file is distributed under the University of Illinois Open Source
2// License. See LICENSE.TXT for details.
3
Daniel Dunbar19336a22009-10-27 17:49:50 +00004#include "../assembly.h"
5
Daniel Dunbarb3a69012009-06-26 16:47:03 +00006// double __floatundidf(du_int a);
7
8#ifdef __i386__
9
10.const
11.align 4
12twop52: .quad 0x4330000000000000
13twop32: .quad 0x41f0000000000000
14
15#define REL_ADDR(_a) (_a)-0b(%eax)
16
17.text
18.align 4
Daniel Dunbarb4b1e8c2009-10-27 17:50:21 +000019DEFINE_COMPILERRT_FUNCTION(__floatdidf)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000020 cvtsi2sd 8(%esp), %xmm1
21 movss 4(%esp), %xmm0 // low 32 bits of a
22 calll 0f
230: popl %eax
24 mulsd REL_ADDR(twop32), %xmm1 // a_hi as a double (without rounding)
25 movsd REL_ADDR(twop52), %xmm2 // 0x1.0p52
26 subsd %xmm2, %xmm1 // a_hi - 0x1p52 (no rounding occurs)
27 orpd %xmm2, %xmm0 // 0x1p52 + a_lo (no rounding occurs)
28 addsd %xmm1, %xmm0 // a_hi + a_lo (round happens here)
29 movsd %xmm0, 4(%esp)
30 fldl 4(%esp)
31 ret
32
33#endif // __i386__