aorslsh1_n.asm revision 1.1.1.1
1dnl  S/390-32 mpn_addlsh1_n
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		 9.25
24C z990		 5
25C z9		 ?
26C z10		 ?
27C z196		 ?
28
29C TODO
30C  * Optimise for small n
31C  * Compute RETVAL for sublsh1_n less stupidly
32
33C INPUT PARAMETERS
34define(`rp',	`%r2')
35define(`up',	`%r3')
36define(`vp',	`%r4')
37define(`n',	`%r5')
38
39ifdef(`OPERATION_addlsh1_n',`
40  define(ADDSUBC,       alr)
41  define(ADDSUBE,       alcr)
42  define(INITCY,        `lhi	%r13, -1')
43  define(RETVAL,        `alr	%r1, %r13
44			lhi	%r2, 2
45			alr	%r2, %r1')
46  define(func, mpn_addlsh1_n)
47')
48ifdef(`OPERATION_sublsh1_n',`
49  define(ADDSUBC,       slr)
50  define(ADDSUBE,       slbr)
51  define(INITCY,        `lhi	%r13, 0')
52  define(RETVAL,        `slr	%r1, %r13
53			lhi	%r2, 1
54			alr	%r2, %r1')
55  define(func, mpn_sublsh1_n)
56')
57
58MULFUNC_PROLOGUE(mpn_addlsh1_n mpn_sublsh1_n)
59
60ASM_START()
61PROLOGUE(func)
62	stm	%r6, %r13, 24(%r15)
63
64	la	%r0, 3(n)
65	lhi	%r7, 3
66	srl	%r0, 2
67	nr	%r7, n			C n mod 4
68	je	L(b0)
69	chi	%r7, 2
70	jl	L(b1)
71	je	L(b2)
72
73L(b3):	lm	%r5, %r7, 0(up)
74	la	up, 12(up)
75	lm	%r9, %r11, 0(vp)
76	la	vp, 12(vp)
77
78	alr	%r9, %r9
79	alcr	%r10, %r10
80	alcr	%r11, %r11
81	slbr	%r1, %r1
82
83	ADDSUBC	%r5, %r9
84	ADDSUBE	%r6, %r10
85	ADDSUBE	%r7, %r11
86	slbr	%r13, %r13
87
88	stm	%r5, %r7, 0(rp)
89	la	rp, 12(rp)
90	brct	%r0, L(top)
91	j	L(end)
92
93L(b0):	lhi	%r1, -1
94	INITCY
95	j	L(top)
96
97L(b1):	l	%r5, 0(up)
98	la	up, 4(up)
99	l	%r9, 0(vp)
100	la	vp, 4(vp)
101
102	alr	%r9, %r9
103	slbr	%r1, %r1
104	ADDSUBC	%r5, %r9
105	slbr	%r13, %r13
106
107	st	%r5, 0(rp)
108	la	rp, 4(rp)
109	brct	%r0, L(top)
110	j	L(end)
111
112L(b2):	lm	%r5, %r6, 0(up)
113	la	up, 8(up)
114	lm	%r9, %r10, 0(vp)
115	la	vp, 8(vp)
116
117	alr	%r9, %r9
118	alcr	%r10, %r10
119	slbr	%r1, %r1
120
121	ADDSUBC	%r5, %r9
122	ADDSUBE	%r6, %r10
123	slbr	%r13, %r13
124
125	stm	%r5, %r6, 0(rp)
126	la	rp, 8(rp)
127	brct	%r0, L(top)
128	j	L(end)
129
130L(top):	lm	%r9, %r12, 0(vp)
131	la	vp, 16(vp)
132
133	ahi	%r1, 1			C restore carry
134
135	alcr	%r9, %r9
136	alcr	%r10, %r10
137	alcr	%r11, %r11
138	alcr	%r12, %r12
139
140	slbr	%r1, %r1		C save carry
141
142	lm	%r5, %r8, 0(up)
143	la	up, 16(up)
144
145	ahi	%r13, 1			C restore carry
146
147	ADDSUBE	%r5, %r9
148	ADDSUBE	%r6, %r10
149	ADDSUBE	%r7, %r11
150	ADDSUBE	%r8, %r12
151
152	slbr	%r13, %r13
153
154	stm	%r5, %r8, 0(rp)
155	la	rp, 16(rp)
156	brct	%r0, L(top)
157
158L(end):
159	RETVAL
160	lm	%r6, %r13, 24(%r15)
161	br	%r14
162EPILOGUE()
163