7
7
// Out - of - line LSE atomics helpers. Ported from libgcc library.
8
8
// N = { 1 , 2 , 4 , 8 }
9
9
// M = { 1 , 2 , 4 , 8 , 16 }
10
- // ORDER = { 'relax' , 'acq' , 'rel' , 'acq_rel' }
10
+ // ORDER = { 'relax' , 'acq' , 'rel' , 'acq_rel' , 'sync' }
11
11
// Routines implemented:
12
12
//
13
13
// iM __aarch64_casM_ORDER(iM expected , iM desired , iM * ptr)
@@ -35,8 +35,8 @@ HIDDEN(___aarch64_have_lse_atomics)
35
35
#endif
36
36
37
37
// Generate mnemonics for
38
- // L_cas: SIZE: 1 , 2 , 4 , 8 , 16 MODEL: 1 , 2 , 3 , 4
39
- // L_swp L_ldadd L_ldclr L_ldeor L_ldset: SIZE: 1 , 2 , 4 , 8 MODEL: 1 , 2 , 3 , 4
38
+ // L_cas: SIZE: 1 , 2 , 4 , 8 , 16 MODEL: 1 , 2 , 3 , 4 , 5
39
+ // L_swp L_ldadd L_ldclr L_ldeor L_ldset: SIZE: 1 , 2 , 4 , 8 MODEL: 1 , 2 , 3 , 4 , 5
40
40
41
41
#if SIZE == 1
42
42
#define S b
@@ -64,24 +64,44 @@ HIDDEN(___aarch64_have_lse_atomics)
64
64
#define L
65
65
#define M 0x000000
66
66
#define N 0x000000
67
+ #define BARRIER
67
68
#elif MODEL == 2
68
69
#define SUFF _acq
69
70
#define A a
70
71
#define L
71
72
#define M 0x400000
72
73
#define N 0x800000
74
+ #define BARRIER
73
75
#elif MODEL == 3
74
76
#define SUFF _rel
75
77
#define A
76
78
#define L l
77
79
#define M 0x008000
78
80
#define N 0x400000
81
+ #define BARRIER
79
82
#elif MODEL == 4
80
83
#define SUFF _acq_rel
81
84
#define A a
82
85
#define L l
83
86
#define M 0x408000
84
87
#define N 0xc00000
88
+ #define BARRIER
89
+ #elif MODEL == 5
90
+ #define SUFF _sync
91
+ #ifdef L_swp
92
+ // swp has _acq semantics.
93
+ #define A a
94
+ #define L
95
+ #define M 0x400000
96
+ #define N 0x800000
97
+ #else
98
+ // All other _sync functions have _seq semantics.
99
+ #define A a
100
+ #define L l
101
+ #define M 0x408000
102
+ #define N 0xc00000
103
+ #endif
104
+ #define BARRIER dmb ish
85
105
#else
86
106
#error
87
107
#endif // MODEL
@@ -96,7 +116,12 @@ HIDDEN(___aarch64_have_lse_atomics)
96
116
#endif
97
117
98
118
#define NAME(BASE) GLUE4(__aarch64_ , BASE , SIZE , SUFF)
119
+ #if MODEL == 5
120
+ // Drop A for _sync functions.
121
+ #define LDXR GLUE3(ld , xr , S)
122
+ #else
99
123
#define LDXR GLUE4(ld , A , xr , S)
124
+ #endif
100
125
#define STXR GLUE4(st , L , xr , S)
101
126
102
127
// Define temporary registers.
@@ -136,9 +161,15 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas))
136
161
STXR w(tmp1) , s( 1 ) , [ x2 ]
137
162
cbnz w(tmp1) , 0b
138
163
1 :
164
+ BARRIER
139
165
ret
140
166
#else
167
+ #if MODEL == 5
168
+ // Drop A for _sync functions.
169
+ #define LDXP GLUE2(ld , xp)
170
+ #else
141
171
#define LDXP GLUE3(ld , A , xp)
172
+ #endif
142
173
#define STXP GLUE3(st , L , xp)
143
174
#ifdef HAS_ASM_LSE
144
175
#define CASP GLUE3(casp , A , L) x0 , x1 , x2 , x3 , [ x4 ]
@@ -159,6 +190,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas))
159
190
STXP w(tmp2) , x2 , x3 , [ x4 ]
160
191
cbnz w(tmp2) , 0b
161
192
1 :
193
+ BARRIER
162
194
ret
163
195
#endif
164
196
END_COMPILERRT_OUTLINE_FUNCTION(NAME(cas))
@@ -180,6 +212,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(swp))
180
212
LDXR s( 0 ) , [ x1 ]
181
213
STXR w(tmp1) , s(tmp0) , [ x1 ]
182
214
cbnz w(tmp1) , 0b
215
+ BARRIER
183
216
ret
184
217
END_COMPILERRT_OUTLINE_FUNCTION(NAME(swp))
185
218
#endif // L_swp
@@ -224,6 +257,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(LDNM))
224
257
OP s(tmp1) , s( 0 ) , s(tmp0)
225
258
STXR w(tmp2) , s(tmp1) , [ x1 ]
226
259
cbnz w(tmp2) , 0b
260
+ BARRIER
227
261
ret
228
262
END_COMPILERRT_OUTLINE_FUNCTION(NAME(LDNM))
229
263
#endif // L_ldadd L_ldclr L_ldeor L_ldset
0 commit comments