beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / arm64 / cnd_aors_n.asm
blobe7836500d5e4fe75942784e17fa25956e12f6a20
1 dnl ARM64 mpn_cnd_add_n, mpn_cnd_sub_n
3 dnl Contributed to the GNU project by Torbjörn Granlund.
5 dnl Copyright 2012, 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 Cortex-A53 ?
37 C Cortex-A57 ?
39 changecom(@&*$)
41 define(`cnd', `x0')
42 define(`rp', `x1')
43 define(`up', `x2')
44 define(`vp', `x3')
45 define(`n', `x4')
47 ifdef(`OPERATION_cnd_add_n', `
48 define(`ADDSUBC', adcs)
49 define(`CLRCY', `cmn xzr, xzr')
50 define(`RETVAL', `adc x0, xzr, xzr')
51 define(func, mpn_cnd_add_n)')
52 ifdef(`OPERATION_cnd_sub_n', `
53 define(`ADDSUBC', sbcs)
54 define(`CLRCY', `cmp xzr, xzr')
55 define(`RETVAL', `sbc x0, xzr, xzr
56 and x0, x0, #1')
57 define(func, mpn_cnd_sub_n)')
59 MULFUNC_PROLOGUE(mpn_cnd_add_n mpn_cnd_sub_n)
61 ASM_START()
62 PROLOGUE(func)
63 cmp cnd, #1
64 sbc cnd, cnd, cnd
66 CLRCY C really only needed for n = 0 (mod 4)
68 tbz n, #0, L(1)
69 ldr x10, [up], #8
70 ldr x12, [vp], #8
71 bic x6, x12, cnd
72 ADDSUBC x8, x10, x6
73 sub n, n, #1
74 str x8, [rp], #8
75 cbz n, L(rt)
77 L(1): ldp x10, x11, [up], #16
78 ldp x12, x13, [vp], #16
79 sub n, n, #2
80 cbz n, L(end)
82 L(top): bic x6, x12, cnd
83 bic x7, x13, cnd
84 ldp x12, x13, [vp], #16
85 ADDSUBC x8, x10, x6
86 ADDSUBC x9, x11, x7
87 ldp x10, x11, [up], #16
88 sub n, n, #2
89 stp x8, x9, [rp], #16
90 cbnz n, L(top)
92 L(end): bic x6, x12, cnd
93 bic x7, x13, cnd
94 ADDSUBC x8, x10, x6
95 ADDSUBC x9, x11, x7
96 stp x8, x9, [rp]
97 L(rt): RETVAL
98 ret
99 EPILOGUE()