Skip to content

Commit 1944254

Browse files
committed
SIL: Use SILFunction type lowering APIs in various places
1 parent d1cf8c9 commit 1944254

15 files changed

+44
-44
lines changed

lib/IRGen/GenType.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ llvm::PointerType *IRGenModule::getStoragePointerTypeForLowered(CanType T) {
14561456
}
14571457

14581458
llvm::Type *IRGenModule::getStorageTypeForUnlowered(Type subst) {
1459-
return getStorageType(getSILTypes().getLoweredType(subst));
1459+
return getStorageType(getLoweredType(subst));
14601460
}
14611461

14621462
llvm::Type *IRGenModule::getStorageType(SILType T) {
@@ -1486,7 +1486,7 @@ IRGenModule::getTypeInfoForUnlowered(AbstractionPattern orig, Type subst) {
14861486
/// have yet undergone SIL type lowering.
14871487
const TypeInfo &
14881488
IRGenModule::getTypeInfoForUnlowered(AbstractionPattern orig, CanType subst) {
1489-
return getTypeInfo(getSILTypes().getLoweredType(orig, subst));
1489+
return getTypeInfo(getLoweredType(orig, subst));
14901490
}
14911491

14921492
/// Get the fragile type information for the given type, which is known

lib/IRGen/LoadableByAddress.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,8 +2221,8 @@ static void rewriteFunction(StructLoweringState &pass,
22212221
retBuilder.createStore(regLoc, retOp, retArg,
22222222
getStoreInitOwnership(pass, retOp->getType()));
22232223
}
2224-
auto emptyTy = retBuilder.getModule().Types.getLoweredType(
2225-
TupleType::getEmpty(retBuilder.getModule().getASTContext()));
2224+
auto emptyTy = SILType::getPrimitiveObjectType(
2225+
retBuilder.getModule().getASTContext().TheEmptyTupleType);
22262226
auto newRetTuple = retBuilder.createTuple(regLoc, emptyTy, {});
22272227
retBuilder.createReturn(newRetTuple->getLoc(), newRetTuple);
22282228
instr->eraseFromParent();

lib/ParseSIL/ParseSIL.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4767,8 +4767,9 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
47674767
= OpenedArchetypeType::get(Val->getType().getASTType())
47684768
->getCanonicalType();
47694769

4770-
SILType LoweredTy = SILMod.Types.getLoweredType(
4771-
Lowering::AbstractionPattern(archetype), Ty)
4770+
auto &F = B.getFunction();
4771+
SILType LoweredTy = F.getLoweredType(
4772+
Lowering::AbstractionPattern(archetype), Ty)
47724773
.getAddressType();
47734774

47744775
// Collect conformances for the type.

lib/SIL/DynamicCasts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ namespace {
798798

799799
private:
800800
const TypeLowering &getTypeLowering(SILType type) {
801-
return M.Types.getTypeLowering(type);
801+
return B.getFunction().getTypeLowering(type);
802802
}
803803

804804
SILValue getOwnedScalar(Source source, const TypeLowering &srcTL) {

lib/SIL/SILOpenedArchetypesTracker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,20 @@ bool SILOpenedArchetypesTracker::registerUsedOpenedArchetypes(CanType Ty) {
6262
return;
6363

6464
auto *CurF = const_cast<SILFunction *>(this->getFunction());
65-
auto &SILMod = CurF->getModule();
65+
6666
// Create a placeholder representing a forward definition.
6767
// Add the placeholder at the beginning of the entry block.
6868
SingleValueInstruction *Placeholder;
6969
if (!CurF->getEntryBlock()->empty()) {
7070
SILBuilder B(CurF->getEntryBlock()->begin());
7171
Placeholder =
7272
B.createGlobalAddr(ArtificialUnreachableLocation(),
73-
SILMod.Types.getLoweredType(archetypeTy));
73+
SILType::getPrimitiveAddressType(archetypeTy));
7474
} else {
7575
SILBuilder B(CurF->getEntryBlock());
7676
Placeholder =
7777
B.createGlobalAddr(ArtificialUnreachableLocation(),
78-
SILMod.Types.getLoweredType(archetypeTy));
78+
SILType::getPrimitiveAddressType(archetypeTy));
7979
}
8080
// Make it available to SILBuilder, so that instructions using this
8181
// archetype can be constructed.

lib/SIL/SILVerifier.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,10 +2069,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
20692069
SILType exType = AEBI->getExistentialType();
20702070
auto archetype = OpenedArchetypeType::get(exType.getASTType());
20712071

2072-
auto loweredTy = F.getModule().Types.getLoweredType(
2073-
Lowering::AbstractionPattern(archetype),
2074-
AEBI->getFormalConcreteType())
2075-
.getAddressType();
2072+
auto loweredTy = F.getLoweredType(Lowering::AbstractionPattern(archetype),
2073+
AEBI->getFormalConcreteType())
2074+
.getAddressType();
20762075

20772076
requireSameType(loweredTy, PEBI->getType(),
20782077
"project_existential_box result should be the lowered "
@@ -3120,9 +3119,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
31203119
// The lowered type must be the properly-abstracted form of the AST type.
31213120
auto archetype = OpenedArchetypeType::get(exType.getASTType());
31223121

3123-
auto loweredTy = F.getModule().Types.getLoweredType(
3124-
Lowering::AbstractionPattern(archetype),
3125-
AEI->getFormalConcreteType())
3122+
auto loweredTy = F.getLoweredType(Lowering::AbstractionPattern(archetype),
3123+
AEI->getFormalConcreteType())
31263124
.getAddressType();
31273125

31283126
requireSameType(loweredTy, AEI->getLoweredConcreteType(),
@@ -3149,8 +3147,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
31493147
// The operand must be at the right abstraction level for the existential.
31503148
SILType exType = IEI->getType();
31513149
auto archetype = OpenedArchetypeType::get(exType.getASTType());
3152-
auto loweredTy = F.getModule().Types.getLoweredType(
3153-
Lowering::AbstractionPattern(archetype), IEI->getFormalConcreteType());
3150+
auto loweredTy = F.getLoweredType(Lowering::AbstractionPattern(archetype),
3151+
IEI->getFormalConcreteType());
31543152
requireSameType(
31553153
concreteType, loweredTy,
31563154
"init_existential_value operand must be lowered to the right "
@@ -3181,9 +3179,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
31813179
// The operand must be at the right abstraction level for the existential.
31823180
SILType exType = IEI->getType();
31833181
auto archetype = OpenedArchetypeType::get(exType.getASTType());
3184-
auto loweredTy = F.getModule().Types.getLoweredType(
3185-
Lowering::AbstractionPattern(archetype),
3186-
IEI->getFormalConcreteType());
3182+
auto loweredTy = F.getLoweredType(Lowering::AbstractionPattern(archetype),
3183+
IEI->getFormalConcreteType());
31873184
requireSameType(concreteType, loweredTy,
31883185
"init_existential_ref operand must be lowered to the right "
31893186
"abstraction level for the existential");
@@ -3333,8 +3330,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
33333330
"downcast operand must be a class type");
33343331
require(toCanTy.getClassOrBoundGenericClass(),
33353332
"downcast must convert to a class type");
3336-
require(SILType::getPrimitiveObjectType(fromCanTy).
3337-
isBindableToSuperclassOf(SILType::getPrimitiveObjectType(toCanTy)),
3333+
require(fromCanTy->isBindableToSuperclassOf(toCanTy),
33383334
"downcast must convert to a subclass");
33393335
}
33403336
}

lib/SILGen/ArgumentSource.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ ManagedValue ArgumentSource::materialize(SILGenFunction &SGF,
189189
SILType destType) && {
190190
auto substFormalType = getSubstRValueType();
191191
assert(!destType || destType.getObjectType() ==
192-
SGF.SGM.Types.getLoweredType(origFormalType,
193-
substFormalType).getObjectType());
192+
SGF.getLoweredType(origFormalType,
193+
substFormalType).getObjectType());
194194

195195
// Fast path: if the types match exactly, no abstraction difference
196196
// is possible and we can just materialize as normal.

lib/SILGen/SILGenApply.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
904904
// If we are already the right rep, just return.
905905
auto givenMetatypeRep = givenMetatype->getRepresentation();
906906
if (givenMetatypeRep == destMetatypeRep) {
907-
return {selfMeta, SGF.SGM.getLoweredType(instanceType)};
907+
return {selfMeta, SGF.getLoweredType(instanceType)};
908908
}
909909

910910
CanAnyMetatypeType destMetatype;
@@ -939,7 +939,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
939939
}
940940

941941
auto result = ManagedValue::forUnmanaged(convertedValue);
942-
return {result, SGF.SGM.getLoweredType(instanceType)};
942+
return {result, SGF.getLoweredType(instanceType)};
943943
}
944944

945945
/// Given a metatype value for the type, allocate an Objective-C

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,7 @@ emitKeyPathRValueBase(SILGenFunction &subSGF,
25772577

25782578
baseType = opened->getCanonicalType();
25792579
auto openedOpaqueValue = subSGF.emitOpenExistential(loc, paramSubstValue,
2580-
opened, subSGF.SGM.getLoweredType(baseType),
2580+
opened, subSGF.getLoweredType(baseType),
25812581
AccessKind::Read);
25822582
// Maybe we could peephole this if we know the property load can borrow the
25832583
// base value…

lib/SILGen/SILGenLValue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2452,7 +2452,7 @@ void LValue::addNonMemberVarComponent(SILGenFunction &SGF, SILLocation loc,
24522452
void emitUsingAddressor(SILDeclRef addressor, bool isDirect,
24532453
LValueTypeData typeData) {
24542454
SILType storageType =
2455-
SGF.SGM.Types.getLoweredType(Storage->getType()).getAddressType();
2455+
SGF.getLoweredType(Storage->getType()).getAddressType();
24562456
LV.add<AddressorComponent>(Storage, addressor,
24572457
/*isSuper=*/false, isDirect, getSubs(),
24582458
CanType(), typeData, storageType, nullptr,

0 commit comments

Comments
 (0)