Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / mips / mips64 / addmul_1.S
blob57edd4aa7693c425b136426c972e81b64a0b3c78
1 /* MIPS3 __mpn_addmul_1 -- Multiply a limb vector with a single limb and
2  * add the product to 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 <http://www.gnu.org/licenses/>.
20  */
22 #include <sysdep.h>
23 #include <sys/asm.h>
25 /* INPUT PARAMETERS
26  * res_ptr      $4
27  * s1_ptr       $5
28  * size         $6
29  * s2_limb      $7
30  */
32 #ifdef PIC
33         .option pic2
34 #endif
35 ENTRY (__mpn_addmul_1)
36 #ifdef PIC
37         SETUP_GP /* ??? unused */
38 #endif
39         .set    noreorder
40         .set    nomacro
42  # warm up phase 0
43         ld      $8,0($5)
45  # warm up phase 1
46         daddiu  $5,$5,8
47         dmultu  $8,$7
49         daddiu  $6,$6,-1
50         beq     $6,$0,L(LC0)
51         move    $2,$0           # zero cy2
53         daddiu  $6,$6,-1
54         beq     $6,$0,L(LC1)
55         ld      $8,0($5)        # load new s1 limb as early as possible
57 L(Loop):        ld      $10,0($4)
58         mflo    $3
59         mfhi    $9
60         daddiu  $5,$5,8
61         daddu   $3,$3,$2        # add old carry limb to low product limb
62         dmultu  $8,$7
63         ld      $8,0($5)        # load new s1 limb as early as possible
64         daddiu  $6,$6,-1        # decrement loop counter
65         sltu    $2,$3,$2        # carry from previous addition -> $2
66         daddu   $3,$10,$3
67         sltu    $10,$3,$10
68         daddu   $2,$2,$10
69         sd      $3,0($4)
70         daddiu  $4,$4,8
71         bne     $6,$0,L(Loop)
72         daddu   $2,$9,$2        # add high product limb and carry from addition
74  # cool down phase 1
75 L(LC1): ld      $10,0($4)
76         mflo    $3
77         mfhi    $9
78         daddu   $3,$3,$2
79         sltu    $2,$3,$2
80         dmultu  $8,$7
81         daddu   $3,$10,$3
82         sltu    $10,$3,$10
83         daddu   $2,$2,$10
84         sd      $3,0($4)
85         daddiu  $4,$4,8
86         daddu   $2,$9,$2        # add high product limb and carry from addition
88  # cool down phase 0
89 L(LC0): ld      $10,0($4)
90         mflo    $3
91         mfhi    $9
92         daddu   $3,$3,$2
93         sltu    $2,$3,$2
94         daddu   $3,$10,$3
95         sltu    $10,$3,$10
96         daddu   $2,$2,$10
97         sd      $3,0($4)
98         j       $31
99         daddu   $2,$9,$2        # add high product limb and carry from addition
101 END (__mpn_addmul_1)