[Mlir-commits] [mlir] 5439582 - Rename NamedAttributeList to MutableDictionaryAttr

Jacques Pienaar llvmlistbot at llvm.org
Wed Apr 29 14:58:28 PDT 2020


Author: Jacques Pienaar
Date: 2020-04-29T14:58:02-07:00
New Revision: 5439582781f3e975ca4e5fa9ba71202eb7c3aaad

URL: https://github.com/llvm/llvm-project/commit/5439582781f3e975ca4e5fa9ba71202eb7c3aaad
DIFF: https://github.com/llvm/llvm-project/commit/5439582781f3e975ca4e5fa9ba71202eb7c3aaad.diff

LOG: Rename NamedAttributeList to MutableDictionaryAttr

Makes the relationship and function clearer. Accordingly rename getAttrList to getMutableAttrDict.

Differential Revision: https://reviews.llvm.org/D79125

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
    mlir/include/mlir/IR/Attributes.h
    mlir/include/mlir/IR/Function.h
    mlir/include/mlir/IR/FunctionSupport.h
    mlir/include/mlir/IR/OpDefinition.h
    mlir/include/mlir/IR/Operation.h
    mlir/lib/Analysis/CallGraph.cpp
    mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
    mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
    mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
    mlir/lib/IR/Attributes.cpp
    mlir/lib/IR/Function.cpp
    mlir/lib/IR/Module.cpp
    mlir/lib/IR/Operation.cpp
    mlir/lib/IR/SymbolTable.cpp
    mlir/lib/Parser/Parser.cpp
    mlir/lib/Pass/IRPrinting.cpp
    mlir/lib/Transforms/CSE.cpp
    mlir/lib/Transforms/DialectConversion.cpp
    mlir/lib/Transforms/SCCP.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 0a0564c43914..b08278f0c2df 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -680,7 +680,7 @@ def LLVM_LLVMFuncOp
     OpBuilder<"OpBuilder &builder, OperationState &result, StringRef name, "
               "LLVMType type, LLVM::Linkage linkage = LLVM::Linkage::External, "
               "ArrayRef<NamedAttribute> attrs = {}, "
-              "ArrayRef<NamedAttributeList> argAttrs = {}">
+              "ArrayRef<MutableDictionaryAttr> argAttrs = {}">
   ];
 
   let extraClassDeclaration = [{

diff  --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h
index 04b99624a6c9..e42f50b7ac32 100644
--- a/mlir/include/mlir/IR/Attributes.h
+++ b/mlir/include/mlir/IR/Attributes.h
@@ -1476,26 +1476,26 @@ inline ::llvm::hash_code hash_value(Attribute arg) {
 }
 
 //===----------------------------------------------------------------------===//
-// NamedAttributeList
+// MutableDictionaryAttr
 //===----------------------------------------------------------------------===//
 
-/// A NamedAttributeList is a mutable wrapper around a DictionaryAttr. It
+/// A MutableDictionaryAttr is a mutable wrapper around a DictionaryAttr. It
 /// provides additional interfaces for adding, removing, replacing attributes
 /// within a DictionaryAttr.
 ///
 /// We assume there will be relatively few attributes on a given operation
 /// (maybe a dozen or so, but not hundreds or thousands) so we use linear
 /// searches for everything.
-class NamedAttributeList {
+class MutableDictionaryAttr {
 public:
-  NamedAttributeList(DictionaryAttr attrs = nullptr)
+  MutableDictionaryAttr(DictionaryAttr attrs = nullptr)
       : attrs((attrs && !attrs.empty()) ? attrs : nullptr) {}
-  NamedAttributeList(ArrayRef<NamedAttribute> attributes);
+  MutableDictionaryAttr(ArrayRef<NamedAttribute> attributes);
 
-  bool operator!=(const NamedAttributeList &other) const {
+  bool operator!=(const MutableDictionaryAttr &other) const {
     return !(*this == other);
   }
-  bool operator==(const NamedAttributeList &other) const {
+  bool operator==(const MutableDictionaryAttr &other) const {
     return attrs == other.attrs;
   }
 

diff  --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h
index 90b45910a2a3..2617a488edf4 100644
--- a/mlir/include/mlir/IR/Function.h
+++ b/mlir/include/mlir/IR/Function.h
@@ -47,13 +47,13 @@ class FuncOp
                        iterator_range<dialect_attr_iterator> attrs);
   static FuncOp create(Location location, StringRef name, FunctionType type,
                        ArrayRef<NamedAttribute> attrs,
-                       ArrayRef<NamedAttributeList> argAttrs);
+                       ArrayRef<MutableDictionaryAttr> argAttrs);
 
   static void build(OpBuilder &builder, OperationState &result, StringRef name,
                     FunctionType type, ArrayRef<NamedAttribute> attrs);
   static void build(OpBuilder &builder, OperationState &result, StringRef name,
                     FunctionType type, ArrayRef<NamedAttribute> attrs,
-                    ArrayRef<NamedAttributeList> argAttrs);
+                    ArrayRef<MutableDictionaryAttr> argAttrs);
 
   /// Operation hooks.
   static ParseResult parse(OpAsmParser &parser, OperationState &result);

diff  --git a/mlir/include/mlir/IR/FunctionSupport.h b/mlir/include/mlir/IR/FunctionSupport.h
index 0787aad534d7..53c513023e29 100644
--- a/mlir/include/mlir/IR/FunctionSupport.h
+++ b/mlir/include/mlir/IR/FunctionSupport.h
@@ -243,7 +243,7 @@ class FunctionLike : public OpTrait::TraitBase<ConcreteType, FunctionLike> {
   }
 
   /// Return all argument attributes of this function.
-  void getAllArgAttrs(SmallVectorImpl<NamedAttributeList> &result) {
+  void getAllArgAttrs(SmallVectorImpl<MutableDictionaryAttr> &result) {
     for (unsigned i = 0, e = getNumArguments(); i != e; ++i)
       result.emplace_back(getArgAttrDict(i));
   }
@@ -270,8 +270,8 @@ class FunctionLike : public OpTrait::TraitBase<ConcreteType, FunctionLike> {
 
   /// Set the attributes held by the argument at 'index'.
   void setArgAttrs(unsigned index, ArrayRef<NamedAttribute> attributes);
-  void setArgAttrs(unsigned index, NamedAttributeList attributes);
-  void setAllArgAttrs(ArrayRef<NamedAttributeList> attributes) {
+  void setArgAttrs(unsigned index, MutableDictionaryAttr attributes);
+  void setAllArgAttrs(ArrayRef<MutableDictionaryAttr> attributes) {
     assert(attributes.size() == getNumArguments());
     for (unsigned i = 0, e = attributes.size(); i != e; ++i)
       setArgAttrs(i, attributes[i]);
@@ -286,8 +286,8 @@ class FunctionLike : public OpTrait::TraitBase<ConcreteType, FunctionLike> {
   }
 
   /// Remove the attribute 'name' from the argument at 'index'.
-  NamedAttributeList::RemoveResult removeArgAttr(unsigned index,
-                                                 Identifier name);
+  MutableDictionaryAttr::RemoveResult removeArgAttr(unsigned index,
+                                                    Identifier name);
 
   //===--------------------------------------------------------------------===//
   // Result Attributes
@@ -306,7 +306,7 @@ class FunctionLike : public OpTrait::TraitBase<ConcreteType, FunctionLike> {
   }
 
   /// Return all result attributes of this function.
-  void getAllResultAttrs(SmallVectorImpl<NamedAttributeList> &result) {
+  void getAllResultAttrs(SmallVectorImpl<MutableDictionaryAttr> &result) {
     for (unsigned i = 0, e = getNumResults(); i != e; ++i)
       result.emplace_back(getResultAttrDict(i));
   }
@@ -333,8 +333,8 @@ class FunctionLike : public OpTrait::TraitBase<ConcreteType, FunctionLike> {
 
   /// Set the attributes held by the result at 'index'.
   void setResultAttrs(unsigned index, ArrayRef<NamedAttribute> attributes);
-  void setResultAttrs(unsigned index, NamedAttributeList attributes);
-  void setAllResultAttrs(ArrayRef<NamedAttributeList> attributes) {
+  void setResultAttrs(unsigned index, MutableDictionaryAttr attributes);
+  void setAllResultAttrs(ArrayRef<MutableDictionaryAttr> attributes) {
     assert(attributes.size() == getNumResults());
     for (unsigned i = 0, e = attributes.size(); i != e; ++i)
       setResultAttrs(i, attributes[i]);
@@ -350,8 +350,8 @@ class FunctionLike : public OpTrait::TraitBase<ConcreteType, FunctionLike> {
   }
 
   /// Remove the attribute 'name' from the result at 'index'.
-  NamedAttributeList::RemoveResult removeResultAttr(unsigned index,
-                                                    Identifier name);
+  MutableDictionaryAttr::RemoveResult removeResultAttr(unsigned index,
+                                                       Identifier name);
 
 protected:
   /// Returns the attribute entry name for the set of argument attributes at
@@ -514,7 +514,7 @@ void FunctionLike<ConcreteType>::setArgAttrs(
 
 template <typename ConcreteType>
 void FunctionLike<ConcreteType>::setArgAttrs(unsigned index,
-                                             NamedAttributeList attributes) {
+                                             MutableDictionaryAttr attributes) {
   assert(index < getNumArguments() && "invalid argument number");
   SmallString<8> nameOut;
   if (auto newAttr = attributes.getDictionary())
@@ -529,25 +529,25 @@ template <typename ConcreteType>
 void FunctionLike<ConcreteType>::setArgAttr(unsigned index, Identifier name,
                                             Attribute value) {
   auto curAttr = getArgAttrDict(index);
-  NamedAttributeList attrList(curAttr);
-  attrList.set(name, value);
+  MutableDictionaryAttr attrDict(curAttr);
+  attrDict.set(name, value);
 
   // If the attribute changed, then set the new arg attribute list.
-  if (curAttr != attrList.getDictionary())
-    setArgAttrs(index, attrList);
+  if (curAttr != attrDict.getDictionary())
+    setArgAttrs(index, attrDict);
 }
 
 /// Remove the attribute 'name' from the argument at 'index'.
 template <typename ConcreteType>
-NamedAttributeList::RemoveResult
+MutableDictionaryAttr::RemoveResult
 FunctionLike<ConcreteType>::removeArgAttr(unsigned index, Identifier name) {
   // Build an attribute list and remove the attribute at 'name'.
-  NamedAttributeList attrList(getArgAttrDict(index));
-  auto result = attrList.remove(name);
+  MutableDictionaryAttr attrDict(getArgAttrDict(index));
+  auto result = attrDict.remove(name);
 
   // If the attribute was removed, then update the argument dictionary.
-  if (result == NamedAttributeList::RemoveResult::Removed)
-    setArgAttrs(index, attrList);
+  if (result == MutableDictionaryAttr::RemoveResult::Removed)
+    setArgAttrs(index, attrDict);
   return result;
 }
 
@@ -570,8 +570,8 @@ void FunctionLike<ConcreteType>::setResultAttrs(
 }
 
 template <typename ConcreteType>
-void FunctionLike<ConcreteType>::setResultAttrs(unsigned index,
-                                                NamedAttributeList attributes) {
+void FunctionLike<ConcreteType>::setResultAttrs(
+    unsigned index, MutableDictionaryAttr attributes) {
   assert(index < getNumResults() && "invalid result number");
   SmallString<8> nameOut;
   if (auto newAttr = attributes.getDictionary())
@@ -587,25 +587,25 @@ template <typename ConcreteType>
 void FunctionLike<ConcreteType>::setResultAttr(unsigned index, Identifier name,
                                                Attribute value) {
   auto curAttr = getResultAttrDict(index);
-  NamedAttributeList attrList(curAttr);
-  attrList.set(name, value);
+  MutableDictionaryAttr attrDict(curAttr);
+  attrDict.set(name, value);
 
   // If the attribute changed, then set the new arg attribute list.
-  if (curAttr != attrList.getDictionary())
-    setResultAttrs(index, attrList);
+  if (curAttr != attrDict.getDictionary())
+    setResultAttrs(index, attrDict);
 }
 
 /// Remove the attribute 'name' from the result at 'index'.
 template <typename ConcreteType>
-NamedAttributeList::RemoveResult
+MutableDictionaryAttr::RemoveResult
 FunctionLike<ConcreteType>::removeResultAttr(unsigned index, Identifier name) {
   // Build an attribute list and remove the attribute at 'name'.
-  NamedAttributeList attrList(getResultAttrDict(index));
-  auto result = attrList.remove(name);
+  MutableDictionaryAttr attrDict(getResultAttrDict(index));
+  auto result = attrDict.remove(name);
 
   // If the attribute was removed, then update the result dictionary.
-  if (result == NamedAttributeList::RemoveResult::Removed)
-    setResultAttrs(index, attrList);
+  if (result == MutableDictionaryAttr::RemoveResult::Removed)
+    setResultAttrs(index, attrDict);
   return result;
 }
 

diff  --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 5dc481d1df2b..121ed1b568ff 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -178,7 +178,7 @@ class OpState {
   void setAttrs(ArrayRef<NamedAttribute> attributes) {
     state->setAttrs(attributes);
   }
-  void setAttrs(NamedAttributeList newAttrs) { state->setAttrs(newAttrs); }
+  void setAttrs(MutableDictionaryAttr newAttrs) { state->setAttrs(newAttrs); }
 
   /// Set the dialect attributes for this operation, and preserve all dependent.
   template <typename DialectAttrs> void setDialectAttrs(DialectAttrs &&attrs) {
@@ -187,10 +187,10 @@ class OpState {
 
   /// Remove the attribute with the specified name if it exists.  The return
   /// value indicates whether the attribute was present or not.
-  NamedAttributeList::RemoveResult removeAttr(Identifier name) {
+  MutableDictionaryAttr::RemoveResult removeAttr(Identifier name) {
     return state->removeAttr(name);
   }
-  NamedAttributeList::RemoveResult removeAttr(StringRef name) {
+  MutableDictionaryAttr::RemoveResult removeAttr(StringRef name) {
     return state->removeAttr(Identifier::get(name, getContext()));
   }
 

diff  --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h
index 1dc0e787aa4f..bd3076780a15 100644
--- a/mlir/include/mlir/IR/Operation.h
+++ b/mlir/include/mlir/IR/Operation.h
@@ -36,11 +36,11 @@ class Operation final
                            ArrayRef<NamedAttribute> attributes,
                            ArrayRef<Block *> successors, unsigned numRegions);
 
-  /// Overload of create that takes an existing NamedAttributeList to avoid
+  /// Overload of create that takes an existing MutableDictionaryAttr to avoid
   /// unnecessarily uniquing a list of attributes.
   static Operation *create(Location location, OperationName name,
                            ArrayRef<Type> resultTypes, ArrayRef<Value> operands,
-                           NamedAttributeList attributes,
+                           MutableDictionaryAttr attributes,
                            ArrayRef<Block *> successors, unsigned numRegions);
 
   /// Create a new Operation from the fields stored in `state`.
@@ -49,7 +49,7 @@ class Operation final
   /// Create a new Operation with the specific fields.
   static Operation *create(Location location, OperationName name,
                            ArrayRef<Type> resultTypes, ArrayRef<Value> operands,
-                           NamedAttributeList attributes,
+                           MutableDictionaryAttr attributes,
                            ArrayRef<Block *> successors = {},
                            RegionRange regions = {});
 
@@ -280,13 +280,13 @@ class Operation final
   /// Return all of the attributes on this operation.
   ArrayRef<NamedAttribute> getAttrs() { return attrs.getAttrs(); }
 
-  /// Return the internal attribute list on this operation.
-  NamedAttributeList &getAttrList() { return attrs; }
+  /// Return mutable container of all the attributes on this operation.
+  MutableDictionaryAttr &getMutableAttrDict() { return attrs; }
 
-  /// Set the attribute list on this operation.
-  /// Using a NamedAttributeList is more efficient as it does not require new
+  /// Set the attribute dictionary on this operation.
+  /// Using a MutableDictionaryAttr is more efficient as it does not require new
   /// uniquing in the MLIRContext.
-  void setAttrs(NamedAttributeList newAttrs) { attrs = newAttrs; }
+  void setAttrs(MutableDictionaryAttr newAttrs) { attrs = newAttrs; }
 
   /// Return the specified attribute if present, null otherwise.
   Attribute getAttr(Identifier name) { return attrs.get(name); }
@@ -309,7 +309,7 @@ class Operation final
 
   /// Remove the attribute with the specified name if it exists.  The return
   /// value indicates whether the attribute was present or not.
-  NamedAttributeList::RemoveResult removeAttr(Identifier name) {
+  MutableDictionaryAttr::RemoveResult removeAttr(Identifier name) {
     return attrs.remove(name);
   }
 
@@ -596,7 +596,7 @@ class Operation final
 private:
   Operation(Location location, OperationName name, ArrayRef<Type> resultTypes,
             unsigned numSuccessors, unsigned numRegions,
-            const NamedAttributeList &attributes, bool hasOperandStorage);
+            const MutableDictionaryAttr &attributes, bool hasOperandStorage);
 
   // Operations are deleted through the destroy() member because they are
   // allocated with malloc.
@@ -658,7 +658,7 @@ class Operation final
   OperationName name;
 
   /// This holds general named attributes for the operation.
-  NamedAttributeList attrs;
+  MutableDictionaryAttr attrs;
 
   // allow ilist_traits access to 'block' field.
   friend struct llvm::ilist_traits<Operation>;

diff  --git a/mlir/lib/Analysis/CallGraph.cpp b/mlir/lib/Analysis/CallGraph.cpp
index e31641a87e05..1cb317fc0f6d 100644
--- a/mlir/lib/Analysis/CallGraph.cpp
+++ b/mlir/lib/Analysis/CallGraph.cpp
@@ -179,7 +179,7 @@ void CallGraph::print(raw_ostream &os) const {
     auto *parentOp = callableRegion->getParentOp();
     os << "'" << callableRegion->getParentOp()->getName() << "' - Region #"
        << callableRegion->getRegionNumber();
-    if (auto attrs = parentOp->getAttrList().getDictionary())
+    if (auto attrs = parentOp->getMutableAttrDict().getDictionary())
       os << " : " << attrs;
   };
 

diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 6f7b620bcde2..0a462d0239e3 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -1173,7 +1173,7 @@ Block *LLVMFuncOp::addEntryBlock() {
 void LLVMFuncOp::build(OpBuilder &builder, OperationState &result,
                        StringRef name, LLVMType type, LLVM::Linkage linkage,
                        ArrayRef<NamedAttribute> attrs,
-                       ArrayRef<NamedAttributeList> argAttrs) {
+                       ArrayRef<MutableDictionaryAttr> argAttrs) {
   result.addRegion();
   result.addAttribute(SymbolTable::getSymbolAttrName(),
                       builder.getStringAttr(name));

diff  --git a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp b/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
index efd15d773f8f..05f0eb4462e8 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
+++ b/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
@@ -353,8 +353,8 @@ struct ConvertSelectionOpToSelect
   }
 
   bool isSameAttrList(spirv::StoreOp lhs, spirv::StoreOp rhs) const {
-    return lhs.getOperation()->getAttrList().getDictionary() ==
-           rhs.getOperation()->getAttrList().getDictionary();
+    return lhs.getOperation()->getMutableAttrDict().getDictionary() ==
+           rhs.getOperation()->getMutableAttrDict().getDictionary();
   }
 
 

diff  --git a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
index fc8d980b3ed5..5a5c2fbcc19f 100644
--- a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
+++ b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
@@ -445,7 +445,7 @@ class Deserializer {
   DenseMap<uint32_t, StringRef> nameMap;
 
   // Result <id> to decorations mapping.
-  DenseMap<uint32_t, NamedAttributeList> decorations;
+  DenseMap<uint32_t, MutableDictionaryAttr> decorations;
 
   // Result <id> to type decorations.
   DenseMap<uint32_t, uint32_t> typeDecorations;

diff  --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp
index f989be507cb7..40f01e0d21ea 100644
--- a/mlir/lib/IR/Attributes.cpp
+++ b/mlir/lib/IR/Attributes.cpp
@@ -1160,19 +1160,20 @@ std::vector<ptr
diff _t> SparseElementsAttr::getFlattenedSparseIndices() const {
 }
 
 //===----------------------------------------------------------------------===//
-// NamedAttributeList
+// MutableDictionaryAttr
 //===----------------------------------------------------------------------===//
 
-NamedAttributeList::NamedAttributeList(ArrayRef<NamedAttribute> attributes) {
+MutableDictionaryAttr::MutableDictionaryAttr(
+    ArrayRef<NamedAttribute> attributes) {
   setAttrs(attributes);
 }
 
-ArrayRef<NamedAttribute> NamedAttributeList::getAttrs() const {
+ArrayRef<NamedAttribute> MutableDictionaryAttr::getAttrs() const {
   return attrs ? attrs.getValue() : llvm::None;
 }
 
 /// Replace the held attributes with ones provided in 'newAttrs'.
-void NamedAttributeList::setAttrs(ArrayRef<NamedAttribute> attributes) {
+void MutableDictionaryAttr::setAttrs(ArrayRef<NamedAttribute> attributes) {
   // Don't create an attribute list if there are no attributes.
   if (attributes.empty())
     attrs = nullptr;
@@ -1181,18 +1182,18 @@ void NamedAttributeList::setAttrs(ArrayRef<NamedAttribute> attributes) {
 }
 
 /// Return the specified attribute if present, null otherwise.
-Attribute NamedAttributeList::get(StringRef name) const {
+Attribute MutableDictionaryAttr::get(StringRef name) const {
   return attrs ? attrs.get(name) : nullptr;
 }
 
 /// Return the specified attribute if present, null otherwise.
-Attribute NamedAttributeList::get(Identifier name) const {
+Attribute MutableDictionaryAttr::get(Identifier name) const {
   return attrs ? attrs.get(name) : nullptr;
 }
 
 /// If the an attribute exists with the specified name, change it to the new
 /// value.  Otherwise, add a new attribute with the specified name/value.
-void NamedAttributeList::set(Identifier name, Attribute value) {
+void MutableDictionaryAttr::set(Identifier name, Attribute value) {
   assert(value && "attributes may never be null");
 
   // Look for an existing value for the given name, and set it in-place.
@@ -1222,7 +1223,7 @@ void NamedAttributeList::set(Identifier name, Attribute value) {
 
 /// Remove the attribute with the specified name if it exists.  The return
 /// value indicates whether the attribute was present or not.
-auto NamedAttributeList::remove(Identifier name) -> RemoveResult {
+auto MutableDictionaryAttr::remove(Identifier name) -> RemoveResult {
   auto origAttrs = getAttrs();
   for (unsigned i = 0, e = origAttrs.size(); i != e; ++i) {
     if (origAttrs[i].first == name) {

diff  --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp
index 29250130cd9d..a26d7db7e921 100644
--- a/mlir/lib/IR/Function.cpp
+++ b/mlir/lib/IR/Function.cpp
@@ -35,7 +35,7 @@ FuncOp FuncOp::create(Location location, StringRef name, FunctionType type,
 }
 FuncOp FuncOp::create(Location location, StringRef name, FunctionType type,
                       ArrayRef<NamedAttribute> attrs,
-                      ArrayRef<NamedAttributeList> argAttrs) {
+                      ArrayRef<MutableDictionaryAttr> argAttrs) {
   FuncOp func = create(location, name, type, attrs);
   func.setAllArgAttrs(argAttrs);
   return func;
@@ -52,7 +52,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name,
 
 void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name,
                    FunctionType type, ArrayRef<NamedAttribute> attrs,
-                   ArrayRef<NamedAttributeList> argAttrs) {
+                   ArrayRef<MutableDictionaryAttr> argAttrs) {
   build(builder, result, name, type, attrs);
   assert(type.getNumInputs() == argAttrs.size());
   SmallString<8> argAttrName;
@@ -115,7 +115,7 @@ void FuncOp::eraseArguments(ArrayRef<unsigned> argIndices) {
 
   // Update the function type and arg attrs.
   SmallVector<Type, 4> newInputTypes;
-  SmallVector<NamedAttributeList, 4> newArgAttrs;
+  SmallVector<MutableDictionaryAttr, 4> newArgAttrs;
   for (int i = 0; i < originalNumArgs; i++) {
     if (shouldEraseArg(i))
       continue;

diff  --git a/mlir/lib/IR/Module.cpp b/mlir/lib/IR/Module.cpp
index a0ef3ffd7f55..1711b05c8533 100644
--- a/mlir/lib/IR/Module.cpp
+++ b/mlir/lib/IR/Module.cpp
@@ -83,7 +83,7 @@ LogicalResult ModuleOp::verify() {
 
   // Check that none of the attributes are non-dialect attributes, except for
   // the symbol related attributes.
-  for (auto attr : getOperation()->getAttrList().getAttrs()) {
+  for (auto attr : getOperation()->getMutableAttrDict().getAttrs()) {
     if (!attr.first.strref().contains('.') &&
         !llvm::is_contained(
             ArrayRef<StringRef>{mlir::SymbolTable::getSymbolAttrName(),

diff  --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index 2e4a7ee02040..c8f2d67e3e65 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -65,21 +65,21 @@ Operation *Operation::create(Location location, OperationName name,
                              ArrayRef<Block *> successors,
                              unsigned numRegions) {
   return create(location, name, resultTypes, operands,
-                NamedAttributeList(attributes), successors, numRegions);
+                MutableDictionaryAttr(attributes), successors, numRegions);
 }
 
 /// Create a new Operation from operation state.
 Operation *Operation::create(const OperationState &state) {
-  return Operation::create(state.location, state.name, state.types,
-                           state.operands, NamedAttributeList(state.attributes),
-                           state.successors, state.regions);
+  return Operation::create(
+      state.location, state.name, state.types, state.operands,
+      MutableDictionaryAttr(state.attributes), state.successors, state.regions);
 }
 
 /// Create a new Operation with the specific fields.
 Operation *Operation::create(Location location, OperationName name,
                              ArrayRef<Type> resultTypes,
                              ArrayRef<Value> operands,
-                             NamedAttributeList attributes,
+                             MutableDictionaryAttr attributes,
                              ArrayRef<Block *> successors,
                              RegionRange regions) {
   unsigned numRegions = regions.size();
@@ -91,12 +91,12 @@ Operation *Operation::create(Location location, OperationName name,
   return op;
 }
 
-/// Overload of create that takes an existing NamedAttributeList to avoid
+/// Overload of create that takes an existing MutableDictionaryAttr to avoid
 /// unnecessarily uniquing a list of attributes.
 Operation *Operation::create(Location location, OperationName name,
                              ArrayRef<Type> resultTypes,
                              ArrayRef<Value> operands,
-                             NamedAttributeList attributes,
+                             MutableDictionaryAttr attributes,
                              ArrayRef<Block *> successors,
                              unsigned numRegions) {
   // We only need to allocate additional memory for a subset of results.
@@ -156,7 +156,8 @@ Operation *Operation::create(Location location, OperationName name,
 
 Operation::Operation(Location location, OperationName name,
                      ArrayRef<Type> resultTypes, unsigned numSuccessors,
-                     unsigned numRegions, const NamedAttributeList &attributes,
+                     unsigned numRegions,
+                     const MutableDictionaryAttr &attributes,
                      bool hasOperandStorage)
     : location(location), numSuccs(numSuccessors), numRegions(numRegions),
       hasOperandStorage(hasOperandStorage), hasSingleResult(false), name(name),

diff  --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp
index dc4186eaf129..e195225d675a 100644
--- a/mlir/lib/IR/SymbolTable.cpp
+++ b/mlir/lib/IR/SymbolTable.cpp
@@ -385,7 +385,7 @@ static WalkResult walkSymbolRefs(
     Operation *op,
     function_ref<WalkResult(SymbolTable::SymbolUse, ArrayRef<int>)> callback) {
   // Check to see if the operation has any attributes.
-  DictionaryAttr attrDict = op->getAttrList().getDictionary();
+  DictionaryAttr attrDict = op->getMutableAttrDict().getDictionary();
   if (!attrDict)
     return WalkResult::advance();
 
@@ -803,7 +803,7 @@ replaceAllSymbolUsesImpl(SymbolT symbol, StringRef newSymbol, IRUnitT *limit) {
   // Generate a new attribute dictionary for the current operation by replacing
   // references to the old symbol.
   auto generateNewAttrDict = [&] {
-    auto oldDict = curOp->getAttrList().getDictionary();
+    auto oldDict = curOp->getMutableAttrDict().getDictionary();
     auto newDict = rebuildAttrAfterRAUW(oldDict, accessChains, /*depth=*/0);
     return newDict.cast<DictionaryAttr>();
   };

diff  --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp
index 973b98b841fb..ec4e8ddfc2ab 100644
--- a/mlir/lib/Parser/Parser.cpp
+++ b/mlir/lib/Parser/Parser.cpp
@@ -5030,7 +5030,7 @@ ParseResult ModuleParser::parseModule(ModuleOp module) {
       if (nested && std::next(operations.begin(), 2) == operations.end()) {
         // Merge the data of the nested module operation into 'module'.
         module.setLoc(nested.getLoc());
-        module.setAttrs(nested.getOperation()->getAttrList());
+        module.setAttrs(nested.getOperation()->getMutableAttrDict());
         bodyBlocks.splice(bodyBlocks.end(), nested.getBodyRegion().getBlocks());
 
         // Erase the original module body.

diff  --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp
index 3398005d8bfa..679a9ec27ead 100644
--- a/mlir/lib/Pass/IRPrinting.cpp
+++ b/mlir/lib/Pass/IRPrinting.cpp
@@ -33,8 +33,9 @@ class OperationFingerPrint {
       //   - Operation pointer
       addDataToHash(hasher, op);
       //   - Attributes
-      addDataToHash(hasher,
-                    op->getAttrList().getDictionary().getAsOpaquePointer());
+      addDataToHash(
+          hasher,
+          op->getMutableAttrDict().getDictionary().getAsOpaquePointer());
       //   - Blocks in Regions
       for (Region &region : op->getRegions()) {
         for (Block &block : region) {

diff  --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp
index 8309099e92a7..1a91849e6102 100644
--- a/mlir/lib/Transforms/CSE.cpp
+++ b/mlir/lib/Transforms/CSE.cpp
@@ -36,7 +36,8 @@ struct SimpleOperationInfo : public llvm::DenseMapInfo<Operation *> {
     //   - Result Types
     //   - Operands
     return llvm::hash_combine(
-        op->getName(), op->getAttrList().getDictionary(), op->getResultTypes(),
+        op->getName(), op->getMutableAttrDict().getDictionary(),
+        op->getResultTypes(),
         llvm::hash_combine_range(op->operand_begin(), op->operand_end()));
   }
   static bool isEqual(const Operation *lhsC, const Operation *rhsC) {
@@ -56,7 +57,7 @@ struct SimpleOperationInfo : public llvm::DenseMapInfo<Operation *> {
         lhs->getNumResults() != rhs->getNumResults())
       return false;
     // Compare attributes.
-    if (lhs->getAttrList() != rhs->getAttrList())
+    if (lhs->getMutableAttrDict() != rhs->getMutableAttrDict())
       return false;
     // Compare operands.
     if (!std::equal(lhs->operand_begin(), lhs->operand_end(),

diff  --git a/mlir/lib/Transforms/DialectConversion.cpp b/mlir/lib/Transforms/DialectConversion.cpp
index 63db2c80c800..e57fb0983b8b 100644
--- a/mlir/lib/Transforms/DialectConversion.cpp
+++ b/mlir/lib/Transforms/DialectConversion.cpp
@@ -468,7 +468,7 @@ class OperationTransactionState {
 public:
   OperationTransactionState() = default;
   OperationTransactionState(Operation *op)
-      : op(op), loc(op->getLoc()), attrs(op->getAttrList()),
+      : op(op), loc(op->getLoc()), attrs(op->getMutableAttrDict()),
         operands(op->operand_begin(), op->operand_end()),
         successors(op->successor_begin(), op->successor_end()) {}
 
@@ -488,7 +488,7 @@ class OperationTransactionState {
 private:
   Operation *op;
   LocationAttr loc;
-  NamedAttributeList attrs;
+  MutableDictionaryAttr attrs;
   SmallVector<Value, 8> operands;
   SmallVector<Block *, 2> successors;
 };

diff  --git a/mlir/lib/Transforms/SCCP.cpp b/mlir/lib/Transforms/SCCP.cpp
index c9fc4ba2f395..2b21bd42b2cc 100644
--- a/mlir/lib/Transforms/SCCP.cpp
+++ b/mlir/lib/Transforms/SCCP.cpp
@@ -514,7 +514,7 @@ void SCCPSolver::visitOperation(Operation *op) {
   // in-place. The constant passed in may not correspond to the real runtime
   // value, so in-place updates are not allowed.
   SmallVector<Value, 8> originalOperands(op->getOperands());
-  NamedAttributeList originalAttrs = op->getAttrList();
+  MutableDictionaryAttr originalAttrs = op->getMutableAttrDict();
 
   // Simulate the result of folding this operation to a constant. If folding
   // fails or was an in-place fold, mark the results as overdefined.


        


More information about the Mlir-commits mailing list