Skip to content

Commit 340efd9

Browse files
committed
Swift SIL: add MultipleValueInstructionResult.index
And make DestructureStructInst and DestructureTupleInst a UnaryInstruction
1 parent ee7446f commit 340efd9

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public final class MultipleValueInstructionResult : Value {
144144

145145
public var definingInstruction: Instruction? { instruction }
146146

147+
public var index: Int { MultiValueInstResult_getIndex(bridged) }
148+
147149
var bridged: BridgedMultiValueResult {
148150
BridgedMultiValueResult(obj: SwiftObject(self))
149151
}
@@ -568,10 +570,10 @@ final public class BeginCOWMutationInst : MultipleValueInstruction,
568570
public var bufferResult: Value { return getResult(index: 1) }
569571
}
570572

571-
final public class DestructureStructInst : MultipleValueInstruction {
573+
final public class DestructureStructInst : MultipleValueInstruction, UnaryInstruction {
572574
}
573575

574-
final public class DestructureTupleInst : MultipleValueInstruction {
576+
final public class DestructureTupleInst : MultipleValueInstruction, UnaryInstruction {
575577
}
576578

577579
final public class BeginApplyInst : MultipleValueInstruction, FullApplySite {

include/swift/SIL/SILBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ BridgedMemoryBehavior SILInstruction_getMemBehavior(BridgedInstruction inst);
247247
bool SILInstruction_mayRelease(BridgedInstruction inst);
248248

249249
BridgedInstruction MultiValueInstResult_getParent(BridgedMultiValueResult result);
250+
SwiftInt MultiValueInstResult_getIndex(BridgedMultiValueResult result);
250251
SwiftInt MultipleValueInstruction_getNumResults(BridgedInstruction inst);
251252
BridgedMultiValueResult
252253
MultipleValueInstruction_getResult(BridgedInstruction inst, SwiftInt index);

lib/SIL/Utils/SILBridging.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,11 @@ BridgedInstruction MultiValueInstResult_getParent(BridgedMultiValueResult result
520520
return {static_cast<MultipleValueInstructionResult *>(result.obj)->getParent()};
521521
}
522522

523+
SwiftInt MultiValueInstResult_getIndex(BridgedMultiValueResult result) {
524+
auto *rs = static_cast<MultipleValueInstructionResult *>(result.obj);
525+
return (SwiftInt)rs->getIndex();
526+
}
527+
523528
SwiftInt MultipleValueInstruction_getNumResults(BridgedInstruction inst) {
524529
return castToInst<MultipleValueInstruction>(inst)->getNumResults();
525530
}

0 commit comments

Comments
 (0)