1// This file is dual licensed under the MIT and the University of Illinois Open
2// Source Licenses. See LICENSE.TXT for details.
3
4#include "../assembly.h"
5
6// float __floatundisf(du_int a);
7
8#ifdef __x86_64__
9
10CONST_SECTION
11
12	.balign 16
13two:
14	.single 2.0
15
16#define REL_ADDR(_a)	(_a)(%rip)
17
18.text
19.balign 4
20DEFINE_COMPILERRT_FUNCTION(__floatundisf)
21	movq		$1,			%rsi
22	testq		%rdi,		%rdi
23	js			1f
24	cvtsi2ssq	%rdi,		%xmm0
25	ret
26
271:	andq		%rdi,		%rsi
28	shrq		%rdi
29	orq			%rsi,		%rdi
30	cvtsi2ssq	%rdi,		%xmm0
31	mulss	REL_ADDR(two),	%xmm0
32	ret
33END_COMPILERRT_FUNCTION(__floatundisf)
34
35#endif // __x86_64__
36
37NO_EXEC_STACK_DIRECTIVE
38
39