File: property_descriptor.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (152 lines) | stat: -rw-r--r-- 8,551 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// RUN: %empty-directory(%t)
// RUN: %{python} %utils/chex.py < %s > %t/property_descriptor.sil
// RUN: %target-swift-frontend -emit-ir %t/property_descriptor.sil | %FileCheck --check-prefix=CHECK-%target-ptrsize --check-prefix=CHECK %t/property_descriptor.sil

sil_stage canonical

import Swift

public struct ExternalGeneric<T: Comparable> {
  @_hasStorage public var ro: T { get }
  @_hasStorage public var rw: T { get set }

  public var computedRO: T { get }
  public var computedRW: T { get set }

  public subscript<U: Hashable>(_: U) -> T { get set }

  public var computedWithTrivialDescriptor: Int { get }

  init()
}

public struct External {
  @_hasStorage public var ro: Int { get }
  @_hasStorage public var rw: Int { get set }

  public var computedRO: Int { get }
  public var computedRW: Int { get set }

  public subscript(_: String) -> Int { get set }

  public var computedWithTrivialDescriptor: Int { get }

  init()
}

public struct ExternalReabstractions<T> {
  @_hasStorage public var ro: T { get }
  @_hasStorage public var reabstracted: () -> () { get set }
}

// -- struct property, offset resolved from field offset vector in metadata
// CHECK-64: @"$s19property_descriptor15ExternalGenericV2roxvpMV" =
// CHECK-32: @"$s19property_descriptor15ExternalGenericV2roxvpMV" =
// CHECK-SAME: <{ <i32 0x01ff_fffe>,
sil_property #ExternalGeneric.ro <T: Comparable> (
  stored_property #ExternalGeneric.ro : $T)
// CHECK-64: @"$s19property_descriptor15ExternalGenericV2rwxvpMV" =
// CHECK-32: @"$s19property_descriptor15ExternalGenericV2rwxvpMV" =
// CHECK-SAME: <{ <i32 0x01ff_fffe>,
sil_property #ExternalGeneric.rw <T: Comparable> (
  stored_property #ExternalGeneric.rw : $T)

// CHECK: @"$s19property_descriptor15ExternalGenericV10computedROxvpMV" =
// -- 0x0108_0000 - computed, readonly, has arguments, identified by indirect
// CHECK-SAME:  <{ <i32 0x0208_0002>,
// CHECK-SAME:     @{{got.|"\\01__imp__?}}id_computed
// CHECK-SAME:     [[GET_COMPUTEDRO:@keypath_get[.0-9]*]]{{(\.ptrauth)?}}
// CHECK-SAME:     [[GET_ARG_LAYOUT_COMPUTEDRO:@keypath_get_arg_layout[.0-9]*]]{{(\.ptrauth)?}}
// -- default witness table
// CHECK-SAME:     i32 0
// CHECK-SAME:     [[ARG_INIT_COMPUTEDRO:@keypath_arg_init[.0-9]*]]{{(\.ptrauth.*)?}}
sil_property #ExternalGeneric.computedRO <T: Comparable> (
  gettable_property $T,
    id @id_computed : $@convention(thin) () -> (),
    getter @get_computed_generic : $@convention(keypath_accessor_getter) <T: Comparable> (@in_guaranteed ExternalGeneric<T>) -> @out T)

// CHECK: @"$s19property_descriptor15ExternalGenericV10computedRWxvpMV" =
// -- 0x01c8_0000 - computed, settable, mutating, has arguments, indirect id
// CHECK-SAME:  <{ <i32 0x02c8_0002>, 
// CHECK-SAME:     @{{got.|"\\01__imp__?}}id_computed
// CHECK-SAME:     [[GET_COMPUTEDRW:@keypath_get[.0-9]*]]{{(\.ptrauth)?}}
// CHECK-SAME:     [[SET_COMPUTEDRW:@keypath_set[.0-9]*]]{{(\.ptrauth)?}}
// CHECK-SAME:     [[GET_ARG_LAYOUT_COMPUTEDRW:@keypath_get_arg_layout[.0-9]*]]{{(\.ptrauth)?}}
// CHECK-SAME:     i32 0
// CHECK-SAME:     [[ARG_INIT_COMPUTEDRW:@keypath_arg_init[.0-9]*]]{{(\.ptrauth.*)?}}
sil_property #ExternalGeneric.computedRW <T: Comparable> (
  settable_property $T,
    id @id_computed : $@convention(thin) () -> (),
    getter @get_computed_generic : $@convention(keypath_accessor_getter) <T: Comparable> (@in_guaranteed ExternalGeneric<T>) -> @out T,
    setter @set_computed_generic : $@convention(keypath_accessor_setter) <T: Comparable> (@in_guaranteed T, @inout ExternalGeneric<T>) -> ())

// CHECK: @"$s19property_descriptor15ExternalGenericVyxqd__cSHRd__luipMV" =
// -- 0x01c8_0000 - computed, settable, mutating, has arguments, indirect id
// CHECK-SAME:  <{ <i32 0x02c8_0002>, 
// CHECK-SAME:     @{{got.|"\\01__imp__?}}id_computed
// CHECK-SAME:     [[GET_SUBSCRIPT:@keypath_get[.0-9]*]]{{(\.ptrauth)?}}
// CHECK-SAME:     [[SET_SUBSCRIPT:@keypath_set[.0-9]*]]{{(\.ptrauth)?}}
// CHECK-SAME:     [[GET_ARG_LAYOUT_SUBSCRIPT:@keypath_get_arg_layout[.0-9]*]]{{(\.ptrauth)?}}
// CHECK-SAME:     i32 0
// CHECK-SAME:     [[ARG_INIT_SUBSCRIPT:@keypath_arg_init[.0-9]*]]{{(\.ptrauth.*)?}}
sil_property #ExternalGeneric.subscript <T: Comparable><U: Hashable> (
  settable_property $T,
    id @id_computed : $@convention(thin) () -> (),
    getter @get_computed_generic_subscript : $@convention(keypath_accessor_getter) <T: Comparable><U: Hashable> (@in_guaranteed ExternalGeneric<T>, @in_guaranteed U) -> @out T,
    setter @set_computed_generic_subscript : $@convention(keypath_accessor_setter) <T: Comparable><U: Hashable> (@in_guaranteed T, @inout ExternalGeneric<T>, @in_guaranteed U) -> ())

// CHECK: @"$s19property_descriptor8ExternalV2roSivpMV" =
// CHECK-64: @"$s19property_descriptor8ExternalV2rwSivpMV" =
// CHECK-32: @"$s19property_descriptor8ExternalV2rwSivpMV" =
sil_property #External.ro (stored_property #External.ro : $Int)
sil_property #External.rw (stored_property #External.rw : $Int)
sil_property #External.computedRO (
  gettable_property $Int,
    id @id_computed : $@convention(thin) () -> (),
    getter @get_computed : $@convention(keypath_accessor_getter) (@in_guaranteed External) -> @out Int)
sil_property #External.computedRW (
  settable_property $Int,
    id @id_computed : $@convention(thin) () -> (),
    getter @get_computed : $@convention(keypath_accessor_getter) (@in_guaranteed External) -> @out Int,
    setter @set_computed : $@convention(keypath_accessor_setter) (@in_guaranteed Int, @inout External) -> ())
sil_property #External.subscript (
  settable_property $Int,
    id @id_computed : $@convention(thin) () -> (),
    getter @get_computed_subscript : $@convention(keypath_accessor_getter) (@in_guaranteed External, @in_guaranteed String) -> @out Int,
    setter @set_computed_subscript : $@convention(keypath_accessor_setter) (@in_guaranteed Int, @inout External, @in_guaranteed String) -> ())

sil_property #ExternalReabstractions.ro <T> (
  stored_property #ExternalReabstractions.ro : $T)

sil_property #ExternalReabstractions.reabstracted <T> (
  settable_property $() -> (),
    id ##ExternalReabstractions.reabstracted,
    getter @get_reabstracted : $@convention(keypath_accessor_getter) <T> (@in_guaranteed ExternalReabstractions<T>) -> @out @callee_guaranteed @substituted <U> () -> @out U for <()>,
    setter @set_reabstracted : $@convention(keypath_accessor_setter) <T> (@in_guaranteed @callee_guaranteed @substituted <U> () -> @out U for <()>, @inout ExternalReabstractions<T>) -> ())

// All trivial descriptors should share a definition by aliasing to the common
// definition

// CHECK-LABEL: @"$s19property_descriptor15ExternalGenericV29computedWithTrivialDescriptorSivpMV" =
// CHECK-SAME:    { i32 } zeroinitializer, align 4
sil_property #ExternalGeneric.computedWithTrivialDescriptor <T: Comparable> ()

// CHECK-LABEL: @"$s19property_descriptor8ExternalV29computedWithTrivialDescriptorSivpMV" =
// CHECK-SAME:    alias {{.*}} @"$s19property_descriptor15ExternalGenericV29computedWithTrivialDescriptorSivpMV"
sil_property #External.computedWithTrivialDescriptor ()

sil @id_computed : $@convention(thin) () -> ()
sil @get_computed : $@convention(keypath_accessor_getter) (@in_guaranteed External) -> @out Int
sil @set_computed : $@convention(keypath_accessor_setter) (@in_guaranteed Int, @inout External) -> ()

sil @get_computed_subscript : $@convention(keypath_accessor_getter) (@in_guaranteed External, @in_guaranteed String) -> @out Int
sil @set_computed_subscript : $@convention(keypath_accessor_setter) (@in_guaranteed Int, @inout External, @in_guaranteed String) -> ()

sil @get_computed_generic : $@convention(keypath_accessor_getter) <T: Comparable> (@in_guaranteed ExternalGeneric<T>) -> @out T
sil @set_computed_generic : $@convention(keypath_accessor_setter) <T: Comparable> (@in_guaranteed T, @inout ExternalGeneric<T>) -> ()

sil @get_computed_generic_subscript : $@convention(keypath_accessor_getter) <T: Comparable><U: Hashable> (@in_guaranteed ExternalGeneric<T>, @in_guaranteed U) -> @out T
sil @set_computed_generic_subscript : $@convention(keypath_accessor_setter) <T: Comparable><U: Hashable> (@in_guaranteed T, @inout ExternalGeneric<T>, @in_guaranteed U) -> ()

sil @get_reabstracted : $@convention(keypath_accessor_getter) <T> (@in_guaranteed ExternalReabstractions<T>) -> @out @callee_guaranteed @substituted <U> () -> @out U for <()>
sil @set_reabstracted : $@convention(keypath_accessor_setter) <T> (@in_guaranteed @callee_guaranteed @substituted <U> () -> @out U for <()>, @inout ExternalReabstractions<T>) -> ()