]>
Commit | Line | Data |
---|---|---|
328c17af | 1 | /* Support routine for SME. |
a945c346 | 2 | Copyright (C) 2023-2024 Free Software Foundation, Inc. |
328c17af SN |
3 | |
4 | This file is part of GCC. | |
5 | ||
6 | GCC is free software; you can redistribute it and/or modify it | |
7 | under the terms of the GNU General Public License as published | |
8 | by the Free Software Foundation; either version 3, or (at your | |
9 | option) any later version. | |
10 | ||
11 | GCC is distributed in the hope that it will be useful, but WITHOUT | |
12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
13 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | |
14 | License for more details. | |
15 | ||
16 | Under Section 7 of GPL version 3, you are granted additional | |
17 | permissions described in the GCC Runtime Library Exception, version | |
18 | 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | You should have received a copy of the GNU General Public License and | |
21 | a copy of the GCC Runtime Library Exception along with this program; | |
22 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | <http://www.gnu.org/licenses/>. */ | |
24 | ||
25 | #include "aarch64-asm.h" | |
26 | ||
27 | /* Query SME state. Call ABI: | |
28 | - Private ZA, streaming-compatible. | |
29 | - x2-x15, x19-x29, sp and fp regs are call preserved. | |
30 | - Takes no argument. | |
31 | - Returns SME state in x0 and TPIDR2_EL0 in x1. */ | |
32 | ||
33 | .hidden __aarch64_have_sme | |
34 | ||
35 | variant_pcs (__arm_sme_state) | |
36 | ||
37 | ENTRY (__arm_sme_state) | |
38 | /* Check if SME is available. */ | |
39 | adrp x1, __aarch64_have_sme | |
40 | ldrb w1, [x1, :lo12:__aarch64_have_sme] | |
41 | cbz w1, L(nosme) | |
42 | ||
43 | /* Expose the bottom 2 bits of svcr (SM, ZA) in x0 and set the | |
44 | top 2 bits indicating that SME and TPIDR2_EL0 are available. */ | |
45 | .inst 0xd53b4240 /* mrs x0, svcr */ | |
46 | .inst 0xd53bd0a1 /* mrs x1, tpidr2_el0 */ | |
47 | and x0, x0, 3 | |
48 | orr x0, x0, 0xc000000000000000 | |
49 | ret | |
50 | ||
51 | L(nosme): | |
52 | mov x0, 0 | |
53 | mov x1, 0 | |
54 | ret | |
55 | END (__arm_sme_state) |