Skip to content

Commit c7af9a7

Browse files
authored
Merge pull request #79294 from Azoy/bye-bye-slab
[stdlib] Rename Slab to InlineArray
2 parents dff88f9 + c673a07 commit c7af9a7

25 files changed

+143
-137
lines changed

Runtimes/Core/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ add_library(swiftCore
8686
HashTable.swift
8787
Identifiable.swift
8888
Indices.swift
89+
InlineArray.swift
8990
InputStream.swift
9091
IntegerParsing.swift
9192
Integers.swift
@@ -145,7 +146,6 @@ add_library(swiftCore
145146
SetVariant.swift
146147
ShadowProtocols.swift
147148
Shims.swift
148-
Slab.swift
149149
Slice.swift
150150
SmallString.swift
151151
Sort.swift

include/swift/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3994,7 +3994,7 @@ class GenericTypeParamDecl final
39943994
/// type parameter.
39953995
///
39963996
/// \code
3997-
/// struct Slab<let count: Int, Element: ~Copyable>
3997+
/// struct InlineArray<let count: Int, Element: ~Copyable>
39983998
/// \endcode
39993999
bool isValue() const {
40004000
return getParamKind() == GenericTypeParamKind::Value;

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8212,11 +8212,11 @@ ERROR(invalid_value_for_type_same_type,none,
82128212
"cannot constrain type parameter %0 to be integer %1", (Type, Type))
82138213

82148214
//===----------------------------------------------------------------------===//
8215-
// MARK: Slab
8215+
// MARK: InlineArray
82168216
//===----------------------------------------------------------------------===//
82178217

8218-
ERROR(slab_literal_incorrect_count,none,
8219-
"expected %0 elements in slab literal, but got %1", (Type, Type))
8218+
ERROR(inlinearray_literal_incorrect_count,none,
8219+
"expected %0 elements in inline array literal, but got %1", (Type, Type))
82208220

82218221
//===----------------------------------------------------------------------===//
82228222
// MARK: @abi Attribute

include/swift/AST/KnownStdlibTypes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,6 @@ KNOWN_STDLIB_TYPE_DECL(DecodingError, NominalTypeDecl, 0)
9999

100100
KNOWN_STDLIB_TYPE_DECL(Result, NominalTypeDecl, 2)
101101

102-
KNOWN_STDLIB_TYPE_DECL(Slab, NominalTypeDecl, 2)
102+
KNOWN_STDLIB_TYPE_DECL(InlineArray, NominalTypeDecl, 2)
103103

104104
#undef KNOWN_STDLIB_TYPE_DECL

include/swift/AST/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7246,7 +7246,7 @@ class GenericTypeParamType : public SubstitutableType,
72467246
/// Returns \c true if this type parameter is declared as a value.
72477247
///
72487248
/// \code
7249-
/// struct Slab<let count: Int, Element: ~Copyable>
7249+
/// struct InlineArray<let count: Int, Element: ~Copyable>
72507250
/// \endcode
72517251
bool isValue() const {
72527252
return ParamKind == GenericTypeParamKind::Value;

include/swift/Sema/CSFix.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,9 @@ enum class FixKind : uint8_t {
484484
/// result.
485485
AllowSendingMismatch,
486486

487-
/// Ignore when a 'Slab' literal has mismatched number of elements to the
488-
/// type it's attempting to bind to.
489-
AllowSlabLiteralCountMismatch,
487+
/// Ignore when an 'InlineArray' literal has mismatched number of elements to
488+
/// the type it's attempting to bind to.
489+
AllowInlineArrayLiteralCountMismatch,
490490
};
491491

492492
class ConstraintFix {
@@ -3841,12 +3841,12 @@ class IgnoreKeyPathSubscriptIndexMismatch final : public ConstraintFix {
38413841
}
38423842
};
38433843

3844-
class AllowSlabLiteralCountMismatch final : public ConstraintFix {
3844+
class AllowInlineArrayLiteralCountMismatch final : public ConstraintFix {
38453845
Type lhsCount, rhsCount;
38463846

3847-
AllowSlabLiteralCountMismatch(ConstraintSystem &cs, Type lhsCount,
3847+
AllowInlineArrayLiteralCountMismatch(ConstraintSystem &cs, Type lhsCount,
38483848
Type rhsCount, ConstraintLocator *locator)
3849-
: ConstraintFix(cs, FixKind::AllowSlabLiteralCountMismatch, locator),
3849+
: ConstraintFix(cs, FixKind::AllowInlineArrayLiteralCountMismatch, locator),
38503850
lhsCount(lhsCount), rhsCount(rhsCount) {}
38513851

38523852
public:
@@ -3856,12 +3856,12 @@ class AllowSlabLiteralCountMismatch final : public ConstraintFix {
38563856

38573857
bool diagnose(const Solution &solution, bool asNote = false) const override;
38583858

3859-
static AllowSlabLiteralCountMismatch *
3859+
static AllowInlineArrayLiteralCountMismatch *
38603860
create(ConstraintSystem &cs, Type lhsCount, Type rhsCount,
38613861
ConstraintLocator *locator);
38623862

38633863
static bool classof(const ConstraintFix *fix) {
3864-
return fix->getKind() == FixKind::AllowSlabLiteralCountMismatch;
3864+
return fix->getKind() == FixKind::AllowInlineArrayLiteralCountMismatch;
38653865
}
38663866
};
38673867

lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ Type TypeBase::isArrayType() {
811811
if (isArray())
812812
return boundStruct->getGenericArgs()[0];
813813

814-
if (isSlab())
814+
if (isInlineArray())
815815
return boundStruct->getGenericArgs()[1];
816816
}
817817
return Type();

lib/Parse/ParseType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ ParserStatus Parser::parseGenericArguments(SmallVectorImpl<TypeRepr *> &Args,
716716
// variadic generic types.
717717
if (!startsWithGreater(Tok)) {
718718
while (true) {
719-
// Note: This can be a value type, e.g. 'Slab<3, Int>'.
719+
// Note: This can be a value type, e.g. 'InlineArray<3, Int>'.
720720
ParserResult<TypeRepr> Ty = parseTypeOrValue(diag::expected_type);
721721
if (Ty.isNull() || Ty.hasCodeCompletion()) {
722722
// Skip until we hit the '>'.

lib/SILGen/SILGenExpr.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4599,17 +4599,17 @@ visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E, SGFContext C) {
45994599
llvm_unreachable("Unhandled MagicIdentifierLiteralExpr in switch.");
46004600
}
46014601

4602-
static RValue emitSlabLiteral(SILGenFunction &SGF, CollectionExpr *E,
4602+
static RValue emitInlineArrayLiteral(SILGenFunction &SGF, CollectionExpr *E,
46034603
SGFContext C) {
46044604
ArgumentScope scope(SGF, E);
46054605

4606-
auto slabType = E->getType()->castTo<BoundGenericType>();
4607-
auto loweredSlabType = SGF.getLoweredType(slabType);
4608-
auto elementType = slabType->getGenericArgs()[1]->getCanonicalType();
4606+
auto iaTy = E->getType()->castTo<BoundGenericType>();
4607+
auto loweredIAType = SGF.getLoweredType(iaTy);
4608+
auto elementType = iaTy->getGenericArgs()[1]->getCanonicalType();
46094609
auto loweredElementType = SGF.getLoweredType(elementType);
46104610
auto &eltTL = SGF.getTypeLowering(AbstractionPattern::getOpaque(), elementType);
46114611

4612-
SILValue alloc = SGF.emitTemporaryAllocation(E, loweredSlabType);
4612+
SILValue alloc = SGF.emitTemporaryAllocation(E, loweredIAType);
46134613
SILValue addr = SGF.B.createUncheckedAddrCast(E, alloc,
46144614
loweredElementType.getAddressType());
46154615

@@ -4642,31 +4642,31 @@ static RValue emitSlabLiteral(SILGenFunction &SGF, CollectionExpr *E,
46424642
.forwardInto(SGF, AbstractionPattern::getOpaque(), &init, eltTL);
46434643
}
46444644

4645-
// Kill the per-element cleanups. The slab will take ownership of them.
4645+
// Kill the per-element cleanups. The inline array will take ownership of them.
46464646
for (auto destCleanup : cleanups)
46474647
SGF.Cleanups.setCleanupState(destCleanup, CleanupState::Dead);
46484648

4649-
SILValue slabVal;
4649+
SILValue iaVal;
46504650

4651-
// If the slab is naturally address-only, then we can adopt the stack slot
4652-
// as the value directly.
4653-
if (loweredSlabType.isAddressOnly(SGF.F)) {
4654-
slabVal = SGF.B.createUncheckedAddrCast(E, alloc, loweredSlabType);
4651+
// If the inline array is naturally address-only, then we can adopt the stack
4652+
// slot as the value directly.
4653+
if (loweredIAType.isAddressOnly(SGF.F)) {
4654+
iaVal = SGF.B.createUncheckedAddrCast(E, alloc, loweredIAType);
46554655
} else {
4656-
// Otherwise, this slab is loadable. Load it.
4657-
slabVal = SGF.B.createTrivialLoadOr(E, alloc, LoadOwnershipQualifier::Take);
4656+
// Otherwise, this inline array is loadable. Load it.
4657+
iaVal = SGF.B.createTrivialLoadOr(E, alloc, LoadOwnershipQualifier::Take);
46584658
}
46594659

4660-
auto slabMV = SGF.emitManagedRValueWithCleanup(slabVal);
4661-
auto slab = RValue(SGF, E, slabMV);
4660+
auto iaMV = SGF.emitManagedRValueWithCleanup(iaVal);
4661+
auto ia = RValue(SGF, E, iaMV);
46624662

4663-
return scope.popPreservingValue(std::move(slab));
4663+
return scope.popPreservingValue(std::move(ia));
46644664
}
46654665

46664666
RValue RValueEmitter::visitCollectionExpr(CollectionExpr *E, SGFContext C) {
4667-
// Handle 'Slab' literals separately.
4668-
if (E->getType()->isSlab()) {
4669-
return emitSlabLiteral(SGF, E, C);
4667+
// Handle 'InlineArray' literals separately.
4668+
if (E->getType()->isInlineArray()) {
4669+
return emitInlineArrayLiteral(SGF, E, C);
46704670
}
46714671

46724672
auto loc = SILLocation(E);

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3804,7 +3804,7 @@ namespace {
38043804
Type arrayTy = cs.getType(expr);
38053805
Type elementType;
38063806

3807-
if (arrayTy->isSlab()) {
3807+
if (arrayTy->isInlineArray()) {
38083808
// <let count: Int, Element>
38093809
elementType = arrayTy->castTo<BoundGenericStructType>()->getGenericArgs()[1];
38103810
} else {

0 commit comments

Comments
 (0)