Update copyright notices with scripts/update-copyrights.
[glibc.git] / ports / sysdeps / mips / mips64 / mul_1.S
blob2fe28d369d6a881330ec80723572f79dde0a9914
1 /* MIPS3 __mpn_mul_1 -- Multiply a limb vector with a single limb and
2  * store the product in a second limb vector.
3  *
4  * Copyright (C) 1992-2013 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         .text
37         .align  4
38         .globl  __mpn_mul_1
39         .ent    __mpn_mul_1
40 __mpn_mul_1:
41 #ifdef __PIC__
42         SETUP_GP /* ??? unused */
43 #endif
44         .set    noreorder
45         .set    nomacro
47  # warm up phase 0
48         ld      $8,0($5)
50  # warm up phase 1
51         daddiu  $5,$5,8
52         dmultu  $8,$7
54         daddiu  $6,$6,-1
55         beq     $6,$0,L(LC0)
56         move    $2,$0           # zero cy2
58         daddiu  $6,$6,-1
59         beq     $6,$0,L(LC1)
60         ld      $8,0($5)        # load new s1 limb as early as possible
62 L(Loop):        mflo    $10
63         mfhi    $9
64         daddiu  $5,$5,8
65         daddu   $10,$10,$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,$10,$2       # carry from previous addition -> $2
70         sd      $10,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): mflo    $10
77         mfhi    $9
78         daddu   $10,$10,$2
79         sltu    $2,$10,$2
80         dmultu  $8,$7
81         sd      $10,0($4)
82         daddiu  $4,$4,8
83         daddu   $2,$9,$2        # add high product limb and carry from addition
85  # cool down phase 0
86 L(LC0): mflo    $10
87         mfhi    $9
88         daddu   $10,$10,$2
89         sltu    $2,$10,$2
90         sd      $10,0($4)
91         j       $31
92         daddu   $2,$9,$2        # add high product limb and carry from addition
94         .end    __mpn_mul_1