Upload Tizen:Base source
[external/gmp.git] / mpn / powerpc64 / mode64 / addlsh1_n.asm
1 dnl  PowerPC-64 mpn_addlsh1_n -- rp[] = up[] + (vp[] << 1)
2
3 dnl  Copyright 2003, 2005 Free Software Foundation, Inc.
4
5 dnl  This file is part of the GNU MP Library.
6
7 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl  it under the terms of the GNU Lesser General Public License as published
9 dnl  by the Free Software Foundation; either version 3 of the License, or (at
10 dnl  your option) any later version.
11
12 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15 dnl  License for more details.
16
17 dnl  You should have received a copy of the GNU Lesser General Public License
18 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20 include(`../config.m4')
21
22 C               cycles/limb
23 C POWER3/PPC630:     2          (1.5 c/l should be possible)
24 C POWER4/PPC970:     4          (2.0 c/l should be possible)
25
26 C INPUT PARAMETERS
27 C rp    r3
28 C up    r4
29 C vp    r5
30 C n     r6
31
32 define(`rp',`r3')
33 define(`up',`r4')
34 define(`vp',`r5')
35
36 define(`s0',`r6')
37 define(`s1',`r7')
38 define(`u0',`r8')
39 define(`v0',`r10')
40 define(`v1',`r11')
41
42 ASM_START()
43 PROLOGUE(mpn_addlsh1_n)
44         mtctr   r6              C copy n in ctr
45         addic   r31, r31, 0     C clear cy
46
47         ld      v0, 0(vp)       C load v limb
48         ld      u0, 0(up)       C load u limb
49         addi    up, up, -8      C update up
50         addi    rp, rp, -8      C update rp
51         sldi    s1, v0, 1
52         bdz     L(end)          C If done, skip loop
53
54 L(oop): ld      v1, 8(vp)       C load v limb
55         adde    s1, s1, u0      C add limbs with cy, set cy
56         std     s1, 8(rp)       C store result limb
57         srdi    s0, v0, 63      C shift down previous v limb
58         ldu     u0, 16(up)      C load u limb and update up
59         rldimi  s0, v1, 1, 0    C left shift v limb and merge with prev v limb
60
61         bdz     L(exit)         C decrement ctr and exit if done
62
63         ldu     v0, 16(vp)      C load v limb and update vp
64         adde    s0, s0, u0      C add limbs with cy, set cy
65         stdu    s0, 16(rp)      C store result limb and update rp
66         srdi    s1, v1, 63      C shift down previous v limb
67         ld      u0, 8(up)       C load u limb
68         rldimi  s1, v0, 1, 0    C left shift v limb and merge with prev v limb
69
70         bdnz    L(oop)          C decrement ctr and loop back
71
72 L(end): adde    r7, s1, u0
73         std     r7, 8(rp)       C store last result limb
74         srdi    r3, v0, 63
75         addze   r3, r3
76         blr
77 L(exit):        adde    r7, s0, u0
78         std     r7, 16(rp)      C store last result limb
79         srdi    r3, v1, 63
80         addze   r3, r3
81         blr
82 EPILOGUE()