@@ -3426,31 +3426,46 @@ void irgen::bindGenericRequirement(IRGenFunction &IGF,
3426
3426
// Get the corresponding context type.
3427
3427
auto type = getInContext (requirement.getTypeParameter ());
3428
3428
3429
- if (requirement.isWitnessTable ()) {
3429
+ switch (requirement.getKind ()) {
3430
+ case GenericRequirement::Kind::Shape: {
3431
+ assert (isa<ArchetypeType>(type));
3432
+ assert (value->getType () == IGF.IGM .SizeTy );
3433
+ auto kind = LocalTypeDataKind::forPackShapeExpression ();
3434
+ IGF.setUnscopedLocalTypeData (type, kind, value);
3435
+ break ;
3436
+ }
3437
+
3438
+ case GenericRequirement::Kind::Metadata: {
3439
+ assert (value->getType () == IGF.IGM .TypeMetadataPtrTy );
3440
+ setTypeMetadataName (IGF.IGM , value, type);
3441
+ IGF.bindLocalTypeDataFromTypeMetadata (type, IsExact, value, metadataState);
3442
+ break ;
3443
+ }
3444
+
3445
+ case GenericRequirement::Kind::WitnessTable: {
3430
3446
auto proto = requirement.getProtocol ();
3431
3447
assert (isa<ArchetypeType>(type));
3432
3448
assert (value->getType () == IGF.IGM .WitnessTablePtrTy );
3433
3449
setProtocolWitnessTableName (IGF.IGM , value, type, proto);
3434
3450
auto kind = LocalTypeDataKind::forAbstractProtocolWitnessTable (proto);
3435
3451
IGF.setUnscopedLocalTypeData (type, kind, value);
3436
- } else {
3437
- assert (requirement.isMetadata ());
3438
- assert (value->getType () == IGF.IGM .TypeMetadataPtrTy );
3439
- setTypeMetadataName (IGF.IGM , value, type);
3440
- IGF.bindLocalTypeDataFromTypeMetadata (type, IsExact, value, metadataState);
3452
+ break ;
3453
+ }
3441
3454
}
3442
3455
}
3443
3456
3444
3457
namespace {
3445
3458
// / A class for expanding a polymorphic signature.
3446
3459
class ExpandPolymorphicSignature : public PolymorphicConvention {
3460
+ unsigned numShapes = 0 ;
3447
3461
unsigned numTypeMetadataPtrs = 0 ;
3462
+ unsigned numWitnessTablePtrs = 0 ;
3448
3463
3449
3464
public:
3450
3465
ExpandPolymorphicSignature (IRGenModule &IGM, CanSILFunctionType fn)
3451
3466
: PolymorphicConvention(IGM, fn) {}
3452
3467
3453
- unsigned
3468
+ ExpandedSignature
3454
3469
expand (SmallVectorImpl<llvm::Type *> &out,
3455
3470
SmallVectorImpl<PolymorphicSignatureExpandedTypeSource> *reqs) {
3456
3471
auto outStartSize = out.size ();
@@ -3461,17 +3476,24 @@ namespace {
3461
3476
enumerateUnfulfilledRequirements ([&](GenericRequirement reqt) {
3462
3477
if (reqs)
3463
3478
reqs->push_back (reqt);
3464
- out.push_back (reqt.isWitnessTable () ? IGM.WitnessTablePtrTy
3465
- : IGM.TypeMetadataPtrTy );
3466
-
3467
- if (reqt.isMetadata ())
3479
+ switch (reqt.getKind ()) {
3480
+ case GenericRequirement::Kind::Shape:
3481
+ out.push_back (IGM.SizeTy );
3482
+ ++numShapes;
3483
+ break ;
3484
+ case GenericRequirement::Kind::Metadata:
3485
+ out.push_back (IGM.TypeMetadataPtrTy );
3468
3486
++numTypeMetadataPtrs;
3469
- else
3470
- assert (reqt.isWitnessTable ());
3487
+ break ;
3488
+ case GenericRequirement::Kind::WitnessTable:
3489
+ out.push_back (IGM.WitnessTablePtrTy );
3490
+ ++numWitnessTablePtrs;
3491
+ break ;
3492
+ }
3471
3493
});
3472
3494
assert ((!reqs || reqs->size () == (out.size () - outStartSize)) &&
3473
3495
" missing type source for type" );
3474
- return numTypeMetadataPtrs;
3496
+ return {numShapes, numTypeMetadataPtrs, numWitnessTablePtrs} ;
3475
3497
}
3476
3498
3477
3499
private:
@@ -3499,7 +3521,7 @@ namespace {
3499
3521
} // end anonymous namespace
3500
3522
3501
3523
// / Given a generic signature, add the argument types required in order to call it.
3502
- unsigned irgen::expandPolymorphicSignature (
3524
+ ExpandedSignature irgen::expandPolymorphicSignature (
3503
3525
IRGenModule &IGM, CanSILFunctionType polyFn,
3504
3526
SmallVectorImpl<llvm::Type *> &out,
3505
3527
SmallVectorImpl<PolymorphicSignatureExpandedTypeSource> *outReqs) {
0 commit comments