Move all files into ports/ subdirectory in preparation for merge with glibc
[glibc.git] / ports / sysdeps / mips / mips64 / addmul_1.S
blobf62b4a1cc4e42b10a595592d4cf4824099d7badf
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, 1994, 1995, 2002, 2003 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         .text
36         .align  4
37         .globl  __mpn_addmul_1
38         .ent    __mpn_addmul_1
39 __mpn_addmul_1:
40 #ifdef PIC
41         SETUP_GP /* ??? unused */
42 #endif
43         .set    noreorder
44         .set    nomacro
46  # warm up phase 0
47         ld      $8,0($5)
49  # warm up phase 1
50         daddiu  $5,$5,8
51         dmultu  $8,$7
53         daddiu  $6,$6,-1
54         beq     $6,$0,L(LC0)
55         move    $2,$0           # zero cy2
57         daddiu  $6,$6,-1
58         beq     $6,$0,L(LC1)
59         ld      $8,0($5)        # load new s1 limb as early as possible
61 L(Loop):        ld      $10,0($4)
62         mflo    $3
63         mfhi    $9
64         daddiu  $5,$5,8
65         daddu   $3,$3,$2        # add old carry limb to low product limb
66         dmultu  $8,$7
67         ld      $8,0($5)        # load new s1 limb as early as possible
68         daddiu  $6,$6,-1        # decrement loop counter
69         sltu    $2,$3,$2        # carry from previous addition -> $2
70         daddu   $3,$10,$3
71         sltu    $10,$3,$10
72         daddu   $2,$2,$10
73         sd      $3,0($4)
74         daddiu  $4,$4,8
75         bne     $6,$0,L(Loop)
76         daddu   $2,$9,$2        # add high product limb and carry from addition
78  # cool down phase 1
79 L(LC1): ld      $10,0($4)
80         mflo    $3
81         mfhi    $9
82         daddu   $3,$3,$2
83         sltu    $2,$3,$2
84         dmultu  $8,$7
85         daddu   $3,$10,$3
86         sltu    $10,$3,$10
87         daddu   $2,$2,$10
88         sd      $3,0($4)
89         daddiu  $4,$4,8
90         daddu   $2,$9,$2        # add high product limb and carry from addition
92  # cool down phase 0
93 L(LC0): ld      $10,0($4)
94         mflo    $3
95         mfhi    $9
96         daddu   $3,$3,$2
97         sltu    $2,$3,$2
98         daddu   $3,$10,$3
99         sltu    $10,$3,$10
100         daddu   $2,$2,$10
101         sd      $3,0($4)
102         j       $31
103         daddu   $2,$9,$2        # add high product limb and carry from addition
105         .end    __mpn_addmul_1