Created
November 17, 2019 11:29
-
-
Save kingnight/16fb074fd78d9872c4dbec0b414493f4 to your computer and use it in GitHub Desktop.
sil file,demo include protocol define
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sil_stage raw | |
import Builtin | |
import Swift | |
import SwiftShims | |
protocol ListDataProtocol { | |
func testFunc() | |
} | |
class TestClass : ListDataProtocol { | |
func testFunc() | |
init() | |
@objc deinit | |
} | |
extension ListDataProtocol { | |
func testFunc() | |
} | |
@_hasStorage @_hasInitialValue let obj: TestClass { get } | |
@_hasStorage @_hasInitialValue let obj2: ListDataProtocol { get } | |
// obj | |
sil_global hidden [let] @$s4demo3objAA9TestClassCvp : $TestClass | |
// obj2 | |
sil_global hidden [let] @$s4demo4obj2AA16ListDataProtocol_pvp : $ListDataProtocol | |
// main | |
sil [ossa] @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { | |
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): | |
alloc_global @$s4demo3objAA9TestClassCvp // id: %2 | |
%3 = global_addr @$s4demo3objAA9TestClassCvp : $*TestClass // users: %8, %7 | |
%4 = metatype $@thick TestClass.Type // user: %6 | |
// function_ref TestClass.__allocating_init() | |
%5 = function_ref @$s4demo9TestClassCACycfC : $@convention(method) (@thick TestClass.Type) -> @owned TestClass // user: %6 | |
%6 = apply %5(%4) : $@convention(method) (@thick TestClass.Type) -> @owned TestClass // user: %7 | |
store %6 to [init] %3 : $*TestClass // id: %7 | |
%8 = load_borrow %3 : $*TestClass // users: %11, %10, %9 | |
%9 = class_method %8 : $TestClass, #TestClass.testFunc!1 : (TestClass) -> () -> (), $@convention(method) (@guaranteed TestClass) -> () // user: %10 | |
%10 = apply %9(%8) : $@convention(method) (@guaranteed TestClass) -> () | |
end_borrow %8 : $TestClass // id: %11 | |
alloc_global @$s4demo4obj2AA16ListDataProtocol_pvp // id: %12 | |
%13 = global_addr @$s4demo4obj2AA16ListDataProtocol_pvp : $*ListDataProtocol // users: %19, %17 | |
%14 = metatype $@thick TestClass.Type // user: %16 | |
// function_ref TestClass.__allocating_init() | |
%15 = function_ref @$s4demo9TestClassCACycfC : $@convention(method) (@thick TestClass.Type) -> @owned TestClass // user: %16 | |
%16 = apply %15(%14) : $@convention(method) (@thick TestClass.Type) -> @owned TestClass // user: %18 | |
%17 = init_existential_addr %13 : $*ListDataProtocol, $TestClass // user: %18 | |
store %16 to [init] %17 : $*TestClass // id: %18 | |
%19 = open_existential_addr immutable_access %13 : $*ListDataProtocol to $*@opened("37F31910-060A-11EA-BC47-ACDE48001122") ListDataProtocol // users: %21, %21, %20 | |
%20 = witness_method $@opened("37F31910-060A-11EA-BC47-ACDE48001122") ListDataProtocol, #ListDataProtocol.testFunc!1 : <Self where Self : ListDataProtocol> (Self) -> () -> (), %19 : $*@opened("37F31910-060A-11EA-BC47-ACDE48001122") ListDataProtocol : $@convention(witness_method: ListDataProtocol) <τ_0_0 where τ_0_0 : ListDataProtocol> (@in_guaranteed τ_0_0) -> () // type-defs: %19; user: %21 | |
%21 = apply %20<@opened("37F31910-060A-11EA-BC47-ACDE48001122") ListDataProtocol>(%19) : $@convention(witness_method: ListDataProtocol) <τ_0_0 where τ_0_0 : ListDataProtocol> (@in_guaranteed τ_0_0) -> () // type-defs: %19 | |
%22 = integer_literal $Builtin.Int32, 0 // user: %23 | |
%23 = struct $Int32 (%22 : $Builtin.Int32) // user: %24 | |
return %23 : $Int32 // id: %24 | |
} // end sil function 'main' | |
// TestClass.testFunc() | |
sil hidden [ossa] @$s4demo9TestClassC8testFuncyyF : $@convention(method) (@guaranteed TestClass) -> () { | |
// %0 // user: %1 | |
bb0(%0 : @guaranteed $TestClass): | |
debug_value %0 : $TestClass, let, name "self", argno 1 // id: %1 | |
%2 = integer_literal $Builtin.Word, 1 // user: %4 | |
// function_ref _allocateUninitializedArray<A>(_:) | |
%3 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %4 | |
%4 = apply %3<Any>(%2) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 | |
(%5, %6) = destructure_tuple %4 : $(Array<Any>, Builtin.RawPointer) // users: %24, %21, %7 | |
%7 = pointer_to_address %6 : $Builtin.RawPointer to [strict] $*Any // user: %14 | |
%8 = string_literal utf8 "ahaha" // user: %13 | |
%9 = integer_literal $Builtin.Word, 5 // user: %13 | |
%10 = integer_literal $Builtin.Int1, -1 // user: %13 | |
%11 = metatype $@thin String.Type // user: %13 | |
// function_ref String.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:) | |
%12 = function_ref @$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String // user: %13 | |
%13 = apply %12(%8, %9, %10, %11) : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String // user: %15 | |
%14 = init_existential_addr %7 : $*Any, $String // user: %15 | |
store %13 to [init] %14 : $*String // id: %15 | |
// function_ref default argument 1 of print(_:separator:terminator:) | |
%16 = function_ref @$ss5print_9separator10terminatoryypd_S2StFfA0_ : $@convention(thin) () -> @owned String // user: %17 | |
%17 = apply %16() : $@convention(thin) () -> @owned String // users: %23, %21 | |
// function_ref default argument 2 of print(_:separator:terminator:) | |
%18 = function_ref @$ss5print_9separator10terminatoryypd_S2StFfA1_ : $@convention(thin) () -> @owned String // user: %19 | |
%19 = apply %18() : $@convention(thin) () -> @owned String // users: %22, %21 | |
// function_ref print(_:separator:terminator:) | |
%20 = function_ref @$ss5print_9separator10terminatoryypd_S2StF : $@convention(thin) (@guaranteed Array<Any>, @guaranteed String, @guaranteed String) -> () // user: %21 | |
%21 = apply %20(%5, %17, %19) : $@convention(thin) (@guaranteed Array<Any>, @guaranteed String, @guaranteed String) -> () | |
destroy_value %19 : $String // id: %22 | |
destroy_value %17 : $String // id: %23 | |
destroy_value %5 : $Array<Any> // id: %24 | |
%25 = tuple () // user: %26 | |
return %25 : $() // id: %26 | |
} // end sil function '$s4demo9TestClassC8testFuncyyF' | |
// _allocateUninitializedArray<A>(_:) | |
sil [serialized] [always_inline] [_semantics "array.uninitialized_intrinsic"] @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) | |
// String.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:) | |
sil [serialized] [always_inline] [readonly] [_semantics "string.makeUTF8"] @$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String | |
// default argument 1 of print(_:separator:terminator:) | |
sil hidden_external [serialized] @$ss5print_9separator10terminatoryypd_S2StFfA0_ : $@convention(thin) () -> @owned String | |
// default argument 2 of print(_:separator:terminator:) | |
sil hidden_external [serialized] @$ss5print_9separator10terminatoryypd_S2StFfA1_ : $@convention(thin) () -> @owned String | |
// print(_:separator:terminator:) | |
sil @$ss5print_9separator10terminatoryypd_S2StF : $@convention(thin) (@guaranteed Array<Any>, @guaranteed String, @guaranteed String) -> () | |
// TestClass.__allocating_init() | |
sil hidden [ossa] @$s4demo9TestClassCACycfC : $@convention(method) (@thick TestClass.Type) -> @owned TestClass { | |
bb0(%0 : $@thick TestClass.Type): | |
%1 = alloc_ref $TestClass // user: %3 | |
// function_ref TestClass.init() | |
%2 = function_ref @$s4demo9TestClassCACycfc : $@convention(method) (@owned TestClass) -> @owned TestClass // user: %3 | |
%3 = apply %2(%1) : $@convention(method) (@owned TestClass) -> @owned TestClass // user: %4 | |
return %3 : $TestClass // id: %4 | |
} // end sil function '$s4demo9TestClassCACycfC' | |
// TestClass.init() | |
sil hidden [ossa] @$s4demo9TestClassCACycfc : $@convention(method) (@owned TestClass) -> @owned TestClass { | |
// %0 // users: %2, %1 | |
bb0(%0 : @owned $TestClass): | |
debug_value %0 : $TestClass, let, name "self", argno 1 // id: %1 | |
%2 = mark_uninitialized [rootself] %0 : $TestClass // users: %4, %3 | |
%3 = copy_value %2 : $TestClass // user: %5 | |
destroy_value %2 : $TestClass // id: %4 | |
return %3 : $TestClass // id: %5 | |
} // end sil function '$s4demo9TestClassCACycfc' | |
// TestClass.deinit | |
sil hidden [ossa] @$s4demo9TestClassCfd : $@convention(method) (@guaranteed TestClass) -> @owned Builtin.NativeObject { | |
// %0 // users: %2, %1 | |
bb0(%0 : @guaranteed $TestClass): | |
debug_value %0 : $TestClass, let, name "self", argno 1 // id: %1 | |
%2 = unchecked_ref_cast %0 : $TestClass to $Builtin.NativeObject // user: %3 | |
%3 = unchecked_ownership_conversion %2 : $Builtin.NativeObject, @guaranteed to @owned // user: %4 | |
return %3 : $Builtin.NativeObject // id: %4 | |
} // end sil function '$s4demo9TestClassCfd' | |
// TestClass.__deallocating_deinit | |
sil hidden [ossa] @$s4demo9TestClassCfD : $@convention(method) (@owned TestClass) -> () { | |
// %0 // users: %6, %3, %1 | |
bb0(%0 : @owned $TestClass): | |
debug_value %0 : $TestClass, let, name "self", argno 1 // id: %1 | |
// function_ref TestClass.deinit | |
%2 = function_ref @$s4demo9TestClassCfd : $@convention(method) (@guaranteed TestClass) -> @owned Builtin.NativeObject // user: %4 | |
%3 = begin_borrow %0 : $TestClass // users: %5, %4 | |
%4 = apply %2(%3) : $@convention(method) (@guaranteed TestClass) -> @owned Builtin.NativeObject // user: %7 | |
end_borrow %3 : $TestClass // id: %5 | |
end_lifetime %0 : $TestClass // id: %6 | |
%7 = unchecked_ref_cast %4 : $Builtin.NativeObject to $TestClass // user: %8 | |
dealloc_ref %7 : $TestClass // id: %8 | |
%9 = tuple () // user: %10 | |
return %9 : $() // id: %10 | |
} // end sil function '$s4demo9TestClassCfD' | |
// protocol witness for ListDataProtocol.testFunc() in conformance TestClass | |
sil private [transparent] [thunk] [ossa] @$s4demo9TestClassCAA16ListDataProtocolA2aDP8testFuncyyFTW : $@convention(witness_method: ListDataProtocol) (@in_guaranteed TestClass) -> () { | |
// %0 // user: %1 | |
bb0(%0 : $*TestClass): | |
%1 = load_borrow %0 : $*TestClass // users: %5, %3, %2 | |
%2 = class_method %1 : $TestClass, #TestClass.testFunc!1 : (TestClass) -> () -> (), $@convention(method) (@guaranteed TestClass) -> () // user: %3 | |
%3 = apply %2(%1) : $@convention(method) (@guaranteed TestClass) -> () | |
%4 = tuple () // user: %6 | |
end_borrow %1 : $TestClass // id: %5 | |
return %4 : $() // id: %6 | |
} // end sil function '$s4demo9TestClassCAA16ListDataProtocolA2aDP8testFuncyyFTW' | |
// ListDataProtocol.testFunc() | |
sil hidden [ossa] @$s4demo16ListDataProtocolPAAE8testFuncyyF : $@convention(method) <Self where Self : ListDataProtocol> (@in_guaranteed Self) -> () { | |
// %0 // user: %1 | |
bb0(%0 : $*Self): | |
debug_value_addr %0 : $*Self, let, name "self", argno 1 // id: %1 | |
%2 = integer_literal $Builtin.Word, 1 // user: %4 | |
// function_ref _allocateUninitializedArray<A>(_:) | |
%3 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %4 | |
%4 = apply %3<Any>(%2) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 | |
(%5, %6) = destructure_tuple %4 : $(Array<Any>, Builtin.RawPointer) // users: %24, %21, %7 | |
%7 = pointer_to_address %6 : $Builtin.RawPointer to [strict] $*Any // user: %14 | |
%8 = string_literal utf8 "bhbhb" // user: %13 | |
%9 = integer_literal $Builtin.Word, 5 // user: %13 | |
%10 = integer_literal $Builtin.Int1, -1 // user: %13 | |
%11 = metatype $@thin String.Type // user: %13 | |
// function_ref String.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:) | |
%12 = function_ref @$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String // user: %13 | |
%13 = apply %12(%8, %9, %10, %11) : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String // user: %15 | |
%14 = init_existential_addr %7 : $*Any, $String // user: %15 | |
store %13 to [init] %14 : $*String // id: %15 | |
// function_ref default argument 1 of print(_:separator:terminator:) | |
%16 = function_ref @$ss5print_9separator10terminatoryypd_S2StFfA0_ : $@convention(thin) () -> @owned String // user: %17 | |
%17 = apply %16() : $@convention(thin) () -> @owned String // users: %23, %21 | |
// function_ref default argument 2 of print(_:separator:terminator:) | |
%18 = function_ref @$ss5print_9separator10terminatoryypd_S2StFfA1_ : $@convention(thin) () -> @owned String // user: %19 | |
%19 = apply %18() : $@convention(thin) () -> @owned String // users: %22, %21 | |
// function_ref print(_:separator:terminator:) | |
%20 = function_ref @$ss5print_9separator10terminatoryypd_S2StF : $@convention(thin) (@guaranteed Array<Any>, @guaranteed String, @guaranteed String) -> () // user: %21 | |
%21 = apply %20(%5, %17, %19) : $@convention(thin) (@guaranteed Array<Any>, @guaranteed String, @guaranteed String) -> () | |
destroy_value %19 : $String // id: %22 | |
destroy_value %17 : $String // id: %23 | |
destroy_value %5 : $Array<Any> // id: %24 | |
%25 = tuple () // user: %26 | |
return %25 : $() // id: %26 | |
} // end sil function '$s4demo16ListDataProtocolPAAE8testFuncyyF' | |
sil_vtable TestClass { | |
#TestClass.testFunc!1: (TestClass) -> () -> () : @$s4demo9TestClassC8testFuncyyF // TestClass.testFunc() | |
#TestClass.init!allocator.1: (TestClass.Type) -> () -> TestClass : @$s4demo9TestClassCACycfC // TestClass.__allocating_init() | |
#TestClass.deinit!deallocator.1: @$s4demo9TestClassCfD // TestClass.__deallocating_deinit | |
} | |
sil_witness_table hidden TestClass: ListDataProtocol module demo { | |
method #ListDataProtocol.testFunc!1: <Self where Self : ListDataProtocol> (Self) -> () -> () : @$s4demo9TestClassCAA16ListDataProtocolA2aDP8testFuncyyFTW // protocol witness for ListDataProtocol.testFunc() in conformance TestClass | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment