xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/s390_64/rshift.asm (revision 6cd39ddb8550f6fa1bff3fed32053d7f19fd0453)
1dnl  S/390-64 mpn_rshift.
2
3dnl  Copyright 2011 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
22C            cycles/limb
23C z900		 7
24C z990           3
25C z9		 ?
26C z10		 ?
27C z196		 ?
28
29C NOTES
30C  * See notes in lshift.asm.
31
32C INPUT PARAMETERS
33define(`rp',	`%r2')
34define(`up',	`%r3')
35define(`n',	`%r4')
36define(`cnt',	`%r5')
37
38define(`tnc',	`%r6')
39
40ASM_START()
41PROLOGUE(mpn_rshift)
42	cghi	n, 3
43	jh	L(gt1)
44
45	stmg	%r6, %r7, 48(%r15)
46	larl	%r1, L(tab)-4
47	lcgr	tnc, cnt
48	sllg	n, n, 2
49	b	0(n,%r1)
50L(tab):	j	L(n1)
51	j	L(n2)
52	j	L(n3)
53
54L(n1):	lg	%r1, 0(up)
55	srlg	%r0, %r1, 0(cnt)
56	stg	%r0, 0(rp)
57	sllg	%r2, %r1, 0(tnc)
58	lg	%r6, 48(%r15)		C restoring r7 not needed
59	br	%r14
60
61L(n2):	lg	%r1, 0(up)
62	sllg	%r4, %r1, 0(tnc)
63	srlg	%r0, %r1, 0(cnt)
64	lg	%r1, 8(up)
65	sllg	%r7, %r1, 0(tnc)
66	ogr	%r7, %r0
67	srlg	%r0, %r1, 0(cnt)
68	stg	%r7, 0(rp)
69	stg	%r0, 8(rp)
70	lgr	%r2, %r4
71	lmg	%r6, %r7, 48(%r15)
72	br	%r14
73
74
75L(n3):	lg	%r1, 0(up)
76	sllg	%r4, %r1, 0(tnc)
77	srlg	%r0, %r1, 0(cnt)
78	lg	%r1, 8(up)
79	sllg	%r7, %r1, 0(tnc)
80	ogr	%r7, %r0
81	srlg	%r0, %r1, 0(cnt)
82	stg	%r7, 0(rp)
83	lg	%r1, 16(up)
84	sllg	%r7, %r1, 0(tnc)
85	ogr	%r7, %r0
86	srlg	%r0, %r1, 0(cnt)
87	stg	%r7, 8(rp)
88	stg	%r0, 16(rp)
89	lgr	%r2, %r4
90	lmg	%r6, %r7, 48(%r15)
91	br	%r14
92
93L(gt1):	stmg	%r6, %r13, 48(%r15)
94	lcgr	tnc, cnt		C tnc = -cnt
95
96	sllg	%r1, n, 3
97	srlg	%r0, n, 2		C loop count
98
99	lghi	%r7, 3
100	ngr	%r7, n
101	je	L(b0)
102	cghi	%r7, 2
103	jl	L(b1)
104	je	L(b2)
105
106L(b3):	aghi	rp, -8
107	lg	%r7, 0(up)
108	sllg	%r9, %r7, 0(tnc)
109	srlg	%r11, %r7, 0(cnt)
110	lg	%r8, 8(up)
111	lg	%r7, 16(up)
112	sllg	%r4, %r8, 0(tnc)
113	srlg	%r13, %r8, 0(cnt)
114	ogr	%r11, %r4
115	la	up, 24(up)
116	j	L(lm3)
117
118L(b2):	aghi	rp, -16
119	lg	%r8, 0(up)
120	lg	%r7, 8(up)
121	sllg	%r9, %r8, 0(tnc)
122	srlg	%r13, %r8, 0(cnt)
123	la	up, 16(up)
124	j	L(lm2)
125
126L(b1):	aghi	rp, -24
127	lg	%r7, 0(up)
128	sllg	%r9, %r7, 0(tnc)
129	srlg	%r11, %r7, 0(cnt)
130	lg	%r8, 8(up)
131	lg	%r7, 16(up)
132	sllg	%r4, %r8, 0(tnc)
133	srlg	%r10, %r8, 0(cnt)
134	ogr	%r11, %r4
135	la	up, 8(up)
136	j	L(lm1)
137
138L(b0):	aghi	rp, -32
139	lg	%r8, 0(up)
140	lg	%r7, 8(up)
141	sllg	%r9, %r8, 0(tnc)
142	srlg	%r10, %r8, 0(cnt)
143	j	L(lm0)
144
145C	ALIGN(16)
146L(top):	sllg	%r4, %r8, 0(tnc)
147	srlg	%r13, %r8, 0(cnt)
148	ogr	%r11, %r4
149	stg	%r10, 0(rp)
150L(lm3):	stg	%r11, 8(rp)
151L(lm2):	sllg	%r12, %r7, 0(tnc)
152	srlg	%r11, %r7, 0(cnt)
153	lg	%r8, 0(up)
154	lg	%r7, 8(up)
155	ogr	%r13, %r12
156	sllg	%r4, %r8, 0(tnc)
157	srlg	%r10, %r8, 0(cnt)
158	ogr	%r11, %r4
159	stg	%r13, 16(rp)
160L(lm1):	stg	%r11, 24(rp)
161L(lm0):	sllg	%r12, %r7, 0(tnc)
162	aghi	rp, 32
163	srlg	%r11, %r7, 0(cnt)
164	lg	%r8, 16(up)
165	lg	%r7, 24(up)
166	aghi	up, 32
167	ogr	%r10, %r12
168	brctg	%r0, L(top)
169
170L(end):	sllg	%r4, %r8, 0(tnc)
171	srlg	%r13, %r8, 0(cnt)
172	ogr	%r11, %r4
173	stg	%r10, 0(rp)
174	stg	%r11, 8(rp)
175	sllg	%r12, %r7, 0(tnc)
176	srlg	%r11, %r7, 0(cnt)
177	ogr	%r13, %r12
178	stg	%r13, 16(rp)
179	stg	%r11, 24(rp)
180	lgr	%r2, %r9
181
182	lmg	%r6, %r13, 48(%r15)
183	br	%r14
184EPILOGUE()
185