Debian Codegraph @

mpi/aarch64/mpih-mul2.S

raw
1 /* ARM64 mul_2 -- Multiply a limb vector with a limb and add the result to
2 * a second limb vector.
3 *
4 * Copyright (C) 2013 Jussi Kivilinna <[email protected]>
5 *
6 * This file is part of Libgcrypt.
7 *
8 * Libgcrypt is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as
10 * published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * Libgcrypt is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23 #include "sysdep.h"
24 #include "asm-syntax.h"
25 #include "asm-common-aarch64.h"
26
27 /*******************
28 * mpi_limb_t
29 * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, x0
30 * mpi_ptr_t s1_ptr, x1
31 * mpi_size_t s1_size, w2
32 * mpi_limb_t s2_limb) x3
33 */
34
35 .text
36
37 .globl C_SYMBOL_NAME(_gcry_mpih_addmul_1)
38 ELF(.type C_SYMBOL_NAME(_gcry_mpih_addmul_1),%function)
39 .align 4
40 C_SYMBOL_NAME(_gcry_mpih_addmul_1):
41 CFI_STARTPROC()
42 and w5, w2, #3;
43 mov x6, xzr;
44 mov x7, xzr;
45
46 cbz w5, .Large_loop;
47
48 .Loop:
49 ldr x5, [x1], #8;
50
51 mul x12, x5, x3;
52 ldr x4, [x0];
53 umulh x13, x5, x3;
54 sub w2, w2, #1;
55
56 adds x12, x12, x4;
57 and w5, w2, #3;
58 adc x13, x13, x7;
59 adds x12, x12, x6;
60 str x12, [x0], #8;
61 adc x6, x7, x13;
62
63 cbz w2, .Lend;
64 cbnz w5, .Loop;
65
66 .Large_loop:
67 ldp x5, x9, [x1], #16;
68 sub w2, w2, #4;
69 ldp x4, x8, [x0];
70
71 mul x12, x5, x3;
72 umulh x13, x5, x3;
73
74 adds x12, x12, x4;
75 mul x14, x9, x3;
76 adc x13, x13, x7;
77 adds x12, x12, x6;
78 umulh x15, x9, x3;
79 str x12, [x0], #8;
80 adc x6, x7, x13;
81
82 adds x14, x14, x8;
83 ldp x5, x9, [x1], #16;
84 adc x15, x15, x7;
85 adds x14, x14, x6;
86 mul x12, x5, x3;
87 str x14, [x0], #8;
88 ldp x4, x8, [x0];
89 umulh x13, x5, x3;
90 adc x6, x7, x15;
91
92 adds x12, x12, x4;
93 mul x14, x9, x3;
94 adc x13, x13, x7;
95 adds x12, x12, x6;
96 umulh x15, x9, x3;
97 str x12, [x0], #8;
98 adc x6, x7, x13;
99
100 adds x14, x14, x8;
101 adc x15, x15, x7;
102 adds x14, x14, x6;
103 str x14, [x0], #8;
104 adc x6, x7, x15;
105
106 cbnz w2, .Large_loop;
107
108 .Lend:
109 mov x0, x6;
110 ret_spec_stop;
111 CFI_ENDPROC()
112 ELF(.size C_SYMBOL_NAME(_gcry_mpih_addmul_1),.-C_SYMBOL_NAME(_gcry_mpih_addmul_1);)