diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGen/bittest-intrin.c | 33 | ||||
-rw-r--r-- | clang/test/Sema/bittest-intrinsics.c | 84 |
2 files changed, 106 insertions, 11 deletions
diff --git a/clang/test/CodeGen/bittest-intrin.c b/clang/test/CodeGen/bittest-intrin.c index 21a26efa107..f89a8267b0c 100644 --- a/clang/test/CodeGen/bittest-intrin.c +++ b/clang/test/CodeGen/bittest-intrin.c @@ -10,7 +10,9 @@ void test32(long *base, long idx) { sink = _bittestandset(base, idx); sink = _interlockedbittestandreset(base, idx); sink = _interlockedbittestandset(base, idx); + sink = _interlockedbittestandset(base, idx); } + void test64(__int64 *base, __int64 idx) { sink = _bittest64(base, idx); sink = _bittestandcomplement64(base, idx); @@ -20,6 +22,17 @@ void test64(__int64 *base, __int64 idx) { sink = _interlockedbittestandset64(base, idx); } +#if defined(_M_ARM) || defined(_M_ARM64) +void test_arm(long *base, long idx) { + sink = _interlockedbittestandreset_acq(base, idx); + sink = _interlockedbittestandreset_rel(base, idx); + sink = _interlockedbittestandreset_nf(base, idx); + sink = _interlockedbittestandset_acq(base, idx); + sink = _interlockedbittestandset_rel(base, idx); + sink = _interlockedbittestandset_nf(base, idx); +} +#endif + // X64-LABEL: define dso_local void @test32(i32* %base, i32 %idx) // X64: call i8 asm sideeffect "btl $2, ($1)\0A\09setc ${0:b}", "=r,r,r,~{{.*}}"(i32* %{{.*}}, i32 {{.*}}) // X64: call i8 asm sideeffect "btcl $2, ($1)\0A\09setc ${0:b}", "=r,r,r,~{{.*}}"(i32* %{{.*}}, i32 {{.*}}) @@ -110,15 +123,13 @@ void test64(__int64 *base, __int64 idx) { // ARM: %[[RES:[^ ]*]] = and i8 %[[BYTESHR]], 1 // ARM: store volatile i8 %[[RES]], i8* @sink, align 1 -// ARM-LABEL: define dso_local {{.*}}void @test64(i64* %base, i64 %idx) -// ARM: %[[IDXHI:[^ ]*]] = ashr i64 %{{.*}}, 3 -// ARM: %[[BASE:[^ ]*]] = bitcast i64* %{{.*}} to i8* -// ARM: %[[BYTEADDR:[^ ]*]] = getelementptr inbounds i8, i8* %[[BASE]], i64 %[[IDXHI]] -// ARM: %[[IDX8:[^ ]*]] = trunc i64 %{{.*}} to i8 -// ARM: %[[IDXLO:[^ ]*]] = and i8 %[[IDX8]], 7 -// ARM: %[[BYTE:[^ ]*]] = load i8, i8* %[[BYTEADDR]], align 1 -// ARM: %[[BYTESHR:[^ ]*]] = lshr i8 %[[BYTE]], %[[IDXLO]] -// ARM: %[[RES:[^ ]*]] = and i8 %[[BYTESHR]], 1 -// ARM: store volatile i8 %[[RES]], i8* @sink, align 1 -// ... the rest is the same, but with i64 instead of i32. +// Just look for the atomicrmw instructions. + +// ARM-LABEL: define dso_local {{.*}}void @test_arm(i32* %base, i32 %idx) +// ARM: atomicrmw and i8* %{{.*}}, i8 {{.*}} acquire +// ARM: atomicrmw and i8* %{{.*}}, i8 {{.*}} release +// ARM: atomicrmw and i8* %{{.*}}, i8 {{.*}} monotonic +// ARM: atomicrmw or i8* %{{.*}}, i8 {{.*}} acquire +// ARM: atomicrmw or i8* %{{.*}}, i8 {{.*}} release +// ARM: atomicrmw or i8* %{{.*}}, i8 {{.*}} monotonic diff --git a/clang/test/Sema/bittest-intrinsics.c b/clang/test/Sema/bittest-intrinsics.c new file mode 100644 index 00000000000..536c1eb066c --- /dev/null +++ b/clang/test/Sema/bittest-intrinsics.c @@ -0,0 +1,84 @@ +// RUN: %clang_cc1 -ffreestanding -fms-compatibility -fms-compatibility-version=19 -verify %s -triple i686-windows-msvc -fms-extensions -DTEST_X86 +// RUN: %clang_cc1 -ffreestanding -fms-compatibility -fms-compatibility-version=19 -verify %s -triple x86_64-windows-msvc -fms-extensions -DTEST_X64 +// RUN: %clang_cc1 -ffreestanding -fms-compatibility -fms-compatibility-version=19 -verify %s -triple arm-windows-msvc -fms-extensions -DTEST_ARM +// RUN: %clang_cc1 -ffreestanding -fms-compatibility -fms-compatibility-version=19 -verify %s -triple thumbv7-windows-msvc -fms-extensions -DTEST_ARM +// RUN: %clang_cc1 -ffreestanding -fms-compatibility -fms-compatibility-version=19 -verify %s -triple aarch64-windows-msvc -fms-extensions -DTEST_ARM + +#include <intrin.h> +extern unsigned char sink; + +#ifdef TEST_X86 +void x86(long *bits, __int64 *bits64, long bitidx) { + sink = _bittest(bits, bitidx); + sink = _bittestandcomplement(bits, bitidx); + sink = _bittestandreset(bits, bitidx); + sink = _bittestandset(bits, bitidx); + sink = _interlockedbittestandreset(bits, bitidx); + sink = _interlockedbittestandset(bits, bitidx); + + sink = _bittest64(bits64, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _bittestandcomplement64(bits64, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _bittestandreset64(bits64, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _bittestandset64(bits64, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandreset64(bits64, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandset64(bits64, bitidx); // expected-error {{builtin is not supported on this target}} + + sink = _interlockedbittestandreset_acq(bits, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandreset_rel(bits, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandreset_nf(bits, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandset_acq(bits, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandset_rel(bits, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandset_nf(bits, bitidx); // expected-error {{builtin is not supported on this target}} +} +#endif + +#ifdef TEST_X64 +void x64(long *bits, __int64 *bits64, long bitidx) { + sink = _bittest(bits, bitidx); + sink = _bittestandcomplement(bits, bitidx); + sink = _bittestandreset(bits, bitidx); + sink = _bittestandset(bits, bitidx); + sink = _interlockedbittestandreset(bits, bitidx); + sink = _interlockedbittestandset(bits, bitidx); + + sink = _bittest64(bits64, bitidx); + sink = _bittestandcomplement64(bits64, bitidx); + sink = _bittestandreset64(bits64, bitidx); + sink = _bittestandset64(bits64, bitidx); + sink = _interlockedbittestandreset64(bits64, bitidx); + sink = _interlockedbittestandset64(bits64, bitidx); + + sink = _interlockedbittestandreset_acq(bits, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandreset_rel(bits, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandreset_nf(bits, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandset_acq(bits, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandset_rel(bits, bitidx); // expected-error {{builtin is not supported on this target}} + sink = _interlockedbittestandset_nf(bits, bitidx); // expected-error {{builtin is not supported on this target}} +} +#endif + +#ifdef TEST_ARM +// expected-no-diagnostics +void arm(long *bits, __int64 *bits64, long bitidx) { + sink = _bittest(bits, bitidx); + sink = _bittestandcomplement(bits, bitidx); + sink = _bittestandreset(bits, bitidx); + sink = _bittestandset(bits, bitidx); + sink = _interlockedbittestandreset(bits, bitidx); + sink = _interlockedbittestandset(bits, bitidx); + + sink = _bittest64(bits64, bitidx); + sink = _bittestandcomplement64(bits64, bitidx); + sink = _bittestandreset64(bits64, bitidx); + sink = _bittestandset64(bits64, bitidx); + sink = _interlockedbittestandreset64(bits64, bitidx); + sink = _interlockedbittestandset64(bits64, bitidx); + + sink = _interlockedbittestandreset_acq(bits, bitidx); + sink = _interlockedbittestandreset_rel(bits, bitidx); + sink = _interlockedbittestandreset_nf(bits, bitidx); + sink = _interlockedbittestandset_acq(bits, bitidx); + sink = _interlockedbittestandset_rel(bits, bitidx); + sink = _interlockedbittestandset_nf(bits, bitidx); +} +#endif |