Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 < %s -triple armv5e-none-linux-gnueabi -emit-llvm -O1 | FileCheck %s
      2 
      3 enum 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 
      8 int *test_c11_atomic_fetch_add_int_ptr(_Atomic(int *) *p) {
      9   // CHECK: test_c11_atomic_fetch_add_int_ptr
     10   // CHECK: {{%[^ ]*}} = tail call i32* @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 12, i32 5)
     11   return __c11_atomic_fetch_add(p, 3, memory_order_seq_cst);
     12 }
     13 
     14 int *test_c11_atomic_fetch_sub_int_ptr(_Atomic(int *) *p) {
     15   // CHECK: test_c11_atomic_fetch_sub_int_ptr
     16   // CHECK: {{%[^ ]*}} = tail call i32* @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 20, i32 5)
     17   return __c11_atomic_fetch_sub(p, 5, memory_order_seq_cst);
     18 }
     19 
     20 int test_c11_atomic_fetch_add_int(_Atomic(int) *p) {
     21   // CHECK: test_c11_atomic_fetch_add_int
     22   // CHECK: {{%[^ ]*}} = tail call i32 bitcast (i32* (i8*, i32, i32)* @__atomic_fetch_add_4 to i32 (i8*, i32, i32)*)(i8* {{%[0-9]+}}, i32 3, i32 5)
     23   return __c11_atomic_fetch_add(p, 3, memory_order_seq_cst);
     24 }
     25 
     26 int test_c11_atomic_fetch_sub_int(_Atomic(int) *p) {
     27   // CHECK: test_c11_atomic_fetch_sub_int
     28   // CHECK: {{%[^ ]*}} = tail call i32 bitcast (i32* (i8*, i32, i32)* @__atomic_fetch_sub_4 to i32 (i8*, i32, i32)*)(i8* {{%[0-9]+}}, i32 5, i32 5)
     29   return __c11_atomic_fetch_sub(p, 5, memory_order_seq_cst);
     30 }
     31 
     32 int *fp2a(int **p) {
     33   // CHECK: @fp2a
     34   // CHECK: {{%[^ ]*}} = tail call i32* @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 4, i32 0)
     35   // Note, the GNU builtins do not multiply by sizeof(T)!
     36   return __atomic_fetch_sub(p, 4, memory_order_relaxed);
     37 }
     38