Skip to content

Commit 6b3e1b3

Browse files
committed
SIL: Add TypeExpansion to SIL type lowering
1 parent 8ec3a77 commit 6b3e1b3

File tree

5 files changed

+628
-349
lines changed

5 files changed

+628
-349
lines changed

include/swift/SIL/SILType.h

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class SILType {
244244
/// tc.getTypeLowering(type).isAddressOnly().
245245
static bool isAddressOnly(CanType type, Lowering::TypeConverter &tc,
246246
CanGenericSignature sig,
247-
ResilienceExpansion expansion);
247+
TypeExpansionContext expansion);
248248

249249
/// Return true if this type must be returned indirectly.
250250
///
@@ -253,7 +253,7 @@ class SILType {
253253
static bool isFormallyReturnedIndirectly(CanType type,
254254
Lowering::TypeConverter &tc,
255255
CanGenericSignature sig) {
256-
return isAddressOnly(type, tc, sig, ResilienceExpansion::Minimal);
256+
return isAddressOnly(type, tc, sig, TypeExpansionContext::minimal());
257257
}
258258

259259
/// Return true if this type must be passed indirectly.
@@ -263,7 +263,7 @@ class SILType {
263263
static bool isFormallyPassedIndirectly(CanType type,
264264
Lowering::TypeConverter &tc,
265265
CanGenericSignature sig) {
266-
return isAddressOnly(type, tc, sig, ResilienceExpansion::Minimal);
266+
return isAddressOnly(type, tc, sig, TypeExpansionContext::minimal());
267267
}
268268

269269
/// True if the type, or the referenced type of an address type, is loadable.
@@ -411,16 +411,20 @@ class SILType {
411411
/// the given field. Applies substitutions as necessary. The
412412
/// result will be an address type if the base type is an address
413413
/// type or a class.
414-
SILType getFieldType(VarDecl *field, Lowering::TypeConverter &TC) const;
414+
SILType getFieldType(VarDecl *field, Lowering::TypeConverter &TC,
415+
TypeExpansionContext context) const;
415416

416-
SILType getFieldType(VarDecl *field, SILModule &M) const;
417+
SILType getFieldType(VarDecl *field, SILModule &M,
418+
TypeExpansionContext context) const;
417419

418420
/// Given that this is an enum type, return the lowered type of the
419421
/// data for the given element. Applies substitutions as necessary.
420422
/// The result will have the same value category as the base type.
421-
SILType getEnumElementType(EnumElementDecl *elt, Lowering::TypeConverter &TC) const;
423+
SILType getEnumElementType(EnumElementDecl *elt, Lowering::TypeConverter &TC,
424+
TypeExpansionContext context) const;
422425

423-
SILType getEnumElementType(EnumElementDecl *elt, SILModule &M) const;
426+
SILType getEnumElementType(EnumElementDecl *elt, SILModule &M,
427+
TypeExpansionContext context) const;
424428

425429
/// Given that this is a tuple type, return the lowered type of the
426430
/// given tuple element. The result will have the same value
@@ -458,11 +462,11 @@ class SILType {
458462
/// generic args with the appropriate item from the substitution.
459463
///
460464
/// Only call this with function types!
461-
SILType substGenericArgs(Lowering::TypeConverter &TC,
462-
SubstitutionMap SubMap) const;
465+
SILType substGenericArgs(Lowering::TypeConverter &TC, SubstitutionMap SubMap,
466+
TypeExpansionContext context) const;
463467

464-
SILType substGenericArgs(SILModule &M,
465-
SubstitutionMap SubMap) const;
468+
SILType substGenericArgs(SILModule &M, SubstitutionMap SubMap,
469+
TypeExpansionContext context) const;
466470

467471
/// If the original type is generic, pass the signature as genericSig.
468472
///
@@ -487,8 +491,9 @@ class SILType {
487491
bool isHeapObjectReferenceType() const;
488492

489493
/// Returns true if this SILType is an aggregate that contains \p Ty
490-
bool aggregateContainsRecord(SILType Ty, SILModule &SILMod) const;
491-
494+
bool aggregateContainsRecord(SILType Ty, SILModule &SILMod,
495+
TypeExpansionContext context) const;
496+
492497
/// Returns true if this SILType is an aggregate with unreferenceable storage,
493498
/// meaning it cannot be fully destructured in SIL.
494499
bool aggregateHasUnreferenceableStorage() const;
@@ -515,7 +520,8 @@ class SILType {
515520

516521
/// Returns true if this SILType could be potentially a lowering of the given
517522
/// formal type. Meant for verification purposes/assertions.
518-
bool isLoweringOf(SILModule &M, CanType formalType);
523+
bool isLoweringOf(TypeExpansionContext context, SILModule &M,
524+
CanType formalType);
519525

520526
/// Returns the hash code for the SILType.
521527
llvm::hash_code getHashCode() const {
@@ -589,8 +595,9 @@ NON_SIL_TYPE(LValue)
589595
#undef NON_SIL_TYPE
590596

591597
CanSILFunctionType getNativeSILFunctionType(
592-
Lowering::TypeConverter &TC, Lowering::AbstractionPattern origType,
593-
CanAnyFunctionType substType, Optional<SILDeclRef> origConstant = None,
598+
Lowering::TypeConverter &TC, TypeExpansionContext context,
599+
Lowering::AbstractionPattern origType, CanAnyFunctionType substType,
600+
Optional<SILDeclRef> origConstant = None,
594601
Optional<SILDeclRef> constant = None,
595602
Optional<SubstitutionMap> reqtSubs = None,
596603
ProtocolConformanceRef witnessMethodConformance = ProtocolConformanceRef());
@@ -616,15 +623,15 @@ inline SILType SILField::getObjectType() const {
616623
return SILType::getPrimitiveObjectType(getLoweredType());
617624
}
618625

619-
CanType getSILBoxFieldLoweredType(SILBoxType *type,
620-
Lowering::TypeConverter &TC,
626+
CanType getSILBoxFieldLoweredType(TypeExpansionContext context,
627+
SILBoxType *type, Lowering::TypeConverter &TC,
621628
unsigned index);
622629

623-
inline SILType getSILBoxFieldType(SILBoxType *type,
624-
Lowering::TypeConverter &TC,
630+
inline SILType getSILBoxFieldType(TypeExpansionContext context,
631+
SILBoxType *type, Lowering::TypeConverter &TC,
625632
unsigned index) {
626633
return SILType::getPrimitiveAddressType(
627-
getSILBoxFieldLoweredType(type, TC, index));
634+
getSILBoxFieldLoweredType(context, type, TC, index));
628635
}
629636

630637
} // end swift namespace

0 commit comments

Comments
 (0)