Debian Codegraph @

mpn/arm64/applem1/addaddmul_1msb0.asm

raw
1 dnl ARM64 mpn_addaddmul_1msb0, R = Au + Bv, u,v < 2^63.
2
3 dnl Copyright 2021 Free Software Foundation, Inc.
4
5 dnl This file is part of the GNU MP Library.
6 dnl
7 dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl it under the terms of either:
9 dnl
10 dnl * the GNU Lesser General Public License as published by the Free
11 dnl Software Foundation; either version 3 of the License, or (at your
12 dnl option) any later version.
13 dnl
14 dnl or
15 dnl
16 dnl * the GNU General Public License as published by the Free Software
17 dnl Foundation; either version 2 of the License, or (at your option) any
18 dnl later version.
19 dnl
20 dnl or both in parallel, as here.
21 dnl
22 dnl The GNU MP Library is distributed in the hope that it will be useful, but
23 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 dnl for more details.
26 dnl
27 dnl You should have received copies of the GNU General Public License and the
28 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
29 dnl see https://www.gnu.org/licenses/.
30
31 include(`../config.m4')
32
33 C cycles/limb
34 C Cortex-A53
35 C Cortex-A55
36 C Cortex-A57
37 C Cortex-A72
38 C Cortex-A73
39 C X-Gene
40 C Apple M1 2.0
41
42 changecom(blah)
43
44 define(`rp', x0)
45 define(`ap', x1)
46 define(`bp', x2)
47 define(`n', x3)
48 define(`u0', x4)
49 define(`v0', x5)
50
51 C TODO
52 C * Use fewer distinct registers, should be trivial.
53
54 PROLOGUE(mpn_addaddmul_1msb0)
55 lsr x7, n, #1
56 adds x6, xzr, xzr
57 tbz n, #0, L(top)
58
59 ldr x11, [ap], #8 C 0
60 ldr x15, [bp], #8 C 0
61 mul x10, x11, u0 C 0
62 umulh x11, x11, u0 C 1
63 mul x14, x15, v0 C 0
64 umulh x15, x15, v0 C 1
65 adds x10, x10, x14 C 0
66 adcs x6, x11, x15 C 1
67 str x10, [rp], #8 C 0
68 cbz x7, L(end)
69
70 L(top): ldp x11, x13, [ap], #16 C 0 1
71 ldp x15, x17, [bp], #16 C 0 1
72 mul x10, x11, u0 C 0
73 umulh x11, x11, u0 C 1
74 mul x14, x15, v0 C 0
75 umulh x15, x15, v0 C 1
76 adcs x10, x10, x14 C 0
77 adc x11, x11, x15 C 1
78 adds x10, x10, x6 C 0
79 mul x12, x13, u0 C 1
80 umulh x13, x13, u0 C 2
81 mul x14, x17, v0 C 1
82 umulh x17, x17, v0 C 2
83 adcs x12, x12, x14 C 1
84 adc x6, x13, x17 C 2
85 adds x11, x12, x11 C 1
86 stp x10, x11, [rp], #16 C 0 1
87 sub x7, x7, #1
88 cbnz x7, L(top)
89
90 L(end): adc x0, x6, xzr
91 ret
92 EPILOGUE()