]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/mips/mips64/submul_1.S
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / mips / mips64 / submul_1.S
CommitLineData
d0c2d3b3
UD
1/* MIPS3 __mpn_submul_1 -- Multiply a limb vector with a single limb and
2 * subtract the product from a second limb vector.
3 *
2b778ceb 4 * Copyright (C) 1992-2021 Free Software Foundation, Inc.
d0c2d3b3
UD
5 *
6 * This file is part of the GNU MP Library.
7 *
8 * The GNU MP Library is free software; you can redistribute it and/or modify
f01ec467
AJ
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
d0c2d3b3
UD
11 * option) any later version.
12 *
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
f01ec467 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
d0c2d3b3
UD
16 * License for more details.
17 *
f01ec467 18 * You should have received a copy of the GNU Lesser General Public License
ab84e3ff 19 * along with the GNU MP Library. If not, see
5a82c748 20 * <https://www.gnu.org/licenses/>.
d0c2d3b3
UD
21 */
22
23#include <sysdep.h>
3e9a9758 24#include <sys/asm.h>
d0c2d3b3
UD
25
26/* INPUT PARAMETERS
27 * res_ptr $4
28 * s1_ptr $5
29 * size $6
30 * s2_limb $7
31 */
32
5494bc3a 33#ifdef __PIC__
d0c2d3b3
UD
34 .option pic2
35#endif
a6ee1783 36ENTRY (__mpn_submul_1)
5494bc3a 37#ifdef __PIC__
3e9a9758 38 SETUP_GP /* ??? unused */
d0c2d3b3 39#endif
3e9a9758 40 .set noreorder
d0c2d3b3
UD
41 .set nomacro
42
43 # warm up phase 0
44 ld $8,0($5)
45
46 # warm up phase 1
47 daddiu $5,$5,8
8b2800c0 48#if __mips_isa_rev < 6
d0c2d3b3 49 dmultu $8,$7
8b2800c0
SE
50#else
51 dmulu $11,$8,$7
52 dmuhu $12,$8,$7
53#endif
d0c2d3b3
UD
54
55 daddiu $6,$6,-1
3e9a9758
RM
56 beq $6,$0,L(LC0)
57 move $2,$0 # zero cy2
d0c2d3b3
UD
58
59 daddiu $6,$6,-1
3e9a9758 60 beq $6,$0,L(LC1)
d0c2d3b3
UD
61 ld $8,0($5) # load new s1 limb as early as possible
62
3e9a9758 63L(Loop): ld $10,0($4)
8b2800c0 64#if __mips_isa_rev < 6
d0c2d3b3
UD
65 mflo $3
66 mfhi $9
8b2800c0
SE
67#else
68 move $3,$11
69 move $9,$12
70#endif
d0c2d3b3
UD
71 daddiu $5,$5,8
72 daddu $3,$3,$2 # add old carry limb to low product limb
8b2800c0 73#if __mips_isa_rev < 6
d0c2d3b3 74 dmultu $8,$7
8b2800c0
SE
75#else
76 dmulu $11,$8,$7
77 dmuhu $12,$8,$7
78#endif
d0c2d3b3
UD
79 ld $8,0($5) # load new s1 limb as early as possible
80 daddiu $6,$6,-1 # decrement loop counter
81 sltu $2,$3,$2 # carry from previous addition -> $2
82 dsubu $3,$10,$3
83 sgtu $10,$3,$10
84 daddu $2,$2,$10
85 sd $3,0($4)
86 daddiu $4,$4,8
3e9a9758
RM
87 bne $6,$0,L(Loop)
88 daddu $2,$9,$2 # add high product limb and carry from addition
d0c2d3b3
UD
89
90 # cool down phase 1
3e9a9758 91L(LC1): ld $10,0($4)
8b2800c0 92#if __mips_isa_rev < 6
d0c2d3b3
UD
93 mflo $3
94 mfhi $9
8b2800c0
SE
95#else
96 move $3,$11
97 move $9,$12
98#endif
d0c2d3b3
UD
99 daddu $3,$3,$2
100 sltu $2,$3,$2
8b2800c0 101#if __mips_isa_rev < 6
d0c2d3b3 102 dmultu $8,$7
8b2800c0
SE
103#else
104 dmulu $11,$8,$7
105 dmuhu $12,$8,$7
106#endif
d0c2d3b3
UD
107 dsubu $3,$10,$3
108 sgtu $10,$3,$10
109 daddu $2,$2,$10
110 sd $3,0($4)
111 daddiu $4,$4,8
112 daddu $2,$9,$2 # add high product limb and carry from addition
113
114 # cool down phase 0
3e9a9758 115L(LC0): ld $10,0($4)
8b2800c0 116#if __mips_isa_rev < 6
d0c2d3b3
UD
117 mflo $3
118 mfhi $9
8b2800c0
SE
119#else
120 move $3,$11
121 move $9,$12
122#endif
d0c2d3b3
UD
123 daddu $3,$3,$2
124 sltu $2,$3,$2
125 dsubu $3,$10,$3
126 sgtu $10,$3,$10
127 daddu $2,$2,$10
128 sd $3,0($4)
129 j $31
130 daddu $2,$9,$2 # add high product limb and carry from addition
131
a6ee1783 132END (__mpn_submul_1)