xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/s390_64/aorrlsh1_n.asm (revision 8e33eff89e26cf71871ead62f0d5063e1313c33a)
1dnl  S/390-64 mpn_addlsh1_n and mpn_rsblsh1_n.
2
3dnl  Copyright 2011 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6dnl
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of either:
9dnl
10dnl    * the GNU Lesser General Public License as published by the Free
11dnl      Software Foundation; either version 3 of the License, or (at your
12dnl      option) any later version.
13dnl
14dnl  or
15dnl
16dnl    * the GNU General Public License as published by the Free Software
17dnl      Foundation; either version 2 of the License, or (at your option) any
18dnl      later version.
19dnl
20dnl  or both in parallel, as here.
21dnl
22dnl  The GNU MP Library is distributed in the hope that it will be useful, but
23dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25dnl  for more details.
26dnl
27dnl  You should have received copies of the GNU General Public License and the
28dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
29dnl  see https://www.gnu.org/licenses/.
30
31include(`../config.m4')
32
33C            cycles/limb
34C z900		 9
35C z990		 4.75
36C z9		 ?
37C z10		11
38C z196		 ?
39
40C TODO
41C  * Optimise for small n, avoid 'la' like in aors_n.asm.
42C  * Tune to reach 3.5 c/l.  For addlsh1, we could let the main alcgr propagate
43C    carry to the lsh1 alcgr.
44C  * Compute RETVAL for sublsh1_n less stupidly.
45
46C INPUT PARAMETERS
47define(`rp',	`%r2')
48define(`up',	`%r3')
49define(`vp',	`%r4')
50define(`n',	`%r5')
51
52ifdef(`OPERATION_addlsh1_n',`
53  define(ADSB,		alg)
54  define(ADSBC,		alcg)
55  define(INITCY,	`lghi	%r9, -1')
56  define(RETVAL,	`la	%r2, 2(%r1,%r9)')
57  define(func, mpn_addlsh1_n)
58')
59ifdef(`OPERATION_rsblsh1_n',`
60  define(ADSB,		slg)
61  define(ADSBC,		slbg)
62  define(INITCY,	`lghi	%r9, 0')
63  define(RETVAL,`dnl
64	algr	%r1, %r9
65	lghi	%r2, 1
66	algr	%r2, %r1')
67  define(func, mpn_rsblsh1_n)
68')
69
70MULFUNC_PROLOGUE(mpn_addlsh1_n mpn_rsblsh1_n)
71
72ASM_START()
73PROLOGUE(func)
74	stmg	%r6, %r9, 48(%r15)
75
76	aghi	n, 3
77	lghi	%r7, 3
78	srlg	%r0, n, 2
79	ngr	%r7, n			C n mod 4
80	je	L(b1)
81	cghi	%r7, 2
82	jl	L(b2)
83	jne	L(b0)
84
85L(b3):	lmg	%r5, %r7, 0(vp)
86	la	vp, 24(vp)
87
88	algr	%r5, %r5
89	alcgr	%r6, %r6
90	alcgr	%r7, %r7
91	slbgr	%r1, %r1
92
93	ADSB	%r5, 0(up)
94	ADSBC	%r6, 8(up)
95	ADSBC	%r7, 16(up)
96	la	up, 24(up)
97	slbgr	%r9, %r9
98
99	stmg	%r5, %r7, 0(rp)
100	la	rp, 24(rp)
101	brctg	%r0, L(top)
102	j	L(end)
103
104L(b0):	lghi	%r1, -1
105	INITCY
106	j	L(top)
107
108L(b1):	lg	%r5, 0(vp)
109	la	vp, 8(vp)
110
111	algr	%r5, %r5
112	slbgr	%r1, %r1
113	ADSB	%r5, 0(up)
114	la	up, 8(up)
115	slbgr	%r9, %r9
116
117	stg	%r5, 0(rp)
118	la	rp, 8(rp)
119	brctg	%r0, L(top)
120	j	L(end)
121
122L(b2):	lmg	%r5, %r6, 0(vp)
123	la	vp, 16(vp)
124
125	algr	%r5, %r5
126	alcgr	%r6, %r6
127	slbgr	%r1, %r1
128
129	ADSB	%r5, 0(up)
130	ADSBC	%r6, 8(up)
131	la	up, 16(up)
132	slbgr	%r9, %r9
133
134	stmg	%r5, %r6, 0(rp)
135	la	rp, 16(rp)
136	brctg	%r0, L(top)
137	j	L(end)
138
139L(top):	lmg	%r5, %r8, 0(vp)
140	la	vp, 32(vp)
141
142	aghi	%r1, 1			C restore carry
143
144	alcgr	%r5, %r5
145	alcgr	%r6, %r6
146	alcgr	%r7, %r7
147	alcgr	%r8, %r8
148
149	slbgr	%r1, %r1		C save carry
150
151	aghi	%r9, 1			C restore carry
152
153	ADSBC	%r5, 0(up)
154	ADSBC	%r6, 8(up)
155	ADSBC	%r7, 16(up)
156	ADSBC	%r8, 24(up)
157	la	up, 32(up)
158
159	slbgr	%r9, %r9		C save carry
160
161	stmg	%r5, %r8, 0(rp)
162	la	rp, 32(rp)
163	brctg	%r0, L(top)
164
165L(end):	RETVAL
166	lmg	%r6, %r9, 48(%r15)
167	br	%r14
168EPILOGUE()
169