Skip to content

Instantly share code, notes, and snippets.

@siracusa
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siracusa/6085684045410246c513 to your computer and use it in GitHub Desktop.
Save siracusa/6085684045410246c513 to your computer and use it in GitHub Desktop.
sil_stage canonical
import Builtin
import Swift
import SwiftShims
// SILDemo.identity <A>(A) -> A
sil @_TF7SILDemo8identityU__FQ_Q_ : $@thin <T> (@out T, @in T) -> () {
bb0(%0 : $*T, %1 : $*T):
debug_value_addr %1 : $*T // let x // id: %2
copy_addr [take] %1 to [initialization] %0 : $*T // id: %3
%4 = tuple () // user: %5
return %4 : $() // id: %5
}
// SILDemo.testInt () -> Swift.Int
sil @_TF7SILDemo7testIntFT_Si : $@thin () -> Int {
bb0:
// function_ref SILDemo.identity <A>(A) -> A
%0 = function_ref @_TF7SILDemo8identityU__FQ_Q_ : $@thin <τ_0_0> (@out τ_0_0, @in τ_0_0) -> () // user: %6
%1 = alloc_stack $Int // users: %4, %6, %9
%2 = integer_literal $Builtin.Word, 42 // user: %3
%3 = struct $Int (%2 : $Builtin.Word) // user: %4
store %3 to %1#1 : $*Int // id: %4
%5 = alloc_stack $Int // users: %6, %7, %8
%6 = apply %0<Int>(%5#1, %1#1) : $@thin <τ_0_0> (@out τ_0_0, @in τ_0_0) -> ()
%7 = load %5#1 : $*Int // user: %10
dealloc_stack %5#0 : $*@local_storage Int // id: %8
dealloc_stack %1#0 : $*@local_storage Int // id: %9
return %7 : $Int // id: %10
}
// Swift.Int._convertFromBuiltinIntegerLiteral (Swift.Int.Type)(Builtin.Int2048) -> Swift.Int
sil public_external [transparent] @_TFSi33_convertFromBuiltinIntegerLiteralfMSiFBi2048_Si : $@thin (Builtin.Int2048, @thin Int.Type) -> Int {
bb0(%0 : $Builtin.Int2048, %1 : $@thin Int.Type):
%2 = builtin_function_ref "s_to_s_checked_trunc_Int2048_Word" : $@thin (Builtin.Int2048) -> (Builtin.Word, Builtin.Int1) // user: %3
%3 = apply %2(%0) : $@thin (Builtin.Int2048) -> (Builtin.Word, Builtin.Int1) // user: %4
%4 = tuple_extract %3 : $(Builtin.Word, Builtin.Int1), 0 // user: %5
%5 = struct $Int (%4 : $Builtin.Word) // user: %6
return %5 : $Int // id: %6
}
// SILDemo.testDouble () -> Swift.Double
sil @_TF7SILDemo10testDoubleFT_Sd : $@thin () -> Double {
bb0:
// function_ref SILDemo.identity <A>(A) -> A
%0 = function_ref @_TF7SILDemo8identityU__FQ_Q_ : $@thin <τ_0_0> (@out τ_0_0, @in τ_0_0) -> () // user: %6
%1 = alloc_stack $Double // users: %4, %6, %9
%2 = float_literal $Builtin.FPIEEE64, 0x4045000000000000 // 42 // user: %3
%3 = struct $Double (%2 : $Builtin.FPIEEE64) // user: %4
store %3 to %1#1 : $*Double // id: %4
%5 = alloc_stack $Double // users: %6, %7, %8
%6 = apply %0<Double>(%5#1, %1#1) : $@thin <τ_0_0> (@out τ_0_0, @in τ_0_0) -> ()
%7 = load %5#1 : $*Double // user: %10
dealloc_stack %5#0 : $*@local_storage Double // id: %8
dealloc_stack %1#0 : $*@local_storage Double // id: %9
return %7 : $Double // id: %10
}
// Swift.Double._convertFromBuiltinFloatLiteral (Swift.Double.Type)(Builtin.Float64) -> Swift.Double
sil public_external [transparent] @_TFSd31_convertFromBuiltinFloatLiteralfMSdFBf64_Sd : $@thin (Builtin.FPIEEE64, @thin Double.Type) -> Double {
bb0(%0 : $Builtin.FPIEEE64, %1 : $@thin Double.Type):
%2 = struct $Double (%0 : $Builtin.FPIEEE64) // user: %3
return %2 : $Double // id: %3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment