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