blob: d846b0450448a4a5028ba17095ca4444c7aefda7 [file] [log] [blame]
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize
import Swift
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} void @c_native_function_pointer(void ()*)
sil @c_native_function_pointer : $@convention(c) (@convention(c) () -> ()) -> () {
entry(%f : $@convention(c) () -> ()):
return undef : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @call_with_native_c_function_pointer(i8*)
sil @call_with_native_c_function_pointer : $@convention(thin) (@convention(c) () -> ()) -> () {
entry(%f : $@convention(c) () -> ()):
%c = function_ref @c_native_function_pointer : $@convention(c) (@convention(c) () -> ()) -> ()
%z = apply %c(%f) : $@convention(c) (@convention(c) () -> ()) -> ()
return %z : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc %swift.type* @c_function_pointer_metadata()
sil @c_function_pointer_metadata : $@convention(thin) () -> @thick Any.Type {
entry:
// CHECK: call swiftcc %swift.metadata_response @"$syyXCMa"([[INT]] 0)
%m = metatype $@thick (@convention(c) () -> ()).Type
%a = init_existential_metatype %m : $@thick (@convention(c) () -> ()).Type, $@thick Any.Type
return %a : $@thick Any.Type
}
// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$syyXCMa"(
// -- 0x3000001 -- C convention, 1 argument
// CHECK: call %swift.type* @swift_getFunctionTypeMetadata0([[WORD:i(32|64)]] 196608, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$sytN", i32 0, i32 1))