beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / arm64 / aorsmul_1.asm
blobe033bda2bf1413095921ceeab923d606c49486a3
1 dnl ARM64 mpn_submul_1
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 Cortex-A53 ?
37 C Cortex-A57 ?
39 changecom(@&*$)
41 define(`rp', `x0')
42 define(`up', `x1')
43 define(`n', `x2')
44 define(`v0', `x3')
46 ifdef(`OPERATION_addmul_1', `
47 define(`ADDSUB', adds)
48 define(`ADDSUBC', adcs)
49 define(`COND', `cc')
50 define(`func', mpn_addmul_1)')
51 ifdef(`OPERATION_submul_1', `
52 define(`ADDSUB', subs)
53 define(`ADDSUBC', sbcs)
54 define(`COND', `cs')
55 define(`func', mpn_submul_1)')
57 MULFUNC_PROLOGUE(mpn_addmul_1 mpn_submul_1)
59 PROLOGUE(func)
60 mov x15, #0
62 tbz n, #0, L(1)
64 ldr x4, [up],#8
65 mul x8, x4, v0
66 umulh x12, x4, v0
67 adds x8, x8, x15
68 ldr x4, [rp,#0]
69 ADDSUB x8, x4, x8
70 csinc x15, x12, x12, COND
71 str x8, [rp],#8
73 L(1): tbz n, #1, L(2)
75 ldp x4, x5, [up],#16
76 mul x8, x4, v0
77 umulh x12, x4, v0
78 mul x9, x5, v0
79 umulh x13, x5, v0
80 adds x8, x8, x15
81 adcs x9, x9, x12
82 ldp x4, x5, [rp,#0]
83 adc x15, x13, xzr
84 sub n, n, #1
85 ADDSUB x8, x4, x8
86 ADDSUBC x9, x5, x9
87 csinc x15, x15, x15, COND
88 stp x8, x9, [rp],#16
90 L(2): lsr n, n, #2
91 cbz n, L(end)
93 L(top): ldp x4, x5, [up],#16
94 ldp x6, x7, [up],#16
95 mul x8, x4, v0
96 umulh x12, x4, v0
97 mul x9, x5, v0
98 umulh x13, x5, v0
99 adds x8, x8, x15
100 mul x10, x6, v0
101 umulh x14, x6, v0
102 adcs x9, x9, x12
103 mul x11, x7, v0
104 umulh x15, x7, v0
105 adcs x10, x10, x13
106 ldp x4, x5, [rp,#0]
107 adcs x11, x11, x14
108 ldp x6, x7, [rp,#16]
109 adc x15, x15, xzr
110 sub n, n, #1
111 ADDSUB x8, x4, x8
112 ADDSUBC x9, x5, x9
113 ADDSUBC x10, x6, x10
114 ADDSUBC x11, x7, x11
115 stp x8, x9, [rp],#16
116 csinc x15, x15, x15, COND
117 stp x10, x11, [rp],#16
118 cbnz n, L(top)
120 L(end): mov x0, x15
122 EPILOGUE()