8
8
9
9
#include "../assembly.h"
10
10
11
- #ifdef HAS_ASM_SME
12
- #define ARCH armv9 - a + sme
13
- #define SMSTOP_SM smstop sm
14
- #define SMSTOP_ZA smstop za
15
- #define REG_TPIDR2_EL0 TPIDR2_EL0
16
- #define REG_SVCR SVCR
17
- #define ADDSVL_X16_X16_1 addsvl x16 , x16 , # 1
18
- #define LDR_ZA_W15_0_X16 ldr za [ w15 , 0 ], [ x16 ]
19
- #define STR_ZA_W15_0_X16 str za [ w15 , 0 ], [ x16 ]
20
- #define CNTD_X0 cntd x0
21
- #define CFI_OFFSET_VG_MINUS_16 .cfi_offset vg , - 16
22
- #else
23
- #define ARCH armv8 - a
24
- #define SMSTOP_SM .inst 0xd503427f
25
- #define SMSTOP_ZA .inst 0xd503447f
26
- #define REG_TPIDR2_EL0 S3_3_C13_C0_5
27
- #define REG_SVCR S3_3_C4_C2_2
28
- #define ADDSVL_X16_X16_1 .inst 0x04305830
29
- #define LDR_ZA_W15_0_X16 .inst 0xe1006200
30
- #define STR_ZA_W15_0_X16 .inst 0xe1206200
31
- #define CNTD_X0 .inst 0x04e0e3e0
32
- #define CFI_OFFSET_VG_MINUS_16 .cfi_escape 0x10 , 0x2e , 0x03 , 0x11 , 0x70 , 0x22 // $ vg @ cfa - 16
33
- #endif
34
11
35
12
#if !defined(__APPLE__)
36
13
#define TPIDR2_SYMBOL SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)
42
19
#define TPIDR2_SYMBOL_OFFSET SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)@pageoff
43
20
#endif
44
21
45
- .arch ARCH
22
+ .arch armv9 - a + sme
46
23
47
24
// Utility function which calls a system's abort() routine. Because the function
48
25
// is streaming - compatible it should disable streaming - SVE mode before calling
49
26
// abort(). Note th at there is no need to preserve any state before the call ,
50
27
// because the function does not return.
51
28
DEFINE_COMPILERRT_PRIVATE_FUNCTION(do_abort)
52
29
.cfi_startproc
53
- .variant_pcs SYMBOL_NAME(do_abort)
30
+ .variant_pcs SYMBOL_NAME(do_abort)
54
31
stp x29 , x30 , [ sp , # - 32 ] !
55
- CNTD_X0
32
+ cntd x0
56
33
// Store VG to a stack location th at we describe with .cfi_offset
57
34
str x0 , [ sp , # 16 ]
58
35
.cfi_def_cfa_offset 32
59
36
.cfi_offset w30 , - 24
60
37
.cfi_offset w29 , - 32
61
- CFI_OFFSET_VG_MINUS_16
38
+ .cfi_offset vg , - 16
62
39
bl __arm_sme_state
63
40
tbz x0 , # 0 , 2f
64
41
1 :
65
- SMSTOP_SM
42
+ smstop sm
66
43
2 :
67
44
// We can't make this into a tail - call because the unwinder would
68
45
// need to restore the value of VG.
@@ -74,7 +51,7 @@ END_COMPILERRT_FUNCTION(do_abort)
74
51
// th at is set as part of the compiler - rt startup code.
75
52
// __aarch64_has_sme_and_tpidr2_el0
76
53
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_sme_state)
77
- .variant_pcs __arm_sme_state
54
+ .variant_pcs __arm_sme_state
78
55
mov x0 , xzr
79
56
mov x1 , xzr
80
57
@@ -83,18 +60,18 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_sme_state)
83
60
cbz w16 , 1f
84
61
0 :
85
62
orr x0 , x0 , # 0xC000000000000000
86
- mrs x16 , REG_SVCR
63
+ mrs x16 , SVCR
87
64
bfxil x0 , x16 , # 0 , # 2
88
- mrs x1 , REG_TPIDR2_EL0
65
+ mrs x1 , TPIDR2_EL0
89
66
1 :
90
67
ret
91
68
END_COMPILERRT_OUTLINE_FUNCTION(__arm_sme_state)
92
69
93
70
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_restore)
94
- .variant_pcs __arm_tpidr2_restore
71
+ .variant_pcs __arm_tpidr2_restore
95
72
// If TPIDR2_EL0 is nonnull , the subroutine aborts in some platform - specific
96
73
// manner.
97
- mrs x14 , REG_TPIDR2_EL0
74
+ mrs x14 , TPIDR2_EL0
98
75
cbnz x14 , 2f
99
76
100
77
// If any of the reserved bytes in the first 16 bytes of BLK are nonzero ,
@@ -114,8 +91,8 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_restore)
114
91
115
92
mov x15 , xzr
116
93
0 :
117
- LDR_ZA_W15_0_X16
118
- ADDSVL_X16_X16_1
94
+ ldr za [ w15 , 0 ], [ x16 ]
95
+ addsvl x16 , x16 , # 1
119
96
add x15 , x15 , # 1
120
97
cmp x14 , x15
121
98
b.ne 0b
@@ -126,14 +103,15 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_restore)
126
103
END_COMPILERRT_OUTLINE_FUNCTION(__arm_tpidr2_restore)
127
104
128
105
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_save)
106
+ .variant_pcs __arm_tpidr2_restore
129
107
// If the current thread does not have access to TPIDR2_EL0 , the subroutine
130
108
// does nothing.
131
109
adrp x14 , TPIDR2_SYMBOL
132
110
ldrb w14 , [ x14 , TPIDR2_SYMBOL_OFFSET ]
133
111
cbz w14 , 1f
134
112
135
113
// If TPIDR2_EL0 is null , the subroutine does nothing.
136
- mrs x16 , REG_TPIDR2_EL0
114
+ mrs x16 , TPIDR2_EL0
137
115
cbz x16 , 1f
138
116
139
117
// If any of the reserved bytes in the first 16 bytes of the TPIDR2 block are
@@ -153,8 +131,8 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_save)
153
131
154
132
mov x15 , xzr
155
133
0 :
156
- STR_ZA_W15_0_X16
157
- ADDSVL_X16_X16_1
134
+ str za [ w15 , 0 ], [ x16 ]
135
+ addsvl x16 , x16 , # 1
158
136
add x15 , x15 , # 1
159
137
cmp x14 , x15
160
138
b.ne 0b
@@ -165,6 +143,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_save)
165
143
END_COMPILERRT_OUTLINE_FUNCTION(__arm_tpidr2_save)
166
144
167
145
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_za_disable)
146
+ .variant_pcs __arm_tpidr2_restore
168
147
// If the current thread does not have access to SME , the subroutine does
169
148
// nothing.
170
149
adrp x14 , TPIDR2_SYMBOL
@@ -182,10 +161,10 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_za_disable)
182
161
bl __arm_tpidr2_save
183
162
184
163
// * Set TPIDR2_EL0 to null.
185
- msr REG_TPIDR2_EL0 , xzr
164
+ msr TPIDR2_EL0 , xzr
186
165
187
166
// * Set PSTATE.ZA to 0 .
188
- SMSTOP_ZA
167
+ smstop za
189
168
190
169
.cfi_def_cfa wsp , 16
191
170
ldp x29 , x30 , [ sp ], # 16
0 commit comments