xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/i386/floatundixf.S (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
10b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
20b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
30b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
40b57cec5SDimitry Andric
50b57cec5SDimitry Andric#include "../assembly.h"
60b57cec5SDimitry Andric
7*5f757f3fSDimitry Andric// xf_float __floatundixf(du_int a);16
80b57cec5SDimitry Andric
90b57cec5SDimitry Andric#ifdef __i386__
100b57cec5SDimitry Andric
110b57cec5SDimitry AndricCONST_SECTION
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric	.balign 16
140b57cec5SDimitry Andrictwop52:
150b57cec5SDimitry Andric	.quad 0x4330000000000000
160b57cec5SDimitry Andric
170b57cec5SDimitry Andric	.balign 16
180b57cec5SDimitry Andrictwop84_plus_twop52_neg:
190b57cec5SDimitry Andric	.quad 0xc530000000100000
200b57cec5SDimitry Andric
210b57cec5SDimitry Andric	.balign 16
220b57cec5SDimitry Andrictwop84:
230b57cec5SDimitry Andric	.quad 0x4530000000000000
240b57cec5SDimitry Andric
250b57cec5SDimitry Andric#define REL_ADDR(_a)	(_a)-0b(%eax)
260b57cec5SDimitry Andric
270b57cec5SDimitry Andric.text
280b57cec5SDimitry Andric.balign 4
290b57cec5SDimitry AndricDEFINE_COMPILERRT_FUNCTION(__floatundixf)
300b57cec5SDimitry Andric	calll	0f
310b57cec5SDimitry Andric0:	popl	%eax
320b57cec5SDimitry Andric	movss	8(%esp),			%xmm0	// hi 32 bits of input
330b57cec5SDimitry Andric	movss	4(%esp),			%xmm1	// lo 32 bits of input
340b57cec5SDimitry Andric	orpd	REL_ADDR(twop84),	%xmm0	// 2^84 + hi (as a double)
350b57cec5SDimitry Andric	orpd	REL_ADDR(twop52),	%xmm1	// 2^52 + lo (as a double)
360b57cec5SDimitry Andric	addsd	REL_ADDR(twop84_plus_twop52_neg),	%xmm0	// hi - 2^52 (no rounding occurs)
370b57cec5SDimitry Andric	movsd	%xmm1,				4(%esp)
380b57cec5SDimitry Andric	fldl	4(%esp)
390b57cec5SDimitry Andric	movsd	%xmm0,				4(%esp)
400b57cec5SDimitry Andric	faddl	4(%esp)
410b57cec5SDimitry Andric	ret
420b57cec5SDimitry AndricEND_COMPILERRT_FUNCTION(__floatundixf)
430b57cec5SDimitry Andric
440b57cec5SDimitry Andric#endif // __i386__
450b57cec5SDimitry Andric
460b57cec5SDimitry AndricNO_EXEC_STACK_DIRECTIVE
470b57cec5SDimitry Andric
48