Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / mips / mips64 / submul_1.S
blobbf24123bde7a0e72c5ea968147f1c2851d1c0256
1 /* MIPS3 __mpn_submul_1 -- Multiply a limb vector with a single limb and
2  * subtract the product from a second limb vector.
3  *
4  * Copyright (C) 1992-2014 Free Software Foundation, Inc.
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
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.
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
15  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with the GNU MP Library.  If not, see
20  * <http://www.gnu.org/licenses/>.
21  */
23 #include <sysdep.h>
24 #include <sys/asm.h>
26 /* INPUT PARAMETERS
27  * res_ptr      $4
28  * s1_ptr       $5
29  * size         $6
30  * s2_limb      $7
31  */
33 #ifdef __PIC__
34         .option pic2
35 #endif
36 ENTRY (__mpn_submul_1)
37 #ifdef __PIC__
38         SETUP_GP /* ??? unused */
39 #endif
40         .set    noreorder
41         .set    nomacro
43  # warm up phase 0
44         ld      $8,0($5)
46  # warm up phase 1
47         daddiu  $5,$5,8
48         dmultu  $8,$7
50         daddiu  $6,$6,-1
51         beq     $6,$0,L(LC0)
52         move    $2,$0           # zero cy2
54         daddiu  $6,$6,-1
55         beq     $6,$0,L(LC1)
56         ld      $8,0($5)        # load new s1 limb as early as possible
58 L(Loop):        ld      $10,0($4)
59         mflo    $3
60         mfhi    $9
61         daddiu  $5,$5,8
62         daddu   $3,$3,$2        # add old carry limb to low product limb
63         dmultu  $8,$7
64         ld      $8,0($5)        # load new s1 limb as early as possible
65         daddiu  $6,$6,-1        # decrement loop counter
66         sltu    $2,$3,$2        # carry from previous addition -> $2
67         dsubu   $3,$10,$3
68         sgtu    $10,$3,$10
69         daddu   $2,$2,$10
70         sd      $3,0($4)
71         daddiu  $4,$4,8
72         bne     $6,$0,L(Loop)
73         daddu   $2,$9,$2        # add high product limb and carry from addition
75  # cool down phase 1
76 L(LC1): ld      $10,0($4)
77         mflo    $3
78         mfhi    $9
79         daddu   $3,$3,$2
80         sltu    $2,$3,$2
81         dmultu  $8,$7
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
87         daddu   $2,$9,$2        # add high product limb and carry from addition
89  # cool down phase 0
90 L(LC0): ld      $10,0($4)
91         mflo    $3
92         mfhi    $9
93         daddu   $3,$3,$2
94         sltu    $2,$3,$2
95         dsubu   $3,$10,$3
96         sgtu    $10,$3,$10
97         daddu   $2,$2,$10
98         sd      $3,0($4)
99         j       $31
100         daddu   $2,$9,$2        # add high product limb and carry from addition
102 END (__mpn_submul_1)