Shorten "TypeLoweringInfo" to "TypeLowering".

Swift SVN r6795
This commit is contained in:
John McCall
2013-08-01 01:28:34 +00:00
parent e98ab3d83a
commit f46ffb3382
11 changed files with 87 additions and 88 deletions

View File

@@ -660,7 +660,7 @@ public:
/// Emit the instruction sequence needed to destroy (but not deallocate) /// Emit the instruction sequence needed to destroy (but not deallocate)
/// a value in memory. /// a value in memory.
void emitDestroyAddress(SILLocation Loc, SILValue addr) { void emitDestroyAddress(SILLocation Loc, SILValue addr) {
auto &ti = F.getModule().getTypeLoweringInfo(addr.getType()); auto &ti = F.getModule().getTypeLowering(addr.getType());
if (ti.isTrivial()) if (ti.isTrivial())
return; return;
if (ti.isAddressOnly()) if (ti.isAddressOnly())
@@ -672,10 +672,10 @@ public:
/// Emit the instruction sequence needed to retain a value, which must not /// Emit the instruction sequence needed to retain a value, which must not
/// be an address. /// be an address.
void emitRetainValue(SILLocation Loc, SILValue v) { void emitRetainValue(SILLocation Loc, SILValue v) {
emitRetainValueImpl(Loc, v, F.getModule().getTypeLoweringInfo(v.getType())); emitRetainValueImpl(Loc, v, F.getModule().getTypeLowering(v.getType()));
} }
void emitReleaseValue(SILLocation Loc, SILValue v) { void emitReleaseValue(SILLocation Loc, SILValue v) {
emitReleaseValueImpl(Loc, v, F.getModule().getTypeLoweringInfo(v.getType())); emitReleaseValueImpl(Loc, v, F.getModule().getTypeLowering(v.getType()));
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@@ -710,9 +710,9 @@ private:
} }
void emitRetainValueImpl(SILLocation Loc, SILValue v, void emitRetainValueImpl(SILLocation Loc, SILValue v,
const Lowering::TypeLoweringInfo &ti); const Lowering::TypeLowering &ti);
void emitReleaseValueImpl(SILLocation Loc, SILValue v, void emitReleaseValueImpl(SILLocation Loc, SILValue v,
const Lowering::TypeLoweringInfo &ti); const Lowering::TypeLowering &ti);
}; };
} // end swift namespace } // end swift namespace

View File

@@ -110,9 +110,9 @@ public:
/// \brief This converts Swift types to SILTypes. /// \brief This converts Swift types to SILTypes.
Lowering::TypeConverter Types; Lowering::TypeConverter Types;
/// Look up the TypeLoweringInfo for a SILType. /// Look up the TypeLowering for a SILType.
const Lowering::TypeLoweringInfo &getTypeLoweringInfo(SILType t) { const Lowering::TypeLowering &getTypeLowering(SILType t) {
return Types.getTypeLoweringInfo(t); return Types.getTypeLowering(t);
} }
/// Construct a SIL module from a translation unit. The module will be /// Construct a SIL module from a translation unit. The module will be

View File

@@ -120,8 +120,8 @@ struct ReferenceTypePath {
llvm::SmallVector<Component, 4> path; llvm::SmallVector<Component, 4> path;
}; };
/// TypeLoweringInfo - Extended type information used by SILGen. /// TypeLowering - Extended type information used by SILGen.
class TypeLoweringInfo { class TypeLowering {
public: public:
enum IsTrivial_t : bool { IsNotTrivial, IsTrivial }; enum IsTrivial_t : bool { IsNotTrivial, IsTrivial };
enum IsAddressOnly_t : bool { IsNotAddressOnly, IsAddressOnly }; enum IsAddressOnly_t : bool { IsNotAddressOnly, IsAddressOnly };
@@ -137,15 +137,15 @@ private:
}; };
protected: protected:
TypeLoweringInfo(SILType type, IsTrivial_t isTrivial, TypeLowering(SILType type, IsTrivial_t isTrivial,
IsAddressOnly_t isAddressOnly) IsAddressOnly_t isAddressOnly)
: LoweredTypeAndFlags(type, : LoweredTypeAndFlags(type,
(isTrivial ? IsTrivialFlag : 0U) | (isTrivial ? IsTrivialFlag : 0U) |
(isAddressOnly ? IsAddressOnlyFlag : 0U)) {} (isAddressOnly ? IsAddressOnlyFlag : 0U)) {}
public: public:
TypeLoweringInfo(const TypeLoweringInfo &) = delete; TypeLowering(const TypeLowering &) = delete;
TypeLoweringInfo &operator=(const TypeLoweringInfo &) = delete; TypeLowering &operator=(const TypeLowering &) = delete;
/// isAddressOnly - Returns true if the type is an address-only type. A type /// isAddressOnly - Returns true if the type is an address-only type. A type
/// is address-only if it is a resilient value type, or if it is a fragile /// is address-only if it is a resilient value type, or if it is a fragile
@@ -172,8 +172,8 @@ public:
SILType getLoweredType() const { SILType getLoweredType() const {
return LoweredTypeAndFlags.getPointer(); return LoweredTypeAndFlags.getPointer();
} }
/// Allocate a new TypeLoweringInfo using the TypeConverter's allocator. /// Allocate a new TypeLowering using the TypeConverter's allocator.
void *operator new(size_t size, TypeConverter &tc); void *operator new(size_t size, TypeConverter &tc);
void *operator new(size_t) = delete; void *operator new(size_t) = delete;
@@ -186,11 +186,11 @@ enum class UncurryDirection {
RightToLeft RightToLeft
}; };
/// TypeConverter - helper class for creating and managing TypeLoweringInfos. /// TypeConverter - helper class for creating and managing TypeLowerings.
class TypeConverter { class TypeConverter {
friend class TypeLoweringInfo; friend class TypeLowering;
llvm::BumpPtrAllocator TypeLoweringInfoBPA; llvm::BumpPtrAllocator TypeLoweringBPA;
enum : unsigned { enum : unsigned {
/// There is a unique entry with this uncurry level in the /// There is a unique entry with this uncurry level in the
@@ -204,7 +204,7 @@ class TypeConverter {
return {t.getPointer(), uncurryLevel}; return {t.getPointer(), uncurryLevel};
} }
llvm::DenseMap<TypeKey, const TypeLoweringInfo *> Types; llvm::DenseMap<TypeKey, const TypeLowering *> Types;
llvm::DenseMap<SILDeclRef, SILType> constantTypes; llvm::DenseMap<SILDeclRef, SILType> constantTypes;
Type makeConstantType(SILDeclRef constant); Type makeConstantType(SILDeclRef constant);
@@ -215,8 +215,8 @@ class TypeConverter {
Optional<CanType> NativeType##Ty; Optional<CanType> NativeType##Ty;
#include "swift/SIL/BridgedTypes.def" #include "swift/SIL/BridgedTypes.def"
const TypeLoweringInfo &getTypeLoweringInfoForLoweredType(CanType type); const TypeLowering &getTypeLoweringForLoweredType(CanType type);
const TypeLoweringInfo &getTypeLoweringInfoForUncachedLoweredType(CanType type); const TypeLowering &getTypeLoweringForUncachedLoweredType(CanType type);
public: public:
SILModule &M; SILModule &M;
@@ -227,18 +227,18 @@ public:
TypeConverter(TypeConverter const &) = delete; TypeConverter(TypeConverter const &) = delete;
TypeConverter &operator=(TypeConverter const &) = delete; TypeConverter &operator=(TypeConverter const &) = delete;
/// Lowers a Swift type to a SILType, and returns the SIL TypeLoweringInfo /// Lowers a Swift type to a SILType, and returns the SIL TypeLowering
/// for that type. /// for that type.
const TypeLoweringInfo &getTypeLoweringInfo(Type t,unsigned uncurryLevel = 0); const TypeLowering &getTypeLowering(Type t,unsigned uncurryLevel = 0);
/// Returns the SIL TypeLoweringInfo for an already lowered SILType. If the /// Returns the SIL TypeLowering for an already lowered SILType. If the
/// SILType is an address, returns the TypeLoweringInfo for the pointed-to /// SILType is an address, returns the TypeLowering for the pointed-to
/// type. /// type.
const TypeLoweringInfo &getTypeLoweringInfo(SILType t); const TypeLowering &getTypeLowering(SILType t);
// Returns the lowered SIL type for a Swift type. // Returns the lowered SIL type for a Swift type.
SILType getLoweredType(Type t, unsigned uncurryLevel = 0) { SILType getLoweredType(Type t, unsigned uncurryLevel = 0) {
return getTypeLoweringInfo(t, uncurryLevel).getLoweredType(); return getTypeLowering(t, uncurryLevel).getLoweredType();
} }
/// Returns the SIL type of a constant reference. /// Returns the SIL type of a constant reference.

View File

@@ -204,7 +204,7 @@ static bool optimizeAllocBox(AllocBoxInst *ABI,
ReleaseInst *LastRelease = getLastRelease(ABI, Users, Releases, PDI); ReleaseInst *LastRelease = getLastRelease(ABI, Users, Releases, PDI);
bool isTrivial = ABI->getModule()->Types. bool isTrivial = ABI->getModule()->Types.
getTypeLoweringInfo(ABI->getElementType()).isTrivial(); getTypeLowering(ABI->getElementType()).isTrivial();
if (LastRelease == nullptr && !isTrivial) { if (LastRelease == nullptr && !isTrivial) {
// If we can't tell where the last release is, we don't know where to insert // If we can't tell where the last release is, we don't know where to insert

View File

@@ -19,14 +19,14 @@ static void rrLoadableValue(SILBuilder &B, SILLocation loc, SILValue v,
void (SILBuilder::*createRR)(SILLocation, SILValue)) { void (SILBuilder::*createRR)(SILLocation, SILValue)) {
auto type = v.getType().getSwiftRValueType(); auto type = v.getType().getSwiftRValueType();
// TODO: abstract this into TypeLoweringInfo // TODO: abstract this into TypeLowering
if (auto tupleTy = dyn_cast<TupleType>(type)) { if (auto tupleTy = dyn_cast<TupleType>(type)) {
unsigned i = 0; unsigned i = 0;
for (auto eltTy : tupleTy.getElementTypes()) { for (auto eltTy : tupleTy.getElementTypes()) {
auto curIndex = i++; auto curIndex = i++;
auto &eltTI = auto &eltTI =
B.getFunction().getParent()->Types.getTypeLoweringInfo(eltTy); B.getFunction().getParent()->Types.getTypeLowering(eltTy);
if (eltTI.isTrivial()) continue; if (eltTI.isTrivial()) continue;
auto eltVal = B.createTupleExtract(loc, v, curIndex, eltTI.getLoweredType()); auto eltVal = B.createTupleExtract(loc, v, curIndex, eltTI.getLoweredType());
rrLoadableValue(B, loc, eltVal, createRR); rrLoadableValue(B, loc, eltVal, createRR);
@@ -41,7 +41,7 @@ static void rrLoadableValue(SILBuilder &B, SILLocation loc, SILValue v,
if (!field || field->isProperty()) continue; if (!field || field->isProperty()) continue;
auto &fieldTI = B.getFunction().getParent()->Types auto &fieldTI = B.getFunction().getParent()->Types
.getTypeLoweringInfo(field->getType()); .getTypeLowering(field->getType());
if (fieldTI.isTrivial()) continue; if (fieldTI.isTrivial()) continue;
auto fieldVal = B.createStructExtract(loc, v, field, auto fieldVal = B.createStructExtract(loc, v, field,
fieldTI.getLoweredType()); fieldTI.getLoweredType());
@@ -55,7 +55,7 @@ static void rrLoadableValue(SILBuilder &B, SILLocation loc, SILValue v,
} }
void SILBuilder::emitRetainValueImpl(SILLocation loc, SILValue v, void SILBuilder::emitRetainValueImpl(SILLocation loc, SILValue v,
const TypeLoweringInfo &ti) { const TypeLowering &ti) {
assert(!v.getType().isAddress() && assert(!v.getType().isAddress() &&
"emitRetainRValue cannot retain an address"); "emitRetainRValue cannot retain an address");
if (ti.isTrivial()) return; if (ti.isTrivial()) return;
@@ -64,7 +64,7 @@ void SILBuilder::emitRetainValueImpl(SILLocation loc, SILValue v,
} }
void SILBuilder::emitReleaseValueImpl(SILLocation loc, SILValue v, void SILBuilder::emitReleaseValueImpl(SILLocation loc, SILValue v,
const TypeLoweringInfo &ti) { const TypeLowering &ti) {
assert(!v.getType().isAddress() && assert(!v.getType().isAddress() &&
"emitReleaseRValue cannot release an address"); "emitReleaseRValue cannot release an address");
if (ti.isTrivial()) return; if (ti.isTrivial()) return;

View File

@@ -174,8 +174,8 @@ public:
// the new. // the new.
assert(!getType().isAddress() && assert(!getType().isAddress() &&
"can't assign loadable type from address"); "can't assign loadable type from address");
const TypeLoweringInfo &ti const TypeLowering &ti
= gen.getTypeLoweringInfo(getType().getSwiftRValueType()); = gen.getTypeLowering(getType().getSwiftRValueType());
SILValue old; SILValue old;

View File

@@ -92,7 +92,7 @@ public:
/// Get the lowered type for a Swift type. /// Get the lowered type for a Swift type.
SILType getLoweredType(Type t) { SILType getLoweredType(Type t) {
return Types.getTypeLoweringInfo(t).getLoweredType(); return Types.getTypeLowering(t).getLoweredType();
} }
/// Generate the mangled symbol name for a SILDeclRef. /// Generate the mangled symbol name for a SILDeclRef.
@@ -356,15 +356,14 @@ public:
SILFunction &getFunction() { return F; } SILFunction &getFunction() { return F; }
SILBuilder &getBuilder() { return B; } SILBuilder &getBuilder() { return B; }
const TypeLoweringInfo &getTypeLoweringInfo(Type t, const TypeLowering &getTypeLowering(Type t, unsigned uncurryLevel = 0) {
unsigned uncurryLevel = 0) { return SGM.Types.getTypeLowering(t, uncurryLevel);
return SGM.Types.getTypeLoweringInfo(t, uncurryLevel);
} }
SILType getLoweredType(Type t, unsigned uncurryLevel = 0) { SILType getLoweredType(Type t, unsigned uncurryLevel = 0) {
return getTypeLoweringInfo(t, uncurryLevel).getLoweredType(); return getTypeLowering(t, uncurryLevel).getLoweredType();
} }
SILType getLoweredLoadableType(Type t, unsigned uncurryLevel = 0) { SILType getLoweredLoadableType(Type t, unsigned uncurryLevel = 0) {
const TypeLoweringInfo &ti = getTypeLoweringInfo(t, uncurryLevel); const TypeLowering &ti = getTypeLowering(t, uncurryLevel);
assert(ti.isLoadable() && "unexpected address-only type"); assert(ti.isLoadable() && "unexpected address-only type");
return ti.getLoweredType(); return ti.getLoweredType();
} }

View File

@@ -653,7 +653,7 @@ ManagedValue SILGenFunction::emitApply(SILLocation Loc,
// Get the result type. // Get the result type.
Type resultTy = Fn.getType().getFunctionResultType(); Type resultTy = Fn.getType().getFunctionResultType();
const TypeLoweringInfo &resultTI = getTypeLoweringInfo(resultTy); const TypeLowering &resultTI = getTypeLowering(resultTy);
SILType instructionTy = resultTI.getLoweredType(); SILType instructionTy = resultTI.getLoweredType();
// Get the callee value. // Get the callee value.
@@ -989,7 +989,7 @@ namespace {
assert(substitutions.size() == 1 && assert(substitutions.size() == 1 &&
"destroy should have a single substitution"); "destroy should have a single substitution");
// The substitution determines the type of the thing we're destroying. // The substitution determines the type of the thing we're destroying.
auto &ti = gen.getTypeLoweringInfo(substitutions[0].Replacement); auto &ti = gen.getTypeLowering(substitutions[0].Replacement);
// Destroy is a no-op for trivial types. // Destroy is a no-op for trivial types.
if (ti.isTrivial()) if (ti.isTrivial())

View File

@@ -562,7 +562,7 @@ static void emitCaptureArguments(SILGenFunction &gen, ValueDecl *capture) {
// Constants are captured by value. // Constants are captured by value.
assert(!capture->getType()->is<LValueType>() && assert(!capture->getType()->is<LValueType>() &&
"capturing byref by value?!"); "capturing byref by value?!");
const TypeLoweringInfo &ti = gen.getTypeLoweringInfo(capture->getType()); const TypeLowering &ti = gen.getTypeLowering(capture->getType());
SILValue value = new (gen.SGM.M) SILArgument(ti.getLoweredType(), SILValue value = new (gen.SGM.M) SILArgument(ti.getLoweredType(),
gen.F.begin()); gen.F.begin());
gen.LocalConstants[SILDeclRef(capture)] = value; gen.LocalConstants[SILDeclRef(capture)] = value;
@@ -609,7 +609,7 @@ void SILGenFunction::emitProlog(CapturingExpr *ce,
void SILGenFunction::emitProlog(ArrayRef<Pattern *> paramPatterns, void SILGenFunction::emitProlog(ArrayRef<Pattern *> paramPatterns,
Type resultType) { Type resultType) {
// If the return type is address-only, emit the indirect return argument. // If the return type is address-only, emit the indirect return argument.
const TypeLoweringInfo &returnTI = getTypeLoweringInfo(resultType); const TypeLowering &returnTI = getTypeLowering(resultType);
if (returnTI.isAddressOnly()) { if (returnTI.isAddressOnly()) {
IndirectReturnAddress = new (SGM.M) SILArgument(returnTI.getLoweredType(), IndirectReturnAddress = new (SGM.M) SILArgument(returnTI.getLoweredType(),
F.begin()); F.begin());
@@ -689,7 +689,7 @@ void SILGenFunction::prepareEpilog(Type resultType) {
// If we have a non-null, non-void, non-address-only return type, receive the // If we have a non-null, non-void, non-address-only return type, receive the
// return value via a BB argument. // return value via a BB argument.
if (resultType && !resultType->isVoid()) { if (resultType && !resultType->isVoid()) {
auto &resultTI = getTypeLoweringInfo(resultType); auto &resultTI = getTypeLowering(resultType);
if (!resultTI.isAddressOnly()) if (!resultTI.isAddressOnly())
new (F.getModule()) SILArgument(resultTI.getLoweredType(), epilogBB); new (F.getModule()) SILArgument(resultTI.getLoweredType(), epilogBB);
} }
@@ -972,7 +972,7 @@ void SILGenFunction::destroyLocalVariable(VarDecl *vd) {
// allocation, so load and destroy the value (or destroy it indirectly if // allocation, so load and destroy the value (or destroy it indirectly if
// it's address-only) then deallocate the variable. // it's address-only) then deallocate the variable.
assert(!loc.box && "fixed-lifetime var shouldn't have been given a box"); assert(!loc.box && "fixed-lifetime var shouldn't have been given a box");
const TypeLoweringInfo &ti = getTypeLoweringInfo(vd->getType()); const TypeLowering &ti = getTypeLowering(vd->getType());
if (!ti.isTrivial()) if (!ti.isTrivial())
B.createDestroyAddr(vd, loc.address); B.createDestroyAddr(vd, loc.address);
B.createDeallocStack(vd, loc.address); B.createDeallocStack(vd, loc.address);

View File

@@ -75,7 +75,7 @@ namespace {
} // end anonymous namespace } // end anonymous namespace
ManagedValue SILGenFunction::emitManagedRValueWithCleanup(SILValue v) { ManagedValue SILGenFunction::emitManagedRValueWithCleanup(SILValue v) {
if (getTypeLoweringInfo(v.getType().getSwiftRValueType()).isTrivial()) { if (getTypeLowering(v.getType().getSwiftRValueType()).isTrivial()) {
return ManagedValue(v, ManagedValue::Unmanaged); return ManagedValue(v, ManagedValue::Unmanaged);
} else if (v.getType().isAddressOnly(SGM.M)) { } else if (v.getType().isAddressOnly(SGM.M)) {
Cleanups.pushCleanup<CleanupMaterializedAddressOnlyValue>(v); Cleanups.pushCleanup<CleanupMaterializedAddressOnlyValue>(v);
@@ -414,7 +414,7 @@ Materialize SILGenFunction::emitMaterialize(SILLocation loc, ManagedValue v) {
v.forwardInto(*this, loc, tmpMem); v.forwardInto(*this, loc, tmpMem);
CleanupsDepth valueCleanup = CleanupsDepth::invalid(); CleanupsDepth valueCleanup = CleanupsDepth::invalid();
if (!getTypeLoweringInfo(v.getType().getSwiftType()).isTrivial()) { if (!getTypeLowering(v.getType().getSwiftType()).isTrivial()) {
Cleanups.pushCleanup<CleanupMaterializedValue>(tmpMem); Cleanups.pushCleanup<CleanupMaterializedValue>(tmpMem);
valueCleanup = getCleanupsDepth(); valueCleanup = getCleanupsDepth();
} }
@@ -1430,7 +1430,7 @@ void SILGenFunction::emitDestructor(ClassDecl *cd, DestructorDecl *dd) {
if (VarDecl *vd = dyn_cast<VarDecl>(member)) { if (VarDecl *vd = dyn_cast<VarDecl>(member)) {
if (vd->isProperty()) if (vd->isProperty())
continue; continue;
const TypeLoweringInfo &ti = getTypeLoweringInfo(vd->getType()); const TypeLowering &ti = getTypeLowering(vd->getType());
if (!ti.isTrivial()) { if (!ti.isTrivial()) {
SILValue addr = B.createRefElementAddr(dd, thisValue, vd, SILValue addr = B.createRefElementAddr(dd, thisValue, vd,
ti.getLoweredType().getAddressType()); ti.getLoweredType().getAddressType());

View File

@@ -462,46 +462,46 @@ bool SILType::isAddressOnly(CanType type, SILModule &M) {
namespace { namespace {
/// A class for trivial, loadable types. /// A class for trivial, loadable types.
class TrivialTypeLoweringInfo : public TypeLoweringInfo { class TrivialTypeLowering : public TypeLowering {
public: public:
TrivialTypeLoweringInfo(SILType type) TrivialTypeLowering(SILType type)
: TypeLoweringInfo(type, IsTrivial, IsNotAddressOnly) {} : TypeLowering(type, IsTrivial, IsNotAddressOnly) {}
}; };
/// A class for non-trivial but loadable types. /// A class for non-trivial but loadable types.
class ScalarTypeLoweringInfo : public TypeLoweringInfo { class ScalarTypeLowering : public TypeLowering {
public: public:
ScalarTypeLoweringInfo(SILType type) ScalarTypeLowering(SILType type)
: TypeLoweringInfo(type, IsNotTrivial, IsNotAddressOnly) {} : TypeLowering(type, IsNotTrivial, IsNotAddressOnly) {}
}; };
/// A class for non-trivial, address-only types. /// A class for non-trivial, address-only types.
class AddressOnlyTypeLoweringInfo : public TypeLoweringInfo { class AddressOnlyTypeLowering : public TypeLowering {
public: public:
AddressOnlyTypeLoweringInfo(SILType type) AddressOnlyTypeLowering(SILType type)
: TypeLoweringInfo(type, IsNotTrivial, IsAddressOnly) {} : TypeLowering(type, IsNotTrivial, IsAddressOnly) {}
}; };
/// Build the appropriate TypeLoweringInfo subclass for the given type. /// Build the appropriate TypeLowering subclass for the given type.
class LowerType : class LowerType :
public TypeClassifierBase<LowerType, const TypeLoweringInfo *> { public TypeClassifierBase<LowerType, const TypeLowering *> {
TypeConverter &TC; TypeConverter &TC;
public: public:
LowerType(TypeConverter &TC) : TypeClassifierBase(TC.M), TC(TC) {} LowerType(TypeConverter &TC) : TypeClassifierBase(TC.M), TC(TC) {}
const TypeLoweringInfo *handleTrivial(CanType type) { const TypeLowering *handleTrivial(CanType type) {
auto silType = SILType::getPrimitiveType(type, false); auto silType = SILType::getPrimitiveType(type, false);
return new (TC) TrivialTypeLoweringInfo(silType); return new (TC) TrivialTypeLowering(silType);
} }
const TypeLoweringInfo *handleScalar(CanType type) { const TypeLowering *handleScalar(CanType type) {
auto silType = SILType::getPrimitiveType(type, false); auto silType = SILType::getPrimitiveType(type, false);
return new (TC) ScalarTypeLoweringInfo(silType); return new (TC) ScalarTypeLowering(silType);
} }
const TypeLoweringInfo *handleAddressOnly(CanType type) { const TypeLowering *handleAddressOnly(CanType type) {
auto silType = SILType::getPrimitiveType(type, true); auto silType = SILType::getPrimitiveType(type, true);
return new (TC) AddressOnlyTypeLoweringInfo(silType); return new (TC) AddressOnlyTypeLowering(silType);
} }
}; };
} }
@@ -512,27 +512,27 @@ TypeConverter::TypeConverter(SILModule &m)
TypeConverter::~TypeConverter() { TypeConverter::~TypeConverter() {
// The bump pointer allocator destructor will deallocate but not destroy all // The bump pointer allocator destructor will deallocate but not destroy all
// our TypeLoweringInfos. // our TypeLowerings.
for (auto &ti : Types) { for (auto &ti : Types) {
// Destroy only the unique entries. // Destroy only the unique entries.
CanType srcType = CanType(ti.first.first); CanType srcType = CanType(ti.first.first);
CanType mappedType = ti.second->getLoweredType().getSwiftRValueType(); CanType mappedType = ti.second->getLoweredType().getSwiftRValueType();
if (srcType == mappedType || isa<LValueType>(srcType)) if (srcType == mappedType || isa<LValueType>(srcType))
ti.second->~TypeLoweringInfo(); ti.second->~TypeLowering();
} }
} }
void *TypeLoweringInfo::operator new(size_t size, TypeConverter &tc) { void *TypeLowering::operator new(size_t size, TypeConverter &tc) {
return tc.TypeLoweringInfoBPA.Allocate<TypeLoweringInfo>(); return tc.TypeLoweringBPA.Allocate<TypeLowering>();
} }
const TypeLoweringInfo & const TypeLowering &
TypeConverter::getTypeLoweringInfo(Type origType, unsigned uncurryLevel) { TypeConverter::getTypeLowering(Type origType, unsigned uncurryLevel) {
CanType type = origType->getCanonicalType(); CanType type = origType->getCanonicalType();
auto key = getTypeKey(type, uncurryLevel); auto key = getTypeKey(type, uncurryLevel);
auto existing = Types.find(key); auto existing = Types.find(key);
if (existing != Types.end()) { if (existing != Types.end()) {
assert(existing->second && "reentered getTypeLoweringInfo"); assert(existing->second && "reentered getTypeLowering");
return *existing->second; return *existing->second;
} }
@@ -544,7 +544,7 @@ TypeConverter::getTypeLoweringInfo(Type origType, unsigned uncurryLevel) {
SILType loweredType = SILType loweredType =
getLoweredType(objectType, uncurryLevel).getAddressType(); getLoweredType(objectType, uncurryLevel).getAddressType();
auto *theInfo = new (*this) TrivialTypeLoweringInfo(loweredType); auto *theInfo = new (*this) TrivialTypeLowering(loweredType);
Types[key] = theInfo; Types[key] = theInfo;
return *theInfo; return *theInfo;
} }
@@ -558,7 +558,7 @@ TypeConverter::getTypeLoweringInfo(Type origType, unsigned uncurryLevel) {
// If the lowering process changed the type, re-check the cache // If the lowering process changed the type, re-check the cache
// and add a cache entry for the unlowered type. // and add a cache entry for the unlowered type.
if (loweredType != type) { if (loweredType != type) {
auto &typeInfo = getTypeLoweringInfoForLoweredType(loweredType); auto &typeInfo = getTypeLoweringForLoweredType(loweredType);
Types[key] = &typeInfo; Types[key] = &typeInfo;
return typeInfo; return typeInfo;
} }
@@ -569,16 +569,16 @@ TypeConverter::getTypeLoweringInfo(Type origType, unsigned uncurryLevel) {
// The Swift type directly corresponds to the lowered type; don't // The Swift type directly corresponds to the lowered type; don't
// re-check the cache. // re-check the cache.
assert(uncurryLevel == 0); assert(uncurryLevel == 0);
return getTypeLoweringInfoForUncachedLoweredType(type); return getTypeLoweringForUncachedLoweredType(type);
} }
const TypeLoweringInfo & const TypeLowering &
TypeConverter::getTypeLoweringInfo(SILType type) { TypeConverter::getTypeLowering(SILType type) {
return getTypeLoweringInfoForLoweredType(type.getSwiftRValueType()); return getTypeLoweringForLoweredType(type.getSwiftRValueType());
} }
const TypeLoweringInfo & const TypeLowering &
TypeConverter::getTypeLoweringInfoForLoweredType(CanType type) { TypeConverter::getTypeLoweringForLoweredType(CanType type) {
assert(!isa<LValueType>(type) && "didn't lower out l-value type?"); assert(!isa<LValueType>(type) && "didn't lower out l-value type?");
// Re-using uncurry level 0 is reasonable because our uncurrying // Re-using uncurry level 0 is reasonable because our uncurrying
@@ -587,16 +587,16 @@ TypeConverter::getTypeLoweringInfoForLoweredType(CanType type) {
auto key = getTypeKey(type, 0); auto key = getTypeKey(type, 0);
auto existing = Types.find(key); auto existing = Types.find(key);
if (existing != Types.end()) { if (existing != Types.end()) {
assert(existing->second && "reentered getTypeLoweringInfoForLoweredType"); assert(existing->second && "reentered getTypeLoweringForLoweredType");
return *existing->second; return *existing->second;
} }
return getTypeLoweringInfoForUncachedLoweredType(type); return getTypeLoweringForUncachedLoweredType(type);
} }
/// Do type-lowering for a lowered type which is not already in the cache. /// Do type-lowering for a lowered type which is not already in the cache.
const TypeLoweringInfo & const TypeLowering &
TypeConverter::getTypeLoweringInfoForUncachedLoweredType(CanType type) { TypeConverter::getTypeLoweringForUncachedLoweredType(CanType type) {
auto key = getTypeKey(type, 0); auto key = getTypeKey(type, 0);
assert(!Types.count(key) && "re-entrant or already cached"); assert(!Types.count(key) && "re-entrant or already cached");
assert(!isa<LValueType>(type) && "didn't lower out l-value type?"); assert(!isa<LValueType>(type) && "didn't lower out l-value type?");
@@ -654,7 +654,7 @@ SILType TypeConverter::getConstantType(SILDeclRef constant) {
AbstractCC cc = getAbstractCC(constant); AbstractCC cc = getAbstractCC(constant);
Type swiftTy = getThinFunctionType(makeConstantType(constant), cc); Type swiftTy = getThinFunctionType(makeConstantType(constant), cc);
SILType loweredTy SILType loweredTy
= getTypeLoweringInfo(swiftTy, constant.uncurryLevel).getLoweredType(); = getTypeLowering(swiftTy, constant.uncurryLevel).getLoweredType();
DEBUG(llvm::dbgs() << "constant "; DEBUG(llvm::dbgs() << "constant ";
constant.print(llvm::dbgs()); constant.print(llvm::dbgs());
llvm::dbgs() << " has type "; llvm::dbgs() << " has type ";