Debian Codegraph @

cipher/simd-common-aarch64.h

raw
1 /* simd-common-aarch64.h - Common macros for AArch64 SIMD code
2 *
3 * Copyright (C) 2024 Jussi Kivilinna <[email protected]>
4 *
5 * This file is part of Libgcrypt.
6 *
7 * Libgcrypt is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * Libgcrypt is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef GCRY_SIMD_COMMON_AARCH64_H
22 #define GCRY_SIMD_COMMON_AARCH64_H
23
24 #include <config.h>
25
26 #define memory_barrier_with_vec(a) __asm__("" : "+w"(a) :: "memory")
27
28 #define clear_vec_regs() __asm__ volatile("movi v0.16b, #0;\n" \
29 "movi v1.16b, #0;\n" \
30 "movi v2.16b, #0;\n" \
31 "movi v3.16b, #0;\n" \
32 "movi v4.16b, #0;\n" \
33 "movi v5.16b, #0;\n" \
34 "movi v6.16b, #0;\n" \
35 "movi v7.16b, #0;\n" \
36 /* v8-v15 are ABI callee saved and \
37 * get cleared by function \
38 * epilog when used. */ \
39 "movi v16.16b, #0;\n" \
40 "movi v17.16b, #0;\n" \
41 "movi v18.16b, #0;\n" \
42 "movi v19.16b, #0;\n" \
43 "movi v20.16b, #0;\n" \
44 "movi v21.16b, #0;\n" \
45 "movi v22.16b, #0;\n" \
46 "movi v23.16b, #0;\n" \
47 "movi v24.16b, #0;\n" \
48 "movi v25.16b, #0;\n" \
49 "movi v26.16b, #0;\n" \
50 "movi v27.16b, #0;\n" \
51 "movi v28.16b, #0;\n" \
52 "movi v29.16b, #0;\n" \
53 "movi v30.16b, #0;\n" \
54 "movi v31.16b, #0;\n" \
55 ::: "memory", "v0", "v1", "v2", \
56 "v3", "v4", "v5", "v6", "v7", \
57 "v16", "v17", "v18", "v19", \
58 "v20", "v21", "v22", "v23", \
59 "v24", "v25", "v26", "v27", \
60 "v28", "v29", "v30", "v31")
61
62 #endif /* GCRY_SIMD_COMMON_AARCH64_H */