xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/s390_32/rshift.asm (revision 92e958de60c71aa0f2452bd7074cbb006fe6546b)
1dnl  S/390-32 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		 6
24C z990	         3
25C z9		 ?
26C z10		 ?
27C z196		 ?
28
29C TODO
30C  *
31
32C INPUT PARAMETERS
33define(`rp',	`%r2')
34define(`up',	`%r3')
35define(`n',	`%r4')
36define(`cnt',	`%r5')
37
38ASM_START()
39PROLOGUE(mpn_rshift)
40	stm	%r6, %r12, 24(%r15)
41	lhi	%r8, 32
42	sr	%r8, cnt
43	l	%r12, 0(up)
44	sll	%r12, 0(%r8)		C return value
45	lhi	%r7, 3
46	nr	%r7, n
47	srl	n, 2
48	je	L(b0)
49	chi	%r7, 2
50	jl	L(b1)
51	je	L(b2)
52
53L(b3):	l	%r11, 0(up)
54	l	%r10, 4(up)
55	l	%r8,  8(up)
56	ahi	up, 8
57	lr	%r9, %r10
58	srdl	%r10, 0(cnt)
59	srdl	%r8,  0(cnt)
60	st	%r11, 0(rp)
61	st	%r9,  4(rp)
62	ahi	rp, 8
63	ltr	n, n
64	je	L(end)
65	j	L(top)
66
67L(b2):	l	%r11, 0(up)
68	l	%r10, 4(up)
69	ahi	up, 4
70	srdl	%r10, 0(cnt)
71	st	%r11, 0(rp)
72	ahi	rp, 4
73	ltr	n, n
74	je	L(end)
75	j	L(top)
76
77L(b1):	ltr	n, n
78	je	L(end)
79	j	L(top)
80
81L(b0):	l	%r11, 0(up)
82	l	%r9,  4(up)
83	l	%r7,  8(up)
84	l	%r1, 12(up)
85	ahi	up, 12
86	lr	%r10, %r9
87	lr	%r8,  %r7
88	lr	%r6,  %r1
89	srdl	%r10, 0(cnt)
90	srdl	%r8,  0(cnt)
91	srdl	%r6,  0(cnt)
92	st	%r11, 0(rp)
93	st	%r9,  4(rp)
94	st	%r7,  8(rp)
95	ahi	rp, 12
96	ahi	n, -1
97	je	L(end)
98
99	ALIGN(8)
100L(top):	l	%r11, 0(up)
101	l	%r9,  4(up)
102	l	%r7,  8(up)
103	l	%r1, 12(up)
104	l	%r0, 16(up)
105	lr	%r10, %r9
106	lr	%r8,  %r7
107	lr	%r6,  %r1
108	ahi	up, 16
109	srdl	%r10, 0(cnt)
110	srdl	%r8,  0(cnt)
111	srdl	%r6,  0(cnt)
112	srdl	%r0,  0(cnt)
113	st	%r11, 0(rp)
114	st	%r9,  4(rp)
115	st	%r7,  8(rp)
116	st	%r1, 12(rp)
117	ahi	rp, 16
118	brct	n, L(top)
119
120L(end):	l	%r11, 0(up)
121	srl	%r11, 0(cnt)
122	st	%r11, 0(rp)
123
124	lr	%r2, %r12
125	lm	%r6, %r12, 24(%r15)
126	br	%r14
127EPILOGUE()
128