xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/atomic-ops-libcall.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 < %s -triple armv5e-none-linux-gnueabi -emit-llvm -O1 | FileCheck %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc enum memory_order {
4*0a6a1f1dSLionel Sambuc   memory_order_relaxed, memory_order_consume, memory_order_acquire,
5*0a6a1f1dSLionel Sambuc   memory_order_release, memory_order_acq_rel, memory_order_seq_cst
6*0a6a1f1dSLionel Sambuc };
7*0a6a1f1dSLionel Sambuc 
test_c11_atomic_fetch_add_int_ptr(_Atomic (int *)* p)8*0a6a1f1dSLionel Sambuc int *test_c11_atomic_fetch_add_int_ptr(_Atomic(int *) *p) {
9*0a6a1f1dSLionel Sambuc   // CHECK: test_c11_atomic_fetch_add_int_ptr
10*0a6a1f1dSLionel Sambuc   // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 12, i32 5)
11*0a6a1f1dSLionel Sambuc   return __c11_atomic_fetch_add(p, 3, memory_order_seq_cst);
12*0a6a1f1dSLionel Sambuc }
13*0a6a1f1dSLionel Sambuc 
test_c11_atomic_fetch_sub_int_ptr(_Atomic (int *)* p)14*0a6a1f1dSLionel Sambuc int *test_c11_atomic_fetch_sub_int_ptr(_Atomic(int *) *p) {
15*0a6a1f1dSLionel Sambuc   // CHECK: test_c11_atomic_fetch_sub_int_ptr
16*0a6a1f1dSLionel Sambuc   // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 20, i32 5)
17*0a6a1f1dSLionel Sambuc   return __c11_atomic_fetch_sub(p, 5, memory_order_seq_cst);
18*0a6a1f1dSLionel Sambuc }
19*0a6a1f1dSLionel Sambuc 
test_c11_atomic_fetch_add_int(_Atomic (int)* p)20*0a6a1f1dSLionel Sambuc int test_c11_atomic_fetch_add_int(_Atomic(int) *p) {
21*0a6a1f1dSLionel Sambuc   // CHECK: test_c11_atomic_fetch_add_int
22*0a6a1f1dSLionel Sambuc   // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 3, i32 5)
23*0a6a1f1dSLionel Sambuc   return __c11_atomic_fetch_add(p, 3, memory_order_seq_cst);
24*0a6a1f1dSLionel Sambuc }
25*0a6a1f1dSLionel Sambuc 
test_c11_atomic_fetch_sub_int(_Atomic (int)* p)26*0a6a1f1dSLionel Sambuc int test_c11_atomic_fetch_sub_int(_Atomic(int) *p) {
27*0a6a1f1dSLionel Sambuc   // CHECK: test_c11_atomic_fetch_sub_int
28*0a6a1f1dSLionel Sambuc   // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 5, i32 5)
29*0a6a1f1dSLionel Sambuc   return __c11_atomic_fetch_sub(p, 5, memory_order_seq_cst);
30*0a6a1f1dSLionel Sambuc }
31*0a6a1f1dSLionel Sambuc 
fp2a(int ** p)32*0a6a1f1dSLionel Sambuc int *fp2a(int **p) {
33*0a6a1f1dSLionel Sambuc   // CHECK: @fp2a
34*0a6a1f1dSLionel Sambuc   // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 4, i32 0)
35*0a6a1f1dSLionel Sambuc   // Note, the GNU builtins do not multiply by sizeof(T)!
36*0a6a1f1dSLionel Sambuc   return __atomic_fetch_sub(p, 4, memory_order_relaxed);
37*0a6a1f1dSLionel Sambuc }
38