Skip to content

Commit 4dcd91a

Browse files
committed
Swift SIL: add all deallocation instructions and let them conform to the Deallocation protocol
1 parent 85052a1 commit 4dcd91a

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,6 @@ final public class EndAccessInst : Instruction, UnaryInstruction {
251251

252252
final public class EndBorrowInst : Instruction, UnaryInstruction {}
253253

254-
final public class DeallocStackInst : Instruction, UnaryInstruction {
255-
public var allocstack: AllocStackInst {
256-
return operand.value as! AllocStackInst
257-
}
258-
}
259-
260-
final public class DeallocStackRefInst : Instruction, UnaryInstruction {
261-
public var allocRef: AllocRefInstBase { operand.value as! AllocRefInstBase }
262-
}
263-
264254
final public class MarkUninitializedInst : SingleValueInstruction, UnaryInstruction {
265255
}
266256

@@ -286,8 +276,6 @@ final public class AbortApplyInst : Instruction, UnaryInstruction {}
286276

287277
final public class SetDeallocatingInst : Instruction, UnaryInstruction {}
288278

289-
final public class DeallocRefInst : Instruction, UnaryInstruction {}
290-
291279
public class RefCountingInst : Instruction, UnaryInstruction {
292280
public var isAtomic: Bool { bridged.RefCountingInst_getIsAtomic() }
293281
}
@@ -320,6 +308,32 @@ final public class InjectEnumAddrInst : Instruction, UnaryInstruction, EnumInstr
320308

321309
final public class UnimplementedRefCountingInst : RefCountingInst {}
322310

311+
//===----------------------------------------------------------------------===//
312+
// no-value deallocation instructions
313+
//===----------------------------------------------------------------------===//
314+
315+
public protocol Deallocation : Instruction { }
316+
317+
final public class DeallocStackInst : Instruction, UnaryInstruction, Deallocation {
318+
public var allocstack: AllocStackInst {
319+
return operand.value as! AllocStackInst
320+
}
321+
}
322+
323+
final public class DeallocPackInst : Instruction, UnaryInstruction, Deallocation {}
324+
325+
final public class DeallocStackRefInst : Instruction, UnaryInstruction, Deallocation {
326+
public var allocRef: AllocRefInstBase { operand.value as! AllocRefInstBase }
327+
}
328+
329+
final public class DeallocRefInst : Instruction, UnaryInstruction, Deallocation {}
330+
331+
final public class DeallocPartialRefInst : Instruction, Deallocation {}
332+
333+
final public class DeallocBoxInst : Instruction, UnaryInstruction, Deallocation {}
334+
335+
final public class DeallocExistentialBoxInst : Instruction, UnaryInstruction, Deallocation {}
336+
323337
//===----------------------------------------------------------------------===//
324338
// single-value instructions
325339
//===----------------------------------------------------------------------===//

SwiftCompilerSources/Sources/SIL/Registration.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ public func registerSILClasses() {
4444
register(CopyAddrInst.self)
4545
register(EndAccessInst.self)
4646
register(EndBorrowInst.self)
47-
register(DeallocStackInst.self)
48-
register(DeallocStackRefInst.self)
4947
register(CondFailInst.self)
5048
register(MarkUninitializedInst.self)
5149
register(FixLifetimeInst.self)
@@ -55,7 +53,6 @@ public func registerSILClasses() {
5553
register(SetDeallocatingInst.self)
5654
register(EndApplyInst.self)
5755
register(AbortApplyInst.self)
58-
register(DeallocRefInst.self)
5956
register(StrongRetainInst.self)
6057
register(RetainValueInst.self)
6158
register(StrongReleaseInst.self)
@@ -65,6 +62,13 @@ public func registerSILClasses() {
6562
register(StrongCopyUnownedValueInst.self)
6663
register(StrongCopyUnmanagedValueInst.self)
6764
register(InjectEnumAddrInst.self)
65+
register(DeallocStackInst.self)
66+
register(DeallocPackInst.self)
67+
register(DeallocStackRefInst.self)
68+
register(DeallocRefInst.self)
69+
register(DeallocPartialRefInst.self)
70+
register(DeallocBoxInst.self)
71+
register(DeallocExistentialBoxInst.self)
6872
register(LoadInst.self)
6973
register(LoadWeakInst.self)
7074
register(LoadUnownedInst.self)

0 commit comments

Comments
 (0)