summaryrefslogtreecommitdiff
path: root/mpn/ia64/logops_n.asm
blob: 2b9e5b7dfadde80343d1b39647adf46ab0cf7479 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
dnl  IA-64 mpn_and_n, mpn_andn_n, mpn_nand_n, mpn_ior_n, mpn_iorn_n,
dnl  mpn_nior_n, mpn_xor_n, mpn_xnor_n -- mpn bitwise logical operations.

dnl  Copyright 2003, 2004, 2005 Free Software Foundation, Inc.
dnl
dnl  This file is part of the GNU MP Library.
dnl
dnl  The GNU MP Library is free software; you can redistribute it and/or modify
dnl  it under the terms of the GNU Lesser General Public License as published
dnl  by the Free Software Foundation; either version 2.1 of the License, or (at
dnl  your option) any later version.
dnl
dnl  The GNU MP Library is distributed in the hope that it will be useful, but
dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
dnl  License for more details.
dnl
dnl  You should have received a copy of the GNU Lesser General Public License
dnl  along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
dnl  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
dnl  MA 02110-1301, USA.

include(`../config.m4')

C           cycles/limb
C Itanium 2:    1

C TODO
C  * Use rp,rpx scheme of aors_n.asm to allow parallel stores (useful in
C    wind-down code).

C INPUT PARAMETERS
define(`rp', `r32')
define(`up', `r33')
define(`vp', `r34')
define(`n', `r35')

ifdef(`OPERATION_and_n',
`	define(`func',`mpn_and_n')
	define(`logop',		`and	$1 = $2, $3')
	define(`notormov',	`mov	$1 = $2')')
ifdef(`OPERATION_andn_n',
`	define(`func',`mpn_andn_n')
	define(`logop',		`andcm	$1 = $2, $3')
	define(`notormov',	`mov	$1 = $2')')
ifdef(`OPERATION_nand_n',
`	define(`func',`mpn_nand_n')
	define(`logop',		`and	$1 = $2, $3')
	define(`notormov',	`sub	$1 = -1, $2')')
ifdef(`OPERATION_ior_n',
`	define(`func',`mpn_ior_n')
	define(`logop',		`or	$1 = $2, $3')
	define(`notormov',	`mov	$1 = $2')')
ifdef(`OPERATION_iorn_n',
`	define(`func',`mpn_iorn_n')
	define(`logop',		`andcm	$1 = $3, $2')
	define(`notormov',	`sub	$1 = -1, $2')')
ifdef(`OPERATION_nior_n',
`	define(`func',`mpn_nior_n')
	define(`logop',		`or	$1 = $2, $3')
	define(`notormov',	`sub	$1 = -1, $2')')
ifdef(`OPERATION_xor_n',
`	define(`func',`mpn_xor_n')
	define(`logop',		`xor	$1 = $2, $3')
	define(`notormov',	`mov	$1 = $2')')
ifdef(`OPERATION_xnor_n',
`	define(`func',`mpn_xnor_n')
	define(`logop',		`xor	$1 = $2, $3')
	define(`notormov',	`sub	$1 = -1, $2')')

MULFUNC_PROLOGUE(mpn_and_n mpn_andn_n mpn_nand_n mpn_ior_n mpn_iorn_n mpn_nior_n mpn_xor_n mpn_xnor_n)

ASM_START()
PROLOGUE(func)
	.prologue
	.save	ar.lc, r2
	.body
ifdef(`HAVE_ABI_32',
`	addp4	rp = 0, rp			C			M I
	addp4	up = 0, up			C			M I
	addp4	vp = 0, vp			C			M I
	zxt4	n = n				C			I
	;;
')
{.mmi
	ld8		r10 = [up], 8		C			M
	ld8		r11 = [vp], 8		C			M
	mov.i		r2 = ar.lc		C			I0
}
{.mmi
	and		r14 = 3, n		C			M I
	cmp.lt		p15, p14 = 4, n		C			M I
	shr.u		n = n, 2		C			I0
	;;
}
{.mmi
	cmp.eq		p6, p0 = 1, r14		C			M I
	cmp.eq		p7, p0 = 2, r14		C			M I
	cmp.eq		p8, p0 = 3, r14		C			M I
}
{.bbb
   (p6)	br.dptk		.Lb01			C			B
   (p7)	br.dptk		.Lb10			C			B
   (p8)	br.dptk		.Lb11			C			B
}

.Lb00:	ld8		r17 = [up], 8		C			M
	ld8		r21 = [vp], 8		C			M
	add		n = -2, n		C			M I
	;;
	ld8		r18 = [up], 8		C			M
	ld8		r22 = [vp], 8		C			M
	;;
	ld8		r19 = [up], 8		C			M
	ld8		r23 = [vp], 8		C			M
  (p15)	br.cond.dpnt	.grt4			C			B

	logop(		r14, r10, r11)		C			M I
	;;
	logop(		r15, r17, r21)		C			M I
	notormov(	r8, r14)		C			M I
	br		.Lcj4			C			B

.grt4:	logop(		r14, r10, r11)		C			M I
	ld8		r16 = [up], 8		C			M
	ld8		r20 = [vp], 8		C			M
	;;
	logop(		r15, r17, r21)		C			M I
	ld8		r17 = [up], 8		C			M
	mov.i		ar.lc = n		C			I0
	notormov(	r8, r14)		C			M I
	ld8		r21 = [vp], 8		C			M
	br		.LL00			C			B

.Lb01:	add		n = -1, n		C			M I
	logop(		r15, r10, r11)		C			M I
  (p15)	br.cond.dpnt	.grt1			C			B
	;;

	notormov(	r9, r15)		C			M I
	br		.Lcj1			C			B

.grt1:	ld8		r16 = [up], 8		C			M
	ld8		r20 = [vp], 8		C			M
	;;
	ld8		r17 = [up], 8		C			M
	ld8		r21 = [vp], 8		C			M
	mov.i		ar.lc = n		C			I0
	;;
	ld8		r18 = [up], 8		C			M
	ld8		r22 = [vp], 8		C			M
	;;
	ld8		r19 = [up], 8		C			M
	ld8		r23 = [vp], 8		C			M
	br.cloop.dptk	.grt5			C			B
	;;

	logop(		r14, r16, r20)		C			M I
	notormov(	r9, r15)		C			M I
	br		.Lcj5			C			B

.grt5:	logop(		r14, r16, r20)		C			M I
	ld8		r16 = [up], 8		C			M
	notormov(	r9, r15)		C			M I
	ld8		r20 = [vp], 8		C			M
	br		.LL01			C			B

.Lb10:	ld8		r19 = [up], 8		C			M
	ld8		r23 = [vp], 8		C			M
  (p15)	br.cond.dpnt	.grt2			C			B

	logop(		r14, r10, r11)		C			M I
	;;
	logop(		r15, r19, r23)		C			M I
	notormov(	r8, r14)		C			M I
	br		.Lcj2			C			B

.grt2:	ld8		r16 = [up], 8		C			M
	ld8		r20 = [vp], 8		C			M
	add		n = -1, n		C			M I
	;;
	ld8		r17 = [up], 8		C			M
	ld8		r21 = [vp], 8		C			M
	logop(		r14, r10, r11)		C			M I
	;;
	ld8		r18 = [up], 8		C			M
	ld8		r22 = [vp], 8		C			M
	mov.i		ar.lc = n		C			I0
	;;
	logop(		r15, r19, r23)		C			M I
	ld8		r19 = [up], 8		C			M
	notormov(	r8, r14)		C			M I
	ld8		r23 = [vp], 8		C			M
	br.cloop.dptk	.Loop			C			B
	br		.Lcj6			C			B

.Lb11:	ld8		r18 = [up], 8		C			M
	ld8		r22 = [vp], 8		C			M
	add		n = -1, n		C			M I
	;;
	ld8		r19 = [up], 8		C			M
	ld8		r23 = [vp], 8		C			M
	logop(		r15, r10, r11)		C			M I
  (p15)	br.cond.dpnt	.grt3			C			B
	;;

	logop(		r14, r18, r22)		C			M I
	notormov(	r9, r15)		C			M I
	br		.Lcj3			C			B

.grt3:	ld8		r16 = [up], 8		C			M
	ld8		r20 = [vp], 8		C			M
	;;
	ld8		r17 = [up], 8		C			M
	ld8		r21 = [vp], 8		C			M
	mov.i		ar.lc = n		C			I0
	;;
	logop(		r14, r18, r22)		C			M I
	ld8		r18 = [up], 8		C			M
	notormov(	r9, r15)		C			M I
	ld8		r22 = [vp], 8		C			M
	br		.LL11			C			B

C *** MAIN LOOP START ***
	ALIGN(32)
.Loop:	st8		[rp] = r8, 8		C			M
	logop(		r14, r16, r20)		C			M I
	notormov(	r9, r15)		C			M I
	ld8		r16 = [up], 8		C			M
	ld8		r20 = [vp], 8		C			M
	nop.b		0
	;;
.LL01:	st8		[rp] = r9, 8		C			M
	logop(		r15, r17, r21)		C			M I
	notormov(	r8, r14)		C			M I
	ld8		r17 = [up], 8		C			M
	ld8		r21 = [vp], 8		C			M
	nop.b		0
	;;
.LL00:	st8		[rp] = r8, 8		C			M
	logop(		r14, r18, r22)		C			M I
	notormov(	r9, r15)		C			M I
	ld8		r18 = [up], 8		C			M
	ld8		r22 = [vp], 8		C			M
	nop.b		0
	;;
.LL11:	st8		[rp] = r9, 8		C			M
	logop(		r15, r19, r23)		C			M I
	notormov(	r8, r14)		C			M I
	ld8		r19 = [up], 8		C			M
	ld8		r23 = [vp], 8		C			M
	br.cloop.dptk	.Loop	;;		C			B
C *** MAIN LOOP END ***

.Lcj6:	st8		[rp] = r8, 8		C			M
	logop(		r14, r16, r20)		C			M I
	notormov(	r9, r15)		C			M I
	;;
.Lcj5:	st8		[rp] = r9, 8		C			M
	logop(		r15, r17, r21)		C			M I
	notormov(	r8, r14)		C			M I
	;;
.Lcj4:	st8		[rp] = r8, 8		C			M
	logop(		r14, r18, r22)		C			M I
	notormov(	r9, r15)		C			M I
	;;
.Lcj3:	st8		[rp] = r9, 8		C			M
	logop(		r15, r19, r23)		C			M I
	notormov(	r8, r14)		C			M I
	;;
.Lcj2:	st8		[rp] = r8, 8		C			M
	notormov(	r9, r15)		C			M I
	;;
.Lcj1:	st8		[rp] = r9, 8		C			M
	mov.i		ar.lc = r2		C			I0
	br.ret.sptk.many b0			C			B
EPILOGUE()
ASM_END()