Line 0
Link Here
|
|
|
1 |
/* simd-common-riscv.h - Common macros for RISC-V vector code |
2 |
* |
3 |
* Copyright (C) 2025 Jussi Kivilinna <jussi.kivilinna@iki.fi> |
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_RISCV_H |
22 |
#define GCRY_SIMD_COMMON_RISCV_H |
23 |
|
24 |
#include <config.h> |
25 |
|
26 |
#define memory_barrier_with_vec(a) __asm__("" : "+vr"(a) :: "memory") |
27 |
|
28 |
#define clear_vec_regs() __asm__ volatile("vsetvli zero, %0, e8, m1, ta, ma;\n" \ |
29 |
"vmv.v.i v0, 0;\n" \ |
30 |
"vmv.v.i v1, 0;\n" \ |
31 |
"vmv2r.v v2, v0;\n" \ |
32 |
"vmv4r.v v4, v0;\n" \ |
33 |
"vmv8r.v v8, v0;\n" \ |
34 |
"vmv8r.v v16, v0;\n" \ |
35 |
"vmv8r.v v24, v0;\n" \ |
36 |
: \ |
37 |
: "r" (~0) \ |
38 |
: "memory", "vl", "vtype", \ |
39 |
"v0", "v1", "v2", "v3", \ |
40 |
"v4", "v5", "v6", "v7", \ |
41 |
"v8", "v9", "v10", "v11", \ |
42 |
"v12", "v13", "v14", "v15", \ |
43 |
"v16", "v17", "v18", "v19", \ |
44 |
"v20", "v21", "v22", "v23", \ |
45 |
"v24", "v25", "v26", "v27", \ |
46 |
"v28", "v29", "v30", "v31") |
47 |
|
48 |
#endif /* GCRY_SIMD_COMMON_RISCV_H */ |