blob: 8321343d6bb73531edc1dd7d919320a25e14a7e0 [file] [log] [blame]
Austin Schuhdace2a62020-08-18 10:56:48 -07001dnl SPARC mpn_lshift -- Shift a number left.
2
3dnl Copyright 1995, 1996, 2000 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 INPUT PARAMETERS
35C res_ptr %o0
36C src_ptr %o1
37C size %o2
38C cnt %o3
39
40ASM_START()
41PROLOGUE(mpn_lshift)
42 sll %o2,2,%g1
43 add %o1,%g1,%o1 C make %o1 point at end of src
44 ld [%o1-4],%g2 C load first limb
45 sub %g0,%o3,%o5 C negate shift count
46 add %o0,%g1,%o0 C make %o0 point at end of res
47 add %o2,-1,%o2
48 andcc %o2,4-1,%g4 C number of limbs in first loop
49 srl %g2,%o5,%g1 C compute function result
50 be L(0) C if multiple of 4 limbs, skip first loop
51 st %g1,[%sp+80]
52
53 sub %o2,%g4,%o2 C adjust count for main loop
54
55L(loop0):
56 ld [%o1-8],%g3
57 add %o0,-4,%o0
58 add %o1,-4,%o1
59 addcc %g4,-1,%g4
60 sll %g2,%o3,%o4
61 srl %g3,%o5,%g1
62 mov %g3,%g2
63 or %o4,%g1,%o4
64 bne L(loop0)
65 st %o4,[%o0+0]
66
67L(0): tst %o2
68 be L(end)
69 nop
70
71L(loop):
72 ld [%o1-8],%g3
73 add %o0,-16,%o0
74 addcc %o2,-4,%o2
75 sll %g2,%o3,%o4
76 srl %g3,%o5,%g1
77
78 ld [%o1-12],%g2
79 sll %g3,%o3,%g4
80 or %o4,%g1,%o4
81 st %o4,[%o0+12]
82 srl %g2,%o5,%g1
83
84 ld [%o1-16],%g3
85 sll %g2,%o3,%o4
86 or %g4,%g1,%g4
87 st %g4,[%o0+8]
88 srl %g3,%o5,%g1
89
90 ld [%o1-20],%g2
91 sll %g3,%o3,%g4
92 or %o4,%g1,%o4
93 st %o4,[%o0+4]
94 srl %g2,%o5,%g1
95
96 add %o1,-16,%o1
97 or %g4,%g1,%g4
98 bne L(loop)
99 st %g4,[%o0+0]
100
101L(end): sll %g2,%o3,%g2
102 st %g2,[%o0-4]
103 retl
104 ld [%sp+80],%o0
105EPILOGUE(mpn_lshift)