blob: e55a1bd1eae37dee80e653b2e9f5765828375399 [file] [log] [blame]
Stephen Hines651f13c2014-04-23 16:59:28 -07001// RUN: %clang_cc1 < %s -triple armv5e-none-linux-gnueabi -emit-llvm -O1 | FileCheck %s
2
3enum memory_order {
4 memory_order_relaxed, memory_order_consume, memory_order_acquire,
5 memory_order_release, memory_order_acq_rel, memory_order_seq_cst
6};
7
8int *test_c11_atomic_fetch_add_int_ptr(_Atomic(int *) *p) {
9 // CHECK: test_c11_atomic_fetch_add_int_ptr
Stephen Hines176edba2014-12-01 14:53:08 -080010 // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 12, i32 5)
Stephen Hines651f13c2014-04-23 16:59:28 -070011 return __c11_atomic_fetch_add(p, 3, memory_order_seq_cst);
12}
13
14int *test_c11_atomic_fetch_sub_int_ptr(_Atomic(int *) *p) {
15 // CHECK: test_c11_atomic_fetch_sub_int_ptr
Stephen Hines176edba2014-12-01 14:53:08 -080016 // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 20, i32 5)
Stephen Hines651f13c2014-04-23 16:59:28 -070017 return __c11_atomic_fetch_sub(p, 5, memory_order_seq_cst);
18}
19
20int test_c11_atomic_fetch_add_int(_Atomic(int) *p) {
21 // CHECK: test_c11_atomic_fetch_add_int
Stephen Hines176edba2014-12-01 14:53:08 -080022 // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 3, i32 5)
Stephen Hines651f13c2014-04-23 16:59:28 -070023 return __c11_atomic_fetch_add(p, 3, memory_order_seq_cst);
24}
25
26int test_c11_atomic_fetch_sub_int(_Atomic(int) *p) {
27 // CHECK: test_c11_atomic_fetch_sub_int
Stephen Hines176edba2014-12-01 14:53:08 -080028 // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 5, i32 5)
Stephen Hines651f13c2014-04-23 16:59:28 -070029 return __c11_atomic_fetch_sub(p, 5, memory_order_seq_cst);
30}
31
32int *fp2a(int **p) {
33 // CHECK: @fp2a
Stephen Hines176edba2014-12-01 14:53:08 -080034 // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 4, i32 0)
Stephen Hines651f13c2014-04-23 16:59:28 -070035 // Note, the GNU builtins do not multiply by sizeof(T)!
36 return __atomic_fetch_sub(p, 4, memory_order_relaxed);
37}