beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / arm / v6 / submul_1.asm
blob8a21733a0a0aa7eb81ae747c55addf4d4686ad31
1 dnl ARM mpn_submul_1.
3 dnl Copyright 2012, 2013 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 StrongARM: -
35 C XScale -
36 C Cortex-A7 ?
37 C Cortex-A8 ?
38 C Cortex-A9 3.75
39 C Cortex-A15 4.0
41 C This loop complements U on the fly,
42 C U' = B^n - 1 - U
43 C and then uses that
44 C R - U*v = R + U'*v + v - B^n v
46 C TODO
47 C * Micro-optimise feed-in code.
48 C * Optimise for n=1,2 by delaying register saving.
49 C * Try using ldm/stm.
51 define(`rp',`r0')
52 define(`up',`r1')
53 define(`n', `r2')
54 define(`v0',`r3')
56 ASM_START()
57 PROLOGUE(mpn_submul_1)
58 stmfd sp!, { r4, r5, r6, r7 }
60 ands r6, n, #3
61 mov r12, v0
62 beq L(fi0)
63 cmp r6, #2
64 bcc L(fi1)
65 beq L(fi2)
67 L(fi3): ldr r4, [up], #12
68 mvn r4, r4
69 ldr r6, [rp, #0]
70 ldr r5, [up, #-8]
71 b L(lo3)
73 L(fi0): ldr r5, [up], #16
74 mvn r5, r5
75 ldr r7, [rp], #4
76 ldr r4, [up, #-12]
77 b L(lo0)
79 L(fi1): ldr r4, [up], #4
80 mvn r4, r4
81 ldr r6, [rp], #8
82 subs n, n, #1
83 beq L(1)
84 ldr r5, [up]
85 b L(lo1)
87 L(fi2): ldr r5, [up], #8
88 mvn r5, r5
89 ldr r7, [rp], #12
90 ldr r4, [up, #-4]
91 b L(lo2)
93 ALIGN(16)
94 L(top): ldr r6, [rp, #-8]
95 ldr r5, [up]
96 str r7, [rp, #-12]
97 L(lo1): umaal r6, r12, r4, v0
98 add up, up, #16
99 mvn r5, r5
100 ldr r7, [rp, #-4]
101 ldr r4, [up, #-12]
102 str r6, [rp, #-8]
103 L(lo0): umaal r7, r12, r5, v0
104 mvn r4, r4
105 ldr r6, [rp, #0]
106 ldr r5, [up, #-8]
107 str r7, [rp, #-4]
108 L(lo3): umaal r6, r12, r4, v0
109 mvn r5, r5
110 ldr r7, [rp, #4]
111 ldr r4, [up, #-4]
112 str r6, [rp], #16
113 L(lo2): umaal r7, r12, r5, v0
114 mvn r4, r4
115 subs n, n, #4
116 bhi L(top)
118 ldr r6, [rp, #-8]
119 str r7, [rp, #-12]
120 L(1): umaal r6, r12, r4, v0
121 str r6, [rp, #-8]
122 sub r0, v0, r12
123 ldmfd sp!, { r4, r5, r6, r7 }
124 bx lr
125 EPILOGUE()