diff options
| author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-06-18 20:51:10 +0000 |
|---|---|---|
| committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-06-18 20:51:10 +0000 |
| commit | 114efe0dc88f9e2a78d2e50c7e5e55329dc59477 (patch) | |
| tree | 1c8f7bea067ec4f81742fd96ddf70488fe474388 /clang/test | |
| parent | 5d64abba0a76260992e36e591f2e67f250195337 (diff) | |
| download | bcm5719-llvm-114efe0dc88f9e2a78d2e50c7e5e55329dc59477.tar.gz bcm5719-llvm-114efe0dc88f9e2a78d2e50c7e5e55329dc59477.zip | |
CodeGen: improve ms instrincics support
Add support for _InterlockedCompareExchangePointer, _InterlockExchangePointer,
_InterlockExchange. These are available as a compiler intrinsic on ARM and x86.
These are used directly by the Windows SDK headers without use of the intrin
header.
llvm-svn: 211216
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CodeGen/ms-intrinsics.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/clang/test/CodeGen/ms-intrinsics.c b/clang/test/CodeGen/ms-intrinsics.c new file mode 100644 index 00000000000..e37a4812a54 --- /dev/null +++ b/clang/test/CodeGen/ms-intrinsics.c @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -triple i686--windows -fms-compatibility -Oz -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple thumbv7--windows -fms-compatibility -Oz -emit-llvm %s -o - | FileCheck %s + +void *test_InterlockedExchangePointer(void * volatile *Target, void *Value) { + return _InterlockedExchangePointer(Target, Value); +} + +// CHECK: define{{.*}}i8* @test_InterlockedExchangePointer(i8** %Target, i8* %Value){{.*}}{ +// CHECK: entry: +// CHECK: %0 = bitcast i8** %Target to i32* +// CHECK: %1 = ptrtoint i8* %Value to i32 +// CHECK: %2 = atomicrmw xchg i32* %0, i32 %1 seq_cst +// CHECK: %3 = inttoptr i32 %2 to i8* +// CHECK: ret i8* %3 +// CHECK: } + +void *test_InterlockedCompareExchangePointer(void * volatile *Destination, + void *Exchange, void *Comparand) { + return _InterlockedCompareExchangePointer(Destination, Exchange, Comparand); +} + +// CHECK: define{{.*}}i8* @test_InterlockedCompareExchangePointer(i8** %Destination, i8* %Exchange, i8* %Comparand){{.*}}{ +// CHECK: entry: +// CHECK: %0 = bitcast i8** %Destination to i32* +// CHECK: %1 = ptrtoint i8* %Exchange to i32 +// CHECK: %2 = ptrtoint i8* %Comparand to i32 +// CHECK: %3 = cmpxchg volatile i32* %0, i32 %2, i32 %1 seq_cst seq_cst +// CHECK: %4 = extractvalue { i32, i1 } %3, 0 +// CHECK: %5 = inttoptr i32 %4 to i8* +// CHECK: ret i8* %5 +// CHECK: } + +long test_InterlockedExchange(long *Target, long Value) { + return _InterlockedExchange(Target, Value); +} + +// CHECK: define{{.*}}i32 @test_InterlockedExchange(i32* %Target, i32 %Value){{.*}}{ +// CHECK: entry: +// CHECK: %0 = atomicrmw xchg i32* %Target, i32 %Value seq_cst +// CHECK: ret i32 %0 +// CHECK: } |

