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#define M	ARG1
43#define X	ARG2
44#define INCX	ARG3
45
46#define I	%rax
47
48#include "l1param.h"
49
50	PROLOGUE
51	PROFCODE
52
53#ifdef WINDOWS_ABI
54	emms
55#endif
56
57	fldz
58	testq	M, M
59	jle	.L999
60	testq	INCX, INCX
61	jle	.L999
62
63	salq	$BASE_SHIFT, INCX
64
65	fldz
66	fldz
67	fldz
68	cmpq	$SIZE, INCX
69	jne	.L40
70
71	movq	M, I
72	sarq	$3,   I
73	jle	.L20
74	ALIGN_4
75
76.L10:
77#ifdef PREFETCH
78	PREFETCH (PREFETCHSIZE +  0) - PREOFFSET(X)
79#endif
80
81	FLD	0 * SIZE(X)
82	fabs
83	FLD	1 * SIZE(X)
84	fabs
85	FLD	2 * SIZE(X)
86	fabs
87	FLD	3 * SIZE(X)
88	fabs
89
90	faddp	%st, %st(7)
91	faddp	%st, %st(5)
92	faddp	%st, %st(3)
93	faddp	%st, %st(1)
94
95	FLD	4 * SIZE(X)
96	fabs
97	FLD	5 * SIZE(X)
98	fabs
99	FLD	6 * SIZE(X)
100	fabs
101	FLD	7 * SIZE(X)
102	fabs
103
104	addq	$8 * SIZE, X
105
106	faddp	%st, %st(7)
107	faddp	%st, %st(5)
108	faddp	%st, %st(3)
109	faddp	%st, %st(1)
110
111	decq	I
112	jg	.L10
113	ALIGN_4
114
115.L20:
116	andq	$7,  M
117	jle	.L998
118	ALIGN_4
119
120.L21:
121	FLD	(X)
122	fabs
123	faddp	%st,%st(1)
124	addq	$1 * SIZE, X
125	decq	M
126	jg	.L21
127	jmp	.L998
128	ALIGN_4
129
130.L40:
131	movq	M, I
132	sarq	$3,   I
133	jle	.L60
134	ALIGN_4
135
136.L50:
137	FLD	(X)
138	addq	INCX, X
139	fabs
140	FLD	(X)
141	addq	INCX, X
142	fabs
143	FLD	(X)
144	addq	INCX, X
145	fabs
146	FLD	(X)
147	addq	INCX, X
148	fabs
149
150	faddp	%st, %st(7)
151	faddp	%st, %st(5)
152	faddp	%st, %st(3)
153	faddp	%st, %st(1)
154
155	FLD	(X)
156	addq	INCX, X
157	fabs
158	FLD	(X)
159	addq	INCX, X
160	fabs
161	FLD	(X)
162	addq	INCX, X
163	fabs
164	FLD	(X)
165	addq	INCX, X
166	fabs
167
168	faddp	%st, %st(7)
169	faddp	%st, %st(5)
170	faddp	%st, %st(3)
171	faddp	%st, %st(1)
172
173	decq	I
174	jg	.L50
175	ALIGN_4
176
177.L60:
178	andq	$7,  M
179	jle	.L998
180	ALIGN_4
181
182
183.L61:
184	FLD	(X)
185	addq	INCX, X
186	fabs
187	faddp	%st,%st(1)
188	decq	M
189	jg	.L61
190	ALIGN_4
191
192.L998:
193	faddp	%st,%st(2)
194	faddp	%st,%st(1)
195	faddp	%st,%st(1)
196	ALIGN_4
197
198.L999:
199	ret
200
201	EPILOGUE
202