@@ -74,6 +74,10 @@ struct TargetGenericContextDescriptorHeader {
7474 // / same order as the requirement descriptors which satisfy
7575 // / hasKeyArgument().
7676 // /
77+ // / a sequence of values, in the same order as the parameter descriptors
78+ // / which satisify getKind() == GenericParamKind::Value and
79+ // / hasKeyArgument();
80+ // /
7781 // / The elements above which are packs are precisely those appearing
7882 // / in the sequence of trailing GenericPackShapeDescriptors.
7983 uint16_t NumKeyArguments;
@@ -319,6 +323,18 @@ struct ConditionalInvertibleProtocolSet: InvertibleProtocolSet {
319323template <typename Runtime>
320324struct TargetConditionalInvertibleProtocolRequirement : TargetGenericRequirementDescriptor<Runtime> { };
321325
326+ struct GenericValueHeader {
327+ // / The total number of generic parameters in this signature where
328+ // / getKind() == GenericParamKind::Value.
329+ uint32_t NumValues;
330+ };
331+
332+ // / The GenericValueHeader is followed by an array of these descriptors,
333+ // / whose length is given by the header's NumValues field.
334+ struct GenericValueDescriptor {
335+ GenericValueType Type;
336+ };
337+
322338// / An array of generic parameter descriptors, all
323339// / GenericParamDescriptor::implicit(), which is by far
324340// / the most common case. Some generic context storage can
@@ -356,20 +372,26 @@ class RuntimeGenericSignature {
356372 const TargetGenericRequirementDescriptor<Runtime> *Requirements;
357373 GenericPackShapeHeader PackShapeHeader;
358374 const GenericPackShapeDescriptor *PackShapeDescriptors;
375+ GenericValueHeader ValueHeader;
376+ const GenericValueDescriptor *ValueDescriptors;
359377
360378public:
361379 RuntimeGenericSignature ()
362- : Header{0 , 0 , 0 , GenericContextDescriptorFlags (false , false )},
380+ : Header{0 , 0 , 0 , GenericContextDescriptorFlags (false , false , false )},
363381 Params (nullptr ), Requirements(nullptr ),
364- PackShapeHeader{0 , 0 }, PackShapeDescriptors(nullptr ) {}
382+ PackShapeHeader{0 , 0 }, PackShapeDescriptors(nullptr ), ValueHeader{0 },
383+ ValueDescriptors (nullptr ) {}
365384
366385 RuntimeGenericSignature (const TargetGenericContextDescriptorHeader<Runtime> &header,
367386 const GenericParamDescriptor *params,
368387 const TargetGenericRequirementDescriptor<Runtime> *requirements,
369388 const GenericPackShapeHeader &packShapeHeader,
370- const GenericPackShapeDescriptor *packShapeDescriptors)
389+ const GenericPackShapeDescriptor *packShapeDescriptors,
390+ const GenericValueHeader &valueHeader,
391+ const GenericValueDescriptor *valueDescriptors)
371392 : Header(header), Params(params), Requirements(requirements),
372- PackShapeHeader (packShapeHeader), PackShapeDescriptors(packShapeDescriptors) {}
393+ PackShapeHeader (packShapeHeader), PackShapeDescriptors(packShapeDescriptors),
394+ ValueHeader(valueHeader), ValueDescriptors(valueDescriptors) {}
373395
374396 llvm::ArrayRef<GenericParamDescriptor> getParams () const {
375397 return llvm::ArrayRef (Params, Header.NumParams );
@@ -387,6 +409,14 @@ class RuntimeGenericSignature {
387409 return llvm::ArrayRef (PackShapeDescriptors, PackShapeHeader.NumPacks );
388410 }
389411
412+ const GenericValueHeader &getGenericValueHeader () const {
413+ return ValueHeader;
414+ }
415+
416+ llvm::ArrayRef<GenericValueDescriptor> getGenericValueDescriptors () const {
417+ return llvm::ArrayRef (ValueDescriptors, ValueHeader.NumValues );
418+ }
419+
390420 size_t getArgumentLayoutSizeInWords () const {
391421 return Header.getArgumentLayoutSizeInWords ();
392422 }
@@ -482,6 +512,8 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
482512 ConditionalInvertibleProtocolSet,
483513 ConditionalInvertibleProtocolsRequirementCount,
484514 TargetConditionalInvertibleProtocolRequirement<Runtime>,
515+ GenericValueHeader,
516+ GenericValueDescriptor,
485517 FollowingTrailingObjects...>
486518{
487519protected:
@@ -500,6 +532,8 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
500532 ConditionalInvertibleProtocolSet,
501533 ConditionalInvertibleProtocolsRequirementCount,
502534 GenericConditionalInvertibleProtocolRequirement,
535+ GenericValueHeader,
536+ GenericValueDescriptor,
503537 FollowingTrailingObjects...>;
504538 friend TrailingObjects;
505539
@@ -648,13 +682,33 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
648682 header.NumPacks };
649683 }
650684
685+ GenericValueHeader getGenericValueHeader () const {
686+ if (!asSelf ()->isGeneric ())
687+ return {0 };
688+ if (!getGenericContextHeader ().Flags .hasValues ())
689+ return {0 };
690+ return *this ->template getTrailingObjects <GenericValueHeader>();
691+ }
692+
693+ llvm::ArrayRef<GenericValueDescriptor> getGenericValueDescriptors () const {
694+ auto header = getGenericValueHeader ();
695+
696+ if (header.NumValues == 0 )
697+ return {};
698+
699+ return {this ->template getTrailingObjects <GenericValueDescriptor>(),
700+ header.NumValues };
701+ }
702+
651703 RuntimeGenericSignature<Runtime> getGenericSignature () const {
652704 if (!asSelf ()->isGeneric ()) return RuntimeGenericSignature<Runtime>();
653705 return {getGenericContextHeader (),
654706 getGenericParams ().data (),
655707 getGenericRequirements ().data (),
656708 getGenericPackShapeHeader (),
657- getGenericPackShapeDescriptors ().data ()};
709+ getGenericPackShapeDescriptors ().data (),
710+ getGenericValueHeader (),
711+ getGenericValueDescriptors ().data ()};
658712 }
659713
660714protected:
@@ -713,6 +767,23 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
713767 return counts.empty () ? 0 : counts.back ().count ;
714768 }
715769
770+ size_t numTrailingObjects (OverloadToken<GenericValueHeader>) const {
771+ if (!asSelf ()->isGeneric ())
772+ return 0 ;
773+
774+ return getGenericContextHeader ().Flags .hasValues () ? 1 : 0 ;
775+ }
776+
777+ size_t numTrailingObjects (OverloadToken<GenericValueDescriptor>) const {
778+ if (!asSelf ()->isGeneric ())
779+ return 0 ;
780+
781+ if (!getGenericContextHeader ().Flags .hasValues ())
782+ return 0 ;
783+
784+ return getGenericValueHeader ().NumValues ;
785+ }
786+
716787#if defined(_MSC_VER) && _MSC_VER < 1920
717788#undef OverloadToken
718789#endif
0 commit comments