| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir |
| 2 |
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR |
| 3 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll |
| 4 |
// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM |
| 5 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll |
| 6 |
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG |
| 7 |
|
| 8 |
void scoped_atomic_load(int *ptr) { |
| 9 |
// CIR-LABEL: @scoped_atomic_load |
| 10 |
// LLVM-LABEL: @scoped_atomic_load |
| 11 |
// OGCG-LABEL: @scoped_atomic_load |
| 12 |
|
| 13 |
int x; |
| 14 |
__scoped_atomic_load(ptr, &x, __ATOMIC_RELAXED, __MEMORY_SCOPE_SINGLE); |
| 15 |
// CIR: %{{.+}} = cir.load align(4) syncscope(single_thread) atomic(relaxed) %{{.+}} : !cir.ptr<!s32i>, !s32i |
| 16 |
// LLVM: %{{.+}} = load atomic i32, ptr %{{.+}} syncscope("singlethread") monotonic, align 4 |
| 17 |
// OGCG: %{{.+}} = load atomic i32, ptr %{{.+}} monotonic, align 4 |
| 18 |
|
| 19 |
__scoped_atomic_load(ptr, &x, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM); |
| 20 |
// CIR: %{{.+}} = cir.load align(4) syncscope(system) atomic(relaxed) %{{.+}} : !cir.ptr<!s32i>, !s32i |
| 21 |
// LLVM: %{{.+}} = load atomic i32, ptr %{{.+}} monotonic, align 4 |
| 22 |
// OGCG: %{{.+}} = load atomic i32, ptr %{{.+}} monotonic, align 4 |
| 23 |
} |
| 24 |
|
| 25 |
void scoped_atomic_load_n(int *ptr) { |
| 26 |
// CIR-LABEL: @scoped_atomic_load_n |
| 27 |
// LLVM-LABEL: @scoped_atomic_load_n |
| 28 |
// OGCG-LABEL: @scoped_atomic_load_n |
| 29 |
|
| 30 |
int x; |
| 31 |
x = __scoped_atomic_load_n(ptr, __ATOMIC_RELAXED, __MEMORY_SCOPE_SINGLE); |
| 32 |
// CIR: %{{.+}} = cir.load align(4) syncscope(single_thread) atomic(relaxed) %{{.+}} : !cir.ptr<!s32i>, !s32i |
| 33 |
// LLVM: %{{.+}} = load atomic i32, ptr %{{.+}} syncscope("singlethread") monotonic, align 4 |
| 34 |
// OGCG: %{{.+}} = load atomic i32, ptr %{{.+}} monotonic, align 4 |
| 35 |
|
| 36 |
x = __scoped_atomic_load_n(ptr, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM); |
| 37 |
// CIR: %{{.+}} = cir.load align(4) syncscope(system) atomic(relaxed) %{{.+}} : !cir.ptr<!s32i>, !s32i |
| 38 |
// LLVM: %{{.+}} = load atomic i32, ptr %{{.+}} monotonic, align 4 |
| 39 |
// OGCG: %{{.+}} = load atomic i32, ptr %{{.+}} monotonic, align 4 |
| 40 |
} |
| 41 |
|
| 42 |
void scoped_atomic_store(int *ptr, int value) { |
| 43 |
// CIR-LABEL: @scoped_atomic_store |
| 44 |
// LLVM-LABEL: @scoped_atomic_store |
| 45 |
// OGCG-LABEL: @scoped_atomic_store |
| 46 |
|
| 47 |
__scoped_atomic_store(ptr, &value, __ATOMIC_RELAXED, __MEMORY_SCOPE_SINGLE); |
| 48 |
// CIR: cir.store align(4) syncscope(single_thread) atomic(relaxed) %{{.+}}, %{{.+}} : !s32i, !cir.ptr<!s32i> |
| 49 |
// LLVM: store atomic i32 %{{.+}}, ptr %{{.+}} syncscope("singlethread") monotonic, align 4 |
| 50 |
// OGCG: store atomic i32 %{{.+}}, ptr %{{.+}} monotonic, align 4 |
| 51 |
|
| 52 |
__scoped_atomic_store(ptr, &value, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM); |
| 53 |
// CIR: cir.store align(4) syncscope(system) atomic(relaxed) %{{.+}}, %{{.+}} : !s32i, !cir.ptr<!s32i> |
| 54 |
// LLVM: store atomic i32 %{{.+}}, ptr %{{.+}} monotonic, align 4 |
| 55 |
// OGCG: store atomic i32 %{{.+}}, ptr %{{.+}} monotonic, align 4 |
| 56 |
} |
| 57 |
|
| 58 |
void scoped_atomic_store_n(int *ptr, int value) { |
| 59 |
// CIR-LABEL: @scoped_atomic_store_n |
| 60 |
// LLVM-LABEL: @scoped_atomic_store_n |
| 61 |
// OGCG-LABEL: @scoped_atomic_store_n |
| 62 |
|
| 63 |
__scoped_atomic_store_n(ptr, value, __ATOMIC_RELAXED, __MEMORY_SCOPE_SINGLE); |
| 64 |
// CIR: cir.store align(4) syncscope(single_thread) atomic(relaxed) %{{.+}}, %{{.+}} : !s32i, !cir.ptr<!s32i> |
| 65 |
// LLVM: store atomic i32 %{{.+}}, ptr %{{.+}} syncscope("singlethread") monotonic, align 4 |
| 66 |
// OGCG: store atomic i32 %{{.+}}, ptr %{{.+}} monotonic, align 4 |
| 67 |
|
| 68 |
__scoped_atomic_store_n(ptr, value, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM); |
| 69 |
// CIR: cir.store align(4) syncscope(system) atomic(relaxed) %{{.+}}, %{{.+}} : !s32i, !cir.ptr<!s32i> |
| 70 |
// LLVM: store atomic i32 %{{.+}}, ptr %{{.+}} monotonic, align 4 |
| 71 |
// OGCG: store atomic i32 %{{.+}}, ptr %{{.+}} monotonic, align 4 |
| 72 |
} |