@@ -2451,6 +2451,20 @@ BEGIN_CAN_TYPE_WRAPPER(TupleType, Type)
24512451 CanTupleEltTypeArrayRef getElementTypes () const {
24522452 return CanTupleEltTypeArrayRef (getPointer ()->getElements ());
24532453 }
2454+
2455+ bool containsPackExpansionType () const {
2456+ return containsPackExpansionTypeImpl (*this );
2457+ }
2458+
2459+ // / Induce a pack type from a range of the elements of this tuple type.
2460+ inline CanTypeWrapper<PackType>
2461+ getInducedPackType (unsigned start, unsigned count) const ;
2462+
2463+ private:
2464+ static bool containsPackExpansionTypeImpl (CanTupleType tuple);
2465+
2466+ static CanTypeWrapper<PackType>
2467+ getInducedPackTypeImpl (CanTupleType tuple, unsigned start, unsigned count);
24542468END_CAN_TYPE_WRAPPER (TupleType, Type)
24552469
24562470// / UnboundGenericType - Represents a generic type where the type arguments have
@@ -4233,6 +4247,11 @@ class SILResultInfo {
42334247 return !isIndirectFormalResult (getConvention ());
42344248 }
42354249
4250+ // / Is this a pack result? Pack results are always indirect.
4251+ bool isPack () const {
4252+ return getConvention () == ResultConvention::Pack;
4253+ }
4254+
42364255 // / Transform this SILResultInfo by applying the user-provided
42374256 // / function to its type.
42384257 // /
@@ -4408,8 +4427,9 @@ class SILFunctionType final
44084427
44094428 // These are *normal* results if this is not a coroutine and *yield* results
44104429 // otherwise.
4411- unsigned NumAnyResults : 16 ; // Not including the ErrorResult.
4412- unsigned NumAnyIndirectFormalResults : 16 ; // Subset of NumAnyResults.
4430+ unsigned NumAnyResults; // Not including the ErrorResult.
4431+ unsigned NumAnyIndirectFormalResults; // Subset of NumAnyResults.
4432+ unsigned NumPackResults; // Subset of NumAnyIndirectFormalResults.
44134433
44144434 // [NOTE: SILFunctionType-layout]
44154435 // The layout of a SILFunctionType in memory is:
@@ -4589,6 +4609,9 @@ class SILFunctionType final
45894609 unsigned getNumDirectFormalResults () const {
45904610 return isCoroutine () ? 0 : NumAnyResults - NumAnyIndirectFormalResults;
45914611 }
4612+ unsigned getNumPackResults () const {
4613+ return isCoroutine () ? 0 : NumPackResults;
4614+ }
45924615
45934616 struct IndirectFormalResultFilter {
45944617 bool operator ()(SILResultInfo result) const {
@@ -4618,6 +4641,21 @@ class SILFunctionType final
46184641 return llvm::make_filter_range (getResults (), DirectFormalResultFilter ());
46194642 }
46204643
4644+ struct PackResultFilter {
4645+ bool operator ()(SILResultInfo result) const {
4646+ return result.isPack ();
4647+ }
4648+ };
4649+ using PackResultIter =
4650+ llvm::filter_iterator<const SILResultInfo *, PackResultFilter>;
4651+ using PackResultRange = iterator_range<PackResultIter>;
4652+
4653+ // / A range of SILResultInfo for all pack results. Pack results are also
4654+ // / included in the set of indirect results.
4655+ PackResultRange getPackResults () const {
4656+ return llvm::make_filter_range (getResults (), PackResultFilter ());
4657+ }
4658+
46214659 // / Get a single non-address SILType that represents all formal direct
46224660 // / results. The actual SIL result type of an apply instruction that calls
46234661 // / this function depends on the current SIL stage and is known by
@@ -4636,6 +4674,9 @@ class SILFunctionType final
46364674 unsigned getNumDirectFormalYields () const {
46374675 return isCoroutine () ? NumAnyResults - NumAnyIndirectFormalResults : 0 ;
46384676 }
4677+ unsigned getNumPackYields () const {
4678+ return isCoroutine () ? NumPackResults : 0 ;
4679+ }
46394680
46404681 struct IndirectFormalYieldFilter {
46414682 bool operator ()(SILYieldInfo yield) const {
@@ -6798,6 +6839,11 @@ BEGIN_CAN_TYPE_WRAPPER(PackType, Type)
67986839 }
67996840END_CAN_TYPE_WRAPPER (PackType, Type)
68006841
6842+ inline CanPackType
6843+ CanTupleType::getInducedPackType (unsigned start, unsigned end) const {
6844+ return getInducedPackTypeImpl (*this , start, end);
6845+ }
6846+
68016847// / PackExpansionType - The interface type of the explicit expansion of a
68026848// / corresponding set of variadic generic parameters.
68036849// /
0 commit comments