Upload Tizen:Base source
[external/gmp.git] / mpn / powerpc64 / mode32 / mul_1.asm
1 dnl  PowerPC-64 mpn_mul_1 -- Multiply a limb vector with a limb and add
2 dnl  the result to a second limb vector.
3
4 dnl  Copyright 1999, 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
5
6 dnl  This file is part of the GNU MP Library.
7
8 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl  it under the terms of the GNU Lesser General Public License as published
10 dnl  by the Free Software Foundation; either version 3 of the License, or (at
11 dnl  your option) any later version.
12
13 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
14 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 dnl  License for more details.
17
18 dnl  You should have received a copy of the GNU Lesser General Public License
19 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21 include(`../config.m4')
22
23 C               cycles/limb
24 C POWER3/PPC630:     ?
25 C POWER4/PPC970:     10
26
27 C INPUT PARAMETERS
28 C rp    r3
29 C up    r4
30 C n     r5
31 C v     r6,r7  or  r7,r8
32
33 ASM_START()
34 PROLOGUE(mpn_mul_1)
35
36 ifdef(`BROKEN_LONGLONG_PARAM',
37 `       rldimi  r8, r7, 32,0    C assemble vlimb from separate 32-bit arguments
38         mr      r6, r8
39 ',`
40         rldimi  r7, r6, 32,0    C assemble vlimb from separate 32-bit arguments
41         mr      r6, r7
42 ')
43         li      r7, 0           C cy_limb = 0
44         mtctr   r5
45         addic   r0, r0, 0
46         addi    r3, r3, -8
47         addi    r4, r4, -8
48
49 L(oop): ldu     r0, 8(r4)
50         mulld   r9, r0, r6
51         adde    r12, r9, r7     C add old high limb and new low limb
52         srdi    r5, r9, 32
53         srdi    r11, r7, 32
54         adde    r5, r5, r11     C add high limb parts, set cy
55         mulhdu  r7, r0, r6
56         stdu    r12, 8(r3)
57         bdnz    L(oop)
58
59         addze   r4, r7
60         srdi    r3, r4, 32
61         blr
62 EPILOGUE()