Skip to content

Commit 43b6fd4

Browse files
committed
SIL: add the IndexingInstruction protocol
It defines (and implements) the `base` and `index` properties, which are used in the conforming classes `IndexRawPointerInst`, `IndexAddrInst` and `TailAddrInst`
1 parent 969a788 commit 43b6fd4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -736,23 +736,27 @@ class PointerToAddressInst : SingleValueInstruction, UnaryInstruction {
736736
}
737737
}
738738

739-
final public
740-
class IndexAddrInst : SingleValueInstruction {
739+
public protocol IndexingInstruction: SingleValueInstruction {
740+
var base: Value { get }
741+
var index: Value { get }
742+
}
743+
744+
extension IndexingInstruction {
741745
public var base: Value { operands[0].value }
742746
public var index: Value { operands[1].value }
743-
747+
}
748+
749+
final public
750+
class IndexAddrInst : SingleValueInstruction, IndexingInstruction {
744751
public var needsStackProtection: Bool {
745752
bridged.IndexAddrInst_needsStackProtection()
746753
}
747754
}
748755

749-
final public class IndexRawPointerInst : SingleValueInstruction {}
756+
final public class IndexRawPointerInst : SingleValueInstruction, IndexingInstruction {}
750757

751758
final public
752-
class TailAddrInst : SingleValueInstruction {
753-
public var base: Value { operands[0].value }
754-
public var index: Value { operands[1].value }
755-
}
759+
class TailAddrInst : SingleValueInstruction, IndexingInstruction {}
756760

757761
final public
758762
class InitExistentialRefInst : SingleValueInstruction, UnaryInstruction {

0 commit comments

Comments
 (0)