1/* SPARC v9 __mpn_lshift --
2
3   Copyright (C) 1996-2018 Free Software Foundation, Inc.
4
5   This file is part of the GNU MP Library.
6
7   The GNU MP Library is free software; you can redistribute it and/or modify
8   it under the terms of the GNU Lesser General Public License as published by
9   the Free Software Foundation; either version 2.1 of the License, or (at your
10   option) any later version.
11
12   The GNU MP Library is distributed in the hope that it will be useful, but
13   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15   License for more details.
16
17   You should have received a copy of the GNU Lesser General Public License
18   along with the GNU MP Library; see the file COPYING.LIB.  If not,
19   see <http://www.gnu.org/licenses/>.  */
20
21#include "sysdep.h"
22
23/* INPUT PARAMETERS
24   res_ptr	%o0
25   src_ptr	%o1
26   size		%o2
27   cnt		%o3  */
28
29	.register	%g2, #scratch
30	.register	%g3, #scratch
31
32ENTRY(__mpn_lshift)
33	sllx	%o2,3,%g1
34	add	%o1,%g1,%o1	! make %o1 point at end of src
35	ldx	[%o1-8],%g2	! load first limb
36	sub	%g0,%o3,%o5	! negate shift count
37	add	%o0,%g1,%o0	! make %o0 point at end of res
38	add	%o2,-1,%o2
39	andcc	%o2,4-1,%g4	! number of limbs in first loop
40	srlx	%g2,%o5,%g1	! compute function result
41	be,pn	%xcc,.L0	! if multiple of 4 limbs, skip first loop
42	 mov	%g1,%g5
43
44	sub	%o2,%g4,%o2	! adjust count for main loop
45
46.Loop0:	ldx	[%o1-16],%g3
47	add	%o0,-8,%o0
48	add	%o1,-8,%o1
49	sllx	%g2,%o3,%o4
50	addcc	%g4,-1,%g4
51	srlx	%g3,%o5,%g1
52	mov	%g3,%g2
53	or	%o4,%g1,%o4
54	bne,pt	%xcc,.Loop0
55	 stx	%o4,[%o0+0]
56
57.L0:	brz,pn	%o2,.Lend
58	 nop
59
60.Loop:	ldx	[%o1-16],%g3
61	add	%o0,-32,%o0
62	sllx	%g2,%o3,%o4
63	addcc	%o2,-4,%o2
64	srlx	%g3,%o5,%g1
65
66	ldx	[%o1-24],%g2
67	sllx	%g3,%o3,%g4
68	or	%o4,%g1,%o4
69	stx	%o4,[%o0+24]
70	srlx	%g2,%o5,%g1
71
72	ldx	[%o1-32],%g3
73	sllx	%g2,%o3,%o4
74	or	%g4,%g1,%g4
75	stx	%g4,[%o0+16]
76	srlx	%g3,%o5,%g1
77
78	ldx	[%o1-40],%g2
79	sllx	%g3,%o3,%g4
80	or	%o4,%g1,%o4
81	stx	%o4,[%o0+8]
82	srlx	%g2,%o5,%g1
83
84	add	%o1,-32,%o1
85	or	%g4,%g1,%g4
86	bne,pt	%xcc,.Loop
87	 stx	%g4,[%o0+0]
88
89.Lend:	sllx	%g2,%o3,%g2
90	stx	%g2,[%o0-8]
91
92	jmpl	%o7+8, %g0
93	 mov	%g5,%o0
94
95END(__mpn_lshift)
96