File: mp32opt.ia64.S

package info (click to toggle)
beecrypt 2.2.0-pre1-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,820 kB
  • ctags: 1,325
  • sloc: ansic: 12,215; sh: 9,073; asm: 2,715; makefile: 80
file content (260 lines) | stat: -rw-r--r-- 5,103 bytes parent folder | download | duplicates (2)
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
/*
 * mp32opt.ia64.S
 *
 * Assembler optimized multiprecision integer routines for ia64 (Intel Itanium)
 *
 * Compile target is GNU Assembler
 *
 * Copyright (c) 2000, 2001 Virtual Unlimited B.V.
 *
 * Author: Bob Deblier <bob@virtualunlimited.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

/*
 * I will need to implement 64 bit multiprecision assembler-optimized routines
 * before this platform can be tested adequately. The current 32 bit ones suffer
 * from loading into integer registers, conversion to floating point, doing the xma
 * and converting back to integer; 64 bit values can be loaded directly into
 * floating point registers, which should shave off a lot of cycles.
 */

#include "beecrypt.gas.h"

#define saved_pfs	r14
#define saved_lc	r15

#define size		r16
#define dst			r17
#define src			r18

	.file	"mp32opt.ia64.S"

	.text

	.explicit

	.align	32
	.global	mp32zero#
	.proc	mp32zero#

mp32zero:
	alloc saved_pfs = ar.pfs,2,0,0,0
	mov saved_lc = ar.lc
	sub size = in0,r0,1;;
	mov src = in1
	mov ar.lc = size;;
.L00:
	st4 [src] = r0,4
	br.ctop.sptk .L00
	;;
	mov ar.lc = saved_lc
	mov ar.pfs = saved_pfs
	br.ret.sptk b0
	.endp	mp32zero#


	.align	32
	.global	mp32copy#
	.proc	mp32copy#

mp32copy:
	alloc saved_pfs = ar.pfs,3,5,0,8
	mov saved_lc = ar.lc
	sub size = in0,r0,1
	mov dst = in1
	mov src = in2;;
	mov ar.lc = size
	mov ar.ec = 2
	mov pr.rot = (1 << 16);;
.L01:
	(p17) st4 [dst] = r33,4
	(p16) ld4 r32 = [src],4;;
	br.ctop.sptk .L01;;
	mov ar.lc = saved_lc
	mov ar.pfs = saved_pfs
	br.ret.sptk b0
	.endp	mp32copy#


	.if		0
	.align	32
	.global	mp32z
	.type	mp32z,@function

mp32z:
	alloc r14 = ar.pfs,2,6,0,8
	mov r15 = ar.lc
	sub r16= in0,r0,1
	mov r17 = in1
	mov r18 = in2;;
	mov r8 = 1
	mov pr.rot = 1 << 16
	mov ar.ec = 2
	mov ar.lc = r16;;
.L02:
	(p16) ld4 r32 = [r18],4
	(p18) cmp.eq p0,p32 = r34,r0
	(p33) mov r8 = r0
	(p33) br.exit
	.endif


	.align	32
	.global	mp32add#
	.proc	mp32add#

mp32add:
	alloc r14 = ar.pfs,3,0,0,0
	mov r15 = ar.lc
	# adjust size by -1
	sub r16 = in0,r0,1
	# clear carry
	mov r8 = r0;;
	# load addresses
	shladd r17 = r16,2,in1
	shladd r18 = r16,2,in2
	# load loop count
	mov ar.lc = r16;;
.L20:
	ld4 r20 = [r18],-4
	ld4 r19 = [r17]
	tbit.z p1,p2 = r8,32;;
	(p1) add r8 = r19,r20
	(p2) add r8 = r19,r20,1;;
	st4 [r17] = r8,-4
	br.cloop.sptk .L20;;
	extr.u r8 = r8,32,1
	mov ar.lc = r15
	mov ar.pfs = r14
	br.ret.sptk b0
	.endp	mp32add#


	.align	32
	.global	mp32sub#
	.proc	mp32sub#

mp32sub:
	alloc r14 = ar.pfs,3,0,0,0
	mov r15 = ar.lc
	# adjust size by -1
	sub r16 = in0,r0,1
	# clear carry
	mov r8 = r0;;
	# load addresses
	shladd r17 = r16,2,in1
	shladd r18 = r16,2,in2
	# load loop count
	mov ar.lc = r16;;
.L30:
	ld4 r20 = [r18],-4
	ld4 r19 = [r17]
	tbit.z p1,p2 = r8,32;;
	(p1) sub r8 = r19,r20
	(p2) sub r8 = r19,r20,1;;
	st4 [r17] = r8,-4
	br.cloop.sptk .L30;;
	extr.u r8 = r8,32,1
	mov ar.lc = r15
	mov ar.pfs = r14
	br.ret.sptk b0
	.endp	mp32sub#


	.if		0

	.align	32
	.global	mp32setmul#
	.proc	mp32setmul#

mp32setmul:
	alloc r14 = ar.pfs,4,0,0,0
	mov r15 = ar.lc
	# load mul
	setf.sig f96 = in3
	# adjust size by -1
	sub r16 = in0,r0,1
	# clear carry
	mov r8 = r0;;
	# adjust addresses
	shladd r17 = r16,2,in1
	shladd r18 = r16,2,in2
	# load loop count
	mov ar.lc = r16;;
.L40:
	ld4 r19 = [r18],-4;;
	setf.sig f98 = r8
	setf.sig f97 = r19;;
	# multiplication can only be done in f registers, but we do have a multiply-add
	xma.l f98 = f96,f97,f98;;
	getf.sig r8 = f98;;
	st4 [r17] = r8,-4
	shr.u r8 = r8,32
	br.cloop.sptk .L40;;
	mov ar.lc = r15
	mov ar.pfs = r14
	br.ret.sptk b0
	.endp	mp32setmul#


	.align	32
	.global	mp32addmul#
	.proc	mp32addmul#

mp32addmul:
	alloc saved_pfs = ar.pfs,4,0,0,0
	mov saved_lc = ar.lc
	# load mul
	setf.sig f96 = in3
	# adjust size by -1
	sub size = in0,r0,1
	# clear carry
	mov r8 = r0;;
	# adjust addresses
	shladd dst = size,2,in1
	shladd src = size,2,in2
	# load loop count
	mov ar.lc = r16;;
.L50:
	ld4 r19 = [dst]
	ld4 r20 = [dst],-4;;
	setf.sig f98 = r8
	setf.sig f97 = r20;;
	# multiplication can only be done in f registers, but we do have a multiply-add
	xma.l f98 = f96,f97,f98;;
	getf.sig r8 = f98;;
	add r8 = r8,r19;;
	st4 [r17] = r8,-4
	shr.u r8 = r8,32
	br.cloop.sptk .L50;;
	mov ar.lc = r15
	mov ar.pfs = r14
	br.ret.sptk b0
	.endp	mp32addmul#

	.endif


	.if 0
	.align	16
	.global	mp32addsqrtrc#
	.proc	mp32addsqrtrc#

mp32addsqrtrc:
	.endp	mp32addsqrtrc#
	.endif