1/*********************************************************************/
2/* Copyright 2009, 2010 The University of Texas at Austin.           */
3/* All rights reserved.                                              */
4/*                                                                   */
5/* Redistribution and use in source and binary forms, with or        */
6/* without modification, are permitted provided that the following   */
7/* conditions are met:                                               */
8/*                                                                   */
9/*   1. Redistributions of source code must retain the above         */
10/*      copyright notice, this list of conditions and the following  */
11/*      disclaimer.                                                  */
12/*                                                                   */
13/*   2. Redistributions in binary form must reproduce the above      */
14/*      copyright notice, this list of conditions and the following  */
15/*      disclaimer in the documentation and/or other materials       */
16/*      provided with the distribution.                              */
17/*                                                                   */
18/*    THIS  SOFTWARE IS PROVIDED  BY THE  UNIVERSITY OF  TEXAS AT    */
19/*    AUSTIN  ``AS IS''  AND ANY  EXPRESS OR  IMPLIED WARRANTIES,    */
20/*    INCLUDING, BUT  NOT LIMITED  TO, THE IMPLIED  WARRANTIES OF    */
21/*    MERCHANTABILITY  AND FITNESS FOR  A PARTICULAR  PURPOSE ARE    */
22/*    DISCLAIMED.  IN  NO EVENT SHALL THE UNIVERSITY  OF TEXAS AT    */
23/*    AUSTIN OR CONTRIBUTORS BE  LIABLE FOR ANY DIRECT, INDIRECT,    */
24/*    INCIDENTAL,  SPECIAL, EXEMPLARY,  OR  CONSEQUENTIAL DAMAGES    */
25/*    (INCLUDING, BUT  NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE    */
26/*    GOODS  OR  SERVICES; LOSS  OF  USE,  DATA,  OR PROFITS;  OR    */
27/*    BUSINESS INTERRUPTION) HOWEVER CAUSED  AND ON ANY THEORY OF    */
28/*    LIABILITY, WHETHER  IN CONTRACT, STRICT  LIABILITY, OR TORT    */
29/*    (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY WAY OUT    */
30/*    OF  THE  USE OF  THIS  SOFTWARE,  EVEN  IF ADVISED  OF  THE    */
31/*    POSSIBILITY OF SUCH DAMAGE.                                    */
32/*                                                                   */
33/* The views and conclusions contained in the software and           */
34/* documentation are those of the authors and should not be          */
35/* interpreted as representing official policies, either expressed   */
36/* or implied, of The University of Texas at Austin.                 */
37/*********************************************************************/
38
39#define ASSEMBLER
40#include "common.h"
41
42	PROLOGUE
43
44	pushl	%edi
45	pushl	%esi
46	pushl	%ebx
47
48	PROFCODE
49
50#if defined(F_INTERFACE_GFORT) || defined(F_INTERFACE_G95)
51	EMMS
52#endif
53
54	movl	16(%esp),%edx
55	FLD	28(%esp)
56
57#ifdef XDOUBLE
58	movl	44(%esp),%edi
59	movl	48(%esp),%esi
60#elif defined(DOUBLE)
61	movl	36(%esp),%edi
62	movl	40(%esp),%esi
63#else
64	movl	32(%esp),%edi
65	movl	36(%esp),%esi
66#endif
67
68	ftst
69	fnstsw	%ax
70	andb	$68, %ah
71	je	.L300		# Alpha != ZERO
72
73/* Alpha == ZERO */
74	cmpl	$1,%esi
75	jne	.L104
76
77	movl	%edx, %ecx		# ecx = n
78	sarl	$3,   %ecx		# (n >> 3)
79	jle	.L102
80	ALIGN_4
81
82.L101:
83#ifndef XDOUBLE
84	FSTU	0 * SIZE(%edi)
85	FSTU	1 * SIZE(%edi)
86	FSTU	2 * SIZE(%edi)
87	FSTU	3 * SIZE(%edi)
88	FSTU	4 * SIZE(%edi)
89	FSTU	5 * SIZE(%edi)
90	FSTU	6 * SIZE(%edi)
91	FSTU	7 * SIZE(%edi)
92#else
93	fld	%st
94	FST	0 * SIZE(%edi)
95	fld	%st
96	FST	1 * SIZE(%edi)
97	fld	%st
98	FST	2 * SIZE(%edi)
99	fld	%st
100	FST	3 * SIZE(%edi)
101	fld	%st
102	FST	4 * SIZE(%edi)
103	fld	%st
104	FST	5 * SIZE(%edi)
105	fld	%st
106	FST	6 * SIZE(%edi)
107	fld	%st
108	FST	7 * SIZE(%edi)
109#endif
110
111	addl	$8 * SIZE, %edi
112	decl	%ecx
113	jg	.L101
114	ALIGN_4
115
116.L102:
117	movl	%edx, %ecx
118	andl	$7,   %ecx
119	jle	.L999
120	ALIGN_4
121
122.L103:
123#ifndef XDOUBLE
124	FSTU	0 * SIZE(%edi)
125#else
126	fld	%st
127	FST	0 * SIZE(%edi)
128#endif
129	addl	$SIZE, %edi
130	decl	%ecx
131	jg	.L103
132	jmp	.L999
133	ALIGN_4
134
135.L104:
136	sall	$BASE_SHIFT, %esi
137
138	movl	%edx, %ecx		# ecx = n
139	sarl	$3,   %ecx		# (n >> 3)
140	jle	.L106
141	ALIGN_4
142
143.L105:
144#ifndef XDOUBLE
145	FSTU	0 * SIZE(%edi)
146	addl	%esi, %edi
147	FSTU	0 * SIZE(%edi)
148	addl	%esi, %edi
149	FSTU	0 * SIZE(%edi)
150	addl	%esi, %edi
151	FSTU	0 * SIZE(%edi)
152	addl	%esi, %edi
153	FSTU	0 * SIZE(%edi)
154	addl	%esi, %edi
155	FSTU	0 * SIZE(%edi)
156	addl	%esi, %edi
157	FSTU	0 * SIZE(%edi)
158	addl	%esi, %edi
159	FSTU	0 * SIZE(%edi)
160	addl	%esi, %edi
161#else
162	fld	%st
163	FST	0 * SIZE(%edi)
164	addl	%esi, %edi
165	fld	%st
166	FST	0 * SIZE(%edi)
167	addl	%esi, %edi
168	fld	%st
169	FST	0 * SIZE(%edi)
170	addl	%esi, %edi
171	fld	%st
172	FST	0 * SIZE(%edi)
173	addl	%esi, %edi
174	fld	%st
175	FST	0 * SIZE(%edi)
176	addl	%esi, %edi
177	fld	%st
178	FST	0 * SIZE(%edi)
179	addl	%esi, %edi
180	fld	%st
181	FST	0 * SIZE(%edi)
182	addl	%esi, %edi
183	fld	%st
184	FST	0 * SIZE(%edi)
185	addl	%esi, %edi
186#endif
187
188	decl	%ecx
189	jg	.L105
190	ALIGN_4
191
192.L106:
193	movl	%edx, %ecx
194	andl	$7,   %ecx
195	jle	.L999
196	ALIGN_4
197
198.L107:
199#ifndef XDOUBLE
200	FSTU	0 * SIZE(%edi)
201#else
202	fld	%st
203	FST	0 * SIZE(%edi)
204#endif
205	addl	%esi, %edi
206	decl	%ecx
207	jg	.L107
208	jmp	.L999
209	ALIGN_4
210
211/* Alpha != ZERO */
212
213.L300:
214	cmpl	$1,%esi
215	jne	.L304
216
217	movl	%edx, %ecx		# ecx = n
218	sarl	$3,   %ecx		# (n >> 3)
219	jle	.L302
220	ALIGN_4
221
222.L301:
223	FLD	0 * SIZE(%edi)
224	fmul	%st(1), %st
225	FST	0 * SIZE(%edi)
226
227	FLD	1 * SIZE(%edi)
228	fmul	%st(1), %st
229	FST	1 * SIZE(%edi)
230
231	FLD	2 * SIZE(%edi)
232	fmul	%st(1), %st
233	FST	2 * SIZE(%edi)
234
235	FLD	3 * SIZE(%edi)
236	fmul	%st(1), %st
237	FST	3 * SIZE(%edi)
238
239	FLD	4 * SIZE(%edi)
240	fmul	%st(1), %st
241	FST	4 * SIZE(%edi)
242
243	FLD	5 * SIZE(%edi)
244	fmul	%st(1), %st
245	FST	5 * SIZE(%edi)
246
247	FLD	6 * SIZE(%edi)
248	fmul	%st(1), %st
249	FST	6 * SIZE(%edi)
250
251	FLD	7 * SIZE(%edi)
252	fmul	%st(1), %st
253	FST	7 * SIZE(%edi)
254
255	addl	$8 * SIZE, %edi
256	decl	%ecx
257	jg	.L301
258	ALIGN_4
259
260.L302:
261	movl	%edx, %ecx
262	andl	$7,   %ecx
263	jle	.L999
264	ALIGN_4
265
266.L303:
267	FLD	0 * SIZE(%edi)
268	fmul	%st(1), %st
269	FST	0 * SIZE(%edi)
270	addl	$SIZE, %edi
271	decl	%ecx
272	jg	.L303
273	jmp	.L999
274	ALIGN_4
275
276.L304:
277	sall	$BASE_SHIFT, %esi
278
279	movl	%edx, %ecx		# ecx = n
280	sarl	$3,   %ecx		# (n >> 3)
281	jle	.L306
282	ALIGN_4
283
284.L305:
285	FLD	0 * SIZE(%edi)
286	fmul	%st(1), %st
287	FST	0 * SIZE(%edi)
288	addl	%esi, %edi
289
290	FLD	0 * SIZE(%edi)
291	fmul	%st(1), %st
292	FST	0 * SIZE(%edi)
293	addl	%esi, %edi
294
295	FLD	0 * SIZE(%edi)
296	fmul	%st(1), %st
297	FST	0 * SIZE(%edi)
298	addl	%esi, %edi
299
300	FLD	0 * SIZE(%edi)
301	fmul	%st(1), %st
302	FST	0 * SIZE(%edi)
303	addl	%esi, %edi
304
305	FLD	0 * SIZE(%edi)
306	fmul	%st(1), %st
307	FST	0 * SIZE(%edi)
308	addl	%esi, %edi
309
310	FLD	0 * SIZE(%edi)
311	fmul	%st(1), %st
312	FST	0 * SIZE(%edi)
313	addl	%esi, %edi
314
315	FLD	0 * SIZE(%edi)
316	fmul	%st(1), %st
317	FST	0 * SIZE(%edi)
318	addl	%esi, %edi
319
320	FLD	0 * SIZE(%edi)
321	fmul	%st(1), %st
322	FST	0 * SIZE(%edi)
323	addl	%esi, %edi
324
325	decl	%ecx
326	jg	.L305
327	ALIGN_4
328
329.L306:
330	movl	%edx, %ecx
331	andl	$7,   %ecx
332	jle	.L999
333	ALIGN_4
334
335.L307:
336	FLD	0 * SIZE(%edi)
337	fmul	%st(1), %st
338	FST	0 * SIZE(%edi)
339	addl	%esi, %edi
340	decl	%ecx
341	jg	.L307
342	ALIGN_4
343
344.L999:
345	ffreep	%st(0)
346	xorl	%eax,%eax
347	popl	%ebx
348	popl	%esi
349	popl	%edi
350	ret
351
352	EPILOGUE
353