85 lines · c
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-ATOMICS4// 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-ATOMICS7// 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-ATOMICS10// 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-ATOMICS13// 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-ATOMICS16 17 18typedef struct {19 char x[16];20} Q;21 22typedef _Atomic(Q) AtomicQ;23 24typedef __int128_t int128_t;25 26// PPC64-LABEL: @test_load(27// PPC64: [[TMP3:%.*]] = load atomic i128, ptr [[TMP1:%.*]] acquire, align 1628//29Q test_load(AtomicQ *ptr) {30 // expected-no-diagnostics31 return __c11_atomic_load(ptr, __ATOMIC_ACQUIRE);32}33 34// PPC64-LABEL: @test_store(35// PPC64: store atomic i128 [[TMP6:%.*]], ptr [[TMP4:%.*]] release, align 1636//37void test_store(Q val, AtomicQ *ptr) {38 // expected-no-diagnostics39 __c11_atomic_store(ptr, val, __ATOMIC_RELEASE);40}41 42// PPC64-LABEL: @test_add(43// PPC64: [[ATOMICRMW:%.*]] = atomicrmw add ptr [[TMP0:%.*]], i128 [[TMP2:%.*]] monotonic, align 1644//45void test_add(_Atomic(int128_t) *ptr, int128_t x) {46 // expected-no-diagnostics47 __c11_atomic_fetch_add(ptr, x, __ATOMIC_RELAXED);48}49 50// PPC64-LABEL: @test_xchg(51// PPC64: [[TMP8:%.*]] = atomicrmw xchg ptr [[TMP4:%.*]], i128 [[TMP7:%.*]] seq_cst, align 1652//53Q test_xchg(AtomicQ *ptr, Q new) {54 // expected-no-diagnostics55 return __c11_atomic_exchange(ptr, new, __ATOMIC_SEQ_CST);56}57 58// PPC64-LABEL: @test_cmpxchg(59// PPC64: [[TMP10:%.*]] = cmpxchg ptr [[TMP5:%.*]], i128 [[TMP8:%.*]], i128 [[TMP9:%.*]] seq_cst monotonic, align 1660//61int test_cmpxchg(AtomicQ *ptr, Q *cmp, Q new) {62 // expected-no-diagnostics63 return __c11_atomic_compare_exchange_strong(ptr, cmp, new, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);64}65 66// PPC64-LABEL: @test_cmpxchg_weak(67// PPC64: [[TMP10:%.*]] = cmpxchg weak ptr [[TMP5:%.*]], i128 [[TMP8:%.*]], i128 [[TMP9:%.*]] seq_cst monotonic, align 1668//69int test_cmpxchg_weak(AtomicQ *ptr, Q *cmp, Q new) {70 // expected-no-diagnostics71 return __c11_atomic_compare_exchange_weak(ptr, cmp, new, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);72}73 74// PPC64-QUADWORD-ATOMICS-LABEL: @is_lock_free(75// PPC64-QUADWORD-ATOMICS: ret i32 176//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)79//80int is_lock_free() {81 AtomicQ q;82 // expected-no-diagnostics83 return __c11_atomic_is_lock_free(sizeof(q));84}85