blob: bcad98db2efa2a9a21d634c38f683bf810ad86ad [file] [log] [blame]
Austin Schuhdace2a62020-08-18 10:56:48 -07001dnl ARM mpn_copyd.
2
3dnl Contributed to the GNU project by Robert Harley and Torbjรถrn Granlund.
4
5dnl Copyright 2003, 2012, 2013 Free Software Foundation, Inc.
6
7dnl This file is part of the GNU MP Library.
8dnl
9dnl The GNU MP Library is free software; you can redistribute it and/or modify
10dnl it under the terms of either:
11dnl
12dnl * the GNU Lesser General Public License as published by the Free
13dnl Software Foundation; either version 3 of the License, or (at your
14dnl option) any later version.
15dnl
16dnl or
17dnl
18dnl * the GNU General Public License as published by the Free Software
19dnl Foundation; either version 2 of the License, or (at your option) any
20dnl later version.
21dnl
22dnl or both in parallel, as here.
23dnl
24dnl The GNU MP Library is distributed in the hope that it will be useful, but
25dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27dnl for more details.
28dnl
29dnl You should have received copies of the GNU General Public License and the
30dnl GNU Lesser General Public License along with the GNU MP Library. If not,
31dnl see https://www.gnu.org/licenses/.
32
33include(`../config.m4')
34
35C cycles/limb
36C StrongARM ?
37C XScale ?
38C Cortex-A7 ?
39C Cortex-A8 ?
40C Cortex-A9 1.25-1.5
41C Cortex-A15 1.25
42
43C TODO
44C * Consider wider unrolling. Analogous 8-way code runs 10% faster on both A9
45C and A15. But it probably slows things down for 8 <= n < a few dozen.
46
47define(`rp', `r0')
48define(`up', `r1')
49define(`n', `r2')
50
51ASM_START()
52PROLOGUE(mpn_copyd)
53 mov r12, n, lsl #2
54 sub r12, r12, #4
55 add rp, rp, r12
56 add up, up, r12
57
58 tst n, #1
59 beq L(skip1)
60 ldr r3, [up], #-4
61 str r3, [rp], #-4
62L(skip1):
63 tst n, #2
64 beq L(skip2)
65 ldmda up!, { r3,r12 }
66 stmda rp!, { r3,r12 }
67L(skip2):
68 bics n, n, #3
69 beq L(rtn)
70
71 push { r4-r5 }
72 subs n, n, #4
73 ldmda up!, { r3,r4,r5,r12 }
74 beq L(end)
75
76L(top): subs n, n, #4
77 stmda rp!, { r3,r4,r5,r12 }
78 ldmda up!, { r3,r4,r5,r12 }
79 bne L(top)
80
81L(end): stmda rp, { r3,r4,r5,r12 }
82 pop { r4-r5 }
83L(rtn): return lr
84EPILOGUE()