Skip to content

Instantly share code, notes, and snippets.

@Azoy
Created January 21, 2019 08:27
Show Gist options
  • Save Azoy/e9f644508454befd21c4b8cb1bfd99f0 to your computer and use it in GitHub Desktop.
Save Azoy/e9f644508454befd21c4b8cb1bfd99f0 to your computer and use it in GitHub Desktop.
Float16(Float(_builtinFloatLiteral: value))
sil_stage canonical
import Builtin
import Swift
import SwiftShims
func x()
// 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'
// x()
sil hidden @$s4main1xyyF : $@convention(thin) () -> () {
bb0:
%0 = alloc_stack $Float16, var, name "x" // users: %3, %4
%1 = float_literal $Builtin.FPIEEE16, 0x3C00 // 1 // user: %2
%2 = struct $Float16 (%1 : $Builtin.FPIEEE16) // user: %3
store %2 to %0 : $*Float16 // id: %3
dealloc_stack %0 : $*Float16 // id: %4
%5 = tuple () // user: %6
return %5 : $() // id: %6
} // end sil function '$s4main1xyyF'
// Float16.init(_builtinFloatLiteral:)
sil public_external [transparent] [serialized] @$ss7Float16V20_builtinFloatLiteralABBf80__tcfC : $@convention(method) (Builtin.FPIEEE80, @thin Float16.Type) -> Float16 {
// %0 // user: %2
bb0(%0 : $Builtin.FPIEEE80, %1 : $@thin Float16.Type):
%2 = builtin "fptrunc_FPIEEE80_FPIEEE32"(%0 : $Builtin.FPIEEE80) : $Builtin.FPIEEE32 // user: %3
%3 = builtin "fptrunc_FPIEEE32_FPIEEE16"(%2 : $Builtin.FPIEEE32) : $Builtin.FPIEEE16 // user: %4
%4 = struct $Float16 (%3 : $Builtin.FPIEEE16) // user: %5
return %4 : $Float16 // id: %5
} // end sil function '$ss7Float16V20_builtinFloatLiteralABBf80__tcfC'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment