• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#include <_mingw_mac.h>
7
8	.file	"floor.S"
9	.text
10	.p2align 4,,15
11	.globl __MINGW_USYMBOL(floor)
12	.def	__MINGW_USYMBOL(floor);	.scl	2;	.type	32;	.endef
13#ifdef __x86_64__
14	.seh_proc __MINGW_USYMBOL(floor)
15#endif
16__MINGW_USYMBOL(floor):
17#if defined(_AMD64_) || defined(__x86_64__)
18	pushq	%rbx
19	.seh_pushreg	%rbx
20	subq	$16, %rsp
21	.seh_stackalloc	16
22	.seh_endprologue
23	movsd	%xmm0, 8(%rsp)
24	movq	8(%rsp), %r9
25	movq	%r9, %rdx
26	movl	%r9d, %r10d
27	shrq	$32, %rdx
28	movl	%edx, %eax
29	movl	%edx, %r11d
30	sarl	$20, %eax
31	andl	$2047, %eax
32	leal	-1023(%rax), %r8d
33	cmpl	$51, %r8d
34	jle	.L2
35	cmpl	$1024, %r8d
36	je	.L27
37.L3:
38	addq	$16, %rsp
39	popq	%rbx
40	ret
41	.p2align 4,,10
42.L2:
43	cmpl	$19, %r8d
44	jg	.L4
45	testl	%r8d, %r8d
46	js	.L28
47	movl	$1048575, %eax
48	movl	%r8d, %ecx
49	shrl	%cl, %eax
50	testl	%r9d, %r9d
51	jne	.L8
52	testl	%edx, %eax
53	je	.L3
54.L8:
55	movsd	.hugeval(%rip), %xmm1
56	xorpd	%xmm2, %xmm2
57	addsd	%xmm0, %xmm1
58	ucomisd	%xmm1, %xmm2
59	jae	.L3
60	xorl	%r9d, %r9d
61	testl	%edx, %edx
62	jns	.L9
63	movl	$1048576, %r9d
64	movl	%r8d, %ecx
65	sarl	%cl, %r9d
66.L9:
67	addl	%r9d, %edx
68	notl	%eax
69	andl	%edx, %eax
70	salq	$32, %rax
71	movq	%rax, 8(%rsp)
72	movsd	8(%rsp), %xmm0
73	addq	$16, %rsp
74	popq	%rbx
75	ret
76	.p2align 4,,10
77.L4:
78	leal	-1043(%rax), %ecx
79	movl	$-1, %ebx
80	shrl	%cl, %ebx
81	testl	%r9d, %ebx
82	je	.L3
83	movsd	.hugeval(%rip), %xmm1
84	xorpd	%xmm2, %xmm2
85	addsd	%xmm0, %xmm1
86	ucomisd	%xmm1, %xmm2
87	jae	.L3
88	testl	%edx, %edx
89	js	.L29
90.L11:
91	notl	%ebx
92	salq	$32, %r11
93	andl	%ebx, %r10d
94	orq	%r10, %r11
95	movq	%r11, 8(%rsp)
96	movsd	8(%rsp), %xmm0
97	addq	$16, %rsp
98	popq	%rbx
99	ret
100	.p2align 4,,10
101.L27:
102	addsd	%xmm0, %xmm0
103	addq	$16, %rsp
104	popq	%rbx
105	ret
106	.p2align 4,,10
107.L28:
108	movsd	.hugeval(%rip), %xmm2
109	xorpd	%xmm1, %xmm1
110	addsd	%xmm0, %xmm2
111	ucomisd	%xmm1, %xmm2
112	jbe	.L3
113	testl	%edx, %edx
114	js	.L7
115	movapd	%xmm1, %xmm0
116	jmp	.L3
117	.p2align 4,,10
118.L7:
119	andl	$2147483647, %edx
120	orl	%r9d, %edx
121	je	.L3
122	movabsq	$-4616189618054758400, %rax
123	movq	%rax, 8(%rsp)
124	movsd	8(%rsp), %xmm0
125	jmp	.L3
126	.p2align 4,,10
127.L29:
128	cmpl	$20, %r8d
129	je	.L25
130	movl	$1075, %ecx
131	movl	$1, %r10d
132	subl	%eax, %ecx
133	sall	%cl, %r10d
134	addl	%r9d, %r10d
135	jae	.L11
136.L25:
137	leal	1(%rdx), %r11d
138	jmp	.L11
139	.seh_endproc
140
141	.section .rdata,"dr"
142	.align 8
143.hugeval:
144	.long	-2013235812
145	.long	2117592124
146#elif defined(_X86_) || defined(__i386__)
147	fldl	4(%esp)
148	subl	$8,%esp
149
150	fstcw	4(%esp)			/* store fpu control word */
151
152	/* We use here %edx although only the low 1 bits are defined.
153	   But none of the operations should care and they are faster
154	   than the 16 bit operations.  */
155	movl	$0x400,%edx		/* round towards -oo */
156	orl	4(%esp),%edx
157	andl	$0xf7ff,%edx
158	movl	%edx,(%esp)
159	fldcw	(%esp)			/* load modified control word */
160
161	frndint				/* round */
162
163	fldcw	4(%esp)			/* restore original control word */
164
165	addl	$8,%esp
166	ret
167#endif
168