xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/arm-atomics.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 %s -emit-llvm -o - -triple=thumbv7-none--eabi | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv6-none--eabi | FileCheck %s
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-openbsd | FileCheck %s
4*0a6a1f1dSLionel Sambuc 
5*0a6a1f1dSLionel Sambuc int i;
6*0a6a1f1dSLionel Sambuc long long l;
7*0a6a1f1dSLionel Sambuc 
8*0a6a1f1dSLionel Sambuc typedef enum memory_order {
9*0a6a1f1dSLionel Sambuc   memory_order_relaxed, memory_order_consume, memory_order_acquire,
10*0a6a1f1dSLionel Sambuc   memory_order_release, memory_order_acq_rel, memory_order_seq_cst
11*0a6a1f1dSLionel Sambuc } memory_order;
12*0a6a1f1dSLionel Sambuc 
test_presence(void)13*0a6a1f1dSLionel Sambuc void test_presence(void)
14*0a6a1f1dSLionel Sambuc {
15*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: @test_presence
16*0a6a1f1dSLionel Sambuc   // CHECK: atomicrmw add i32* {{.*}} seq_cst
17*0a6a1f1dSLionel Sambuc   __atomic_fetch_add(&i, 1, memory_order_seq_cst);
18*0a6a1f1dSLionel Sambuc   // CHECK: atomicrmw sub i32* {{.*}} seq_cst
19*0a6a1f1dSLionel Sambuc   __atomic_fetch_sub(&i, 1, memory_order_seq_cst);
20*0a6a1f1dSLionel Sambuc   // CHECK: load atomic i32* {{.*}} seq_cst
21*0a6a1f1dSLionel Sambuc   int r;
22*0a6a1f1dSLionel Sambuc   __atomic_load(&i, &r, memory_order_seq_cst);
23*0a6a1f1dSLionel Sambuc   // CHECK: store atomic i32 {{.*}} seq_cst
24*0a6a1f1dSLionel Sambuc   r = 0;
25*0a6a1f1dSLionel Sambuc   __atomic_store(&i, &r, memory_order_seq_cst);
26*0a6a1f1dSLionel Sambuc 
27*0a6a1f1dSLionel Sambuc   // CHECK: atomicrmw add i64* {{.*}} seq_cst
28*0a6a1f1dSLionel Sambuc   __atomic_fetch_add(&l, 1, memory_order_seq_cst);
29*0a6a1f1dSLionel Sambuc   // CHECK: atomicrmw sub i64* {{.*}} seq_cst
30*0a6a1f1dSLionel Sambuc   __atomic_fetch_sub(&l, 1, memory_order_seq_cst);
31*0a6a1f1dSLionel Sambuc   // CHECK: load atomic i64* {{.*}} seq_cst
32*0a6a1f1dSLionel Sambuc   long long rl;
33*0a6a1f1dSLionel Sambuc   __atomic_load(&l, &rl, memory_order_seq_cst);
34*0a6a1f1dSLionel Sambuc   // CHECK: store atomic i64 {{.*}} seq_cst
35*0a6a1f1dSLionel Sambuc   rl = 0;
36*0a6a1f1dSLionel Sambuc   __atomic_store(&l, &rl, memory_order_seq_cst);
37*0a6a1f1dSLionel Sambuc }
38