xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/sparc64/ultrasparc1234/lshiftc.asm (revision d16b7486a53dcb8072b60ec6fcb4373a2d0c27b7)
1dnl  SPARC v9 mpn_lshiftc
2
3dnl  Copyright 1996, 2000-2003, 2010 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
31
32include(`../config.m4')
33
34C		   cycles/limb
35C UltraSPARC 1&2:     3
36C UltraSPARC 3:	      2.67
37
38C INPUT PARAMETERS
39define(`rp', `%i0')
40define(`up', `%i1')
41define(`n',  `%i2')
42define(`cnt',`%i3')
43
44define(`u0', `%l0')
45define(`u1', `%l2')
46define(`u2', `%l4')
47define(`u3', `%l6')
48
49define(`tnc',`%i4')
50
51define(`fanop',`fitod %f0,%f2')		dnl  A quasi nop running in the FA pipe
52
53ASM_START()
54	REGISTER(%g2,#scratch)
55	REGISTER(%g3,#scratch)
56PROLOGUE(mpn_lshiftc)
57	save	%sp,-160,%sp
58
59	sllx	n,3,%g1
60	sub	%g0,cnt,tnc		C negate shift count
61	add	up,%g1,up		C make %o1 point at end of src
62	add	rp,%g1,rp		C make %o0 point at end of res
63	ldx	[up-8],u3		C load first limb
64	subcc	n,5,n
65	srlx	u3,tnc,%i5		C compute function result
66	bl,pn	%xcc,.Lend1234
67	sllx	u3,cnt,%g3
68
69	subcc	n,4,n
70	ldx	[up-16],u0
71	ldx	[up-24],u1
72	add	up,-32,up
73	ldx	[up-0],u2
74	ldx	[up-8],u3
75	srlx	u0,tnc,%g2
76	bl,pn	%xcc,.Lend5678
77	not	%g3, %g3
78
79	b,a	.Loop
80	ALIGN(16)
81.Loop:
82	sllx	u0,cnt,%g1
83	andn	%g3,%g2,%g3
84	ldx	[up-16],u0
85	fanop
86C --
87	srlx	u1,tnc,%g2
88	subcc	n,4,n
89	stx	%g3,[rp-8]
90	not	%g1, %g1
91C --
92	sllx	u1,cnt,%g3
93	andn	%g1,%g2,%g1
94	ldx	[up-24],u1
95	fanop
96C --
97	srlx	u2,tnc,%g2
98	stx	%g1,[rp-16]
99	add	up,-32,up
100	not	%g3, %g3
101C --
102	sllx	u2,cnt,%g1
103	andn	%g3,%g2,%g3
104	ldx	[up-0],u2
105	fanop
106C --
107	srlx	u3,tnc,%g2
108	stx	%g3,[rp-24]
109	add	rp,-32,rp
110	not	%g1, %g1
111C --
112	sllx	u3,cnt,%g3
113	andn	%g1,%g2,%g1
114	ldx	[up-8],u3
115	fanop
116C --
117	srlx	u0,tnc,%g2
118	stx	%g1,[rp-0]
119	bge,pt	%xcc,.Loop
120	not	%g3, %g3
121C --
122.Lend5678:
123	sllx	u0,cnt,%g1
124	andn	%g3,%g2,%g3
125	srlx	u1,tnc,%g2
126	stx	%g3,[rp-8]
127	not	%g1, %g1
128	sllx	u1,cnt,%g3
129	andn	%g1,%g2,%g1
130	srlx	u2,tnc,%g2
131	stx	%g1,[rp-16]
132	not	%g3, %g3
133	sllx	u2,cnt,%g1
134	andn	%g3,%g2,%g3
135	srlx	u3,tnc,%g2
136	stx	%g3,[rp-24]
137	add	rp,-32,rp
138	not	%g1, %g1
139	sllx	u3,cnt,%g3		C carry...
140	andn	%g1,%g2,%g1
141	stx	%g1,[rp-0]
142
143.Lend1234:
144	addcc	n,4,n
145	bz,pn	%xcc,.Lret
146	fanop
147.Loop0:
148	add	rp,-8,rp
149	subcc	n,1,n
150	ldx	[up-16],u3
151	add	up,-8,up
152	srlx	u3,tnc,%g2
153	not	%g3, %g3
154	andn	%g3,%g2,%g3
155	stx	%g3,[rp]
156	sllx	u3,cnt,%g3
157	bnz,pt	%xcc,.Loop0
158	fanop
159.Lret:
160	not	%g3, %g3
161	stx	%g3,[rp-8]
162	mov	%i5,%i0
163	ret
164	restore
165EPILOGUE()
166