1 ! SPARC __mpn_add_n -- Add two limb vectors of the same length > 0 and store
2 ! sum in a third limb vector.
4 ! Copyright (C) 1995-2023 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,
20 ! see <https://www.gnu.org/licenses/>.
32 xor S2_PTR,RES_PTR,%g1
34 bne LOC(1) ! branch if alignment differs
37 LOC(0): andcc RES_PTR,4,%g0 ! RES_PTR unaligned? Side effect: cy=0
38 be LOC(v1) ! if no, branch
40 /* Add least significant limb separately to align RES_PTR and S2_PTR */
50 addx %g0,%g0,%o4 ! save cy in register
51 cmp SIZE,2 ! if SIZE < 2 ...
52 bl LOC(end2) ! ... branch to tail code
53 subcc %g0,%o4,%g0 ! restore cy
60 subcc %g0,%o4,%g0 ! restore cy
61 /* Add blocks of 8 limbs until less than 8 limbs remain */
87 addx %g0,%g0,%o4 ! save cy in register
91 add RES_PTR,32,RES_PTR
93 subcc %g0,%o4,%g0 ! restore cy
98 subcc %g0,%o4,%g0 ! restore cy
99 /* Add blocks of 2 limbs until less than 2 limbs remain */
107 addx %g0,%g0,%o4 ! save cy in register
111 add RES_PTR,8,RES_PTR
113 subcc %g0,%o4,%g0 ! restore cy
118 addx %g0,%g0,%o4 ! save cy in register
122 subcc %g0,%o4,%g0 ! restore cy
131 addx %g0,%g0,%o0 ! return carry-out from most sign. limb
133 LOC(1): xor S1_PTR,RES_PTR,%g1
144 /* If we come here, the alignment of S1_PTR and RES_PTR as well as the
145 alignment of S2_PTR and RES_PTR differ. Since there are only two ways
146 things can be aligned (that we care about) we now know that the alignment
147 of S1_PTR and S2_PTR are the same. */
152 andcc S1_PTR,4,%g0 ! S1_PTR unaligned? Side effect: cy=0
153 be LOC(v2) ! if no, branch
155 /* Add least significant limb separately to align S1_PTR and S2_PTR */
163 add RES_PTR,4,RES_PTR
166 addx %g0,%g0,%o4 ! save cy in register
169 subcc %g0,%o4,%g0 ! restore cy
170 /* Add blocks of 8 limbs until less than 8 limbs remain */
196 addx %g0,%g0,%o4 ! save cy in register
200 add RES_PTR,32,RES_PTR
202 subcc %g0,%o4,%g0 ! restore cy
207 subcc %g0,%o4,%g0 ! restore cy
215 addx %g0,%g0,%o4 ! save cy in register
219 add RES_PTR,8,RES_PTR
221 subcc %g0,%o4,%g0 ! restore cy
225 subcc %g0,%o4,%g0 ! restore cy
235 addx %g0,%g0,%o0 ! return carry-out from most sign. limb