1// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2// See https://llvm.org/LICENSE.txt for license information.
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#include "../assembly.h"
6
7// double __floatdidf(du_int a);
8
9#ifdef __i386__
10
11CONST_SECTION
12
13 .balign 16
14twop52:
15 .quad 0x4330000000000000
16
17 .balign 16
18twop32:
19 .quad 0x41f0000000000000
20
21#define REL_ADDR(_a) (_a)-0b(%eax)
22
23.text
24.balign 4
25DEFINE_COMPILERRT_FUNCTION(__floatdidf)
26 cvtsi2sd 8(%esp), %xmm1
27 movss 4(%esp), %xmm0 // low 32 bits of a
28 calll 0f
290: popl %eax
30 mulsd REL_ADDR(twop32), %xmm1 // a_hi as a double (without rounding)
31 movsd REL_ADDR(twop52), %xmm2 // 0x1.0p52
32 subsd %xmm2, %xmm1 // a_hi - 0x1p52 (no rounding occurs)
33 orpd %xmm2, %xmm0 // 0x1p52 + a_lo (no rounding occurs)
34 addsd %xmm1, %xmm0 // a_hi + a_lo (round happens here)
35 movsd %xmm0, 4(%esp)
36 fldl 4(%esp)
37 ret
38END_COMPILERRT_FUNCTION(__floatdidf)
39
40#endif // __i386__
41
42NO_EXEC_STACK_DIRECTIVE
43
44

source code of compiler-rt/lib/builtins/i386/floatdidf.S