Created
June 5, 2014 14:44
-
-
Save landonf/bb450910269c1bed0481 to your computer and use it in GitHub Desktop.
Swift SIL as a compilation target? /Applications/Xcode6-Beta.app/Contents/Developer/usr/bin/xcrun swift -emit-silgen example.swift -module-name MyNameSpace
This file contains hidden or 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 | |
enum MyEnum<T> { | |
case Foo(T) | |
} | |
protocol MyProtocol { | |
typealias B | |
func returnObject() -> B | |
} | |
class MyClass : MyProtocol { | |
typealias B = String | |
let string: String | |
let int: Int | |
let e: MyEnum<String> | |
init(string: String, int: Int, e: MyEnum<String>) | |
func returnObject() -> B | |
} | |
// top_level_code | |
sil private @top_level_code : $@thin () -> () { | |
bb0: | |
%0 = tuple () // user: %1 | |
return %0 : $() // id: %1 | |
} | |
// MyNameSpace.MyEnum.Foo <A>(MyNameSpace.MyEnum<A>.Type)(A) -> MyNameSpace.MyEnum<A> | |
sil [transparent] @_TFO11MyNameSpace6MyEnum3FooU__fMGS0_Q__FQ_GS0_Q__ : $@thin <T> (@out MyEnum<T>, @in T, @thin MyEnum<T>.Type) -> () { | |
bb0(%0 : $*MyEnum<T>, %1 : $*T, %2 : $@thin MyEnum<T>.Type): | |
%3 = init_enum_data_addr %0 : $*MyEnum<T>, #MyEnum.Foo!enumelt.1 // user: %4 | |
copy_addr [take] %1 to [initialization] %3 : $*T // id: %4 | |
inject_enum_addr %0 : $*MyEnum<T>, #MyEnum.Foo!enumelt.1 // id: %5 | |
%6 = tuple () // user: %7 | |
return %6 : $() // id: %7 | |
} | |
// MyNameSpace.MyClass.init (MyNameSpace.MyClass.Type)(string : Swift.String, int : Swift.Int, e : MyNameSpace.MyEnum<Swift.String>) -> MyNameSpace.MyClass | |
sil @_TFC11MyNameSpace7MyClasscfMS0_FT6stringSS3intSi1eGOS_6MyEnumSS__S0_ : $@cc(method) @thin (@owned String, Int, @owned MyEnum<String>, @owned MyClass) -> @owned MyClass { | |
bb0(%0 : $String, %1 : $Int, %2 : $MyEnum<String>, %3 : $MyClass): | |
debug_value %0 : $String // let string // id: %4 | |
debug_value %1 : $Int // let int // id: %5 | |
debug_value %2 : $MyEnum<String> // let e // id: %6 | |
debug_value %3 : $MyClass // let self // id: %7 | |
%8 = mark_uninitialized [rootself] %3 : $MyClass // users: %10, %12, %15, %19 | |
retain_value %0 : $String // id: %9 | |
%10 = ref_element_addr %8 : $MyClass, #MyClass.string // user: %11 | |
assign %0 to %10 : $*String // id: %11 | |
%12 = ref_element_addr %8 : $MyClass, #MyClass.int // user: %13 | |
assign %1 to %12 : $*Int // id: %13 | |
retain_value %2 : $MyEnum<String> // id: %14 | |
%15 = ref_element_addr %8 : $MyClass, #MyClass.e // user: %16 | |
assign %2 to %15 : $*MyEnum<String> // id: %16 | |
release_value %2 : $MyEnum<String> // id: %17 | |
release_value %0 : $String // id: %18 | |
return %8 : $MyClass // id: %19 | |
} | |
// MyNameSpace.MyClass.__allocating_init (MyNameSpace.MyClass.Type)(string : Swift.String, int : Swift.Int, e : MyNameSpace.MyEnum<Swift.String>) -> MyNameSpace.MyClass | |
sil @_TFC11MyNameSpace7MyClassCfMS0_FT6stringSS3intSi1eGOS_6MyEnumSS__S0_ : $@thin (@owned String, Int, @owned MyEnum<String>, @thick MyClass.Type) -> @owned MyClass { | |
bb0(%0 : $String, %1 : $Int, %2 : $MyEnum<String>, %3 : $@thick MyClass.Type): | |
%4 = alloc_ref $MyClass // user: %6 | |
// function_ref MyNameSpace.MyClass.init (MyNameSpace.MyClass.Type)(string : Swift.String, int : Swift.Int, e : MyNameSpace.MyEnum<Swift.String>) -> MyNameSpace.MyClass | |
%5 = function_ref @_TFC11MyNameSpace7MyClasscfMS0_FT6stringSS3intSi1eGOS_6MyEnumSS__S0_ : $@cc(method) @thin (@owned String, Int, @owned MyEnum<String>, @owned MyClass) -> @owned MyClass // user: %6 | |
%6 = apply %5(%0, %1, %2, %4) : $@cc(method) @thin (@owned String, Int, @owned MyEnum<String>, @owned MyClass) -> @owned MyClass // user: %7 | |
return %6 : $MyClass // id: %7 | |
} | |
// MyNameSpace.MyClass.returnObject (MyNameSpace.MyClass)() -> Swift.String | |
sil @_TFC11MyNameSpace7MyClass12returnObjectfS0_FT_SS : $@cc(method) @thin (@owned MyClass) -> @owned String { | |
bb0(%0 : $MyClass): | |
debug_value %0 : $MyClass // let self // id: %1 | |
strong_retain %0 : $MyClass // id: %2 | |
%3 = class_method %0 : $MyClass, #MyClass.string!getter.1 : MyClass -> () -> String , $@cc(method) @thin (@owned MyClass) -> @owned String // user: %4 | |
%4 = apply %3(%0) : $@cc(method) @thin (@owned MyClass) -> @owned String // user: %6 | |
strong_release %0 : $MyClass // id: %5 | |
return %4 : $String // id: %6 | |
} | |
// MyNameSpace.MyClass.deinit | |
sil @_TFC11MyNameSpace7MyClassd : $@cc(method) @thin (@owned MyClass) -> @owned Builtin.NativeObject { | |
bb0(%0 : $MyClass): | |
debug_value %0 : $MyClass // let self // id: %1 | |
%2 = unchecked_ref_cast %0 : $MyClass to $Builtin.NativeObject // user: %7 | |
%3 = ref_element_addr %0 : $MyClass, #MyClass.string // user: %4 | |
destroy_addr %3 : $*String // id: %4 | |
%5 = ref_element_addr %0 : $MyClass, #MyClass.e // user: %6 | |
destroy_addr %5 : $*MyEnum<String> // id: %6 | |
return %2 : $Builtin.NativeObject // id: %7 | |
} | |
// MyNameSpace.MyClass.__deallocating_deinit | |
sil @_TFC11MyNameSpace7MyClassD : $@cc(method) @thin (@owned MyClass) -> () { | |
bb0(%0 : $MyClass): | |
debug_value %0 : $MyClass // let self // id: %1 | |
// function_ref MyNameSpace.MyClass.deinit | |
%2 = function_ref @_TFC11MyNameSpace7MyClassd : $@cc(method) @thin (@owned MyClass) -> @owned Builtin.NativeObject // user: %3 | |
%3 = apply %2(%0) : $@cc(method) @thin (@owned MyClass) -> @owned Builtin.NativeObject // user: %4 | |
%4 = unchecked_ref_cast %3 : $Builtin.NativeObject to $MyClass // user: %5 | |
dealloc_ref %4 : $MyClass // id: %5 | |
%6 = tuple () // user: %7 | |
return %6 : $() // id: %7 | |
} | |
// MyNameSpace.MyClass.string.getter : Swift.String | |
sil [transparent] @_TFC11MyNameSpace7MyClassg6stringSS : $@cc(method) @thin (@owned MyClass) -> @owned String { | |
bb0(%0 : $MyClass): | |
debug_value %0 : $MyClass // let self // id: %1 | |
%2 = ref_element_addr %0 : $MyClass, #MyClass.string // user: %3 | |
%3 = load %2 : $*String // users: %4, %6 | |
retain_value %3 : $String // id: %4 | |
strong_release %0 : $MyClass // id: %5 | |
return %3 : $String // id: %6 | |
} | |
// MyNameSpace.MyClass.int.getter : Swift.Int | |
sil [transparent] @_TFC11MyNameSpace7MyClassg3intSi : $@cc(method) @thin (@owned MyClass) -> Int { | |
bb0(%0 : $MyClass): | |
debug_value %0 : $MyClass // let self // id: %1 | |
%2 = ref_element_addr %0 : $MyClass, #MyClass.int // user: %3 | |
%3 = load %2 : $*Int // user: %5 | |
strong_release %0 : $MyClass // id: %4 | |
return %3 : $Int // id: %5 | |
} | |
// MyNameSpace.MyClass.e.getter : MyNameSpace.MyEnum<Swift.String> | |
sil [transparent] @_TFC11MyNameSpace7MyClassg1eGOS_6MyEnumSS_ : $@cc(method) @thin (@owned MyClass) -> @owned MyEnum<String> { | |
bb0(%0 : $MyClass): | |
debug_value %0 : $MyClass // let self // id: %1 | |
%2 = ref_element_addr %0 : $MyClass, #MyClass.e // user: %3 | |
%3 = load %2 : $*MyEnum<String> // users: %4, %6 | |
retain_value %3 : $MyEnum<String> // id: %4 | |
strong_release %0 : $MyClass // id: %5 | |
return %3 : $MyEnum<String> // id: %6 | |
} | |
// protocol witness for MyNameSpace.MyProtocol.returnObject <A : MyNameSpace.MyProtocol>(@inout MyNameSpace.MyProtocol.Self)() -> MyNameSpace.MyProtocol.Self.B in conformance MyNameSpace.MyClass : MyNameSpace.MyProtocol | |
sil @_TTWC11MyNameSpace7MyClassS_10MyProtocolFS1_12returnObjectUS1__U__fRQPS1_FT_QS2_1B : $@cc(witness_method) @thin (@out String, @inout MyClass) -> () { | |
bb0(%0 : $*String, %1 : $*MyClass): | |
%2 = load %1 : $*MyClass // users: %3, %4, %5 | |
strong_retain %2 : $MyClass // id: %3 | |
%4 = class_method %2 : $MyClass, #MyClass.returnObject!1 : MyClass -> () -> B , $@cc(method) @thin (@owned MyClass) -> @owned String // user: %5 | |
%5 = apply %4(%2) : $@cc(method) @thin (@owned MyClass) -> @owned String // user: %6 | |
store %5 to %0 : $*String // id: %6 | |
%7 = tuple () // user: %8 | |
return %7 : $() // id: %8 | |
} | |
sil_vtable MyClass { | |
#MyClass.init!initializer.1: _TFC11MyNameSpace7MyClasscfMS0_FT6stringSS3intSi1eGOS_6MyEnumSS__S0_ // MyNameSpace.MyClass.init (MyNameSpace.MyClass.Type)(string : Swift.String, int : Swift.Int, e : MyNameSpace.MyEnum<Swift.String>) -> MyNameSpace.MyClass | |
#MyClass.returnObject!1: _TFC11MyNameSpace7MyClass12returnObjectfS0_FT_SS // MyNameSpace.MyClass.returnObject (MyNameSpace.MyClass)() -> Swift.String | |
#MyClass.string!getter.1: _TFC11MyNameSpace7MyClassg6stringSS // MyNameSpace.MyClass.string.getter : Swift.String | |
#MyClass.int!getter.1: _TFC11MyNameSpace7MyClassg3intSi // MyNameSpace.MyClass.int.getter : Swift.Int | |
#MyClass.e!getter.1: _TFC11MyNameSpace7MyClassg1eGOS_6MyEnumSS_ // MyNameSpace.MyClass.e.getter : MyNameSpace.MyEnum<Swift.String> | |
} | |
sil_witness_table MyClass: MyProtocol module MyNameSpace { | |
associated_type B: String | |
method #MyProtocol.returnObject!1: @_TTWC11MyNameSpace7MyClassS_10MyProtocolFS1_12returnObjectUS1__U__fRQPS1_FT_QS2_1B // protocol witness for MyNameSpace.MyProtocol.returnObject <A : MyNameSpace.MyProtocol>(@inout MyNameSpace.MyProtocol.Self)() -> MyNameSpace.MyProtocol.Self.B in conformance MyNameSpace.MyClass : MyNameSpace.MyProtocol | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment