2.9
[glibc/nacl-glibc.git] / sysdeps / sparc / sparc32 / mul_1.S
blob868ca2614a483ce31d27e3f51f5a845dba862c35
1 ! SPARC __mpn_mul_1 -- Multiply a limb vector with a limb and store
2 ! the result in a second limb vector.
4 ! Copyright (C) 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
6 ! This file is part of the GNU MP Library.
8 ! The GNU MP Library is free software; you can redistribute it and/or modify
9 ! it under the terms of the GNU Lesser General Public License as published by
10 ! the Free Software Foundation; either version 2.1 of the License, or (at your
11 ! option) any later version.
13 ! The GNU MP Library is distributed in the hope that it will be useful, but
14 ! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ! or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 ! License for more details.
18 ! You should have received a copy of the GNU Lesser General Public License
19 ! along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
20 ! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 ! MA 02111-1307, USA.
24 ! INPUT PARAMETERS
25 ! RES_PTR       o0
26 ! S1_PTR        o1
27 ! SIZE          o2
28 ! S2_LIMB       o3
30 ! ADD CODE FOR SMALL MULTIPLIERS!
31 !1:     ld
32 !       st
34 !2:     ld      ,a
35 !       addxcc  a,a,x
36 !       st      x,
38 !3_unrolled:
39 !       ld      ,a
40 !       addxcc  a,a,x1          ! 2a + cy
41 !       addx    %g0,%g0,x2
42 !       addcc   a,x1,x          ! 3a + c
43 !       st      x,
45 !       ld      ,a
46 !       addxcc  a,a,y1
47 !       addx    %g0,%g0,y2
48 !       addcc   a,y1,x
49 !       st      x,
51 !4_unrolled:
52 !       ld      ,a
53 !       srl     a,2,x1          ! 4a
54 !       addxcc  y2,x1,x
55 !       sll     a,30,x2
56 !       st      x,
58 !       ld      ,a
59 !       srl     a,2,y1
60 !       addxcc  x2,y1,y
61 !       sll     a,30,y2
62 !       st      x,
64 !5_unrolled:
65 !       ld      ,a
66 !       srl     a,2,x1          ! 4a
67 !       addxcc  a,x1,x          ! 5a + c
68 !       sll     a,30,x2
69 !       addx    %g0,x2,x2
70 !       st      x,
72 !       ld      ,a
73 !       srl     a,2,y1
74 !       addxcc  a,y1,x
75 !       sll     a,30,y2
76 !       addx    %g0,y2,y2
77 !       st      x,
79 !8_unrolled:
80 !       ld      ,a
81 !       srl     a,3,x1          ! 8a
82 !       addxcc  y2,x1,x
83 !       sll     a,29,x2
84 !       st      x,
86 !       ld      ,a
87 !       srl     a,3,y1
88 !       addxcc  x2,y1,y
89 !       sll     a,29,y2
90 !       st      x,
92 #include <sysdep.h>
94 ENTRY(__mpn_mul_1)
95         ! Make S1_PTR and RES_PTR point at the end of their blocks
96         ! and put (- 4 x SIZE) in index/loop counter.
97         sll     %o2,2,%o2
98         add     %o0,%o2,%o4     ! RES_PTR in o4 since o0 is retval
99         add     %o1,%o2,%o1
100         sub     %g0,%o2,%o2
102         cmp     %o3,0xfff
103         bgu     LOC(large)
104         nop
106         ld      [%o1+%o2],%o5
107         mov     0,%o0
108         b       LOC(0)
109          add    %o4,-4,%o4
110 LOC(loop0):
111         st      %g1,[%o4+%o2]
112 LOC(0): wr      %g0,%o3,%y
113         sra     %o5,31,%g2
114         and     %o3,%g2,%g2
115         andcc   %g1,0,%g1
116         mulscc  %g1,%o5,%g1
117         mulscc  %g1,%o5,%g1
118         mulscc  %g1,%o5,%g1
119         mulscc  %g1,%o5,%g1
120         mulscc  %g1,%o5,%g1
121         mulscc  %g1,%o5,%g1
122         mulscc  %g1,%o5,%g1
123         mulscc  %g1,%o5,%g1
124         mulscc  %g1,%o5,%g1
125         mulscc  %g1,%o5,%g1
126         mulscc  %g1,%o5,%g1
127         mulscc  %g1,%o5,%g1
128         mulscc  %g1,0,%g1
129         sra     %g1,20,%g4
130         sll     %g1,12,%g1
131         rd      %y,%g3
132         srl     %g3,20,%g3
133         or      %g1,%g3,%g1
135         addcc   %g1,%o0,%g1
136         addx    %g2,%g4,%o0     ! add sign-compensation and cy to hi limb
137         addcc   %o2,4,%o2       ! loop counter
138         bne,a   LOC(loop0)
139          ld     [%o1+%o2],%o5
141         retl
142         st      %g1,[%o4+%o2]
145 LOC(large):
146         ld      [%o1+%o2],%o5
147         mov     0,%o0
148         sra     %o3,31,%g4      ! g4 = mask of ones iff S2_LIMB < 0
149         b       LOC(1)
150          add    %o4,-4,%o4
151 LOC(loop):
152         st      %g3,[%o4+%o2]
153 LOC(1): wr      %g0,%o5,%y
154         and     %o5,%g4,%g2     ! g2 = S1_LIMB iff S2_LIMB < 0, else 0
155         andcc   %g0,%g0,%g1
156         mulscc  %g1,%o3,%g1
157         mulscc  %g1,%o3,%g1
158         mulscc  %g1,%o3,%g1
159         mulscc  %g1,%o3,%g1
160         mulscc  %g1,%o3,%g1
161         mulscc  %g1,%o3,%g1
162         mulscc  %g1,%o3,%g1
163         mulscc  %g1,%o3,%g1
164         mulscc  %g1,%o3,%g1
165         mulscc  %g1,%o3,%g1
166         mulscc  %g1,%o3,%g1
167         mulscc  %g1,%o3,%g1
168         mulscc  %g1,%o3,%g1
169         mulscc  %g1,%o3,%g1
170         mulscc  %g1,%o3,%g1
171         mulscc  %g1,%o3,%g1
172         mulscc  %g1,%o3,%g1
173         mulscc  %g1,%o3,%g1
174         mulscc  %g1,%o3,%g1
175         mulscc  %g1,%o3,%g1
176         mulscc  %g1,%o3,%g1
177         mulscc  %g1,%o3,%g1
178         mulscc  %g1,%o3,%g1
179         mulscc  %g1,%o3,%g1
180         mulscc  %g1,%o3,%g1
181         mulscc  %g1,%o3,%g1
182         mulscc  %g1,%o3,%g1
183         mulscc  %g1,%o3,%g1
184         mulscc  %g1,%o3,%g1
185         mulscc  %g1,%o3,%g1
186         mulscc  %g1,%o3,%g1
187         mulscc  %g1,%o3,%g1
188         mulscc  %g1,%g0,%g1
189         rd      %y,%g3
190         addcc   %g3,%o0,%g3
191         addx    %g2,%g1,%o0     ! add sign-compensation and cy to hi limb
192         addcc   %o2,4,%o2       ! loop counter
193         bne,a   LOC(loop)
194          ld     [%o1+%o2],%o5
196         retl
197         st      %g3,[%o4+%o2]
199 END(__mpn_mul_1)