@@ -7805,6 +7805,45 @@ class TuplePackElementAddrInst final
78057805 }
78067806};
78077807
7808+ // / Extracts a tuple element as appropriate for the given
7809+ // / pack element index. The pack index must index into a pack with
7810+ // / the same shape as the tuple element type list.
7811+ // /
7812+ // / Legal only in opaque values mode. Transformed by AddressLowering to
7813+ // / TuplePackElementAddrInst.
7814+ class TuplePackExtractInst final
7815+ : public InstructionBaseWithTrailingOperands<
7816+ SILInstructionKind::TuplePackExtractInst, TuplePackExtractInst,
7817+ OwnershipForwardingSingleValueInstruction> {
7818+ public:
7819+ enum { IndexOperand = 0 , TupleOperand = 1 };
7820+
7821+ private:
7822+ friend SILBuilder;
7823+
7824+ TuplePackExtractInst (SILDebugLocation debugLoc,
7825+ ArrayRef<SILValue> allOperands, SILType elementType,
7826+ ValueOwnershipKind forwardingOwnershipKind)
7827+ : InstructionBaseWithTrailingOperands(allOperands, debugLoc, elementType,
7828+ forwardingOwnershipKind) {}
7829+
7830+ static TuplePackExtractInst *
7831+ create (SILFunction &F, SILDebugLocation debugLoc, SILValue indexOperand,
7832+ SILValue tupleOperand, SILType elementType,
7833+ ValueOwnershipKind forwardingOwnershipKind);
7834+
7835+ public:
7836+ SILValue getIndex () const { return getAllOperands ()[IndexOperand].get (); }
7837+
7838+ SILValue getTuple () const { return getAllOperands ()[TupleOperand].get (); }
7839+
7840+ CanTupleType getTupleType () const {
7841+ return getTuple ()->getType ().castTo <TupleType>();
7842+ }
7843+
7844+ SILType getElementType () const { return getType (); }
7845+ };
7846+
78087847// / Projects the capture storage address from a @block_storage address.
78097848class ProjectBlockStorageInst
78107849 : public UnaryInstructionBase<SILInstructionKind::ProjectBlockStorageInst,
@@ -10543,6 +10582,7 @@ OwnershipForwardingSingleValueInstruction::classof(SILInstructionKind kind) {
1054310582 case SILInstructionKind::CopyableToMoveOnlyWrapperValueInst:
1054410583 case SILInstructionKind::MarkUninitializedInst:
1054510584 case SILInstructionKind::TupleExtractInst:
10585+ case SILInstructionKind::TuplePackExtractInst:
1054610586 case SILInstructionKind::StructExtractInst:
1054710587 case SILInstructionKind::DifferentiableFunctionExtractInst:
1054810588 case SILInstructionKind::LinearFunctionExtractInst:
0 commit comments