blob: e37a4812a54089be2f62edce049a6a919c96853c [file] [log] [blame]
Saleem Abdulrasool114efe02014-06-18 20:51:10 +00001// RUN: %clang_cc1 -triple i686--windows -fms-compatibility -Oz -emit-llvm %s -o - | FileCheck %s
2// RUN: %clang_cc1 -triple thumbv7--windows -fms-compatibility -Oz -emit-llvm %s -o - | FileCheck %s
3
4void *test_InterlockedExchangePointer(void * volatile *Target, void *Value) {
5 return _InterlockedExchangePointer(Target, Value);
6}
7
8// CHECK: define{{.*}}i8* @test_InterlockedExchangePointer(i8** %Target, i8* %Value){{.*}}{
9// CHECK: entry:
10// CHECK: %0 = bitcast i8** %Target to i32*
11// CHECK: %1 = ptrtoint i8* %Value to i32
12// CHECK: %2 = atomicrmw xchg i32* %0, i32 %1 seq_cst
13// CHECK: %3 = inttoptr i32 %2 to i8*
14// CHECK: ret i8* %3
15// CHECK: }
16
17void *test_InterlockedCompareExchangePointer(void * volatile *Destination,
18 void *Exchange, void *Comparand) {
19 return _InterlockedCompareExchangePointer(Destination, Exchange, Comparand);
20}
21
22// CHECK: define{{.*}}i8* @test_InterlockedCompareExchangePointer(i8** %Destination, i8* %Exchange, i8* %Comparand){{.*}}{
23// CHECK: entry:
24// CHECK: %0 = bitcast i8** %Destination to i32*
25// CHECK: %1 = ptrtoint i8* %Exchange to i32
26// CHECK: %2 = ptrtoint i8* %Comparand to i32
27// CHECK: %3 = cmpxchg volatile i32* %0, i32 %2, i32 %1 seq_cst seq_cst
28// CHECK: %4 = extractvalue { i32, i1 } %3, 0
29// CHECK: %5 = inttoptr i32 %4 to i8*
30// CHECK: ret i8* %5
31// CHECK: }
32
33long test_InterlockedExchange(long *Target, long Value) {
34 return _InterlockedExchange(Target, Value);
35}
36
37// CHECK: define{{.*}}i32 @test_InterlockedExchange(i32* %Target, i32 %Value){{.*}}{
38// CHECK: entry:
39// CHECK: %0 = atomicrmw xchg i32* %Target, i32 %Value seq_cst
40// CHECK: ret i32 %0
41// CHECK: }