@@ -46,7 +46,7 @@ class GenericContextDescriptorFlags {
46
46
47
47
// / Whether this generic context has at least one type parameter
48
48
// / pack, in which case the generic context will have a trailing
49
- // / GenericParamPackShapeHeader .
49
+ // / GenericPackShapeHeader .
50
50
constexpr bool hasTypePacks () const {
51
51
return (Value & 0x1 ) != 0 ;
52
52
}
@@ -245,23 +245,39 @@ class TargetGenericRequirementDescriptor {
245
245
using GenericRequirementDescriptor =
246
246
TargetGenericRequirementDescriptor<InProcess>;
247
247
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.
250
251
// /
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;
254
258
255
259
// / The number of equivalence classes in the same-shape relation.
256
260
uint16_t NumShapeClasses;
257
261
};
258
262
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.
262
276
// /
263
- // / Must be less than GenericParamPackShapeHeader ::NumShapeClasses.
277
+ // / Must be less than GenericPackShapeHeader ::NumShapeClasses.
264
278
uint16_t ShapeClass;
279
+
280
+ uint16_t Unused;
265
281
};
266
282
267
283
// / An array of generic parameter descriptors, all
@@ -299,8 +315,8 @@ class RuntimeGenericSignature {
299
315
TargetGenericContextDescriptorHeader<Runtime> Header;
300
316
const GenericParamDescriptor *Params;
301
317
const TargetGenericRequirementDescriptor<Runtime> *Requirements;
302
- GenericParamPackShapeHeader PackShapeHeader;
303
- const GenericParamPackShapeDescriptor *PackShapeDescriptors;
318
+ GenericPackShapeHeader PackShapeHeader;
319
+ const GenericPackShapeDescriptor *PackShapeDescriptors;
304
320
305
321
public:
306
322
RuntimeGenericSignature ()
@@ -310,8 +326,8 @@ class RuntimeGenericSignature {
310
326
RuntimeGenericSignature (const TargetGenericContextDescriptorHeader<Runtime> &header,
311
327
const GenericParamDescriptor *params,
312
328
const TargetGenericRequirementDescriptor<Runtime> *requirements,
313
- const GenericParamPackShapeHeader &packShapeHeader,
314
- const GenericParamPackShapeDescriptor *packShapeDescriptors)
329
+ const GenericPackShapeHeader &packShapeHeader,
330
+ const GenericPackShapeDescriptor *packShapeDescriptors)
315
331
: Header(header), Params(params), Requirements(requirements),
316
332
PackShapeHeader (packShapeHeader), PackShapeDescriptors(packShapeDescriptors) {}
317
333
@@ -323,8 +339,12 @@ class RuntimeGenericSignature {
323
339
return llvm::makeArrayRef (Requirements, Header.NumRequirements );
324
340
}
325
341
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 );
328
348
}
329
349
330
350
size_t getArgumentLayoutSizeInWords () const {
@@ -417,8 +437,8 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
417
437
TargetGenericContextHeaderType<Runtime>,
418
438
GenericParamDescriptor,
419
439
TargetGenericRequirementDescriptor<Runtime>,
420
- GenericParamPackShapeHeader ,
421
- GenericParamPackShapeDescriptor ,
440
+ GenericPackShapeHeader ,
441
+ GenericPackShapeDescriptor ,
422
442
FollowingTrailingObjects...>
423
443
{
424
444
protected:
@@ -431,8 +451,8 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
431
451
GenericContextHeaderType,
432
452
GenericParamDescriptor,
433
453
GenericRequirementDescriptor,
434
- GenericParamPackShapeHeader ,
435
- GenericParamPackShapeDescriptor ,
454
+ GenericPackShapeHeader ,
455
+ GenericPackShapeDescriptor ,
436
456
FollowingTrailingObjects...>;
437
457
friend TrailingObjects;
438
458
@@ -487,21 +507,21 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
487
507
getGenericContextHeader ().NumRequirements };
488
508
}
489
509
490
- GenericParamPackShapeHeader getGenericParamPackShapeHeader () const {
510
+ GenericPackShapeHeader getGenericPackShapeHeader () const {
491
511
if (!asSelf ()->isGeneric ())
492
512
return {0 , 0 };
493
513
if (!getGenericContextHeader ().Flags .hasTypePacks ())
494
514
return {0 , 0 };
495
- return *this ->template getTrailingObjects <GenericParamPackShapeHeader >();
515
+ return *this ->template getTrailingObjects <GenericPackShapeHeader >();
496
516
}
497
517
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 )
501
521
return {};
502
522
503
- return {this ->template getTrailingObjects <GenericParamPackShapeDescriptor >(),
504
- header.NumTypePacks };
523
+ return {this ->template getTrailingObjects <GenericPackShapeDescriptor >(),
524
+ header.NumPacks };
505
525
}
506
526
507
527
// / Return the amount of space that the generic arguments take up in
@@ -516,8 +536,8 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
516
536
return {getGenericContextHeader (),
517
537
getGenericParams ().data (),
518
538
getGenericRequirements ().data (),
519
- getGenericParamPackShapeHeader (),
520
- getGenericParamPackShapeDescriptors ().data ()};
539
+ getGenericPackShapeHeader (),
540
+ getGenericPackShapeDescriptors ().data ()};
521
541
}
522
542
523
543
protected:
@@ -533,21 +553,21 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
533
553
return asSelf ()->isGeneric () ? getGenericContextHeader ().NumRequirements : 0 ;
534
554
}
535
555
536
- size_t numTrailingObjects (OverloadToken<GenericParamPackShapeHeader >) const {
556
+ size_t numTrailingObjects (OverloadToken<GenericPackShapeHeader >) const {
537
557
if (!asSelf ()->isGeneric ())
538
558
return 0 ;
539
559
540
560
return getGenericContextHeader ().Flags .hasTypePacks () ? 1 : 0 ;
541
561
}
542
562
543
- size_t numTrailingObjects (OverloadToken<GenericParamPackShapeDescriptor >) const {
563
+ size_t numTrailingObjects (OverloadToken<GenericPackShapeDescriptor >) const {
544
564
if (!asSelf ()->isGeneric ())
545
565
return 0 ;
546
566
547
567
if (!getGenericContextHeader ().Flags .hasTypePacks ())
548
568
return 0 ;
549
569
550
- return getGenericParamPackShapeHeader ().NumTypePacks ;
570
+ return getGenericPackShapeHeader ().NumPacks ;
551
571
}
552
572
553
573
#if defined(_MSC_VER) && _MSC_VER < 1920
0 commit comments