beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / arm / v7a / cora15 / com.asm
bloba258afe934e2dbc666a9b056ccaeeceaeeb766c9
1 dnl ARM mpn_com optimised for A15.
3 dnl Contributed to the GNU project by Torbjörn Granlund.
5 dnl Copyright 2013 Free Software Foundation, Inc.
7 dnl This file is part of the GNU MP Library.
8 dnl
9 dnl The GNU MP Library is free software; you can redistribute it and/or modify
10 dnl it under the terms of either:
11 dnl
12 dnl * the GNU Lesser General Public License as published by the Free
13 dnl Software Foundation; either version 3 of the License, or (at your
14 dnl option) any later version.
15 dnl
16 dnl or
17 dnl
18 dnl * the GNU General Public License as published by the Free Software
19 dnl Foundation; either version 2 of the License, or (at your option) any
20 dnl later version.
21 dnl
22 dnl or both in parallel, as here.
23 dnl
24 dnl The GNU MP Library is distributed in the hope that it will be useful, but
25 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 dnl for more details.
28 dnl
29 dnl You should have received copies of the GNU General Public License and the
30 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
31 dnl see https://www.gnu.org/licenses/.
33 include(`../config.m4')
35 C cycles/limb
36 C StrongARM ?
37 C XScale ?
38 C Cortex-A7 ?
39 C Cortex-A8 ?
40 C Cortex-A9 2.5
41 C Cortex-A15 1.0
43 C This is great A15 core register code, but it is a bit large.
44 C We use FEEDIN_VARIANT 1 to save some space, but use 8-way unrolling.
46 C Architecture requirements:
47 C v5 -
48 C v5t -
49 C v5te ldrd strd
50 C v6 -
51 C v6t2 -
52 C v7a -
54 define(`FEEDIN_VARIANT', 1) C alternatives: 0 1 2
55 define(`UNROLL', 4x2) C alternatives: 4 4x2
57 define(`rp', `r0')
58 define(`up', `r1')
59 define(`n', `r2')
61 ASM_START()
62 PROLOGUE(mpn_com)
63 push { r4-r5,r8-r9 }
65 ifelse(FEEDIN_VARIANT,0,`
66 ands r12, n, #3
67 mov n, n, lsr #2
68 beq L(b00a)
69 tst r12, #1
70 beq L(bx0)
71 ldr r5, [up], #4
72 mvn r9, r5
73 str r9, [rp], #4
74 tst r12, #2
75 beq L(b00)
76 L(bx0): ldrd r4, r5, [up, #0]
77 sub rp, rp, #8
78 b L(lo)
79 L(b00): tst n, n
80 beq L(wd1)
81 L(b00a):ldrd r4, r5, [up], #-8
82 sub rp, rp, #16
83 b L(mid)
85 ifelse(FEEDIN_VARIANT,1,`
86 and r12, n, #3
87 mov n, n, lsr #2
88 tst r12, #1
89 beq L(bx0)
90 ldr r5, [up], #4
91 mvn r9, r5
92 str r9, [rp], #4
93 L(bx0): tst r12, #2
94 beq L(b00)
95 ldrd r4, r5, [up, #0]
96 sub rp, rp, #8
97 b L(lo)
98 L(b00): tst n, n
99 beq L(wd1)
100 ldrd r4, r5, [up], #-8
101 sub rp, rp, #16
102 b L(mid)
104 ifelse(FEEDIN_VARIANT,2,`
105 ands r12, n, #3
106 mov n, n, lsr #2
107 beq L(b00)
108 cmp r12, #2
109 bcc L(b01)
110 beq L(b10)
112 L(b11): ldr r5, [up], #4
113 mvn r9, r5
114 ldrd r4, r5, [up, #0]
115 str r9, [rp], #-4
116 b L(lo)
118 L(b00): ldrd r4, r5, [up], #-8
119 sub rp, rp, #16
120 b L(mid)
122 L(b01): ldr r5, [up], #-4
123 mvn r9, r5
124 str r9, [rp], #-12
125 tst n, n
126 beq L(wd1)
127 L(gt1): ldrd r4, r5, [up, #8]
128 b L(mid)
130 L(b10): ldrd r4, r5, [up]
131 sub rp, rp, #8
132 b L(lo)
134 ALIGN(16)
135 ifelse(UNROLL,4,`
136 L(top): ldrd r4, r5, [up, #8]
137 strd r8, r9, [rp, #8]
138 L(mid): mvn r8, r4
139 mvn r9, r5
140 ldrd r4, r5, [up, #16]!
141 strd r8, r9, [rp, #16]!
142 sub n, n, #1
143 L(lo): mvn r8, r4
144 mvn r9, r5
145 tst n, n
146 bne L(top)
148 ifelse(UNROLL,4x2,`
149 L(top): ldrd r4, r5, [up, #8]
150 strd r8, r9, [rp, #8]
151 L(mid): mvn r8, r4
152 mvn r9, r5
153 ldrd r4, r5, [up, #16]
154 strd r8, r9, [rp, #16]
155 mvn r8, r4
156 mvn r9, r5
157 sub n, n, #2
158 tst n, n
159 bmi L(dne)
160 ldrd r4, r5, [up, #24]
161 strd r8, r9, [rp, #24]
162 mvn r8, r4
163 mvn r9, r5
164 ldrd r4, r5, [up, #32]!
165 strd r8, r9, [rp, #32]!
166 L(lo): mvn r8, r4
167 mvn r9, r5
168 tst n, n
169 bne L(top)
172 L(end): strd r8, r9, [rp, #8]
173 L(wd1): pop { r4-r5,r8-r9 }
174 bx r14
175 ifelse(UNROLL,4x2,`
176 L(dne): strd r8, r9, [rp, #24]
177 pop { r4-r5,r8-r9 }
178 bx r14
180 EPILOGUE()