@@ -46,7 +46,7 @@ class GenericContextDescriptorFlags {
4646
4747 // / Whether this generic context has at least one type parameter
4848 // / pack, in which case the generic context will have a trailing
49- // / GenericParamPackShapeHeader .
49+ // / GenericPackShapeHeader .
5050 constexpr bool hasTypePacks () const {
5151 return (Value & 0x1 ) != 0 ;
5252 }
@@ -245,23 +245,39 @@ class TargetGenericRequirementDescriptor {
245245using GenericRequirementDescriptor =
246246 TargetGenericRequirementDescriptor<InProcess>;
247247
248- struct GenericParamPackShapeHeader {
249- // / The number of generic parameters which are packs.
248+ struct GenericPackShapeHeader {
249+ // / The number of generic parameters and conformance requirements
250+ // / which are packs.
250251 // /
251- // / Must equal the number of GenericParamDescriptors whose kind is
252- // / GenericParamKind::TypePack.
253- uint16_t NumTypePacks;
252+ // / Must equal the sum of:
253+ // / - the number of GenericParamDescriptors whose kind is
254+ // / GenericParamKind::TypePack and isKeyArgument bits set;
255+ // / - the number of GenericRequirementDescriptors with the
256+ // / isPackRequirement and isKeyArgument bits set
257+ uint16_t NumPacks;
254258
255259 // / The number of equivalence classes in the same-shape relation.
256260 uint16_t NumShapeClasses;
257261};
258262
259- struct GenericParamPackShapeDescriptor {
260- // / The equivalence class of this generic parameter pack under
261- // / the same-shape relation.
263+ enum class GenericPackKind : uint16_t {
264+ Metadata = 0 ,
265+ WitnessTable = 1
266+ };
267+
268+ struct GenericPackShapeDescriptor {
269+ GenericPackKind Kind;
270+
271+ // / The index of this metadata pack or witness table pack in the
272+ // / generic arguments array.
273+ uint16_t Index;
274+
275+ // / The equivalence class of this pack under the same-shape relation.
262276 // /
263- // / Must be less than GenericParamPackShapeHeader ::NumShapeClasses.
277+ // / Must be less than GenericPackShapeHeader ::NumShapeClasses.
264278 uint16_t ShapeClass;
279+
280+ uint16_t Unused;
265281};
266282
267283// / An array of generic parameter descriptors, all
@@ -299,8 +315,8 @@ class RuntimeGenericSignature {
299315 TargetGenericContextDescriptorHeader<Runtime> Header;
300316 const GenericParamDescriptor *Params;
301317 const TargetGenericRequirementDescriptor<Runtime> *Requirements;
302- GenericParamPackShapeHeader PackShapeHeader;
303- const GenericParamPackShapeDescriptor *PackShapeDescriptors;
318+ GenericPackShapeHeader PackShapeHeader;
319+ const GenericPackShapeDescriptor *PackShapeDescriptors;
304320
305321public:
306322 RuntimeGenericSignature ()
@@ -310,8 +326,8 @@ class RuntimeGenericSignature {
310326 RuntimeGenericSignature (const TargetGenericContextDescriptorHeader<Runtime> &header,
311327 const GenericParamDescriptor *params,
312328 const TargetGenericRequirementDescriptor<Runtime> *requirements,
313- const GenericParamPackShapeHeader &packShapeHeader,
314- const GenericParamPackShapeDescriptor *packShapeDescriptors)
329+ const GenericPackShapeHeader &packShapeHeader,
330+ const GenericPackShapeDescriptor *packShapeDescriptors)
315331 : Header(header), Params(params), Requirements(requirements),
316332 PackShapeHeader (packShapeHeader), PackShapeDescriptors(packShapeDescriptors) {}
317333
@@ -323,8 +339,12 @@ class RuntimeGenericSignature {
323339 return llvm::makeArrayRef (Requirements, Header.NumRequirements );
324340 }
325341
326- llvm::ArrayRef<GenericParamPackShapeDescriptor> getPackShapeDescriptors () const {
327- return llvm::makeArrayRef (PackShapeDescriptors, PackShapeHeader.NumTypePacks );
342+ const GenericPackShapeHeader &getGenericPackShapeHeader () const {
343+ return PackShapeHeader;
344+ }
345+
346+ llvm::ArrayRef<GenericPackShapeDescriptor> getGenericPackShapeDescriptors () const {
347+ return llvm::makeArrayRef (PackShapeDescriptors, PackShapeHeader.NumPacks );
328348 }
329349
330350 size_t getArgumentLayoutSizeInWords () const {
@@ -417,8 +437,8 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
417437 TargetGenericContextHeaderType<Runtime>,
418438 GenericParamDescriptor,
419439 TargetGenericRequirementDescriptor<Runtime>,
420- GenericParamPackShapeHeader ,
421- GenericParamPackShapeDescriptor ,
440+ GenericPackShapeHeader ,
441+ GenericPackShapeDescriptor ,
422442 FollowingTrailingObjects...>
423443{
424444protected:
@@ -431,8 +451,8 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
431451 GenericContextHeaderType,
432452 GenericParamDescriptor,
433453 GenericRequirementDescriptor,
434- GenericParamPackShapeHeader ,
435- GenericParamPackShapeDescriptor ,
454+ GenericPackShapeHeader ,
455+ GenericPackShapeDescriptor ,
436456 FollowingTrailingObjects...>;
437457 friend TrailingObjects;
438458
@@ -487,21 +507,21 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
487507 getGenericContextHeader ().NumRequirements };
488508 }
489509
490- GenericParamPackShapeHeader getGenericParamPackShapeHeader () const {
510+ GenericPackShapeHeader getGenericPackShapeHeader () const {
491511 if (!asSelf ()->isGeneric ())
492512 return {0 , 0 };
493513 if (!getGenericContextHeader ().Flags .hasTypePacks ())
494514 return {0 , 0 };
495- return *this ->template getTrailingObjects <GenericParamPackShapeHeader >();
515+ return *this ->template getTrailingObjects <GenericPackShapeHeader >();
496516 }
497517
498- llvm::ArrayRef<GenericParamPackShapeDescriptor> getGenericParamPackShapeDescriptors () const {
499- auto header = getGenericParamPackShapeHeader ();
500- if (header.NumTypePacks == 0 )
518+ llvm::ArrayRef<GenericPackShapeDescriptor> getGenericPackShapeDescriptors () const {
519+ auto header = getGenericPackShapeHeader ();
520+ if (header.NumPacks == 0 )
501521 return {};
502522
503- return {this ->template getTrailingObjects <GenericParamPackShapeDescriptor >(),
504- header.NumTypePacks };
523+ return {this ->template getTrailingObjects <GenericPackShapeDescriptor >(),
524+ header.NumPacks };
505525 }
506526
507527 // / Return the amount of space that the generic arguments take up in
@@ -516,8 +536,8 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
516536 return {getGenericContextHeader (),
517537 getGenericParams ().data (),
518538 getGenericRequirements ().data (),
519- getGenericParamPackShapeHeader (),
520- getGenericParamPackShapeDescriptors ().data ()};
539+ getGenericPackShapeHeader (),
540+ getGenericPackShapeDescriptors ().data ()};
521541 }
522542
523543protected:
@@ -533,21 +553,21 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
533553 return asSelf ()->isGeneric () ? getGenericContextHeader ().NumRequirements : 0 ;
534554 }
535555
536- size_t numTrailingObjects (OverloadToken<GenericParamPackShapeHeader >) const {
556+ size_t numTrailingObjects (OverloadToken<GenericPackShapeHeader >) const {
537557 if (!asSelf ()->isGeneric ())
538558 return 0 ;
539559
540560 return getGenericContextHeader ().Flags .hasTypePacks () ? 1 : 0 ;
541561 }
542562
543- size_t numTrailingObjects (OverloadToken<GenericParamPackShapeDescriptor >) const {
563+ size_t numTrailingObjects (OverloadToken<GenericPackShapeDescriptor >) const {
544564 if (!asSelf ()->isGeneric ())
545565 return 0 ;
546566
547567 if (!getGenericContextHeader ().Flags .hasTypePacks ())
548568 return 0 ;
549569
550- return getGenericParamPackShapeHeader ().NumTypePacks ;
570+ return getGenericPackShapeHeader ().NumPacks ;
551571 }
552572
553573#if defined(_MSC_VER) && _MSC_VER < 1920
0 commit comments