beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / powerpc32 / aors_n.asm
blob25ece0966e9a115be2d45b472538e3817a930f73
1 dnl PowerPC-32 mpn_add_n and mpn_sub_n.
3 dnl Copyright 2002, 2005, 2007 Free Software Foundation, Inc.
5 dnl This file is part of the GNU MP Library.
6 dnl
7 dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl it under the terms of either:
9 dnl
10 dnl * the GNU Lesser General Public License as published by the Free
11 dnl Software Foundation; either version 3 of the License, or (at your
12 dnl option) any later version.
13 dnl
14 dnl or
15 dnl
16 dnl * the GNU General Public License as published by the Free Software
17 dnl Foundation; either version 2 of the License, or (at your option) any
18 dnl later version.
19 dnl
20 dnl or both in parallel, as here.
21 dnl
22 dnl The GNU MP Library is distributed in the hope that it will be useful, but
23 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 dnl for more details.
26 dnl
27 dnl You should have received copies of the GNU General Public License and the
28 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
29 dnl see https://www.gnu.org/licenses/.
31 include(`../config.m4')
33 C cycles/limb
34 C 603e: ?
35 C 604e: ? old: 3.25
36 C 75x (G3): ? old: 3.5
37 C 7400,7410 (G4): 3.25
38 C 744x,745x (G4+): 4
39 C POWER3/PPC630 2
40 C POWER4/PPC970 2.4
41 C POWER5 2.75
42 C POWER6 40-140
43 C POWER7 3
45 C INPUT PARAMETERS
46 define(`rp', `r3')
47 define(`up', `r4')
48 define(`vp', `r5')
49 define(`n', `r6')
50 define(`cy', `r7')
52 ifdef(`OPERATION_add_n', `
53 define(ADCSBC, adde)
54 define(func, mpn_add_n)
55 define(func_nc, mpn_add_nc)
56 define(IFADD, `$1')
57 define(IFSUB, `')')
58 ifdef(`OPERATION_sub_n', `
59 define(ADCSBC, subfe)
60 define(func, mpn_sub_n)
61 define(func_nc, mpn_sub_nc)
62 define(IFADD, `')
63 define(IFSUB, `$1')')
65 MULFUNC_PROLOGUE(mpn_add_n mpn_add_nc mpn_sub_n mpn_sub_nc)
67 ASM_START()
69 PROLOGUE(func_nc)
70 IFADD(` addic r0, cy, -1') C set carry from argument
71 IFSUB(` subfic r0, cy, 0') C set carry from argument
72 b L(ent)
73 EPILOGUE()
75 PROLOGUE(func)
76 IFADD(` addic r0, n, 0') C clear carry
77 IFSUB(` addic r0, n, -1') C set carry
78 L(ent): andi. r0, n, 3
79 addi r3, r3, -12
80 addi n, n, 1
81 cmpwi cr7, r0, 2
82 srwi r0, n, 2
83 sub r4, r4, r3
84 sub r5, r5, r3
85 mtctr r0
86 bne cr0, L(n00)
88 lwzx r7, r4, r3 C n = 4, 8, 12, ...
89 lwzx r8, r5, r3
90 addi r3, r3, 4
91 lwzx r9, r4, r3
92 ADCSBC r7, r8, r7
93 lwzx r10, r5, r3
94 addi r3, r3, 4
95 b L(00)
97 L(n00): bge cr7, L(n01)
98 cmpwi cr0, r0, 0 C n = 1, 5, 9, 13, ...
99 lwzx r0, r4, r3
100 lwzx r6, r5, r3
101 addi r3, r3, 4
102 ADCSBC r0, r6, r0
103 ble L(ret)
104 L(gt1): lwzx r7, r4, r3
105 lwzx r8, r5, r3
106 addi r3, r3, 4
107 b L(01)
109 L(n10):
110 lwzx r9, r4, r3 C n = 3, 7, 11, 15, ...
111 lwzx r10, r5, r3
112 addi r3, r3, 4
113 lwzx r11, r4, r3
114 ADCSBC r9, r10, r9
115 lwzx r12, r5, r3
116 addi r3, r3, 4
117 b L(11)
119 L(n01): bne cr7, L(n10)
120 cmpwi cr0, r0, 0 C n = 2, 6, 10, 14, ...
121 lwzx r11, r4, r3
122 lwzx r12, r5, r3
123 addi r3, r3, 4
124 lwzx r0, r4, r3
125 ADCSBC r11, r12, r11
126 lwzx r6, r5, r3
127 addi r3, r3, 4
128 ble cr0, L(end)
131 L(lp): lwzx r7, r4, r3
132 ADCSBC r0, r6, r0
133 lwzx r8, r5, r3
134 stwu r11, 4(r3)
135 L(01): lwzx r9, r4, r3
136 ADCSBC r7, r8, r7
137 lwzx r10, r5, r3
138 stwu r0, 4(r3)
139 L(00): lwzx r11, r4, r3
140 ADCSBC r9, r10, r9
141 lwzx r12, r5, r3
142 stwu r7, 4(r3)
143 L(11): lwzx r0, r4, r3
144 ADCSBC r11, r12, r11
145 lwzx r6, r5, r3
146 stwu r9, 4(r3)
147 bdnz L(lp)
149 L(end): ADCSBC r0, r6, r0
150 stw r11, 4(r3)
151 L(ret): stw r0, 8(r3)
152 IFADD(` li r3, 0 ')
153 IFADD(` addze r3, r3 ')
154 IFSUB(` subfe r3, r0, r0')
155 IFSUB(` neg r3, r3')
157 EPILOGUE()