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
5 #include "../assembly.h"
7 // double __floatdidf(du_int a);
15 .quad 0x4330000000000000
19 .quad 0x41f0000000000000
21 #define REL_ADDR(_a) (_a)-0b(%eax)
25 DEFINE_COMPILERRT_FUNCTION(__floatdidf)
26 cvtsi2sd 8(%esp), %xmm1
27 movss 4(%esp), %xmm0 // low 32 bits of a
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)
38 END_COMPILERRT_FUNCTION(__floatdidf)
42 NO_EXEC_STACK_DIRECTIVE