sublsh1_n.asm revision 1.1.1.1
1dnl  S/390-64 mpn_sublsh1_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		10
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(ADSBR,		algr)
41  define(ADSBCR,	alcgr)
42  define(INITCY,	`lghi	%r13, -1')
43  define(RETVAL,	`la	%r2, 2(%r1,%r13)')
44  define(func, mpn_addlsh1_n)
45')
46ifdef(`OPERATION_sublsh1_n',`
47  define(ADSBR,		slgr)
48  define(ADSBCR,	slbgr)
49  define(INITCY,	`lghi	%r13, 0')
50  define(RETVAL,`dnl
51	slgr	%r1, %r13
52	lghi	%r2, 1
53	algr	%r2, %r1')
54  define(func, mpn_sublsh1_n)
55')
56
57ASM_START()
58PROLOGUE(mpn_sublsh1_n)
59	stmg	%r6, %r13, 48(%r15)
60
61	aghi	n, 3
62	lghi	%r7, 3
63	srlg	%r0, n, 2
64	ngr	%r7, n			C n mod 4
65	je	L(b1)
66	cghi	%r7, 2
67	jl	L(b2)
68	jne	L(b0)
69
70L(b3):	lmg	%r5, %r7, 0(up)
71	la	up, 24(up)
72	lmg	%r9, %r11, 0(vp)
73	la	vp, 24(vp)
74
75	algr	%r9, %r9
76	alcgr	%r10, %r10
77	alcgr	%r11, %r11
78	slbgr	%r1, %r1
79
80	ADSBR	%r5, %r9
81	ADSBCR	%r6, %r10
82	ADSBCR	%r7, %r11
83	slbgr	%r13, %r13
84
85	stmg	%r5, %r7, 0(rp)
86	la	rp, 24(rp)
87	brctg	%r0, L(top)
88	j	L(end)
89
90L(b0):	lghi	%r1, -1
91	INITCY
92	j	L(top)
93
94L(b1):	lg	%r5, 0(up)
95	la	up, 8(up)
96	lg	%r9, 0(vp)
97	la	vp, 8(vp)
98
99	algr	%r9, %r9
100	slbgr	%r1, %r1
101	ADSBR	%r5, %r9
102	slbgr	%r13, %r13
103
104	stg	%r5, 0(rp)
105	la	rp, 8(rp)
106	brctg	%r0, L(top)
107	j	L(end)
108
109L(b2):	lmg	%r5, %r6, 0(up)
110	la	up, 16(up)
111	lmg	%r9, %r10, 0(vp)
112	la	vp, 16(vp)
113
114	algr	%r9, %r9
115	alcgr	%r10, %r10
116	slbgr	%r1, %r1
117
118	ADSBR	%r5, %r9
119	ADSBCR	%r6, %r10
120	slbgr	%r13, %r13
121
122	stmg	%r5, %r6, 0(rp)
123	la	rp, 16(rp)
124	brctg	%r0, L(top)
125	j	L(end)
126
127L(top):	lmg	%r9, %r12, 0(vp)
128	la	vp, 32(vp)
129
130	aghi	%r1, 1			C restore carry
131
132	alcgr	%r9, %r9
133	alcgr	%r10, %r10
134	alcgr	%r11, %r11
135	alcgr	%r12, %r12
136
137	slbgr	%r1, %r1		C save carry
138
139	lmg	%r5, %r8, 0(up)
140	la	up, 32(up)
141
142	aghi	%r13, 1			C restore carry
143
144	ADSBCR	%r5, %r9
145	ADSBCR	%r6, %r10
146	ADSBCR	%r7, %r11
147	ADSBCR	%r8, %r12
148
149	slbgr	%r13, %r13		C save carry
150
151	stmg	%r5, %r8, 0(rp)
152	la	rp, 32(rp)
153	brctg	%r0, L(top)
154
155L(end):	RETVAL
156	lmg	%r6, %r13, 48(%r15)
157	br	%r14
158EPILOGUE()
159