diff --git a/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h b/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h index 9fca37390da5f..fda5835450d5e 100644 --- a/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h +++ b/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h @@ -66,14 +66,14 @@ enum class IdKind { Symbol, Local, Domain, Range, SetDim = Range }; /// other than Locals are equal. Equality of two spaces implies that number of /// identifiers of each kind are equal. /// -/// PresburgerSpace optionally also supports attaching attachements to each -/// variable in space. `resetAttachements` enables attaching -/// attachements to space. All attachements must be of the same type, -/// `AttachementType`. `AttachementType` must have a +/// PresburgerSpace optionally also supports attaching attachments to each +/// variable in space. `resetAttachments` enables attaching +/// attachments to space. All attachments must be of the same type, +/// `AttachmentType`. `AttachmentType` must have a /// `llvm::PointerLikeTypeTraits` specialization available and should be /// supported via mlir::TypeID. /// -/// These attachements can be used to check if two variables in two different +/// These attachments can be used to check if two variables in two different /// spaces correspond to the same variable. class PresburgerSpace { public: @@ -127,8 +127,8 @@ class PresburgerSpace { /// column position (i.e., not relative to the kind of identifier) of the /// first added identifier. /// - /// If attachements are being used, the newly added variables have no - /// attachements. + /// If attachments are being used, the newly added variables have no + /// attachments. unsigned insertId(IdKind kind, unsigned pos, unsigned num = 1); /// Removes identifiers of the specified kind in the column range [idStart, @@ -157,76 +157,76 @@ class PresburgerSpace { void dump() const; //===--------------------------------------------------------------------===// - // Attachement Interactions + // Attachment Interactions //===--------------------------------------------------------------------===// - /// Set the attachement for `i^th` variable to `attachement`. `T` here should - /// match the type used to enable attachements. + /// Set the attachment for `i^th` variable to `attachment`. `T` here should + /// match the type used to enable attachments. template - void setAttachement(IdKind kind, unsigned i, T attachement) { + void setAttachment(IdKind kind, unsigned i, T attachment) { #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS - assert(TypeID::get() == attachementType && "Type mismatch"); + assert(TypeID::get() == attachmentType && "Type mismatch"); #endif - atAttachement(kind, i) = - llvm::PointerLikeTypeTraits::getAsVoidPointer(attachement); + atAttachment(kind, i) = + llvm::PointerLikeTypeTraits::getAsVoidPointer(attachment); } - /// Get the attachement for `i^th` variable casted to type `T`. `T` here - /// should match the type used to enable attachements. + /// Get the attachment for `i^th` variable casted to type `T`. `T` here + /// should match the type used to enable attachments. template - T getAttachement(IdKind kind, unsigned i) const { + T getAttachment(IdKind kind, unsigned i) const { #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS - assert(TypeID::get() == attachementType && "Type mismatch"); + assert(TypeID::get() == attachmentType && "Type mismatch"); #endif return llvm::PointerLikeTypeTraits::getFromVoidPointer( - atAttachement(kind, i)); + atAttachment(kind, i)); } /// Check if the i^th variable of the specified kind has a non-null - /// attachement. - bool hasAttachement(IdKind kind, unsigned i) const { - return atAttachement(kind, i) != nullptr; + /// attachment. + bool hasAttachment(IdKind kind, unsigned i) const { + return atAttachment(kind, i) != nullptr; } - /// Check if the spaces are compatible, as well as have the same attachements + /// Check if the spaces are compatible, as well as have the same attachments /// for each variable. bool isAligned(const PresburgerSpace &other) const; /// Check if the number of variables of the specified kind match, and have - /// same attachements with the other space. + /// same attachments with the other space. bool isAligned(const PresburgerSpace &other, IdKind kind) const; - /// Find the variable of the specified kind with attachement `val`. - /// PresburgerSpace::kIdNotFound if attachement is not found. + /// Find the variable of the specified kind with attachment `val`. + /// PresburgerSpace::kIdNotFound if attachment is not found. template unsigned findId(IdKind kind, T val) const { unsigned i = 0; for (unsigned e = getNumIdKind(kind); i < e; ++i) - if (hasAttachement(kind, i) && getAttachement(kind, i) == val) + if (hasAttachment(kind, i) && getAttachment(kind, i) == val) return i; return kIdNotFound; } static const unsigned kIdNotFound = UINT_MAX; - /// Returns if attachements are being used. - bool isUsingAttachements() const { return usingAttachements; } + /// Returns if attachments are being used. + bool isUsingAttachments() const { return usingAttachments; } - /// Reset the stored attachements in the space. Enables `usingAttachements` if + /// Reset the stored attachments in the space. Enables `usingAttachments` if /// it was `false` before. template - void resetAttachements() { - attachements.clear(); - attachements.resize(getNumDimAndSymbolIds()); + void resetAttachments() { + attachments.clear(); + attachments.resize(getNumDimAndSymbolIds()); #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS - attachementType = TypeID::get(); + attachmentType = TypeID::get(); #endif - usingAttachements = true; + usingAttachments = true; } - /// Disable attachements being stored in space. - void disableAttachements() { - attachements.clear(); - usingAttachements = false; + /// Disable attachments being stored in space. + void disableAttachments() { + attachments.clear(); + usingAttachments = false; } protected: @@ -235,20 +235,18 @@ class PresburgerSpace { : numDomain(numDomain), numRange(numRange), numSymbols(numSymbols), numLocals(numLocals) {} - void *&atAttachement(IdKind kind, unsigned i) { - assert(usingAttachements && - "Cannot access attachements when `usingAttachements` is false."); - assert(kind != IdKind::Local && - "Local variables cannot have attachements."); - return attachements[getIdKindOffset(kind) + i]; + void *&atAttachment(IdKind kind, unsigned i) { + assert(usingAttachments && + "Cannot access attachments when `usingAttachments` is false."); + assert(kind != IdKind::Local && "Local variables cannot have attachments."); + return attachments[getIdKindOffset(kind) + i]; } - void *atAttachement(IdKind kind, unsigned i) const { - assert(usingAttachements && - "Cannot access attachements when `usingAttachements` is false."); - assert(kind != IdKind::Local && - "Local variables cannot have attachements."); - return attachements[getIdKindOffset(kind) + i]; + void *atAttachment(IdKind kind, unsigned i) const { + assert(usingAttachments && + "Cannot access attachments when `usingAttachments` is false."); + assert(kind != IdKind::Local && "Local variables cannot have attachments."); + return attachments[getIdKindOffset(kind) + i]; } private: @@ -266,16 +264,16 @@ class PresburgerSpace { /// to existentially quantified variables). unsigned numLocals; - /// Stores whether or not attachements are being used in this space. - bool usingAttachements = false; + /// Stores whether or not attachments are being used in this space. + bool usingAttachments = false; #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS - /// TypeID of the attachements in space. This should be used in asserts only. - TypeID attachementType; + /// TypeID of the attachments in space. This should be used in asserts only. + TypeID attachmentType; #endif - /// Stores a attachement for each non-local identifier as a `void` pointer. - SmallVector attachements; + /// Stores a attachment for each non-local identifier as a `void` pointer. + SmallVector attachments; }; } // namespace presburger diff --git a/mlir/lib/Analysis/Presburger/PresburgerSpace.cpp b/mlir/lib/Analysis/Presburger/PresburgerSpace.cpp index fe6c6dfec5a8f..6d82145eddc26 100644 --- a/mlir/lib/Analysis/Presburger/PresburgerSpace.cpp +++ b/mlir/lib/Analysis/Presburger/PresburgerSpace.cpp @@ -83,10 +83,10 @@ unsigned PresburgerSpace::insertId(IdKind kind, unsigned pos, unsigned num) { else numLocals += num; - // Insert NULL attachements if `usingAttachements` and variables inserted are + // Insert NULL attachments if `usingAttachments` and variables inserted are // not locals. - if (usingAttachements && kind != IdKind::Local) - attachements.insert(attachements.begin() + absolutePos, num, nullptr); + if (usingAttachments && kind != IdKind::Local) + attachments.insert(attachments.begin() + absolutePos, num, nullptr); return absolutePos; } @@ -108,33 +108,33 @@ void PresburgerSpace::removeIdRange(IdKind kind, unsigned idStart, else numLocals -= numIdsEliminated; - // Remove attachements if `usingAttachements` and variables removed are not + // Remove attachments if `usingAttachments` and variables removed are not // locals. - if (usingAttachements && kind != IdKind::Local) - attachements.erase(attachements.begin() + getIdKindOffset(kind) + idStart, - attachements.begin() + getIdKindOffset(kind) + idLimit); + if (usingAttachments && kind != IdKind::Local) + attachments.erase(attachments.begin() + getIdKindOffset(kind) + idStart, + attachments.begin() + getIdKindOffset(kind) + idLimit); } void PresburgerSpace::swapId(IdKind kindA, IdKind kindB, unsigned posA, unsigned posB) { - if (!usingAttachements) + if (!usingAttachments) return; if (kindA == IdKind::Local && kindB == IdKind::Local) return; if (kindA == IdKind::Local) { - atAttachement(kindB, posB) = nullptr; + atAttachment(kindB, posB) = nullptr; return; } if (kindB == IdKind::Local) { - atAttachement(kindA, posA) = nullptr; + atAttachment(kindA, posA) = nullptr; return; } - std::swap(atAttachement(kindA, posA), atAttachement(kindB, posB)); + std::swap(atAttachment(kindA, posA), atAttachment(kindB, posB)); } bool PresburgerSpace::isCompatible(const PresburgerSpace &other) const { @@ -148,25 +148,25 @@ bool PresburgerSpace::isEqual(const PresburgerSpace &other) const { } bool PresburgerSpace::isAligned(const PresburgerSpace &other) const { - assert(isUsingAttachements() && other.isUsingAttachements() && - "Both spaces should be using attachements to check for " + assert(isUsingAttachments() && other.isUsingAttachments() && + "Both spaces should be using attachments to check for " "alignment."); - return isCompatible(other) && attachements == other.attachements; + return isCompatible(other) && attachments == other.attachments; } bool PresburgerSpace::isAligned(const PresburgerSpace &other, IdKind kind) const { - assert(isUsingAttachements() && other.isUsingAttachements() && - "Both spaces should be using attachements to check for " + assert(isUsingAttachments() && other.isUsingAttachments() && + "Both spaces should be using attachments to check for " "alignment."); - ArrayRef kindAttachements = - makeArrayRef(attachements) + ArrayRef kindAttachments = + makeArrayRef(attachments) .slice(getIdKindOffset(kind), getNumIdKind(kind)); - ArrayRef otherKindAttachements = - makeArrayRef(other.attachements) + ArrayRef otherKindAttachments = + makeArrayRef(other.attachments) .slice(other.getIdKindOffset(kind), other.getNumIdKind(kind)); - return kindAttachements == otherKindAttachements; + return kindAttachments == otherKindAttachments; } void PresburgerSpace::setDimSymbolSeparation(unsigned newSymbolCount) { @@ -174,8 +174,8 @@ void PresburgerSpace::setDimSymbolSeparation(unsigned newSymbolCount) { "invalid separation position"); numRange = numRange + numSymbols - newSymbolCount; numSymbols = newSymbolCount; - // We do not need to change `attachements` since the ordering of - // `attachements` remains same. + // We do not need to change `attachments` since the ordering of + // `attachments` remains same. } void PresburgerSpace::print(llvm::raw_ostream &os) const { @@ -184,15 +184,15 @@ void PresburgerSpace::print(llvm::raw_ostream &os) const { << "Symbols: " << getNumSymbolIds() << ", " << "Locals: " << getNumLocalIds() << "\n"; - if (usingAttachements) { + if (usingAttachments) { #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS - os << "TypeID of attachements: " << attachementType.getAsOpaquePointer() + os << "TypeID of attachments: " << attachmentType.getAsOpaquePointer() << "\n"; #endif os << "("; - for (void *attachement : attachements) - os << attachement << " "; + for (void *attachment : attachments) + os << attachment << " "; os << ")\n"; } } diff --git a/mlir/unittests/Analysis/Presburger/PresburgerSpaceTest.cpp b/mlir/unittests/Analysis/Presburger/PresburgerSpaceTest.cpp index 87c816014e019..87164cc8f43f5 100644 --- a/mlir/unittests/Analysis/Presburger/PresburgerSpaceTest.cpp +++ b/mlir/unittests/Analysis/Presburger/PresburgerSpaceTest.cpp @@ -50,14 +50,14 @@ TEST(PresburgerSpaceTest, removeIdRange) { EXPECT_EQ(space.getNumSymbolIds(), 2u); } -TEST(PresburgerSpaceTest, insertIdAttachement) { +TEST(PresburgerSpaceTest, insertIdAttachment) { PresburgerSpace space = PresburgerSpace::getRelationSpace(2, 2, 1, 0); - space.resetAttachements(); + space.resetAttachments(); - // Attach attachement to domain ids. - int attachements[2] = {0, 1}; - space.setAttachement(IdKind::Domain, 0, &attachements[0]); - space.setAttachement(IdKind::Domain, 1, &attachements[1]); + // Attach attachment to domain ids. + int attachments[2] = {0, 1}; + space.setAttachment(IdKind::Domain, 0, &attachments[0]); + space.setAttachment(IdKind::Domain, 1, &attachments[1]); // Try inserting 2 domain ids. space.insertId(IdKind::Domain, 0, 2); @@ -67,28 +67,28 @@ TEST(PresburgerSpaceTest, insertIdAttachement) { space.insertId(IdKind::Range, 0, 1); EXPECT_EQ(space.getNumRangeIds(), 3u); - // Check if the attachements for the old ids are still attached properly. - EXPECT_EQ(*space.getAttachement(IdKind::Domain, 2), attachements[0]); - EXPECT_EQ(*space.getAttachement(IdKind::Domain, 3), attachements[1]); + // Check if the attachments for the old ids are still attached properly. + EXPECT_EQ(*space.getAttachment(IdKind::Domain, 2), attachments[0]); + EXPECT_EQ(*space.getAttachment(IdKind::Domain, 3), attachments[1]); } -TEST(PresburgerSpaceTest, removeIdRangeAttachement) { +TEST(PresburgerSpaceTest, removeIdRangeAttachment) { PresburgerSpace space = PresburgerSpace::getRelationSpace(2, 1, 3, 0); - space.resetAttachements(); + space.resetAttachments(); - int attachements[6] = {0, 1, 2, 3, 4, 5}; + int attachments[6] = {0, 1, 2, 3, 4, 5}; - // Attach attachements to domain identifiers. - space.setAttachement(IdKind::Domain, 0, &attachements[0]); - space.setAttachement(IdKind::Domain, 1, &attachements[1]); + // Attach attachments to domain identifiers. + space.setAttachment(IdKind::Domain, 0, &attachments[0]); + space.setAttachment(IdKind::Domain, 1, &attachments[1]); - // Attach attachements to range identifiers. - space.setAttachement(IdKind::Range, 0, &attachements[2]); + // Attach attachments to range identifiers. + space.setAttachment(IdKind::Range, 0, &attachments[2]); - // Attach attachements to symbol identifiers. - space.setAttachement(IdKind::Symbol, 0, &attachements[3]); - space.setAttachement(IdKind::Symbol, 1, &attachements[4]); - space.setAttachement(IdKind::Symbol, 2, &attachements[5]); + // Attach attachments to symbol identifiers. + space.setAttachment(IdKind::Symbol, 0, &attachments[3]); + space.setAttachment(IdKind::Symbol, 1, &attachments[4]); + space.setAttachment(IdKind::Symbol, 2, &attachments[5]); // Remove 1 domain identifier. space.removeIdRange(IdKind::Domain, 0, 1); @@ -101,10 +101,10 @@ TEST(PresburgerSpaceTest, removeIdRangeAttachement) { EXPECT_EQ(space.getNumRangeIds(), 0u); EXPECT_EQ(space.getNumSymbolIds(), 2u); - // Check if domain attachements are attached properly. - EXPECT_EQ(*space.getAttachement(IdKind::Domain, 0), attachements[1]); + // Check if domain attachments are attached properly. + EXPECT_EQ(*space.getAttachment(IdKind::Domain, 0), attachments[1]); - // Check if symbol attachements are attached properly. - EXPECT_EQ(*space.getAttachement(IdKind::Range, 0), attachements[4]); - EXPECT_EQ(*space.getAttachement(IdKind::Range, 1), attachements[5]); + // Check if symbol attachments are attached properly. + EXPECT_EQ(*space.getAttachment(IdKind::Range, 0), attachments[4]); + EXPECT_EQ(*space.getAttachment(IdKind::Range, 1), attachments[5]); }