mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Use the generic type lowering algorithm described in "docs/CallingConvention.rst#physical-lowering" to map from IRGen's explosion type to the type expected by the ABI. Change IRGen to use the swift calling convention (swiftcc) for native swift functions. Use the 'swiftself' attribute on self parameters and for closures contexts. Use the 'swifterror' parameter for swift error parameters. Change functions in the runtime that are called as native swift functions to use the swift calling convention. rdar://19978563
51 lines
1.6 KiB
Plaintext
51 lines
1.6 KiB
Plaintext
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -gnone -emit-ir | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
|
|
|
|
// REQUIRES: CPU=x86_64
|
|
|
|
sil_stage canonical
|
|
|
|
import Swift
|
|
|
|
sil hidden @test_helper : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = tuple ()
|
|
return %0 : $()
|
|
}
|
|
|
|
// CHECK-64: define hidden swiftcc void @test1([[WORD:i64]], [[WORD]])
|
|
// CHECK-32: define hidden swiftcc void @test1([[WORD:i32]], [[WORD]])
|
|
sil hidden @test1 : $@convention(thin) (@owned Optional<() -> ()>) -> () {
|
|
bb0(%0 : $Optional<() -> ()>):
|
|
// CHECK: call void @_T0SqWy
|
|
retain_value %0 : $Optional<() -> ()>
|
|
|
|
// CHECK: icmp eq i64 %0, 0
|
|
switch_enum %0 : $Optional<() -> ()>, case #Optional.some!enumelt.1: bb1, case #Optional.none!enumelt: bb2
|
|
|
|
// CHECK: [[FNPTR:%.*]] = inttoptr [[WORD]] %0 to i8*
|
|
// CHECK: [[CTX:%.*]] = inttoptr [[WORD]] %1 to %swift.refcounted*
|
|
// CHECK: br label
|
|
// CHECK: [[FNPTR2:%.*]] = phi i8* [ [[FNPTR]], {{%.*}} ]
|
|
// CHECK: [[CTX2:%.*]] = phi %swift.refcounted* [ [[CTX]], {{%.*}} ]
|
|
bb1(%1 : $() -> ()):
|
|
|
|
// CHECK: [[FNPTR3:%.*]] = bitcast i8* [[FNPTR2]] to void (%swift.refcounted*)*
|
|
// CHECK: call swiftcc void [[FNPTR3]](%swift.refcounted* swiftself [[CTX2]])
|
|
apply %1() : $() -> ()
|
|
|
|
// CHECK: br label [[CONT:%[0-9]+]]
|
|
br bb3
|
|
|
|
bb2:
|
|
%4 = function_ref @test_helper : $@convention(thin) () -> ()
|
|
apply %4() : $@convention(thin) () -> ()
|
|
// CHECK: call swiftcc void @test_helper()
|
|
// CHECK: br label [[CONT]]
|
|
br bb3
|
|
|
|
bb3:
|
|
%5 = tuple ()
|
|
// CHECK: ret void
|
|
return %5 : $()
|
|
}
|