mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This changes layout of the `TargetFunctionTypeFlags` to allocate 8 bits for flags, 8 bits for convesion and 16 bits for number of parameters. Documentation is updated accordingly.
31 lines
1.5 KiB
Plaintext
31 lines
1.5 KiB
Plaintext
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s
|
|
|
|
import Swift
|
|
|
|
// CHECK-LABEL: define{{( 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{{( 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{{( protected)?}} swiftcc %swift.type* @c_function_pointer_metadata()
|
|
sil @c_function_pointer_metadata : $@convention(thin) () -> @thick Any.Type {
|
|
entry:
|
|
// CHECK: call %swift.type* @_T0yyXCMa()
|
|
%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 %swift.type* @_T0yyXCMa()
|
|
// -- 0x3000001 -- C convention, 1 argument
|
|
// CHECK: call %swift.type* @swift_getFunctionTypeMetadata([[WORD:i(32|64)]] 196608, %swift.type** null, i32* null, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @_T0ytN, i32 0, i32 1))
|