Skip to content

Commit 5995990

Browse files
committed
SILOptimizer: Bridge new Pack_Inout, Pack_Owned, Pack_Guaranteed ownership kinds
1 parent fe889fa commit 5995990

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

SwiftCompilerSources/Sources/SIL/Argument.swift

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,26 @@ public enum ArgumentConvention {
122122
/// guarantees its validity for the entirety of the call.
123123
case directGuaranteed
124124

125+
/// This argument is a value pack of mutable references to storage,
126+
/// which the function is being given exclusive access to. The elements
127+
/// must be passed indirectly.
128+
case packInout
129+
130+
/// This argument is a value pack, and ownership of the elements is being
131+
/// transferred into this function. Whether the elements are passed
132+
/// indirectly is recorded in the pack type.
133+
case packOwned
134+
135+
/// This argument is a value pack, and ownership of the elements is not
136+
/// being transferred into this function. Whether the elements are passed
137+
/// indirectly is recorded in the pack type.
138+
case packGuaranteed
139+
125140
public var isIndirect: Bool {
126141
switch self {
127142
case .indirectIn, .indirectInGuaranteed,
128-
.indirectInout, .indirectInoutAliasable, .indirectOut:
143+
.indirectInout, .indirectInoutAliasable, .indirectOut,
144+
.packInout, .packOwned, .packGuaranteed:
129145
return true
130146
case .directOwned, .directUnowned, .directGuaranteed:
131147
return false
@@ -134,20 +150,23 @@ public enum ArgumentConvention {
134150

135151
public var isIndirectIn: Bool {
136152
switch self {
137-
case .indirectIn, .indirectInGuaranteed:
153+
case .indirectIn, .indirectInGuaranteed,
154+
.packOwned, .packGuaranteed:
138155
return true
139156
case .directOwned, .directUnowned, .directGuaranteed,
140-
.indirectInout, .indirectInoutAliasable, .indirectOut:
157+
.indirectInout, .indirectInoutAliasable, .indirectOut,
158+
.packInout:
141159
return false
142160
}
143161
}
144162

145163
public var isGuaranteed: Bool {
146164
switch self {
147-
case .indirectInGuaranteed, .directGuaranteed:
165+
case .indirectInGuaranteed, .directGuaranteed, .packGuaranteed:
148166
return true
149167
case .indirectIn, .directOwned, .directUnowned,
150-
.indirectInout, .indirectInoutAliasable, .indirectOut:
168+
.indirectInout, .indirectInoutAliasable, .indirectOut,
169+
.packInout, .packOwned:
151170
return false
152171
}
153172
}
@@ -157,7 +176,10 @@ public enum ArgumentConvention {
157176
case .indirectIn,
158177
.indirectOut,
159178
.indirectInGuaranteed,
160-
.indirectInout:
179+
.indirectInout,
180+
.packInout,
181+
.packOwned,
182+
.packGuaranteed:
161183
return true
162184

163185
case .indirectInoutAliasable,
@@ -171,15 +193,18 @@ public enum ArgumentConvention {
171193
public var isInout: Bool {
172194
switch self {
173195
case .indirectInout,
174-
.indirectInoutAliasable:
196+
.indirectInoutAliasable,
197+
.packInout:
175198
return true
176199

177200
case .indirectIn,
178201
.indirectOut,
179202
.indirectInGuaranteed,
180203
.directUnowned,
181204
.directGuaranteed,
182-
.directOwned:
205+
.directOwned,
206+
.packOwned,
207+
.packGuaranteed:
183208
return false
184209
}
185210
}
@@ -204,6 +229,9 @@ extension BridgedArgumentConvention {
204229
case .Direct_Owned: return .directOwned
205230
case .Direct_Unowned: return .directUnowned
206231
case .Direct_Guaranteed: return .directGuaranteed
232+
case .Pack_Inout: return .packInout
233+
case .Pack_Owned: return .packOwned
234+
case .Pack_Guaranteed: return .packGuaranteed
207235
default:
208236
fatalError("unsupported argument convention")
209237
}

SwiftCompilerSources/Sources/SIL/Effects.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,12 @@ public struct SideEffects : CustomStringConvertible, NoReflectionChildren {
541541
result.ownership = SideEffects.Ownership()
542542
}
543543
switch convention {
544-
case .indirectIn:
544+
case .indirectIn, .packOwned:
545545
result.memory.write = false
546-
case .indirectInGuaranteed:
546+
case .indirectInGuaranteed, .packGuaranteed:
547547
result.memory.write = false
548548
result.ownership.destroy = false
549-
case .indirectOut:
549+
case .indirectOut, .packInout:
550550
result.memory.read = false
551551
result.ownership.copy = false
552552
result.ownership.destroy = false

0 commit comments

Comments
 (0)