1 // RUN: %clang_cc1 -Werror -Wno-atomic-alignment -triple powerpc64le-linux-gnu \
2 // RUN: -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s \
3 // RUN: --check-prefixes=PPC64,PPC64-QUADWORD-ATOMICS
4 // RUN: %clang_cc1 -Werror -Wno-atomic-alignment -triple powerpc64le-linux-gnu \
5 // RUN: -emit-llvm -o - %s | FileCheck %s \
6 // RUN: --check-prefixes=PPC64,PPC64-NO-QUADWORD-ATOMICS
7 // RUN: %clang_cc1 -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
8 // RUN: -target-cpu pwr7 -emit-llvm -o - %s | FileCheck %s \
9 // RUN: --check-prefixes=PPC64,PPC64-NO-QUADWORD-ATOMICS
10 // RUN: %clang_cc1 -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
11 // RUN: -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s \
12 // RUN: --check-prefixes=PPC64,PPC64-NO-QUADWORD-ATOMICS
13 // RUN: %clang_cc1 -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
14 // RUN: -mabi=quadword-atomics -target-cpu pwr8 -emit-llvm -o - %s | \
15 // RUN: FileCheck %s --check-prefixes=PPC64,PPC64-QUADWORD-ATOMICS
22 typedef _Atomic(Q
) AtomicQ
;
24 typedef __int128_t int128_t
;
26 // PPC64-LABEL: @test_load(
27 // PPC64: [[TMP3:%.*]] = load atomic i128, ptr [[TMP1:%.*]] acquire, align 16
29 Q
test_load(AtomicQ
*ptr
) {
30 // expected-no-diagnostics
31 return __c11_atomic_load(ptr
, __ATOMIC_ACQUIRE
);
34 // PPC64-LABEL: @test_store(
35 // PPC64: store atomic i128 [[TMP6:%.*]], ptr [[TMP4:%.*]] release, align 16
37 void test_store(Q val
, AtomicQ
*ptr
) {
38 // expected-no-diagnostics
39 __c11_atomic_store(ptr
, val
, __ATOMIC_RELEASE
);
42 // PPC64-LABEL: @test_add(
43 // PPC64: [[ATOMICRMW:%.*]] = atomicrmw add ptr [[TMP0:%.*]], i128 [[TMP2:%.*]] monotonic, align 16
45 void test_add(_Atomic(int128_t
) *ptr
, int128_t x
) {
46 // expected-no-diagnostics
47 __c11_atomic_fetch_add(ptr
, x
, __ATOMIC_RELAXED
);
50 // PPC64-LABEL: @test_xchg(
51 // PPC64: [[TMP8:%.*]] = atomicrmw xchg ptr [[TMP4:%.*]], i128 [[TMP7:%.*]] seq_cst, align 16
53 Q
test_xchg(AtomicQ
*ptr
, Q
new) {
54 // expected-no-diagnostics
55 return __c11_atomic_exchange(ptr
, new, __ATOMIC_SEQ_CST
);
58 // PPC64-LABEL: @test_cmpxchg(
59 // PPC64: [[TMP10:%.*]] = cmpxchg ptr [[TMP5:%.*]], i128 [[TMP8:%.*]], i128 [[TMP9:%.*]] seq_cst monotonic, align 16
61 int test_cmpxchg(AtomicQ
*ptr
, Q
*cmp
, Q
new) {
62 // expected-no-diagnostics
63 return __c11_atomic_compare_exchange_strong(ptr
, cmp
, new, __ATOMIC_SEQ_CST
, __ATOMIC_RELAXED
);
66 // PPC64-LABEL: @test_cmpxchg_weak(
67 // PPC64: [[TMP10:%.*]] = cmpxchg weak ptr [[TMP5:%.*]], i128 [[TMP8:%.*]], i128 [[TMP9:%.*]] seq_cst monotonic, align 16
69 int test_cmpxchg_weak(AtomicQ
*ptr
, Q
*cmp
, Q
new) {
70 // expected-no-diagnostics
71 return __c11_atomic_compare_exchange_weak(ptr
, cmp
, new, __ATOMIC_SEQ_CST
, __ATOMIC_RELAXED
);
74 // PPC64-QUADWORD-ATOMICS-LABEL: @is_lock_free(
75 // PPC64-QUADWORD-ATOMICS: ret i32 1
77 // PPC64-NO-QUADWORD-ATOMICS-LABEL: @is_lock_free(
78 // PPC64-NO-QUADWORD-ATOMICS: [[CALL:%.*]] = call zeroext i1 @__atomic_is_lock_free(i64 noundef 16, ptr noundef null)
82 // expected-no-diagnostics
83 return __c11_atomic_is_lock_free(sizeof(q
));