mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
68 lines
2.5 KiB
Plaintext
68 lines
2.5 KiB
Plaintext
// RUN: rm -rf %t && mkdir -p %t
|
|
// RUN: %build-irgen-test-overlays
|
|
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir | %FileCheck %s
|
|
|
|
// REQUIRES: CPU=armv7k, OS=watchos
|
|
// REQUIRES: objc_interop
|
|
|
|
import Swift
|
|
import gizmo
|
|
|
|
//
|
|
// A pure Swift class. We can access its isa directly.
|
|
//
|
|
|
|
class Purebred {
|
|
func method() {}
|
|
}
|
|
sil_vtable Purebred {}
|
|
|
|
// CHECK-LABEL: define{{( protected)?}} swiftcc void @purebred_method(%T33class_isa_pointers_armv7k_watchos8PurebredC*) {{.*}} {
|
|
// CHECK: [[ISA_PTR:%.*]] = bitcast %T33class_isa_pointers_armv7k_watchos8PurebredC* %0 to %swift.type**
|
|
// CHECK: [[ISA:%.*]] = load %swift.type*, %swift.type** [[ISA_PTR]]
|
|
// CHECK: [[VTABLE:%.*]] = bitcast %swift.type* [[ISA]]
|
|
// CHECK: getelementptr inbounds {{.*}} [[VTABLE]]
|
|
sil @purebred_method : $@convention(thin) (@owned Purebred) -> () {
|
|
entry(%0 : $Purebred):
|
|
%m = class_method %0 : $Purebred, #Purebred.method!1 : (Purebred) -> () -> (), $@convention(method) (@guaranteed Purebred) -> ()
|
|
%z = apply %m(%0) : $@convention(method) (@guaranteed Purebred) -> ()
|
|
return %z : $()
|
|
}
|
|
|
|
//
|
|
// A mixed Swift/ObjC class. We have to mask when reading its isa.
|
|
//
|
|
|
|
class Mongrel: Gizmo {
|
|
func method() {}
|
|
}
|
|
sil_vtable Mongrel {}
|
|
|
|
// CHECK-LABEL: define{{( protected)?}} swiftcc void @mongrel_method(%T33class_isa_pointers_armv7k_watchos7MongrelC*) {{.*}} {
|
|
// CHECK: [[T0:%.*]] = bitcast {{.*}} %0 to %objc_object*
|
|
// CHECK: [[T1:%.*]] = call %objc_class* @object_getClass(%objc_object* [[T0]])
|
|
// CHECK: [[ISA:%.*]] = bitcast %objc_class* [[T1]] to %swift.type*
|
|
// CHECK: [[VTABLE:%.*]] = bitcast %swift.type* [[ISA]]
|
|
// CHECK: getelementptr inbounds {{.*}} [[VTABLE]]
|
|
sil @mongrel_method : $@convention(thin) (@owned Mongrel) -> () {
|
|
entry(%0 : $Mongrel):
|
|
%m = class_method %0 : $Mongrel, #Mongrel.method!1 : (Mongrel) -> () -> (), $@convention(method) (@guaranteed Mongrel) -> ()
|
|
%z = apply %m(%0) : $@convention(method) (@guaranteed Mongrel) -> ()
|
|
return %z : $()
|
|
}
|
|
|
|
// ObjC stubs expected by ObjC metadata emission
|
|
|
|
sil private @_T033class_isa_pointers_armv7k_watchos7MongrelC6methodyyFTo : $@convention(objc_method) (Purebred) -> () {
|
|
entry(%0 : $Purebred):
|
|
unreachable
|
|
}
|
|
sil private @_T033class_isa_pointers_armv7k_watchos7MongrelCSQyACGSi7bellsOn_tcfcTo : $@convention(objc_method) (Int, Purebred) -> () {
|
|
entry(%0 : $Int, %1 : $Purebred):
|
|
unreachable
|
|
}
|
|
sil private @_T033class_isa_pointers_armv7k_watchos7MongrelCACycfcTo : $@convention(objc_method) (Purebred) -> () {
|
|
entry(%0 : $Purebred):
|
|
unreachable
|
|
}
|