Max Shvetsov | 959be33 | 2021-03-16 14:18:13 +0000 | [diff] [blame] | 1 | /* |
Olivier Deprez | 569be40 | 2022-07-08 10:24:39 +0200 | [diff] [blame] | 2 | * Copyright (c) 2021-2022, Arm Limited. All rights reserved. |
Max Shvetsov | 959be33 | 2021-03-16 14:18:13 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef SVE_H |
| 8 | #define SVE_H |
| 9 | |
| 10 | #define fill_sve_helper(num) "ldr z"#num", [%0, #"#num", MUL VL];" |
| 11 | #define read_sve_helper(num) "str z"#num", [%0, #"#num", MUL VL];" |
| 12 | |
Olivier Deprez | 569be40 | 2022-07-08 10:24:39 +0200 | [diff] [blame] | 13 | /* |
| 14 | * Max. vector length permitted by the architecture: |
| 15 | * SVE: 2048 bits = 256 bytes |
| 16 | */ |
| 17 | #define SVE_VECTOR_LEN_BYTES 256 |
| 18 | #define SVE_NUM_VECTORS 32 |
| 19 | |
Kathleen Capella | c59184c | 2022-08-23 19:09:41 -0400 | [diff] [blame^] | 20 | #ifndef __ASSEMBLY__ |
| 21 | |
Olivier Deprez | 569be40 | 2022-07-08 10:24:39 +0200 | [diff] [blame] | 22 | typedef uint8_t sve_vector_t[SVE_VECTOR_LEN_BYTES]; |
| 23 | |
| 24 | #ifdef __aarch64__ |
| 25 | |
| 26 | /* Returns the SVE implemented VL in bytes (constrained by ZCR_EL3.LEN) */ |
| 27 | static inline uint64_t sve_vector_length_get(void) |
| 28 | { |
| 29 | uint64_t vl; |
| 30 | |
| 31 | __asm__ volatile( |
| 32 | ".arch_extension sve\n" |
| 33 | "rdvl %0, #1;" |
| 34 | ".arch_extension nosve\n" |
| 35 | : "=r" (vl) |
| 36 | ); |
| 37 | |
| 38 | return vl; |
| 39 | } |
| 40 | |
| 41 | #endif /* __aarch64__ */ |
Kathleen Capella | c59184c | 2022-08-23 19:09:41 -0400 | [diff] [blame^] | 42 | #endif /* __ASSEMBLY__ */ |
Olivier Deprez | 569be40 | 2022-07-08 10:24:39 +0200 | [diff] [blame] | 43 | #endif /* SVE_H */ |