ms-intrinsics.c revision 176edba5311f6eff0cad2631449885ddf4fbc9ea
1// RUN: %clang_cc1 -triple i686--windows -fms-compatibility -Oz -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK -check-prefix CHECK-I386 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: %[[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]] 14// CHECK: } 15 16void *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){{.*}}{ 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]+]] 29// CHECK: } 30 31long test_InterlockedExchange(long *Target, long Value) { 32 return _InterlockedExchange(Target, Value); 33} 34 35// CHECK: define{{.*}}i32 @test_InterlockedExchange(i32* %Target, i32 %Value){{.*}}{ 36// CHECK: %[[EXCHANGE:[0-9]+]] = atomicrmw xchg i32* %Target, i32 %Value seq_cst 37// CHECK: ret i32 %[[EXCHANGE:[0-9]+]] 38// CHECK: } 39 40#if defined(__i386__) 41long test__readfsdword(unsigned long Offset) { 42 return __readfsdword(Offset); 43} 44 45// CHECK-I386: define i32 @test__readfsdword(i32 %Offset){{.*}}{ 46// CHECK-I386: [[PTR:%[0-9]+]] = inttoptr i32 %Offset to i32 addrspace(257)* 47// CHECK-I386: [[VALUE:%[0-9]+]] = load volatile i32 addrspace(257)* [[PTR]], align 4 48// CHECK-I386: ret i32 [[VALUE:%[0-9]+]] 49// CHECK-I386: } 50#endif 51 52