Skip to content

Commit e4d227a

Browse files
committed
SwiftCompilerSources: add StoreBorrowInst and BorrowIntroducingInstruction
`BorrowIntroducingInstruction` is a protocol to which all instructions conform which start a borrow-scope which must be ended by `EndBorrowInst` instructions: `begin_borrow`, `load_borrow` and `store_borrow`
1 parent 52eab43 commit e4d227a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ extension UnaryInstruction {
234234
final public class UnimplementedInstruction : Instruction {
235235
}
236236

237-
public protocol StoringInstruction : AnyObject {
237+
public protocol StoringInstruction : Instruction {
238238
var operands: OperandArray { get }
239239
}
240240

@@ -270,6 +270,8 @@ final public class StoreInst : Instruction, StoringInstruction {
270270
final public class StoreWeakInst : Instruction, StoringInstruction { }
271271
final public class StoreUnownedInst : Instruction, StoringInstruction { }
272272

273+
final public class StoreBorrowInst : SingleValueInstruction, StoringInstruction, BorrowIntroducingInstruction { }
274+
273275
final public class AssignInst : Instruction, StoringInstruction {
274276
// must match with enum class swift::AssignOwnershipQualifier
275277
public enum AssignOwnership: Int {
@@ -495,6 +497,9 @@ extension LoadInstruction {
495497
public var address: Value { operand.value }
496498
}
497499

500+
/// Instructions, beginning a borrow-scope which must be ended by `end_borrow`.
501+
public protocol BorrowIntroducingInstruction : SingleValueInstruction {}
502+
498503
final public class LoadInst : SingleValueInstruction, LoadInstruction {
499504
// must match with enum class LoadOwnershipQualifier
500505
public enum LoadOwnership: Int {
@@ -507,7 +512,7 @@ final public class LoadInst : SingleValueInstruction, LoadInstruction {
507512

508513
final public class LoadWeakInst : SingleValueInstruction, LoadInstruction {}
509514
final public class LoadUnownedInst : SingleValueInstruction, LoadInstruction {}
510-
final public class LoadBorrowInst : SingleValueInstruction, LoadInstruction {}
515+
final public class LoadBorrowInst : SingleValueInstruction, LoadInstruction, BorrowIntroducingInstruction {}
511516

512517
final public class BuiltinInst : SingleValueInstruction {
513518
public typealias ID = BridgedInstruction.BuiltinValueKind
@@ -872,7 +877,7 @@ extension BeginAccessInst : ScopedInstruction {
872877
}
873878
}
874879

875-
final public class BeginBorrowInst : SingleValueInstruction, UnaryInstruction {
880+
final public class BeginBorrowInst : SingleValueInstruction, UnaryInstruction, BorrowIntroducingInstruction {
876881
public var borrowedValue: Value { operand.value }
877882

878883
public typealias EndBorrowSequence = LazyMapSequence<LazyFilterSequence<LazyMapSequence<UseList, EndBorrowInst?>>,

SwiftCompilerSources/Sources/SIL/Registration.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public func registerSILClasses() {
4141
register(StoreInst.self)
4242
register(StoreWeakInst.self)
4343
register(StoreUnownedInst.self)
44+
register(StoreBorrowInst.self)
4445
register(AssignInst.self)
4546
register(CopyAddrInst.self)
4647
register(EndAccessInst.self)

0 commit comments

Comments
 (0)