|
9 | 9 | #include "../assembly.h"
|
10 | 10 |
|
11 | 11 | .set FEAT_SVE_BIT, 30
|
| 12 | +.set FEAT_SME_BIT, 42 |
12 | 13 | .set SVCR_PSTATE_SM_BIT, 0
|
13 | 14 |
|
14 | 15 | #if !defined(__APPLE__)
|
15 |
| -#define TPIDR2_SYMBOL SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0) |
16 |
| -#define TPIDR2_SYMBOL_OFFSET :lo12:SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0) |
17 | 16 | #define CPU_FEATS_SYMBOL SYMBOL_NAME(__aarch64_cpu_features)
|
18 | 17 | #define CPU_FEATS_SYMBOL_OFFSET :lo12:SYMBOL_NAME(__aarch64_cpu_features)
|
19 | 18 | #else
|
20 | 19 | // MachO requires @page/@pageoff directives because the global is defined
|
21 | 20 | // in a different file. Otherwise this file may fail to build.
|
22 |
| -#define TPIDR2_SYMBOL SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)@page |
23 |
| -#define TPIDR2_SYMBOL_OFFSET SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)@pageoff |
24 | 21 | #define CPU_FEATS_SYMBOL SYMBOL_NAME(__aarch64_cpu_features)@page
|
25 | 22 | #define CPU_FEATS_SYMBOL_OFFSET SYMBOL_NAME(__aarch64_cpu_features)@pageoff
|
26 | 23 | #endif
|
@@ -63,9 +60,9 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_sme_state)
|
63 | 60 | mov x0, xzr
|
64 | 61 | mov x1, xzr
|
65 | 62 |
|
66 |
| - adrp x16, TPIDR2_SYMBOL |
67 |
| - ldrb w16, [x16, TPIDR2_SYMBOL_OFFSET] |
68 |
| - cbz w16, 1f |
| 63 | + adrp x16, CPU_FEATS_SYMBOL |
| 64 | + ldr x16, [x16, CPU_FEATS_SYMBOL_OFFSET] |
| 65 | + tbz x16, #FEAT_SME_BIT, 1f |
69 | 66 | 0:
|
70 | 67 | orr x0, x0, #0xC000000000000000
|
71 | 68 | mrs x16, SVCR
|
@@ -116,9 +113,9 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_save)
|
116 | 113 | BTI_C
|
117 | 114 | // If the current thread does not have access to TPIDR2_EL0, the subroutine
|
118 | 115 | // does nothing.
|
119 |
| - adrp x14, TPIDR2_SYMBOL |
120 |
| - ldrb w14, [x14, TPIDR2_SYMBOL_OFFSET] |
121 |
| - cbz w14, 1f |
| 116 | + adrp x14, CPU_FEATS_SYMBOL |
| 117 | + ldr x14, [x14, CPU_FEATS_SYMBOL_OFFSET] |
| 118 | + tbz x14, #FEAT_SME_BIT, 1f |
122 | 119 |
|
123 | 120 | // If TPIDR2_EL0 is null, the subroutine does nothing.
|
124 | 121 | mrs x16, TPIDR2_EL0
|
@@ -157,9 +154,9 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_za_disable)
|
157 | 154 | BTI_C
|
158 | 155 | // If the current thread does not have access to SME, the subroutine does
|
159 | 156 | // nothing.
|
160 |
| - adrp x14, TPIDR2_SYMBOL |
161 |
| - ldrb w14, [x14, TPIDR2_SYMBOL_OFFSET] |
162 |
| - cbz w14, 0f |
| 157 | + adrp x14, CPU_FEATS_SYMBOL |
| 158 | + ldr x14, [x14, CPU_FEATS_SYMBOL_OFFSET] |
| 159 | + tbz x14, #FEAT_SME_BIT, 0f |
163 | 160 |
|
164 | 161 | // Otherwise, the subroutine behaves as if it did the following:
|
165 | 162 | // * Call __arm_tpidr2_save.
|
@@ -191,11 +188,9 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_get_current_vg)
|
191 | 188 | BTI_C
|
192 | 189 |
|
193 | 190 | adrp x17, CPU_FEATS_SYMBOL
|
194 |
| - ldr w17, [x17, CPU_FEATS_SYMBOL_OFFSET] |
| 191 | + ldr x17, [x17, CPU_FEATS_SYMBOL_OFFSET] |
195 | 192 | tbnz w17, #FEAT_SVE_BIT, 1f
|
196 |
| - adrp x17, TPIDR2_SYMBOL |
197 |
| - ldrb w17, [x17, TPIDR2_SYMBOL_OFFSET] |
198 |
| - cbz x17, 2f |
| 193 | + tbz x17, #FEAT_SME_BIT, 2f |
199 | 194 | 0:
|
200 | 195 | mrs x17, SVCR
|
201 | 196 | tbz x17, #SVCR_PSTATE_SM_BIT, 2f
|
|
0 commit comments