Skip to content

Commit 2e16045

Browse files
committed
Merge pull request #716 from ezephir/sil-docs-misc-updates
[SIL] Miscellaneous documentation fixes & updates
2 parents 0cd2cbb + c20f6a5 commit 2e16045

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

docs/SIL.rst

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ Some additional meaningful categories of type:
604604

605605
- A *heap object reference* type is a type whose representation consists of a
606606
single strong-reference-counted pointer. This includes all class types,
607-
the ``Builtin.ObjectPointer`` and ``Builtin.ObjCPointer`` types, and
607+
the ``Builtin.NativeObject`` and ``Builtin.UnknownObject`` types, and
608608
archetypes that conform to one or more class protocols.
609609
- A *reference type* is more general in that its low-level representation may
610610
include additional global pointers alongside a strong-reference-counted
@@ -2561,13 +2561,13 @@ dynamic_method
25612561
// or protocol type
25622562
//
25632563
// The "self" argument of the method type $@convention(thin) U -> V must be
2564-
// Builtin.ObjCPointer
2564+
// Builtin.UnknownObject
25652565

25662566
Looks up the implementation of an Objective-C method with the same
25672567
selector as the named method for the dynamic type of the
25682568
value inside an existential container. The "self" operand of the result
25692569
function value is represented using an opaque type, the value for which must
2570-
be projected out as a value of type ``Builtin.ObjCPointer``.
2570+
be projected out as a value of type ``Builtin.UnknownObject``.
25712571

25722572
It is undefined behavior if the dynamic type of the operand does not
25732573
have an implementation for the Objective-C method with the selector to
@@ -2740,7 +2740,7 @@ lowers to an uncurried entry point and is curried in the enclosing function::
27402740
// Create the bar closure
27412741
%bar_uncurried = function_ref @bar : $(Int, Int) -> Int
27422742
%bar = partial_apply %bar_uncurried(%x_box#0, %x_box#1) \
2743-
: $(Int, Builtin.ObjectPointer, *Int) -> Int
2743+
: $(Int, Builtin.NativeObject, *Int) -> Int
27442744

27452745
// Apply it
27462746
%1 = integer_literal $Int, 1
@@ -2778,8 +2778,8 @@ metatype
27782778

27792779
sil-instruction ::= 'metatype' sil-type
27802780

2781-
%1 = metatype $T.metatype
2782-
// %1 has type $T.metatype
2781+
%1 = metatype $T.Type
2782+
// %1 has type $T.Type
27832783

27842784
Creates a reference to the metatype object for type ``T``.
27852785

@@ -2789,9 +2789,9 @@ value_metatype
27892789

27902790
sil-instruction ::= 'value_metatype' sil-type ',' sil-operand
27912791

2792-
%1 = value_metatype $T.metatype, %0 : $T
2792+
%1 = value_metatype $T.Type, %0 : $T
27932793
// %0 must be a value or address of type $T
2794-
// %1 will be of type $T.metatype
2794+
// %1 will be of type $T.Type
27952795

27962796
Obtains a reference to the dynamic metatype of the value ``%0``.
27972797

@@ -2801,10 +2801,10 @@ existential_metatype
28012801

28022802
sil-instruction ::= 'existential_metatype' sil-type ',' sil-operand
28032803

2804-
%1 = existential_metatype $P.metatype, %0 : $P
2804+
%1 = existential_metatype $P.Type, %0 : $P
28052805
// %0 must be a value of class protocol or protocol composition
28062806
// type $P, or an address of address-only protocol type $*P
2807-
// %1 will be a $P.metatype value referencing the metatype of the
2807+
// %1 will be a $P.Type value referencing the metatype of the
28082808
// concrete value inside %0
28092809

28102810
Obtains the metatype of the concrete value
@@ -3004,16 +3004,16 @@ the enum is injected with an `inject_enum_addr`_ instruction::
30043004
sil @init_with_data : $(AddressOnlyType) -> AddressOnlyEnum {
30053005
entry(%0 : $*AddressOnlyEnum, %1 : $*AddressOnlyType):
30063006
// Store the data argument for the case.
3007-
%2 = init_enum_data_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.HasData
3007+
%2 = init_enum_data_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.HasData!enumelt.1
30083008
copy_addr [take] %2 to [initialization] %1 : $*AddressOnlyType
30093009
// Inject the tag.
3010-
inject_enum_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.HasData
3010+
inject_enum_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.HasData!enumelt.1
30113011
return
30123012
}
30133013

30143014
sil @init_without_data : $() -> AddressOnlyEnum {
30153015
// No data. We only need to inject the tag.
3016-
inject_enum_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.NoData
3016+
inject_enum_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.NoData!enumelt
30173017
return
30183018
}
30193019

@@ -3024,7 +3024,7 @@ discriminator and is done with the `switch_enum`_ terminator::
30243024

30253025
sil @switch_foo : $(Foo) -> () {
30263026
entry(%foo : $Foo):
3027-
switch_enum %foo : $Foo, case #Foo.A: a_dest, case #Foo.B: b_dest
3027+
switch_enum %foo : $Foo, case #Foo.A!enumelt.1: a_dest, case #Foo.B!enumelt.1: b_dest
30283028
30293029
a_dest(%a : $Int):
30303030
/* use %a */
@@ -3041,14 +3041,15 @@ projecting the enum value with `unchecked_take_enum_data_addr`_::
30413041

30423042
sil @switch_foo : $<T> (Foo<T>) -> () {
30433043
entry(%foo : $*Foo<T>):
3044-
switch_enum_addr %foo : $*Foo<T>, case #Foo.A: a_dest, case #Foo.B: b_dest
3044+
switch_enum_addr %foo : $*Foo<T>, case #Foo.A!enumelt.1: a_dest, \
3045+
case #Foo.B!enumelt.1: b_dest
30453046
30463047
a_dest:
3047-
%a = unchecked_take_enum_data_addr %foo : $*Foo<T>, #Foo.A
3048+
%a = unchecked_take_enum_data_addr %foo : $*Foo<T>, #Foo.A!enumelt.1
30483049
/* use %a */
30493050
30503051
b_dest:
3051-
%b = unchecked_take_enum_data_addr %foo : $*Foo<T>, #Foo.B
3052+
%b = unchecked_take_enum_data_addr %foo : $*Foo<T>, #Foo.B!enumelt.1
30523053
/* use %b */
30533054
}
30543055

@@ -3058,8 +3059,8 @@ enum
30583059

30593060
sil-instruction ::= 'enum' sil-type ',' sil-decl-ref (',' sil-operand)?
30603061

3061-
%1 = enum $U, #U.EmptyCase
3062-
%1 = enum $U, #U.DataCase, %0 : $T
3062+
%1 = enum $U, #U.EmptyCase!enumelt
3063+
%1 = enum $U, #U.DataCase!enumelt.1, %0 : $T
30633064
// $U must be an enum type
30643065
// #U.DataCase or #U.EmptyCase must be a case of enum $U
30653066
// If #U.Case has a data type $T, %0 must be a value of type $T
@@ -3075,7 +3076,7 @@ unchecked_enum_data
30753076

30763077
sil-instruction ::= 'unchecked_enum_data' sil-operand ',' sil-decl-ref
30773078

3078-
%1 = unchecked_enum_data %0 : $U, #U.DataCase
3079+
%1 = unchecked_enum_data %0 : $U, #U.DataCase!enumelt.1
30793080
// $U must be an enum type
30803081
// #U.DataCase must be a case of enum $U with data
30813082
// %1 will be of object type $T for the data type of case U.DataCase
@@ -3090,7 +3091,7 @@ init_enum_data_addr
30903091

30913092
sil-instruction ::= 'init_enum_data_addr' sil-operand ',' sil-decl-ref
30923093

3093-
%1 = init_enum_data_addr %0 : $*U, #U.DataCase
3094+
%1 = init_enum_data_addr %0 : $*U, #U.DataCase!enumelt.1
30943095
// $U must be an enum type
30953096
// #U.DataCase must be a case of enum $U with data
30963097
// %1 will be of address type $*T for the data type of case U.DataCase
@@ -3112,7 +3113,7 @@ inject_enum_addr
31123113

31133114
sil-instruction ::= 'inject_enum_addr' sil-operand ',' sil-decl-ref
31143115

3115-
inject_enum_addr %0 : $*U, #U.Case
3116+
inject_enum_addr %0 : $*U, #U.Case!enumelt
31163117
// $U must be an enum type
31173118
// #U.Case must be a case of enum $U
31183119
// %0 will be overlaid with the tag for #U.Case
@@ -3132,7 +3133,7 @@ unchecked_take_enum_data_addr
31323133

31333134
sil-instruction ::= 'unchecked_take_enum_data_addr' sil-operand ',' sil-decl-ref
31343135

3135-
%1 = unchecked_take_enum_data_addr %0 : $*U, #U.DataCase
3136+
%1 = unchecked_take_enum_data_addr %0 : $*U, #U.DataCase!enumelt.1
31363137
// $U must be an enum type
31373138
// #U.DataCase must be a case of enum $U with data
31383139
// %1 will be of address type $*T for the data type of case U.DataCase
@@ -3159,8 +3160,8 @@ select_enum
31593160
':' sil-type
31603161

31613162
%n = select_enum %0 : $U, \
3162-
case #U.Case1: %1, \
3163-
case #U.Case2: %2, /* ... */ \
3163+
case #U.Case1!enumelt: %1, \
3164+
case #U.Case2!enumelt: %2, /* ... */ \
31643165
default %3 : $T
31653166

31663167
// $U must be an enum type
@@ -3173,8 +3174,8 @@ enum value. This is equivalent to a trivial `switch_enum`_ branch sequence::
31733174

31743175
entry:
31753176
switch_enum %0 : $U, \
3176-
case #U.Case1: bb1, \
3177-
case #U.Case2: bb2, /* ... */ \
3177+
case #U.Case1!enumelt: bb1, \
3178+
case #U.Case2!enumelt: bb2, /* ... */ \
31783179
default bb_default
31793180
bb1:
31803181
br cont(%1 : $T) // value for #U.Case1
@@ -3198,8 +3199,8 @@ select_enum_addr
31983199
':' sil-type
31993200

32003201
%n = select_enum_addr %0 : $*U, \
3201-
case #U.Case1: %1, \
3202-
case #U.Case2: %2, /* ... */ \
3202+
case #U.Case1!enumelt: %1, \
3203+
case #U.Case2!enumelt: %2, /* ... */ \
32033204
default %3 : $T
32043205

32053206
// %0 must be the address of an enum type $*U
@@ -3629,7 +3630,7 @@ ref_to_raw_pointer
36293630
sil-instruction ::= 'ref_to_raw_pointer' sil-operand 'to' sil-type
36303631

36313632
%1 = ref_to_raw_pointer %0 : $C to $Builtin.RawPointer
3632-
// $C must be a class type, or Builtin.ObjectPointer, or Builtin.ObjCPointer
3633+
// $C must be a class type, or Builtin.NativeObject, or Builtin.UnknownObject
36333634
// %1 will be of type $Builtin.RawPointer
36343635

36353636
Converts a heap object reference to a ``Builtin.RawPointer``. The ``RawPointer``
@@ -3644,7 +3645,7 @@ raw_pointer_to_ref
36443645
sil-instruction ::= 'raw_pointer_to_ref' sil-operand 'to' sil-type
36453646

36463647
%1 = raw_pointer_to_ref %0 : $Builtin.RawPointer to $C
3647-
// $C must be a class type, or Builtin.ObjectPointer, or Builtin.ObjCPointer
3648+
// $C must be a class type, or Builtin.NativeObject, or Builtin.UnknownObject
36483649
// %1 will be of type $C
36493650

36503651
Converts a ``Builtin.RawPointer`` back to a heap object reference. Casting
@@ -3811,10 +3812,10 @@ thick_to_objc_metatype
38113812

38123813
sil-instruction ::= 'thick_to_objc_metatype' sil-operand 'to' sil-type
38133814

3814-
%1 = thick_to_objc_metatype %0 : $@thick T.metatype to $@objc_metatype T.metatype
3815-
// %0 must be of a thick metatype type $@thick T.metatype
3815+
%1 = thick_to_objc_metatype %0 : $@thick T.Type to $@objc_metatype T.Type
3816+
// %0 must be of a thick metatype type $@thick T.Type
38163817
// The destination type must be the corresponding Objective-C metatype type
3817-
// %1 will be of type $@objc_metatype T.metatype
3818+
// %1 will be of type $@objc_metatype T.Type
38183819

38193820
Converts a thick metatype to an Objective-C class metatype. ``T`` must
38203821
be of class, class protocol, or class protocol composition type.
@@ -3825,10 +3826,10 @@ objc_to_thick_metatype
38253826

38263827
sil-instruction ::= 'objc_to_thick_metatype' sil-operand 'to' sil-type
38273828

3828-
%1 = objc_to_thick_metatype %0 : $@objc_metatype T.metatype to $@thick T.metatype
3829-
// %0 must be of an Objective-C metatype type $@objc_metatype T.metatype
3829+
%1 = objc_to_thick_metatype %0 : $@objc_metatype T.Type to $@thick T.Type
3830+
// %0 must be of an Objective-C metatype type $@objc_metatype T.Type
38303831
// The destination type must be the corresponding thick metatype type
3831-
// %1 will be of type $@thick T.metatype
3832+
// %1 will be of type $@thick T.Type
38323833

38333834
Converts an Objective-C class metatype to a thick metatype. ``T`` must
38343835
be of class, class protocol, or class protocol composition type.
@@ -4089,8 +4090,8 @@ switch_enum
40894090
(',' sil-switch-default)?
40904091
sil-switch-enum-case ::= 'case' sil-decl-ref ':' sil-identifier
40914092

4092-
switch_enum %0 : $U, case #U.Foo: label1, \
4093-
case #U.Bar: label2, \
4093+
switch_enum %0 : $U, case #U.Foo!enumelt: label1, \
4094+
case #U.Bar!enumelt: label2, \
40944095
..., \
40954096
default labelN
40964097

@@ -4124,9 +4125,9 @@ original enum value. For example::
41244125
sil @sum_of_foo : $Foo -> Int {
41254126
entry(%x : $Foo):
41264127
switch_enum %x : $Foo, \
4127-
case #Foo.Nothing: nothing, \
4128-
case #Foo.OneInt: one_int, \
4129-
case #Foo.TwoInts: two_ints
4128+
case #Foo.Nothing!enumelt: nothing, \
4129+
case #Foo.OneInt!enumelt.1: one_int, \
4130+
case #Foo.TwoInts!enumelt.1: two_ints
41304131

41314132
nothing:
41324133
%zero = integer_literal 0 : $Int
@@ -4165,8 +4166,8 @@ switch_enum_addr
41654166
(',' sil-switch-enum-case)*
41664167
(',' sil-switch-default)?
41674168

4168-
switch_enum_addr %0 : $*U, case #U.Foo: label1, \
4169-
case #U.Bar: label2, \
4169+
switch_enum_addr %0 : $*U, case #U.Foo!enumelt: label1, \
4170+
case #U.Bar!enumelt: label2, \
41704171
..., \
41714172
default labelN
41724173

0 commit comments

Comments
 (0)