1 ; RUN: llc -mtriple=arm64_32-apple-ios7.0 -o - %s | FileCheck %s
3 define i8 @test_load_8(i8* %addr) {
4 ; CHECK-LABAL: test_load_8:
5 ; CHECK: ldarb w0, [x0]
6 %val = load atomic i8, i8* %addr seq_cst, align 1
10 define i16 @test_load_16(i16* %addr) {
11 ; CHECK-LABAL: test_load_16:
12 ; CHECK: ldarh w0, [x0]
13 %val = load atomic i16, i16* %addr acquire, align 2
17 define i32 @test_load_32(i32* %addr) {
18 ; CHECK-LABAL: test_load_32:
19 ; CHECK: ldar w0, [x0]
20 %val = load atomic i32, i32* %addr seq_cst, align 4
24 define i64 @test_load_64(i64* %addr) {
25 ; CHECK-LABAL: test_load_64:
26 ; CHECK: ldar x0, [x0]
27 %val = load atomic i64, i64* %addr seq_cst, align 8
31 define i8* @test_load_ptr(i8** %addr) {
32 ; CHECK-LABAL: test_load_ptr:
33 ; CHECK: ldar w0, [x0]
34 %val = load atomic i8*, i8** %addr seq_cst, align 8
38 define void @test_store_8(i8* %addr) {
39 ; CHECK-LABAL: test_store_8:
40 ; CHECK: stlrb wzr, [x0]
41 store atomic i8 0, i8* %addr seq_cst, align 1
45 define void @test_store_16(i16* %addr) {
46 ; CHECK-LABAL: test_store_16:
47 ; CHECK: stlrh wzr, [x0]
48 store atomic i16 0, i16* %addr seq_cst, align 2
52 define void @test_store_32(i32* %addr) {
53 ; CHECK-LABAL: test_store_32:
54 ; CHECK: stlr wzr, [x0]
55 store atomic i32 0, i32* %addr seq_cst, align 4
59 define void @test_store_64(i64* %addr) {
60 ; CHECK-LABAL: test_store_64:
61 ; CHECK: stlr xzr, [x0]
62 store atomic i64 0, i64* %addr seq_cst, align 8
66 define void @test_store_ptr(i8** %addr) {
67 ; CHECK-LABAL: test_store_ptr:
68 ; CHECK: stlr wzr, [x0]
69 store atomic i8* null, i8** %addr seq_cst, align 8
73 declare i64 @llvm.aarch64.ldxr.p0i8(i8* %addr)
74 declare i64 @llvm.aarch64.ldxr.p0i16(i16* %addr)
75 declare i64 @llvm.aarch64.ldxr.p0i32(i32* %addr)
76 declare i64 @llvm.aarch64.ldxr.p0i64(i64* %addr)
78 define i8 @test_ldxr_8(i8* %addr) {
79 ; CHECK-LABEL: test_ldxr_8:
80 ; CHECK: ldxrb w0, [x0]
82 %val = call i64 @llvm.aarch64.ldxr.p0i8(i8* %addr)
83 %val8 = trunc i64 %val to i8
87 define i16 @test_ldxr_16(i16* %addr) {
88 ; CHECK-LABEL: test_ldxr_16:
89 ; CHECK: ldxrh w0, [x0]
91 %val = call i64 @llvm.aarch64.ldxr.p0i16(i16* %addr)
92 %val16 = trunc i64 %val to i16
96 define i32 @test_ldxr_32(i32* %addr) {
97 ; CHECK-LABEL: test_ldxr_32:
98 ; CHECK: ldxr w0, [x0]
100 %val = call i64 @llvm.aarch64.ldxr.p0i32(i32* %addr)
101 %val32 = trunc i64 %val to i32
105 define i64 @test_ldxr_64(i64* %addr) {
106 ; CHECK-LABEL: test_ldxr_64:
107 ; CHECK: ldxr x0, [x0]
109 %val = call i64 @llvm.aarch64.ldxr.p0i64(i64* %addr)
113 declare i64 @llvm.aarch64.ldaxr.p0i8(i8* %addr)
114 declare i64 @llvm.aarch64.ldaxr.p0i16(i16* %addr)
115 declare i64 @llvm.aarch64.ldaxr.p0i32(i32* %addr)
116 declare i64 @llvm.aarch64.ldaxr.p0i64(i64* %addr)
118 define i8 @test_ldaxr_8(i8* %addr) {
119 ; CHECK-LABEL: test_ldaxr_8:
120 ; CHECK: ldaxrb w0, [x0]
122 %val = call i64 @llvm.aarch64.ldaxr.p0i8(i8* %addr)
123 %val8 = trunc i64 %val to i8
127 define i16 @test_ldaxr_16(i16* %addr) {
128 ; CHECK-LABEL: test_ldaxr_16:
129 ; CHECK: ldaxrh w0, [x0]
131 %val = call i64 @llvm.aarch64.ldaxr.p0i16(i16* %addr)
132 %val16 = trunc i64 %val to i16
136 define i32 @test_ldaxr_32(i32* %addr) {
137 ; CHECK-LABEL: test_ldaxr_32:
138 ; CHECK: ldaxr w0, [x0]
140 %val = call i64 @llvm.aarch64.ldaxr.p0i32(i32* %addr)
141 %val32 = trunc i64 %val to i32
145 define i64 @test_ldaxr_64(i64* %addr) {
146 ; CHECK-LABEL: test_ldaxr_64:
147 ; CHECK: ldaxr x0, [x0]
149 %val = call i64 @llvm.aarch64.ldaxr.p0i64(i64* %addr)
153 declare i32 @llvm.aarch64.stxr.p0i8(i64, i8*)
154 declare i32 @llvm.aarch64.stxr.p0i16(i64, i16*)
155 declare i32 @llvm.aarch64.stxr.p0i32(i64, i32*)
156 declare i32 @llvm.aarch64.stxr.p0i64(i64, i64*)
158 define i32 @test_stxr_8(i8* %addr, i8 %val) {
159 ; CHECK-LABEL: test_stxr_8:
160 ; CHECK: stxrb [[TMP:w[0-9]+]], w1, [x0]
161 ; CHECK: mov w0, [[TMP]]
163 %extval = zext i8 %val to i64
164 %success = call i32 @llvm.aarch64.stxr.p0i8(i64 %extval, i8* %addr)
168 define i32 @test_stxr_16(i16* %addr, i16 %val) {
169 ; CHECK-LABEL: test_stxr_16:
170 ; CHECK: stxrh [[TMP:w[0-9]+]], w1, [x0]
171 ; CHECK: mov w0, [[TMP]]
173 %extval = zext i16 %val to i64
174 %success = call i32 @llvm.aarch64.stxr.p0i16(i64 %extval, i16* %addr)
178 define i32 @test_stxr_32(i32* %addr, i32 %val) {
179 ; CHECK-LABEL: test_stxr_32:
180 ; CHECK: stxr [[TMP:w[0-9]+]], w1, [x0]
181 ; CHECK: mov w0, [[TMP]]
183 %extval = zext i32 %val to i64
184 %success = call i32 @llvm.aarch64.stxr.p0i32(i64 %extval, i32* %addr)
188 define i32 @test_stxr_64(i64* %addr, i64 %val) {
189 ; CHECK-LABEL: test_stxr_64:
190 ; CHECK: stxr [[TMP:w[0-9]+]], x1, [x0]
191 ; CHECK: mov w0, [[TMP]]
193 %success = call i32 @llvm.aarch64.stxr.p0i64(i64 %val, i64* %addr)
197 declare i32 @llvm.aarch64.stlxr.p0i8(i64, i8*)
198 declare i32 @llvm.aarch64.stlxr.p0i16(i64, i16*)
199 declare i32 @llvm.aarch64.stlxr.p0i32(i64, i32*)
200 declare i32 @llvm.aarch64.stlxr.p0i64(i64, i64*)
202 define i32 @test_stlxr_8(i8* %addr, i8 %val) {
203 ; CHECK-LABEL: test_stlxr_8:
204 ; CHECK: stlxrb [[TMP:w[0-9]+]], w1, [x0]
205 ; CHECK: mov w0, [[TMP]]
207 %extval = zext i8 %val to i64
208 %success = call i32 @llvm.aarch64.stlxr.p0i8(i64 %extval, i8* %addr)
212 define i32 @test_stlxr_16(i16* %addr, i16 %val) {
213 ; CHECK-LABEL: test_stlxr_16:
214 ; CHECK: stlxrh [[TMP:w[0-9]+]], w1, [x0]
215 ; CHECK: mov w0, [[TMP]]
217 %extval = zext i16 %val to i64
218 %success = call i32 @llvm.aarch64.stlxr.p0i16(i64 %extval, i16* %addr)
222 define i32 @test_stlxr_32(i32* %addr, i32 %val) {
223 ; CHECK-LABEL: test_stlxr_32:
224 ; CHECK: stlxr [[TMP:w[0-9]+]], w1, [x0]
225 ; CHECK: mov w0, [[TMP]]
227 %extval = zext i32 %val to i64
228 %success = call i32 @llvm.aarch64.stlxr.p0i32(i64 %extval, i32* %addr)
232 define i32 @test_stlxr_64(i64* %addr, i64 %val) {
233 ; CHECK-LABEL: test_stlxr_64:
234 ; CHECK: stlxr [[TMP:w[0-9]+]], x1, [x0]
235 ; CHECK: mov w0, [[TMP]]
237 %success = call i32 @llvm.aarch64.stlxr.p0i64(i64 %val, i64* %addr)
241 define {i8*, i1} @test_cmpxchg_ptr(i8** %addr, i8* %cmp, i8* %new) {
242 ; CHECK-LABEL: test_cmpxchg_ptr:
243 ; CHECK: [[LOOP:LBB[0-9]+_[0-9]+]]:
244 ; CHECK: ldaxr [[OLD:w[0-9]+]], [x0]
245 ; CHECK: cmp [[OLD]], w1
246 ; CHECK: b.ne [[DONE:LBB[0-9]+_[0-9]+]]
247 ; CHECK: stlxr [[SUCCESS:w[0-9]+]], w2, [x0]
248 ; CHECK: cbnz [[SUCCESS]], [[LOOP]]
251 ; CHECK: mov w0, [[OLD]]
257 ; CHECK: mov w0, [[OLD]]
259 %res = cmpxchg i8** %addr, i8* %cmp, i8* %new acq_rel acquire