Saleem Abdulrasool | 114efe0 | 2014-06-18 20:51:10 +0000 | [diff] [blame] | 1 | // 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 | |
| 4 | void *test_InterlockedExchangePointer(void * volatile *Target, void *Value) { |
| 5 | return _InterlockedExchangePointer(Target, Value); |
| 6 | } |
| 7 | |
| 8 | // CHECK: define{{.*}}i8* @test_InterlockedExchangePointer(i8** %Target, i8* %Value){{.*}}{ |
Saleem Abdulrasool | 11415c6 | 2014-06-18 21:48:44 +0000 | [diff] [blame] | 9 | // CHECK: %[[TARGET:[0-9]+]] = bitcast i8** %Target to i32* |
| 10 | // CHECK: %[[VALUE:[0-9]+]] = ptrtoint i8* %Value to i32 |
| 11 | // CHECK: %[[EXCHANGE:[0-9]+]] = atomicrmw xchg i32* %[[TARGET]], i32 %[[VALUE]] seq_cst |
| 12 | // CHECK: %[[RESULT:[0-9]+]] = inttoptr i32 %[[EXCHANGE]] to i8* |
| 13 | // CHECK: ret i8* %[[RESULT]] |
Saleem Abdulrasool | 114efe0 | 2014-06-18 20:51:10 +0000 | [diff] [blame] | 14 | // CHECK: } |
| 15 | |
| 16 | void *test_InterlockedCompareExchangePointer(void * volatile *Destination, |
| 17 | void *Exchange, void *Comparand) { |
| 18 | return _InterlockedCompareExchangePointer(Destination, Exchange, Comparand); |
| 19 | } |
| 20 | |
| 21 | // CHECK: define{{.*}}i8* @test_InterlockedCompareExchangePointer(i8** %Destination, i8* %Exchange, i8* %Comparand){{.*}}{ |
Saleem Abdulrasool | 11415c6 | 2014-06-18 21:48:44 +0000 | [diff] [blame] | 22 | // CHECK: %[[DEST:[0-9]+]] = bitcast i8** %Destination to i32* |
| 23 | // CHECK: %[[EXCHANGE:[0-9]+]] = ptrtoint i8* %Exchange to i32 |
| 24 | // CHECK: %[[COMPARAND:[0-9]+]] = ptrtoint i8* %Comparand to i32 |
| 25 | // CHECK: %[[XCHG:[0-9]+]] = cmpxchg volatile i32* %[[DEST:[0-9]+]], i32 %[[COMPARAND:[0-9]+]], i32 %[[EXCHANGE:[0-9]+]] seq_cst seq_cst |
| 26 | // CHECK: %[[EXTRACT:[0-9]+]] = extractvalue { i32, i1 } %[[XCHG]], 0 |
| 27 | // CHECK: %[[RESULT:[0-9]+]] = inttoptr i32 %[[EXTRACT]] to i8* |
| 28 | // CHECK: ret i8* %[[RESULT:[0-9]+]] |
Saleem Abdulrasool | 114efe0 | 2014-06-18 20:51:10 +0000 | [diff] [blame] | 29 | // CHECK: } |
| 30 | |
| 31 | long test_InterlockedExchange(long *Target, long Value) { |
| 32 | return _InterlockedExchange(Target, Value); |
| 33 | } |
| 34 | |
| 35 | // CHECK: define{{.*}}i32 @test_InterlockedExchange(i32* %Target, i32 %Value){{.*}}{ |
Saleem Abdulrasool | 11415c6 | 2014-06-18 21:48:44 +0000 | [diff] [blame] | 36 | // CHECK: %[[EXCHANGE:[0-9]+]] = atomicrmw xchg i32* %Target, i32 %Value seq_cst |
| 37 | // CHECK: ret i32 %[[EXCHANGE:[0-9]+]] |
Saleem Abdulrasool | 114efe0 | 2014-06-18 20:51:10 +0000 | [diff] [blame] | 38 | // CHECK: } |