@@ -74,6 +74,10 @@ struct TargetGenericContextDescriptorHeader {
74
74
// / same order as the requirement descriptors which satisfy
75
75
// / hasKeyArgument().
76
76
// /
77
+ // / a sequence of values, in the same order as the parameter descriptors
78
+ // / which satisify getKind() == GenericParamKind::Value and
79
+ // / hasKeyArgument();
80
+ // /
77
81
// / The elements above which are packs are precisely those appearing
78
82
// / in the sequence of trailing GenericPackShapeDescriptors.
79
83
uint16_t NumKeyArguments;
@@ -319,6 +323,18 @@ struct ConditionalInvertibleProtocolSet: InvertibleProtocolSet {
319
323
template <typename Runtime>
320
324
struct TargetConditionalInvertibleProtocolRequirement : TargetGenericRequirementDescriptor<Runtime> { };
321
325
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
+
322
338
// / An array of generic parameter descriptors, all
323
339
// / GenericParamDescriptor::implicit(), which is by far
324
340
// / the most common case. Some generic context storage can
@@ -356,20 +372,26 @@ class RuntimeGenericSignature {
356
372
const TargetGenericRequirementDescriptor<Runtime> *Requirements;
357
373
GenericPackShapeHeader PackShapeHeader;
358
374
const GenericPackShapeDescriptor *PackShapeDescriptors;
375
+ GenericValueHeader ValueHeader;
376
+ const GenericValueDescriptor *ValueDescriptors;
359
377
360
378
public:
361
379
RuntimeGenericSignature ()
362
- : Header{0 , 0 , 0 , GenericContextDescriptorFlags (false , false )},
380
+ : Header{0 , 0 , 0 , GenericContextDescriptorFlags (false , false , false )},
363
381
Params (nullptr ), Requirements(nullptr ),
364
- PackShapeHeader{0 , 0 }, PackShapeDescriptors(nullptr ) {}
382
+ PackShapeHeader{0 , 0 }, PackShapeDescriptors(nullptr ), ValueHeader{0 },
383
+ ValueDescriptors (nullptr ) {}
365
384
366
385
RuntimeGenericSignature (const TargetGenericContextDescriptorHeader<Runtime> &header,
367
386
const GenericParamDescriptor *params,
368
387
const TargetGenericRequirementDescriptor<Runtime> *requirements,
369
388
const GenericPackShapeHeader &packShapeHeader,
370
- const GenericPackShapeDescriptor *packShapeDescriptors)
389
+ const GenericPackShapeDescriptor *packShapeDescriptors,
390
+ const GenericValueHeader &valueHeader,
391
+ const GenericValueDescriptor *valueDescriptors)
371
392
: Header(header), Params(params), Requirements(requirements),
372
- PackShapeHeader (packShapeHeader), PackShapeDescriptors(packShapeDescriptors) {}
393
+ PackShapeHeader (packShapeHeader), PackShapeDescriptors(packShapeDescriptors),
394
+ ValueHeader(valueHeader), ValueDescriptors(valueDescriptors) {}
373
395
374
396
llvm::ArrayRef<GenericParamDescriptor> getParams () const {
375
397
return llvm::ArrayRef (Params, Header.NumParams );
@@ -387,6 +409,14 @@ class RuntimeGenericSignature {
387
409
return llvm::ArrayRef (PackShapeDescriptors, PackShapeHeader.NumPacks );
388
410
}
389
411
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
+
390
420
size_t getArgumentLayoutSizeInWords () const {
391
421
return Header.getArgumentLayoutSizeInWords ();
392
422
}
@@ -482,6 +512,8 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
482
512
ConditionalInvertibleProtocolSet,
483
513
ConditionalInvertibleProtocolsRequirementCount,
484
514
TargetConditionalInvertibleProtocolRequirement<Runtime>,
515
+ GenericValueHeader,
516
+ GenericValueDescriptor,
485
517
FollowingTrailingObjects...>
486
518
{
487
519
protected:
@@ -500,6 +532,8 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
500
532
ConditionalInvertibleProtocolSet,
501
533
ConditionalInvertibleProtocolsRequirementCount,
502
534
GenericConditionalInvertibleProtocolRequirement,
535
+ GenericValueHeader,
536
+ GenericValueDescriptor,
503
537
FollowingTrailingObjects...>;
504
538
friend TrailingObjects;
505
539
@@ -648,13 +682,33 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
648
682
header.NumPacks };
649
683
}
650
684
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
+
651
703
RuntimeGenericSignature<Runtime> getGenericSignature () const {
652
704
if (!asSelf ()->isGeneric ()) return RuntimeGenericSignature<Runtime>();
653
705
return {getGenericContextHeader (),
654
706
getGenericParams ().data (),
655
707
getGenericRequirements ().data (),
656
708
getGenericPackShapeHeader (),
657
- getGenericPackShapeDescriptors ().data ()};
709
+ getGenericPackShapeDescriptors ().data (),
710
+ getGenericValueHeader (),
711
+ getGenericValueDescriptors ().data ()};
658
712
}
659
713
660
714
protected:
@@ -713,6 +767,23 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
713
767
return counts.empty () ? 0 : counts.back ().count ;
714
768
}
715
769
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
+
716
787
#if defined(_MSC_VER) && _MSC_VER < 1920
717
788
#undef OverloadToken
718
789
#endif
0 commit comments