beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / sparc64 / ultrasparct3 / mod_1_4.asm
blob08facbd1ccde4c386fbdcaa1dfcec2236d696dc9
1 dnl SPARC T3/T4/T5 mpn_mod_1s_4p.
3 dnl Contributed to the GNU project by Torbjörn Granlund.
5 dnl Copyright 2013 Free Software Foundation, Inc.
7 dnl This file is part of the GNU MP Library.
8 dnl
9 dnl The GNU MP Library is free software; you can redistribute it and/or modify
10 dnl it under the terms of either:
11 dnl
12 dnl * the GNU Lesser General Public License as published by the Free
13 dnl Software Foundation; either version 3 of the License, or (at your
14 dnl option) any later version.
15 dnl
16 dnl or
17 dnl
18 dnl * the GNU General Public License as published by the Free Software
19 dnl Foundation; either version 2 of the License, or (at your option) any
20 dnl later version.
21 dnl
22 dnl or both in parallel, as here.
23 dnl
24 dnl The GNU MP Library is distributed in the hope that it will be useful, but
25 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 dnl for more details.
28 dnl
29 dnl You should have received copies of the GNU General Public License and the
30 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
31 dnl see https://www.gnu.org/licenses/.
33 include(`../config.m4')
35 C cycles/limb
36 C UltraSPARC T3: 30
37 C UltraSPARC T4/T5: 4
39 C INPUT PARAMETERS
40 define(`ap', `%o0')
41 define(`n', `%o1')
42 define(`d', `%o2')
43 define(`cps', `%o3')
46 ASM_START()
47 REGISTER(%g2,#scratch)
48 REGISTER(%g3,#scratch)
49 PROLOGUE(mpn_mod_1s_4p)
50 save %sp, -176, %sp
51 ldx [%i3+16], %o4
52 ldx [%i3+24], %o3
53 ldx [%i3+32], %o2
54 ldx [%i3+40], %o1
55 ldx [%i3+48], %o0
57 and %i1, 3, %g3
58 sllx %i1, 3, %g1
59 add %i0, %g1, %i0
60 brz %g3, L(b00)
61 cmp %g3, 2
62 bcs %xcc, L(b01)
63 nop
64 be %xcc, L(b10)
65 nop
67 L(b11): ldx [%i0-16], %g2
68 mulx %g2, %o4, %g5
69 umulxhi(%g2, %o4, %g3)
70 ldx [%i0-24], %g4
71 addcc %g5, %g4, %g5
72 addxc( %g3, %g0, %g4)
73 ldx [%i0-8], %g2
74 mulx %g2, %o3, %g1
75 umulxhi(%g2, %o3, %g3)
76 addcc %g1, %g5, %g1
77 addxc( %g3, %g4, %g2)
78 ba,pt %xcc, .L8
79 add %i0, -32, %i0
81 L(b00): ldx [%i0-24], %g3
82 mulx %g3, %o4, %g2
83 umulxhi(%g3, %o4, %g5)
84 ldx [%i0-32], %g4
85 addcc %g2, %g4, %g2
86 addxc( %g5, %g0, %g3)
87 ldx [%i0-16], %g4
88 mulx %g4, %o3, %g5
89 umulxhi(%g4, %o3, %i5)
90 addcc %g2, %g5, %g5
91 addxc( %g3, %i5, %g4)
92 ldx [%i0-8], %g2
93 mulx %g2, %o2, %g1
94 umulxhi(%g2, %o2, %g3)
95 addcc %g1, %g5, %g1
96 addxc( %g3, %g4, %g2)
97 ba,pt %xcc, .L8
98 add %i0, -40, %i0
100 L(b01): ldx [%i0-8], %g1
101 mov 0, %g2
102 ba,pt %xcc, .L8
103 add %i0, -16, %i0
105 L(b10): ldx [%i0-8], %g2
106 ldx [%i0-16], %g1
107 add %i0, -24, %i0
109 .L8: add %i1, -5, %g3
110 brlz,pn %g3, L(end)
113 L(top): ldx [%i0-16], %i4
114 mulx %i4, %o4, %o5
115 umulxhi(%i4, %o4, %i1)
116 ldx [%i0-24], %i5
117 addcc %o5, %i5, %o5
118 addxc( %i1, %g0, %i4)
119 ldx [%i0-8], %i5
120 mulx %i5, %o3, %o7
121 umulxhi(%i5, %o3, %i1)
122 addcc %o5, %o7, %o7
123 addxc( %i4, %i1, %i5)
124 ldx [%i0+0], %g4
125 mulx %g4, %o2, %i1
126 umulxhi(%g4, %o2, %i4)
127 addcc %o7, %i1, %i1
128 addxc( %i5, %i4, %g4)
129 mulx %g1, %o1, %i5
130 umulxhi(%g1, %o1, %i4)
131 addcc %i1, %i5, %i5
132 addxc( %g4, %i4, %g5)
133 mulx %g2, %o0, %g1
134 umulxhi(%g2, %o0, %g4)
135 addcc %g1, %i5, %g1
136 addxc( %g4, %g5, %g2)
137 add %g3, -4, %g3
138 brgez,pt %g3, L(top)
139 add %i0, -32, %i0
141 L(end): mulx %g2, %o4, %g5
142 umulxhi(%g2, %o4, %g3)
143 addcc %g1, %g5, %g5
144 addxc( %g3, %g0, %g2)
145 ldx [%i3+8], %i0
146 ldx [%i3], %g4
147 sub %g0, %i0, %i5
148 srlx %g5, %i5, %i5
149 sllx %g2, %i0, %g2
150 or %i5, %g2, %g1
151 mulx %g1, %g4, %l7
152 umulxhi(%g1, %g4, %g3)
153 sllx %g5, %i0, %g2
154 add %g1, 1, %g1
155 addcc %l7, %g2, %g5
156 addxc( %g3, %g1, %g1)
157 mulx %g1, %i2, %g1
158 sub %g2, %g1, %g2
159 cmp %g2, %g5
160 add %i2, %g2, %g1
161 movlu %xcc, %g2, %g1
162 subcc %g1, %i2, %g2
163 movgeu %xcc, %g2, %g1
164 return %i7+8
165 srlx %g1, %o0, %o0
166 EPILOGUE()
168 PROLOGUE(mpn_mod_1s_4p_cps)
169 save %sp, -176, %sp
170 lzcnt( %i1, %i5)
171 sllx %i1, %i5, %i1
172 call mpn_invert_limb, 0
173 mov %i1, %o0
174 stx %o0, [%i0]
175 sra %i5, 0, %g1
176 stx %g1, [%i0+8]
177 sub %g0, %i5, %g2
178 srlx %o0, %g2, %g2
179 mov 1, %g1
180 sllx %g1, %i5, %g1
181 or %g2, %g1, %g2
182 sub %g0, %i1, %g1
183 mulx %g2, %g1, %g2
184 srlx %g2, %i5, %g1
185 stx %g1, [%i0+16]
187 umulxhi(%o0, %g2, %g3)
188 add %g2, %g3, %g3
189 xnor %g0, %g3, %g3
190 mulx %g3, %i1, %g3
191 mulx %g2, %o0, %g2
192 cmp %g2, %g3
193 add %i1, %g3, %g1
194 movgeu %xcc, %g3, %g1
195 srlx %g1, %i5, %g2
196 stx %g2, [%i0+24]
198 umulxhi(%o0, %g1, %g3)
199 add %g1, %g3, %g3
200 xnor %g0, %g3, %g3
201 mulx %g3, %i1, %g3
202 mulx %g1, %o0, %g1
203 cmp %g1, %g3
204 add %i1, %g3, %g2
205 movgeu %xcc, %g3, %g2
206 srlx %g2, %i5, %g1
207 stx %g1, [%i0+32]
209 umulxhi(%o0, %g2, %g3)
210 add %g2, %g3, %g3
211 xnor %g0, %g3, %g3
212 mulx %g3, %i1, %g3
213 mulx %g2, %o0, %g2
214 cmp %g2, %g3
215 add %i1, %g3, %g1
216 movgeu %xcc, %g3, %g1
217 srlx %g1, %i5, %g2
218 stx %g2, [%i0+40]
220 umulxhi(%o0, %g1, %g2)
221 add %g1, %g2, %g2
222 xnor %g0, %g2, %g2
223 mulx %g2, %i1, %g2
224 mulx %g1, %o0, %o0
225 cmp %o0, %g2
226 add %i1, %g2, %g3
227 movgeu %xcc, %g2, %g3
228 srlx %g3, %i5, %i5
229 stx %i5, [%i0+48]
231 return %i7+8
233 EPILOGUE()