beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / arm / aors_n.asm
blobfdad9f7ba68b556d5d68d75e633b49c42f9e3cd9
1 dnl ARM mpn_add_n and mpn_sub_n
3 dnl Contributed to the GNU project by Robert Harley.
5 dnl Copyright 1997, 2000, 2001, 2012 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 slightly fluctuating
41 C Cortex-A15 2.25
43 define(`rp', `r0')
44 define(`up', `r1')
45 define(`vp', `r2')
46 define(`n', `r3')
48 ifdef(`OPERATION_add_n', `
49 define(`ADDSUB', adds)
50 define(`ADDSUBC', adcs)
51 define(`CLRCY', `cmn r0, #0')
52 define(`SETCY', `cmp $1, #1')
53 define(`RETVAL', `adc r0, n, #0')
54 define(`func', mpn_add_n)
55 define(`func_nc', mpn_add_nc)')
56 ifdef(`OPERATION_sub_n', `
57 define(`ADDSUB', subs)
58 define(`ADDSUBC', sbcs)
59 define(`CLRCY', `cmp r0, r0')
60 define(`SETCY', `rsbs $1, $1, #0')
61 define(`RETVAL', `sbc r0, r0, r0
62 and r0, r0, #1')
63 define(`func', mpn_sub_n)
64 define(`func_nc', mpn_sub_nc)')
66 MULFUNC_PROLOGUE(mpn_add_n mpn_add_nc mpn_sub_n mpn_sub_nc)
68 ASM_START()
69 PROLOGUE(func_nc)
70 ldr r12, [sp, #0]
71 stmfd sp!, { r8, r9, lr }
72 SETCY( r12)
73 b L(ent)
74 EPILOGUE()
75 PROLOGUE(func)
76 stmfd sp!, { r8, r9, lr }
77 CLRCY( r12)
78 L(ent): tst n, #1
79 beq L(skip1)
80 ldr r12, [up], #4
81 ldr lr, [vp], #4
82 ADDSUBC r12, r12, lr
83 str r12, [rp], #4
84 L(skip1):
85 tst n, #2
86 beq L(skip2)
87 ldmia up!, { r8, r9 }
88 ldmia vp!, { r12, lr }
89 ADDSUBC r8, r8, r12
90 ADDSUBC r9, r9, lr
91 stmia rp!, { r8, r9 }
92 L(skip2):
93 bics n, n, #3
94 beq L(rtn)
95 stmfd sp!, { r4, r5, r6, r7 }
97 L(top): ldmia up!, { r4, r5, r6, r7 }
98 ldmia vp!, { r8, r9, r12, lr }
99 ADDSUBC r4, r4, r8
100 sub n, n, #4
101 ADDSUBC r5, r5, r9
102 ADDSUBC r6, r6, r12
103 ADDSUBC r7, r7, lr
104 stmia rp!, { r4, r5, r6, r7 }
105 teq n, #0
106 bne L(top)
108 ldmfd sp!, { r4, r5, r6, r7 }
110 L(rtn): RETVAL
111 ldmfd sp!, { r8, r9, pc }
112 EPILOGUE()