Upload Tizen:Base source
[external/gmp.git] / mpn / powerpc32 / sublsh1_n.asm
1 dnl  PowerPC-32 mpn_sublsh1_n -- rp[] = up[] - (vp[] << 1)
2
3 dnl  Copyright 2003, 2005, 2007 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 603e:            ?
24 C 604e:            4.0
25 C 75x (G3):        5.0
26 C 7400,7410 (G4):  5.0
27 C 744x,745x (G4+): 5.0
28 C power4/ppc970:   4.25
29 C power5:          5.0
30
31 C INPUT PARAMETERS
32 C rp    r3
33 C up    r4
34 C vp    r5
35 C n     r6
36
37 define(`rp',`r3')
38 define(`up',`r4')
39 define(`vp',`r5')
40
41 define(`s0',`r6')
42 define(`s1',`r7')
43 define(`u0',`r8')
44 define(`v0',`r10')
45 define(`v1',`r11')
46
47 ASM_START()
48 PROLOGUE(mpn_sublsh1_n)
49         mtctr   r6              C copy n in ctr
50
51         lwz     v0, 0(vp)       C load v limb
52         lwz     u0, 0(up)       C load u limb
53         addic   up, up, -4      C update up; set cy
54         addi    rp, rp, -4      C update rp
55         slwi    s1, v0, 1
56         bdz     L(end)          C If done, skip loop
57
58 L(loop):
59         lwz     v1, 4(vp)       C load v limb
60         subfe   s1, s1, u0      C add limbs with cy, set cy
61         srwi    s0, v0, 31      C shift down previous v limb
62         stw     s1, 4(rp)       C store result limb
63         lwzu    u0, 8(up)       C load u limb and update up
64         rlwimi  s0, v1, 1, 0,30 C left shift v limb and merge with prev v limb
65
66         bdz     L(exit)         C decrement ctr and exit if done
67
68         lwzu    v0, 8(vp)       C load v limb and update vp
69         subfe   s0, s0, u0      C add limbs with cy, set cy
70         srwi    s1, v1, 31      C shift down previous v limb
71         stwu    s0, 8(rp)       C store result limb and update rp
72         lwz     u0, 4(up)       C load u limb
73         rlwimi  s1, v0, 1, 0,30 C left shift v limb and merge with prev v limb
74
75         bdnz    L(loop)         C decrement ctr and loop back
76
77 L(end): subfe   r7, s1, u0
78         srwi    r4, v0, 31
79         stw     r7, 4(rp)       C store last result limb
80         subfze  r3, r4
81         neg     r3, r3
82         blr
83 L(exit):
84         subfe   r7, s0, u0
85         srwi    r4, v1, 31
86         stw     r7, 8(rp)       C store last result limb
87         subfze  r3, r4
88         neg     r3, r3
89         blr
90 EPILOGUE()