xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/powerpc32/750/lshift.asm (revision a4ddc2c8fb9af816efe3b1c375a5530aef0e89e9)
1dnl  PowerPC 750 mpn_lshift -- mpn left shift.
2
3dnl  Copyright 2002, 2003 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of the GNU Lesser General Public License as published
9dnl  by the Free Software Foundation; either version 3 of the License, or (at
10dnl  your option) any later version.
11
12dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15dnl  License for more details.
16
17dnl  You should have received a copy of the GNU Lesser General Public License
18dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20include(`../config.m4')
21
22
23C       cycles/limb
24C 750:     3.0
25C 7400:    3.0
26
27
28C mp_limb_t mpn_lshift (mp_ptr dst, mp_srcptr src, mp_size_t size,
29C                       unsigned shift);
30C
31C This code is the same per-limb speed as mpn/powerpc32/lshift.asm, but
32C smaller and saving about 30 or so cycles of overhead.
33
34ASM_START()
35PROLOGUE(mpn_lshift)
36
37	C r3	dst
38	C r4	src
39	C r5	size
40	C r6	shift
41
42	mtctr	r5		C size
43	slwi	r5, r5, 2	C 4*size
44
45	subfic	r7, r6, 32	C 32-shift
46	add	r4, r4, r5	C &src[size]
47
48	add	r5, r3, r5	C &dst[size]
49	lwz	r8, -4(r4)	C src[size-1]
50	bdz	L(one)
51
52	lwzu	r9, -8(r4)	C src[size-2]
53
54	srw	r3, r8, r7	C return value
55	slw	r8, r8, r6	C src[size-1] << shift
56	bdz	L(two)
57
58
59L(top):
60	C r3	return value
61	C r4	src, incrementing
62	C r5	dst, incrementing
63	C r6	lshift
64	C r7	32-shift
65	C r8	src[i+1] << shift
66	C r9	src[i]
67	C r10
68
69	lwzu	r10, -4(r4)
70	srw	r11, r9, r7
71
72	or	r8, r8, r11
73	stwu	r8, -4(r5)
74
75	slw	r8, r9, r6
76	bdz	L(odd)
77
78	C r8	src[i+1] << shift
79	C r9
80	C r10	src[i]
81
82	lwzu	r9, -4(r4)
83	srw	r11, r10, r7
84
85	or	r8, r8, r11
86	stwu	r8, -4(r5)
87
88	slw	r8, r10, r6
89	bdnz	L(top)
90
91
92L(two):
93	C r3	return value
94	C r4
95	C r5	&dst[2]
96	C r6	shift
97	C r7	32-shift
98	C r8	src[1] << shift
99	C r9	src[0]
100	C r10
101
102	srw	r11, r9, r7
103	slw	r12, r9, r6	C src[0] << shift
104
105	or	r8, r8, r11
106	stw	r12, -8(r5)	C dst[0]
107
108	stw	r8, -4(r5)	C dst[1]
109	blr
110
111
112L(odd):
113	C r3	return value
114	C r4
115	C r5	&dst[2]
116	C r6	shift
117	C r7	32-shift
118	C r8	src[1] << shift
119	C r9
120	C r10	src[0]
121
122	srw	r11, r10, r7
123	slw	r12, r10, r6
124
125	or	r8, r8, r11
126	stw	r12, -8(r5)	C dst[0]
127
128	stw	r8, -4(r5)	C dst[1]
129	blr
130
131
132L(one):
133	C r5	&dst[1]
134	C r6	shift
135	C r7	32-shift
136	C r8	src[0]
137
138	srw	r3, r8, r7	C return value
139	slw	r8, r8, r6	C src[size-1] << shift
140
141	stw	r8, -4(r5)	C dst[0]
142	blr
143
144EPILOGUE(mpn_lshift)
145