Last active
July 21, 2017 03:48
-
-
Save omochi/81d0f7a0fa784eaf7cea0e53013af55f to your computer and use it in GitHub Desktop.
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
//$ swiftc -emit-sil -O a.swift > a-o.sil | |
sil_stage canonical | |
import Builtin | |
import Swift | |
import SwiftShims | |
// main | |
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { | |
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): | |
%2 = integer_literal $Builtin.Int32, 0 // user: %3 | |
%3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 | |
return %3 : $Int32 // id: %4 | |
} // end sil function 'main' | |
// fooooooooo(_:_:) | |
sil hidden @_T01a10foooooooooSiAA1P_p_AaC_ptF : $@convention(thin) (@in P, @in P) -> Int { | |
// %0 // users: %19, %4, %2 | |
// %1 // users: %18, %7, %3 | |
bb0(%0 : $*P, %1 : $*P): | |
debug_value_addr %0 : $*P, let, name "a", argno 1 // id: %2 | |
debug_value_addr %1 : $*P, let, name "b", argno 2 // id: %3 | |
%4 = open_existential_addr immutable_access %0 : $*P to $*@opened("55B10148-6DC7-11E7-BEF6-A860B63CCE03") P // users: %6, %6, %5 | |
%5 = witness_method $@opened("55B10148-6DC7-11E7-BEF6-A860B63CCE03") P, #P.a!1 : <Self where Self : P> (Self) -> () -> Int, %4 : $*@opened("55B10148-6DC7-11E7-BEF6-A860B63CCE03") P : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int // type-defs: %4; user: %6 | |
%6 = apply %5<@opened("55B10148-6DC7-11E7-BEF6-A860B63CCE03") P>(%4) : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int // type-defs: %4; user: %10 | |
%7 = open_existential_addr immutable_access %1 : $*P to $*@opened("55B102D8-6DC7-11E7-BEF6-A860B63CCE03") P // users: %9, %9, %8 | |
%8 = witness_method $@opened("55B102D8-6DC7-11E7-BEF6-A860B63CCE03") P, #P.a!1 : <Self where Self : P> (Self) -> () -> Int, %7 : $*@opened("55B102D8-6DC7-11E7-BEF6-A860B63CCE03") P : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int // type-defs: %7; user: %9 | |
%9 = apply %8<@opened("55B102D8-6DC7-11E7-BEF6-A860B63CCE03") P>(%7) : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int // type-defs: %7; user: %11 | |
%10 = struct_extract %6 : $Int, #Int._value // user: %13 | |
%11 = struct_extract %9 : $Int, #Int._value // user: %13 | |
%12 = integer_literal $Builtin.Int1, -1 // user: %13 | |
%13 = builtin "sadd_with_overflow_Int64"(%10 : $Builtin.Int64, %11 : $Builtin.Int64, %12 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1) // users: %15, %14 | |
%14 = tuple_extract %13 : $(Builtin.Int64, Builtin.Int1), 0 // user: %17 | |
%15 = tuple_extract %13 : $(Builtin.Int64, Builtin.Int1), 1 // user: %16 | |
cond_fail %15 : $Builtin.Int1 // id: %16 | |
%17 = struct $Int (%14 : $Builtin.Int64) // user: %20 | |
destroy_addr %1 : $*P // id: %18 | |
destroy_addr %0 : $*P // id: %19 | |
return %17 : $Int // id: %20 | |
} // end sil function '_T01a10foooooooooSiAA1P_p_AaC_ptF' | |
// gooooooooo(_:) | |
sil hidden @_T01a10goooooooooSiAA1P_pF : $@convention(thin) (@in P) -> Int { | |
// %0 // users: %13, %2, %1 | |
bb0(%0 : $*P): | |
debug_value_addr %0 : $*P, let, name "a", argno 1 // id: %1 | |
%2 = open_existential_addr immutable_access %0 : $*P to $*@opened("55B14374-6DC7-11E7-BEF6-A860B63CCE03") P // users: %4, %4, %3 | |
%3 = witness_method $@opened("55B14374-6DC7-11E7-BEF6-A860B63CCE03") P, #P.a!1 : <Self where Self : P> (Self) -> () -> Int, %2 : $*@opened("55B14374-6DC7-11E7-BEF6-A860B63CCE03") P : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int // type-defs: %2; user: %4 | |
%4 = apply %3<@opened("55B14374-6DC7-11E7-BEF6-A860B63CCE03") P>(%2) : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int // type-defs: %2; user: %6 | |
%5 = integer_literal $Builtin.Int64, 2 // user: %8 | |
%6 = struct_extract %4 : $Int, #Int._value // user: %8 | |
%7 = integer_literal $Builtin.Int1, -1 // user: %8 | |
%8 = builtin "smul_with_overflow_Int64"(%6 : $Builtin.Int64, %5 : $Builtin.Int64, %7 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1) // users: %10, %9 | |
%9 = tuple_extract %8 : $(Builtin.Int64, Builtin.Int1), 0 // user: %12 | |
%10 = tuple_extract %8 : $(Builtin.Int64, Builtin.Int1), 1 // user: %11 | |
cond_fail %10 : $Builtin.Int1 // id: %11 | |
%12 = struct $Int (%9 : $Builtin.Int64) // user: %14 | |
destroy_addr %0 : $*P // id: %13 | |
return %12 : $Int // id: %14 | |
} // end sil function '_T01a10goooooooooSiAA1P_pF' | |
// hooooooooo<A>(_:) | |
sil hidden [thunk] [always_inline] @_T01a10hoooooooooSixAA1PRzlF : $@convention(thin) <X where X : P> (@in X) -> Int { | |
// %0 // users: %3, %2 | |
bb0(%0 : $*X): | |
// function_ref specialized hooooooooo<A>(_:) | |
%1 = function_ref @_T01a10hoooooooooSixAA1PRzlFTf4g_n : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int // user: %2 | |
%2 = apply %1<X>(%0) : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int // user: %4 | |
destroy_addr %0 : $*X // id: %3 | |
return %2 : $Int // id: %4 | |
} // end sil function '_T01a10hoooooooooSixAA1PRzlF' | |
// Int.a() | |
sil hidden @_T0Si1aEAASiyF : $@convention(method) (Int) -> Int { | |
bb0(%0 : $Int): | |
%1 = integer_literal $Builtin.Int64, 33 // user: %2 | |
%2 = struct $Int (%1 : $Builtin.Int64) // user: %3 | |
return %2 : $Int // id: %3 | |
} // end sil function '_T0Si1aEAASiyF' | |
// protocol witness for P.a() in conformance Int | |
sil private [transparent] [thunk] @_T0Si1a1PA2aBPAASiyFTW : $@convention(witness_method) (@in_guaranteed Int) -> Int { | |
bb0(%0 : $*Int): | |
%1 = integer_literal $Builtin.Int64, 33 // user: %2 | |
%2 = struct $Int (%1 : $Builtin.Int64) // user: %3 | |
return %2 : $Int // id: %3 | |
} // end sil function '_T0Si1a1PA2aBPAASiyFTW' | |
// String.a() | |
sil hidden @_T0SS1aEAASiyF : $@convention(method) (@guaranteed String) -> Int { | |
bb0(%0 : $String): | |
%1 = integer_literal $Builtin.Int64, 100 // user: %2 | |
%2 = struct $Int (%1 : $Builtin.Int64) // user: %3 | |
return %2 : $Int // id: %3 | |
} // end sil function '_T0SS1aEAASiyF' | |
// protocol witness for P.a() in conformance String | |
sil private [transparent] [thunk] @_T0SS1a1PA2aBPAASiyFTW : $@convention(witness_method) (@in_guaranteed String) -> Int { | |
bb0(%0 : $*String): | |
%1 = integer_literal $Builtin.Int64, 100 // user: %2 | |
%2 = struct $Int (%1 : $Builtin.Int64) // user: %3 | |
return %2 : $Int // id: %3 | |
} // end sil function '_T0SS1a1PA2aBPAASiyFTW' | |
// ManagedBuffer.__deallocating_deinit | |
sil [serialized] @_T0s13ManagedBufferCfD : $@convention(method) <Header, Element> (@owned ManagedBuffer<Header, Element>) -> () | |
// specialized hooooooooo<A>(_:) | |
sil shared @_T01a10hoooooooooSixAA1PRzlFTf4g_n : $@convention(thin) <X where X : P> (@in_guaranteed X) -> Int { | |
// %0 // users: %3, %1 | |
bb0(%0 : $*X): | |
debug_value_addr %0 : $*X, let, name "a", argno 1 // id: %1 | |
%2 = witness_method $X, #P.a!1 : <Self where Self : P> (Self) -> () -> Int : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int // user: %3 | |
%3 = apply %2<X>(%0) : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int // user: %5 | |
%4 = integer_literal $Builtin.Int64, 3 // user: %7 | |
%5 = struct_extract %3 : $Int, #Int._value // user: %7 | |
%6 = integer_literal $Builtin.Int1, -1 // user: %7 | |
%7 = builtin "smul_with_overflow_Int64"(%5 : $Builtin.Int64, %4 : $Builtin.Int64, %6 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1) // users: %9, %8 | |
%8 = tuple_extract %7 : $(Builtin.Int64, Builtin.Int1), 0 // user: %11 | |
%9 = tuple_extract %7 : $(Builtin.Int64, Builtin.Int1), 1 // user: %10 | |
cond_fail %9 : $Builtin.Int1 // id: %10 | |
%11 = struct $Int (%8 : $Builtin.Int64) // user: %12 | |
return %11 : $Int // id: %12 | |
} // end sil function '_T01a10hoooooooooSixAA1PRzlFTf4g_n' | |
sil_vtable ManagedBuffer { | |
#ManagedBuffer.deinit!deallocator: _T0s13ManagedBufferCfD // ManagedBuffer.__deallocating_deinit | |
} | |
sil_witness_table hidden Int: P module a { | |
method #P.a!1: <Self where Self : P> (Self) -> () -> Int : @_T0Si1a1PA2aBPAASiyFTW // protocol witness for P.a() in conformance Int | |
} | |
sil_witness_table hidden String: P module a { | |
method #P.a!1: <Self where Self : P> (Self) -> () -> Int : @_T0SS1a1PA2aBPAASiyFTW // protocol witness for P.a() in conformance String | |
} | |
sil_default_witness_table hidden P { | |
no_default | |
} | |
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
protocol P { | |
func a() -> Int | |
} | |
func fooooooooo(_ a: P, _ b: P) -> Int { | |
return a.a() + b.a() | |
} | |
func gooooooooo(_ a: P) -> Int { | |
return a.a() * 2 | |
} | |
func hooooooooo<X: P>(_ a: X) -> Int { | |
return a.a() * 3 | |
} | |
extension Int: P { | |
func a() -> Int { | |
return 33 | |
} | |
} | |
extension String: P { | |
func a() -> Int { | |
return 100 | |
} | |
} | |
fooooooooo(3, 4) | |
fooooooooo(3, "aa") | |
gooooooooo(4) | |
hooooooooo(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment