Skip to content

Instantly share code, notes, and snippets.

@tanabe1478
Last active November 21, 2019 04:35
Show Gist options
  • Select an option

  • Save tanabe1478/cd82a2abc48faf4c345afdcad8b899cd to your computer and use it in GitHub Desktop.

Select an option

Save tanabe1478/cd82a2abc48faf4c345afdcad8b899cd to your computer and use it in GitHub Desktop.
sil_stage canonical
import Builtin
import Swift
import SwiftShims
import Foundation
struct UserDefinedString {
@_hasStorage var value: String { get set }
init(value: String)
}
extension UserDefinedString : ExpressibleByStringLiteral {
init(stringLiteral value: String)
typealias StringLiteralType = String
typealias ExtendedGraphemeClusterLiteralType = String
typealias UnicodeScalarLiteralType = String
}
@_hasStorage @_hasInitialValue let userDefinedString: UserDefinedString { get }
// globalinit_33_EE3F0113CE9469DE1DA818E2E4164E99_token0
sil_global private @globalinit_33_EE3F0113CE9469DE1DA818E2E4164E99_token0 : $Builtin.Word
// userDefinedString
sil_global hidden [let] @$s11userdefined17userDefinedStringAA04UsercD0Vvp : $UserDefinedString
// UserDefinedString.value.getter
sil hidden [transparent] @$s11userdefined17UserDefinedStringV5valueSSvg : $@convention(method) (@guaranteed UserDefinedString) -> @owned String {
// %0 // users: %2, %1
bb0(%0 : $UserDefinedString):
debug_value %0 : $UserDefinedString, let, name "self", argno 1 // id: %1
%2 = struct_extract %0 : $UserDefinedString, #UserDefinedString.value // users: %4, %3
retain_value %2 : $String // id: %3
return %2 : $String // id: %4
} // end sil function '$s11userdefined17UserDefinedStringV5valueSSvg'
// UserDefinedString.value.setter
sil hidden [transparent] @$s11userdefined17UserDefinedStringV5valueSSvs : $@convention(method) (@owned String, @inout UserDefinedString) -> () {
// %0 // users: %11, %8, %4, %2
// %1 // users: %5, %3
bb0(%0 : $String, %1 : $*UserDefinedString):
debug_value %0 : $String, let, name "value", argno 1 // id: %2
debug_value_addr %1 : $*UserDefinedString, var, name "self", argno 2 // id: %3
retain_value %0 : $String // id: %4
%5 = begin_access [modify] [static] %1 : $*UserDefinedString // users: %10, %6
%6 = struct_element_addr %5 : $*UserDefinedString, #UserDefinedString.value // users: %8, %7
%7 = load %6 : $*String // user: %9
store %0 to %6 : $*String // id: %8
release_value %7 : $String // id: %9
end_access %5 : $*UserDefinedString // id: %10
release_value %0 : $String // id: %11
%12 = tuple () // user: %13
return %12 : $() // id: %13
} // end sil function '$s11userdefined17UserDefinedStringV5valueSSvs'
// UserDefinedString.value.modify
sil hidden [transparent] @$s11userdefined17UserDefinedStringV5valueSSvM : $@yield_once @convention(method) (@inout UserDefinedString) -> @yields @inout String {
// %0 // users: %2, %1
bb0(%0 : $*UserDefinedString):
debug_value_addr %0 : $*UserDefinedString, var, name "self", argno 1 // id: %1
%2 = begin_access [modify] [static] %0 : $*UserDefinedString // users: %5, %8, %3
%3 = struct_element_addr %2 : $*UserDefinedString, #UserDefinedString.value // user: %4
yield %3 : $*String, resume bb1, unwind bb2 // id: %4
bb1: // Preds: bb0
end_access %2 : $*UserDefinedString // id: %5
%6 = tuple () // user: %7
return %6 : $() // id: %7
bb2: // Preds: bb0
end_access %2 : $*UserDefinedString // id: %8
unwind // id: %9
} // end sil function '$s11userdefined17UserDefinedStringV5valueSSvM'
// UserDefinedString.init(value:)
sil hidden @$s11userdefined17UserDefinedStringV5valueACSS_tcfC : $@convention(method) (@owned String, @thin UserDefinedString.Type) -> @owned UserDefinedString {
// %0 // user: %2
bb0(%0 : $String, %1 : $@thin UserDefinedString.Type):
%2 = struct $UserDefinedString (%0 : $String) // user: %3
return %2 : $UserDefinedString // id: %3
} // end sil function '$s11userdefined17UserDefinedStringV5valueACSS_tcfC'
// UserDefinedString.init(stringLiteral:)
sil hidden @$s11userdefined17UserDefinedStringV13stringLiteralACSS_tcfC : $@convention(method) (@owned String, @thin UserDefinedString.Type) -> @owned UserDefinedString {
// %0 // users: %8, %6, %3
bb0(%0 : $String, %1 : $@thin UserDefinedString.Type):
%2 = alloc_stack $UserDefinedString, var, name "self" // users: %4, %10, %11
debug_value %0 : $String, let, name "value", argno 1 // id: %3
%4 = begin_access [modify] [static] %2 : $*UserDefinedString // users: %7, %5
%5 = struct_element_addr %4 : $*UserDefinedString, #UserDefinedString.value // user: %6
store %0 to %5 : $*String // id: %6
end_access %4 : $*UserDefinedString // id: %7
%8 = struct $UserDefinedString (%0 : $String) // users: %9, %12
retain_value %8 : $UserDefinedString // id: %9
destroy_addr %2 : $*UserDefinedString // id: %10
dealloc_stack %2 : $*UserDefinedString // id: %11
return %8 : $UserDefinedString // id: %12
} // end sil function '$s11userdefined17UserDefinedStringV13stringLiteralACSS_tcfC'
// protocol witness for ExpressibleByStringLiteral.init(stringLiteral:) in conformance UserDefinedString
sil private [transparent] [thunk] @$s11userdefined17UserDefinedStringVs013ExpressibleByD7LiteralAAsADP06stringG0x0dG4TypeQz_tcfCTW : $@convention(witness_method: ExpressibleByStringLiteral) (@in String, @thick UserDefinedString.Type) -> @out UserDefinedString {
// %0 // user: %7
// %1 // user: %3
bb0(%0 : $*UserDefinedString, %1 : $*String, %2 : $@thick UserDefinedString.Type):
%3 = load %1 : $*String // user: %6
%4 = metatype $@thin UserDefinedString.Type // user: %6
// function_ref UserDefinedString.init(stringLiteral:)
%5 = function_ref @$s11userdefined17UserDefinedStringV13stringLiteralACSS_tcfC : $@convention(method) (@owned String, @thin UserDefinedString.Type) -> @owned UserDefinedString // user: %6
%6 = apply %5(%3, %4) : $@convention(method) (@owned String, @thin UserDefinedString.Type) -> @owned UserDefinedString // user: %7
store %6 to %0 : $*UserDefinedString // id: %7
%8 = tuple () // user: %9
return %8 : $() // id: %9
} // end sil function '$s11userdefined17UserDefinedStringVs013ExpressibleByD7LiteralAAsADP06stringG0x0dG4TypeQz_tcfCTW'
// protocol witness for ExpressibleByExtendedGraphemeClusterLiteral.init(extendedGraphemeClusterLiteral:) in conformance UserDefinedString
sil private [transparent] [thunk] @$s11userdefined17UserDefinedStringVs43ExpressibleByExtendedGraphemeClusterLiteralAAsADP08extendedhiJ0x0ghiJ4TypeQz_tcfCTW : $@convention(witness_method: ExpressibleByExtendedGraphemeClusterLiteral) (@in String, @thick UserDefinedString.Type) -> @out UserDefinedString {
// %0 // user: %4
// %1 // user: %4
// %2 // user: %4
bb0(%0 : $*UserDefinedString, %1 : $*String, %2 : $@thick UserDefinedString.Type):
// function_ref ExpressibleByStringLiteral<>.init(extendedGraphemeClusterLiteral:)
%3 = function_ref @$ss26ExpressibleByStringLiteralPs0cD4TypeQz023ExtendedGraphemeClusterdE0RtzrlE08extendedghD0xAF_tcfC : $@convention(method) <τ_0_0 where τ_0_0 : ExpressibleByStringLiteral, τ_0_0.ExtendedGraphemeClusterLiteralType == τ_0_0.StringLiteralType> (@in τ_0_0.ExtendedGraphemeClusterLiteralType, @thick τ_0_0.Type) -> @out τ_0_0 // user: %4
%4 = apply %3<UserDefinedString>(%0, %1, %2) : $@convention(method) <τ_0_0 where τ_0_0 : ExpressibleByStringLiteral, τ_0_0.ExtendedGraphemeClusterLiteralType == τ_0_0.StringLiteralType> (@in τ_0_0.ExtendedGraphemeClusterLiteralType, @thick τ_0_0.Type) -> @out τ_0_0
%5 = tuple () // user: %6
return %5 : $() // id: %6
} // end sil function '$s11userdefined17UserDefinedStringVs43ExpressibleByExtendedGraphemeClusterLiteralAAsADP08extendedhiJ0x0ghiJ4TypeQz_tcfCTW'
// ExpressibleByStringLiteral<>.init(extendedGraphemeClusterLiteral:)
sil [transparent] [serialized] @$ss26ExpressibleByStringLiteralPs0cD4TypeQz023ExtendedGraphemeClusterdE0RtzrlE08extendedghD0xAF_tcfC : $@convention(method) <τ_0_0 where τ_0_0 : ExpressibleByStringLiteral, τ_0_0.ExtendedGraphemeClusterLiteralType == τ_0_0.StringLiteralType> (@in τ_0_0.ExtendedGraphemeClusterLiteralType, @thick τ_0_0.Type) -> @out τ_0_0
// protocol witness for ExpressibleByUnicodeScalarLiteral.init(unicodeScalarLiteral:) in conformance UserDefinedString
sil private [transparent] [thunk] @$s11userdefined17UserDefinedStringVs33ExpressibleByUnicodeScalarLiteralAAsADP07unicodehI0x0ghI4TypeQz_tcfCTW : $@convention(witness_method: ExpressibleByUnicodeScalarLiteral) (@in String, @thick UserDefinedString.Type) -> @out UserDefinedString {
// %0 // user: %4
// %1 // user: %4
// %2 // user: %4
bb0(%0 : $*UserDefinedString, %1 : $*String, %2 : $@thick UserDefinedString.Type):
// function_ref ExpressibleByExtendedGraphemeClusterLiteral<>.init(unicodeScalarLiteral:)
%3 = function_ref @$ss43ExpressibleByExtendedGraphemeClusterLiteralPs013UnicodeScalarF4TypeQz0cdefI0RtzrlE07unicodehF0xAF_tcfC : $@convention(method) <τ_0_0 where τ_0_0 : ExpressibleByExtendedGraphemeClusterLiteral, τ_0_0.ExtendedGraphemeClusterLiteralType == τ_0_0.UnicodeScalarLiteralType> (@in τ_0_0.ExtendedGraphemeClusterLiteralType, @thick τ_0_0.Type) -> @out τ_0_0 // user: %4
%4 = apply %3<UserDefinedString>(%0, %1, %2) : $@convention(method) <τ_0_0 where τ_0_0 : ExpressibleByExtendedGraphemeClusterLiteral, τ_0_0.ExtendedGraphemeClusterLiteralType == τ_0_0.UnicodeScalarLiteralType> (@in τ_0_0.ExtendedGraphemeClusterLiteralType, @thick τ_0_0.Type) -> @out τ_0_0
%5 = tuple () // user: %6
return %5 : $() // id: %6
} // end sil function '$s11userdefined17UserDefinedStringVs33ExpressibleByUnicodeScalarLiteralAAsADP07unicodehI0x0ghI4TypeQz_tcfCTW'
// ExpressibleByExtendedGraphemeClusterLiteral<>.init(unicodeScalarLiteral:)
sil [transparent] [serialized] @$ss43ExpressibleByExtendedGraphemeClusterLiteralPs013UnicodeScalarF4TypeQz0cdefI0RtzrlE07unicodehF0xAF_tcfC : $@convention(method) <τ_0_0 where τ_0_0 : ExpressibleByExtendedGraphemeClusterLiteral, τ_0_0.ExtendedGraphemeClusterLiteralType == τ_0_0.UnicodeScalarLiteralType> (@in τ_0_0.ExtendedGraphemeClusterLiteralType, @thick τ_0_0.Type) -> @out τ_0_0
// globalinit_33_EE3F0113CE9469DE1DA818E2E4164E99_func0
sil private @globalinit_33_EE3F0113CE9469DE1DA818E2E4164E99_func0 : $@convention(c) () -> () {
bb0:
alloc_global @$s11userdefined17userDefinedStringAA04UsercD0Vvp // id: %0
%1 = global_addr @$s11userdefined17userDefinedStringAA04UsercD0Vvp : $*UserDefinedString // user: %11
%2 = string_literal utf8 "user defined" // user: %7
%3 = integer_literal $Builtin.Word, 12 // user: %7
%4 = integer_literal $Builtin.Int1, -1 // user: %7
%5 = metatype $@thin String.Type // user: %7
// function_ref String.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:)
%6 = function_ref @$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String // user: %7
%7 = apply %6(%2, %3, %4, %5) : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String // user: %10
%8 = metatype $@thin UserDefinedString.Type // user: %10
// function_ref UserDefinedString.init(stringLiteral:)
%9 = function_ref @$s11userdefined17UserDefinedStringV13stringLiteralACSS_tcfC : $@convention(method) (@owned String, @thin UserDefinedString.Type) -> @owned UserDefinedString // user: %10
%10 = apply %9(%7, %8) : $@convention(method) (@owned String, @thin UserDefinedString.Type) -> @owned UserDefinedString // user: %11
store %10 to %1 : $*UserDefinedString // id: %11
%12 = tuple () // user: %13
return %12 : $() // id: %13
} // end sil function 'globalinit_33_EE3F0113CE9469DE1DA818E2E4164E99_func0'
// 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
// userDefinedString.unsafeMutableAddressor
sil hidden [global_init] @$s11userdefined17userDefinedStringAA04UsercD0Vvau : $@convention(thin) () -> Builtin.RawPointer {
bb0:
%0 = global_addr @globalinit_33_EE3F0113CE9469DE1DA818E2E4164E99_token0 : $*Builtin.Word // user: %1
%1 = address_to_pointer %0 : $*Builtin.Word to $Builtin.RawPointer // user: %3
// function_ref globalinit_33_EE3F0113CE9469DE1DA818E2E4164E99_func0
%2 = function_ref @globalinit_33_EE3F0113CE9469DE1DA818E2E4164E99_func0 : $@convention(c) () -> () // user: %3
%3 = builtin "once"(%1 : $Builtin.RawPointer, %2 : $@convention(c) () -> ()) : $()
%4 = global_addr @$s11userdefined17userDefinedStringAA04UsercD0Vvp : $*UserDefinedString // user: %5
%5 = address_to_pointer %4 : $*UserDefinedString to $Builtin.RawPointer // user: %6
return %5 : $Builtin.RawPointer // id: %6
} // end sil function '$s11userdefined17userDefinedStringAA04UsercD0Vvau'
sil_witness_table hidden UserDefinedString: ExpressibleByStringLiteral module userdefined {
base_protocol ExpressibleByExtendedGraphemeClusterLiteral: UserDefinedString: ExpressibleByExtendedGraphemeClusterLiteral module userdefined
associated_type_protocol (StringLiteralType: _ExpressibleByBuiltinStringLiteral): String: _ExpressibleByBuiltinStringLiteral module Swift
associated_type StringLiteralType: String
method #ExpressibleByStringLiteral.init!allocator.1: <Self where Self : ExpressibleByStringLiteral> (Self.Type) -> (Self.StringLiteralType) -> Self : @$s11userdefined17UserDefinedStringVs013ExpressibleByD7LiteralAAsADP06stringG0x0dG4TypeQz_tcfCTW // protocol witness for ExpressibleByStringLiteral.init(stringLiteral:) in conformance UserDefinedString
}
sil_witness_table hidden UserDefinedString: ExpressibleByExtendedGraphemeClusterLiteral module userdefined {
base_protocol ExpressibleByUnicodeScalarLiteral: UserDefinedString: ExpressibleByUnicodeScalarLiteral module userdefined
associated_type_protocol (ExtendedGraphemeClusterLiteralType: _ExpressibleByBuiltinExtendedGraphemeClusterLiteral): String: _ExpressibleByBuiltinExtendedGraphemeClusterLiteral module Swift
associated_type ExtendedGraphemeClusterLiteralType: String
method #ExpressibleByExtendedGraphemeClusterLiteral.init!allocator.1: <Self where Self : ExpressibleByExtendedGraphemeClusterLiteral> (Self.Type) -> (Self.ExtendedGraphemeClusterLiteralType) -> Self : @$s11userdefined17UserDefinedStringVs43ExpressibleByExtendedGraphemeClusterLiteralAAsADP08extendedhiJ0x0ghiJ4TypeQz_tcfCTW // protocol witness for ExpressibleByExtendedGraphemeClusterLiteral.init(extendedGraphemeClusterLiteral:) in conformance UserDefinedString
}
sil_witness_table hidden UserDefinedString: ExpressibleByUnicodeScalarLiteral module userdefined {
associated_type_protocol (UnicodeScalarLiteralType: _ExpressibleByBuiltinUnicodeScalarLiteral): String: _ExpressibleByBuiltinUnicodeScalarLiteral module Swift
associated_type UnicodeScalarLiteralType: String
method #ExpressibleByUnicodeScalarLiteral.init!allocator.1: <Self where Self : ExpressibleByUnicodeScalarLiteral> (Self.Type) -> (Self.UnicodeScalarLiteralType) -> Self : @$s11userdefined17UserDefinedStringVs33ExpressibleByUnicodeScalarLiteralAAsADP07unicodehI0x0ghI4TypeQz_tcfCTW // protocol witness for ExpressibleByUnicodeScalarLiteral.init(unicodeScalarLiteral:) in conformance UserDefinedString
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment