@@ -974,6 +974,9 @@ static Operand *getProjectedDefOperand(SILValue value) {
974
974
case ValueKind::OpenExistentialBoxValueInst:
975
975
assert (value->getOwnershipKind () == OwnershipKind::Guaranteed);
976
976
return &cast<SingleValueInstruction>(value)->getAllOperands ()[0 ];
977
+ case ValueKind::TuplePackExtractInst:
978
+ assert (value->getOwnershipKind () == OwnershipKind::Guaranteed);
979
+ return &cast<SingleValueInstruction>(value)->getAllOperands ()[1 ];
977
980
}
978
981
}
979
982
@@ -1703,6 +1706,8 @@ class AddressMaterialization {
1703
1706
1704
1707
SILValue materializeTupleExtract (SILInstruction *extractInst,
1705
1708
SILValue elementValue, unsigned fieldIdx);
1709
+ SILValue materializeTuplePackExtract (SILInstruction *extractInst,
1710
+ SILValue elementValue, SILValue index);
1706
1711
1707
1712
SILValue materializeProjectionIntoUse (Operand *operand, bool intoPhiOperand);
1708
1713
SILValue materializeProjectionIntoUseImpl (Operand *operand,
@@ -1859,6 +1864,11 @@ SILValue AddressMaterialization::materializeDefProjection(SILValue origValue) {
1859
1864
return materializeTupleExtract (extractInst, origValue,
1860
1865
extractInst->getFieldIndex ());
1861
1866
}
1867
+ case ValueKind::TuplePackExtractInst: {
1868
+ auto *extractInst = cast<TuplePackExtractInst>(origValue);
1869
+ return materializeTuplePackExtract (extractInst, origValue,
1870
+ extractInst->getIndex ());
1871
+ }
1862
1872
case ValueKind::SILPhiArgument: {
1863
1873
// Handle this in the caller. unchecked_take_enum_data_addr is
1864
1874
// destructive. It cannot be materialized on demand.
@@ -1888,6 +1898,14 @@ SILValue AddressMaterialization::materializeTupleExtract(
1888
1898
elementValue->getType ().getAddressType ());
1889
1899
}
1890
1900
1901
+ SILValue AddressMaterialization::materializeTuplePackExtract (
1902
+ SILInstruction *extractInst, SILValue elementValue, SILValue fieldIdx) {
1903
+ SILValue srcAddr = pass.getMaterializedAddress (extractInst->getOperand (1 ));
1904
+ return projectionBuilder.createTuplePackElementAddr (
1905
+ pass.genLoc (), fieldIdx, srcAddr,
1906
+ elementValue->getType ().getAddressType ());
1907
+ }
1908
+
1891
1909
SILValue
1892
1910
AddressMaterialization::materializeProjectionIntoUse (Operand *operand,
1893
1911
bool intoPhiOperand) {
@@ -3528,6 +3546,9 @@ class UseRewriter : SILInstructionVisitor<UseRewriter> {
3528
3546
// Extract from an opaque tuple.
3529
3547
void visitTupleExtractInst (TupleExtractInst *extractInst);
3530
3548
3549
+ // Extract from an opaque pack tuple.
3550
+ void visitTuplePackExtractInst (TuplePackExtractInst *extractInst);
3551
+
3531
3552
void
3532
3553
visitUncheckedBitwiseCastInst (UncheckedBitwiseCastInst *uncheckedCastInst) {
3533
3554
SILValue srcVal = uncheckedCastInst->getOperand ();
@@ -3819,6 +3840,10 @@ void UseRewriter::visitTupleExtractInst(TupleExtractInst *extractInst) {
3819
3840
emitExtract (extractInst);
3820
3841
}
3821
3842
3843
+ void UseRewriter::visitTuplePackExtractInst (TuplePackExtractInst *extractInst) {
3844
+ emitExtract (extractInst);
3845
+ }
3846
+
3822
3847
// Rewrite switch_enum to switch_enum_addr. All associated block arguments are
3823
3848
// removed.
3824
3849
void UseRewriter::visitSwitchEnumInst (SwitchEnumInst * switchEnum) {
0 commit comments