summary refs log tree commit diff
path: root/sysdeps/powerpc/lshift.s
blob: 9612a3dbec79b0136b5bda3214edd5057fc2df05 (plain) (blame)
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
 # Shift a limb left, low level routine.
 # Copyright (C) 1996, 1997 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 #
 # The GNU C Library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public License as
 # published by the Free Software Foundation; either version 2 of the
 # License, or (at your option) any later version.
 #
 # The GNU C 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
 # Library General Public License for more details.
 #
 # You should have received a copy of the GNU Library General Public
 # License along with the GNU C Library; see the file COPYING.LIB.  If not,
 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.

 # mp_limb_t mpn_lshift (mp_ptr wp, mp_srcptr up, mp_size_t usize,
 #			 unsigned int cnt)

	.align 3
	.globl __mpn_lshift
	.type	 __mpn_lshift,@function
__mpn_lshift:
	mtctr	%r5		# copy size into CTR
	cmplwi	%cr0,%r5,16	# is size < 16
	slwi	%r0,%r5,2
	add	%r7,%r3,%r0	# make r7 point at end of res
	add	%r4,%r4,%r0	# make r4 point at end of s1
	lwzu	%r11,-4(%r4)	# load first s1 limb
	subfic	%r8,%r6,32
	srw	%r3,%r11,%r8	# compute function return value
	bge	%cr0,Lbig	# branch if size >= 16

	bdz	Lend1

Loop:	lwzu	%r10,-4(%r4)
	slw	%r9,%r11,%r6
	srw	%r12,%r10,%r8
	or	%r9,%r9,%r12
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slw	%r9,%r10,%r6
	srw	%r12,%r11,%r8
	or	%r9,%r9,%r12
	stwu	%r9,-4(%r7)
	bdnz	Loop
	b	Lend1

 # Guaranteed not to succeed.
LBoom:	tweq    %r0,%r0

 # We imitate a case statement, by using (yuk!) fixed-length code chunks,
 # of size 4*12 bytes.  We have to do this (or something) to make this PIC.
Lbig:	mflr    %r9
	bltl    %cr0,LBoom      # Never taken, only used to set LR.
	slwi    %r10,%r6,4
	mflr    %r12
	add     %r10,%r12,%r10
	slwi	%r8,%r6,5
	add     %r10,%r8,%r10
	mtctr   %r10
	addi	%r5,%r5,-1
	mtlr    %r9
	bctr

Lend1:	slw	%r0,%r11,%r6
	stw	%r0,-4(%r7)
	blr

	mtctr	%r5
Loop1:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,1
	inslwi	%r9,%r10,1,31
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,1
	inslwi	%r9,%r11,1,31
	stwu	%r9,-4(%r7)
	bdnz	Loop1
	b	Lend1

	mtctr	%r5
Loop2:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,2
	inslwi	%r9,%r10,2,30
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,2
	inslwi	%r9,%r11,2,30
	stwu	%r9,-4(%r7)
	bdnz	Loop2
	b	Lend1

	mtctr	%r5
Loop3:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,3
	inslwi	%r9,%r10,3,29
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,3
	inslwi	%r9,%r11,3,29
	stwu	%r9,-4(%r7)
	bdnz	Loop3
	b	Lend1

	mtctr	%r5
Loop4:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,4
	inslwi	%r9,%r10,4,28
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,4
	inslwi	%r9,%r11,4,28
	stwu	%r9,-4(%r7)
	bdnz	Loop4
	b	Lend1

	mtctr	%r5
Loop5:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,5
	inslwi	%r9,%r10,5,27
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,5
	inslwi	%r9,%r11,5,27
	stwu	%r9,-4(%r7)
	bdnz	Loop5
	b	Lend1

	mtctr	%r5
Loop6:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,6
	inslwi	%r9,%r10,6,26
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,6
	inslwi	%r9,%r11,6,26
	stwu	%r9,-4(%r7)
	bdnz	Loop6
	b	Lend1

	mtctr	%r5
Loop7:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,7
	inslwi	%r9,%r10,7,25
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,7
	inslwi	%r9,%r11,7,25
	stwu	%r9,-4(%r7)
	bdnz	Loop7
	b	Lend1

	mtctr	%r5
Loop8:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,8
	inslwi	%r9,%r10,8,24
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,8
	inslwi	%r9,%r11,8,24
	stwu	%r9,-4(%r7)
	bdnz	Loop8
	b	Lend1

	mtctr	%r5
Loop9:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,9
	inslwi	%r9,%r10,9,23
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,9
	inslwi	%r9,%r11,9,23
	stwu	%r9,-4(%r7)
	bdnz	Loop9
	b	Lend1

	mtctr	%r5
Loop10:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,10
	inslwi	%r9,%r10,10,22
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,10
	inslwi	%r9,%r11,10,22
	stwu	%r9,-4(%r7)
	bdnz	Loop10
	b	Lend1

	mtctr	%r5
Loop11:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,11
	inslwi	%r9,%r10,11,21
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,11
	inslwi	%r9,%r11,11,21
	stwu	%r9,-4(%r7)
	bdnz	Loop11
	b	Lend1

	mtctr	%r5
Loop12:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,12
	inslwi	%r9,%r10,12,20
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,12
	inslwi	%r9,%r11,12,20
	stwu	%r9,-4(%r7)
	bdnz	Loop12
	b	Lend1

	mtctr	%r5
Loop13:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,13
	inslwi	%r9,%r10,13,19
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,13
	inslwi	%r9,%r11,13,19
	stwu	%r9,-4(%r7)
	bdnz	Loop13
	b	Lend1

	mtctr	%r5
Loop14:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,14
	inslwi	%r9,%r10,14,18
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,14
	inslwi	%r9,%r11,14,18
	stwu	%r9,-4(%r7)
	bdnz	Loop14
	b	Lend1

	mtctr	%r5
Loop15:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,15
	inslwi	%r9,%r10,15,17
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,15
	inslwi	%r9,%r11,15,17
	stwu	%r9,-4(%r7)
	bdnz	Loop15
	b	Lend1

	mtctr	%r5
Loop16:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,16
	inslwi	%r9,%r10,16,16
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,16
	inslwi	%r9,%r11,16,16
	stwu	%r9,-4(%r7)
	bdnz	Loop16
	b	Lend1

	mtctr	%r5
Loop17:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,17
	inslwi	%r9,%r10,17,15
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,17
	inslwi	%r9,%r11,17,15
	stwu	%r9,-4(%r7)
	bdnz	Loop17
	b	Lend1

	mtctr	%r5
Loop18:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,18
	inslwi	%r9,%r10,18,14
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,18
	inslwi	%r9,%r11,18,14
	stwu	%r9,-4(%r7)
	bdnz	Loop18
	b	Lend1

	mtctr	%r5
Loop19:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,19
	inslwi	%r9,%r10,19,13
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,19
	inslwi	%r9,%r11,19,13
	stwu	%r9,-4(%r7)
	bdnz	Loop19
	b	Lend1

	mtctr	%r5
Loop20:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,20
	inslwi	%r9,%r10,20,12
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,20
	inslwi	%r9,%r11,20,12
	stwu	%r9,-4(%r7)
	bdnz	Loop20
	b	Lend1

	mtctr	%r5
Loop21:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,21
	inslwi	%r9,%r10,21,11
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,21
	inslwi	%r9,%r11,21,11
	stwu	%r9,-4(%r7)
	bdnz	Loop21
	b	Lend1

	mtctr	%r5
Loop22:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,22
	inslwi	%r9,%r10,22,10
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,22
	inslwi	%r9,%r11,22,10
	stwu	%r9,-4(%r7)
	bdnz	Loop22
	b	Lend1

	mtctr	%r5
Loop23:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,23
	inslwi	%r9,%r10,23,9
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,23
	inslwi	%r9,%r11,23,9
	stwu	%r9,-4(%r7)
	bdnz	Loop23
	b	Lend1

	mtctr	%r5
Loop24:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,24
	inslwi	%r9,%r10,24,8
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,24
	inslwi	%r9,%r11,24,8
	stwu	%r9,-4(%r7)
	bdnz	Loop24
	b	Lend1

	mtctr	%r5
Loop25:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,25
	inslwi	%r9,%r10,25,7
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,25
	inslwi	%r9,%r11,25,7
	stwu	%r9,-4(%r7)
	bdnz	Loop25
	b	Lend1

	mtctr	%r5
Loop26:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,26
	inslwi	%r9,%r10,26,6
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,26
	inslwi	%r9,%r11,26,6
	stwu	%r9,-4(%r7)
	bdnz	Loop26
	b	Lend1

	mtctr	%r5
Loop27:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,27
	inslwi	%r9,%r10,27,5
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,27
	inslwi	%r9,%r11,27,5
	stwu	%r9,-4(%r7)
	bdnz	Loop27
	b	Lend1

	mtctr	%r5
Loop28:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,28
	inslwi	%r9,%r10,28,4
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,28
	inslwi	%r9,%r11,28,4
	stwu	%r9,-4(%r7)
	bdnz	Loop28
	b	Lend1

	mtctr	%r5
Loop29:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,29
	inslwi	%r9,%r10,29,3
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,29
	inslwi	%r9,%r11,29,3
	stwu	%r9,-4(%r7)
	bdnz	Loop29
	b	Lend1

	mtctr	%r5
Loop30:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,30
	inslwi	%r9,%r10,30,2
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,30
	inslwi	%r9,%r11,30,2
	stwu	%r9,-4(%r7)
	bdnz	Loop30
	b	Lend1

	mtctr	%r5
Loop31:	lwzu	%r10,-4(%r4)
	slwi	%r9,%r11,31
	inslwi	%r9,%r10,31,1
	stwu	%r9,-4(%r7)
	bdz	Lend2
	lwzu	%r11,-4(%r4)
	slwi	%r9,%r10,31
	inslwi	%r9,%r11,31,1
	stwu	%r9,-4(%r7)
	bdnz	Loop31
	b	Lend1

Lend2:	slw	%r0,%r10,%r6
	stw	%r0,-4(%r7)
	blr