[Mlir-commits] [mlir] [mlir][IR] Rename `DenseIntOrFPElementsAttr` to `DenseTypedElementsAttr` (PR #185687)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Mar 10 09:46:06 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Author: Matthias Springer (matthias-springer)

<details>
<summary>Changes</summary>

`DenseIntOrFPElementsAttr` was recently generalized to accept any type that implement the `DenseElementType` interface. The name `DenseIntOrFPElementsAttr` does not make sense anymore. This commit renames the attribute to `DenseTypedElementsAttr`. An alias is kept for migration purposes. The alias will be removed after some time.


---

Patch is 37.82 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/185687.diff


20 Files Affected:

- (modified) mlir/docs/Tutorials/Toy/Ch-2.md (+1-1) 
- (modified) mlir/include/mlir-c/BuiltinAttributes.h (+2-2) 
- (modified) mlir/include/mlir/IR/BuiltinAttributes.h (+9-5) 
- (modified) mlir/include/mlir/IR/BuiltinAttributes.td (+4-7) 
- (modified) mlir/include/mlir/IR/BuiltinDialectBytecode.td (+4-4) 
- (modified) mlir/include/mlir/IR/CommonAttrConstraints.td (+13) 
- (modified) mlir/lib/AsmParser/AttributeParser.cpp (+1-1) 
- (modified) mlir/lib/Bindings/Python/IRAttributes.cpp (+5-7) 
- (modified) mlir/lib/CAPI/IR/BuiltinAttributes.cpp (+2-2) 
- (modified) mlir/lib/Dialect/Arith/Transforms/ShardingInterfaceImpl.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/ConstantFold.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp (+1-1) 
- (modified) mlir/lib/IR/AsmPrinter.cpp (+9-10) 
- (modified) mlir/lib/IR/AttributeDetail.h (+5-5) 
- (modified) mlir/lib/IR/BuiltinAttributes.cpp (+43-43) 
- (modified) mlir/lib/IR/BuiltinDialectBytecode.cpp (+7-8) 
- (modified) mlir/lib/Rewrite/ByteCode.cpp (+2-2) 
- (modified) mlir/test/Bytecode/invalid/invalid-dense-elem-type-interface.mlir (+2-2) 
- (modified) mlir/test/Dialect/Builtin/Bytecode/attrs.mlir (+3-3) 
- (modified) mlir/utils/gdb-scripts/prettyprinters.py (+1-1) 


``````````diff
diff --git a/mlir/docs/Tutorials/Toy/Ch-2.md b/mlir/docs/Tutorials/Toy/Ch-2.md
index 81e41615ee55d..5ed8a4c227bfa 100644
--- a/mlir/docs/Tutorials/Toy/Ch-2.md
+++ b/mlir/docs/Tutorials/Toy/Ch-2.md
@@ -241,7 +241,7 @@ operation. This operation will represent a constant value in the Toy language.
 ```
 
 This operation takes zero operands, a
-[dense elements](../../Dialects/Builtin.md/#denseintorfpelementsattr) attribute named
+[dense elements](../../Dialects/Builtin.md/#densetypedelementsattr) attribute named
 `value` to represent the constant value, and returns a single result of
 [RankedTensorType](../../Dialects/Builtin.md/#rankedtensortype). An operation class
 inherits from the [CRTP](https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern)
diff --git a/mlir/include/mlir-c/BuiltinAttributes.h b/mlir/include/mlir-c/BuiltinAttributes.h
index 69a50942e8ee6..6e21373613b7e 100644
--- a/mlir/include/mlir-c/BuiltinAttributes.h
+++ b/mlir/include/mlir-c/BuiltinAttributes.h
@@ -468,8 +468,8 @@ MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseElements(MlirAttribute attr);
 MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseIntElements(MlirAttribute attr);
 MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseFPElements(MlirAttribute attr);
 
-/// Returns the typeID of an DenseIntOrFPElements attribute.
-MLIR_CAPI_EXPORTED MlirTypeID mlirDenseIntOrFPElementsAttrGetTypeID(void);
+/// Returns the typeID of a DenseTypedElements attribute.
+MLIR_CAPI_EXPORTED MlirTypeID mlirDenseTypedElementsAttrGetTypeID(void);
 
 /// Creates a dense elements attribute with the given Shaped type and elements
 /// in the same context as the type.
diff --git a/mlir/include/mlir/IR/BuiltinAttributes.h b/mlir/include/mlir/IR/BuiltinAttributes.h
index ee6a8f4e4d948..021074baafd26 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.h
+++ b/mlir/include/mlir/IR/BuiltinAttributes.h
@@ -32,7 +32,7 @@ class Operation;
 class RankedTensorType;
 
 namespace detail {
-struct DenseIntOrFPElementsAttrStorage;
+struct DenseTypedElementsAttrStorage;
 struct DenseStringElementsAttrStorage;
 struct StringAttrStorage;
 } // namespace detail
@@ -702,6 +702,10 @@ using DenseResourceElementsHandle = DialectResourceBlobHandle<BuiltinDialect>;
 //===----------------------------------------------------------------------===//
 
 namespace mlir {
+/// DenseIntOrFPElementsAttr was renamed to DenseTypedElementsAttr. This alias
+/// is provided for backwards compatibility. It will be removed in the future.
+using DenseIntOrFPElementsAttr = DenseTypedElementsAttr;
+
 //===----------------------------------------------------------------------===//
 // DenseArrayAttr
 //===----------------------------------------------------------------------===//
@@ -897,11 +901,11 @@ class FlatSymbolRefAttr : public SymbolRefAttr {
 
 /// An attribute that represents a reference to a dense float vector or tensor
 /// object. Each element is stored as a double.
-class DenseFPElementsAttr : public DenseIntOrFPElementsAttr {
+class DenseFPElementsAttr : public DenseTypedElementsAttr {
 public:
   using iterator = DenseElementsAttr::FloatElementIterator;
 
-  using DenseIntOrFPElementsAttr::DenseIntOrFPElementsAttr;
+  using DenseTypedElementsAttr::DenseTypedElementsAttr;
 
   /// Get an instance of a DenseFPElementsAttr with the given arguments. This
   /// simply wraps the DenseElementsAttr::get calls.
@@ -936,13 +940,13 @@ class DenseFPElementsAttr : public DenseIntOrFPElementsAttr {
 
 /// An attribute that represents a reference to a dense integer vector or tensor
 /// object.
-class DenseIntElementsAttr : public DenseIntOrFPElementsAttr {
+class DenseIntElementsAttr : public DenseTypedElementsAttr {
 public:
   /// DenseIntElementsAttr iterates on APInt, so we can use the raw element
   /// iterator directly.
   using iterator = DenseElementsAttr::IntElementIterator;
 
-  using DenseIntOrFPElementsAttr::DenseIntOrFPElementsAttr;
+  using DenseTypedElementsAttr::DenseTypedElementsAttr;
 
   /// Get an instance of a DenseIntElementsAttr with the given arguments. This
   /// simply wraps the DenseElementsAttr::get calls.
diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td
index dced379d1f979..0cc556ef5d852 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.td
+++ b/mlir/include/mlir/IR/BuiltinAttributes.td
@@ -169,7 +169,7 @@ def Builtin_DenseArray : Builtin_Attr<"DenseArray", "dense_array",
   let summary = "A dense array of integer or floating point elements.";
   let description = [{
     A dense array attribute is an attribute that represents a dense array of
-    primitive element types. Contrary to DenseIntOrFPElementsAttr this is a
+    primitive element types. Contrary to DenseTypedElementsAttr this is a
     flat unidimensional array which does not have a storage optimization for
     splat. This allows to expose the raw array through a C++ API as
     `ArrayRef<T>` for compatible types. The element type must be bool or an
@@ -231,11 +231,11 @@ def Builtin_DenseArray : Builtin_Attr<"DenseArray", "dense_array",
 }
 
 //===----------------------------------------------------------------------===//
-// DenseIntOrFPElementsAttr
+// DenseTypedElementsAttr
 //===----------------------------------------------------------------------===//
 
-def Builtin_DenseIntOrFPElementsAttr : Builtin_Attr<
-    "DenseIntOrFPElements", "dense_int_or_fp_elements", [ElementsAttrInterface],
+def Builtin_DenseTypedElementsAttr : Builtin_Attr<
+    "DenseTypedElements", "dense_typed_elements", [ElementsAttrInterface],
     "DenseElementsAttr"
   > {
   let summary = "An Attribute containing a dense multi-dimensional array of "
@@ -258,9 +258,6 @@ def Builtin_DenseIntOrFPElementsAttr : Builtin_Attr<
     offset "i * ceildiv(w, 8)". In other words, each element starts at a full
     byte offset.
 
-    TODO: The name `DenseIntOrFPElements` is no longer accurate. The attribute
-    will be renamed in the future.
-
     Examples:
 
     ```
diff --git a/mlir/include/mlir/IR/BuiltinDialectBytecode.td b/mlir/include/mlir/IR/BuiltinDialectBytecode.td
index b5ffa3eeb58c4..53a859e32d64b 100644
--- a/mlir/include/mlir/IR/BuiltinDialectBytecode.td
+++ b/mlir/include/mlir/IR/BuiltinDialectBytecode.td
@@ -173,12 +173,12 @@ def DenseArrayAttr : DialectAttribute<(attr
 )>;
 
 def DenseElementsAttr : WithType<"DenseElementsAttr", Attribute>;
-def DenseIntOrFPElementsAttr : DialectAttribute<(attr
+def DenseTypedElementsAttr : DialectAttribute<(attr
   ShapedType:$type,
   WithBuilder<"$_args",
     WithType<"SmallVector<char>",
-    WithParser<"succeeded(readDenseIntOrFPElementsAttr($_reader, type, $_var))",
-    WithPrinter<"writeDenseIntOrFPElementsAttr($_writer, $_name)">>>>:$rawData
+    WithParser<"succeeded(readDenseTypedElementsAttr($_reader, type, $_var))",
+    WithPrinter<"writeDenseTypedElementsAttr($_writer, $_name)">>>>:$rawData
 )>;
 
 def DenseStringElementsAttr : DialectAttribute<(attr
@@ -334,7 +334,7 @@ def BuiltinDialectAttributes : DialectAttributes<"Builtin"> {
     UnknownLoc,
     DenseResourceElementsAttr,
     DenseArrayAttr,
-    DenseIntOrFPElementsAttr,
+    DenseTypedElementsAttr,
     DenseStringElementsAttr,
     SparseElementsAttr,
     DistinctAttr,
diff --git a/mlir/include/mlir/IR/CommonAttrConstraints.td b/mlir/include/mlir/IR/CommonAttrConstraints.td
index ba6cf55a8fb9e..04d140c333638 100644
--- a/mlir/include/mlir/IR/CommonAttrConstraints.td
+++ b/mlir/include/mlir/IR/CommonAttrConstraints.td
@@ -436,6 +436,19 @@ class ElementsAttrBase<Pred condition, string summary> :
 def ElementsAttr : ElementsAttrBase<CPred<"::llvm::isa<::mlir::ElementsAttr>($_self)">,
                                     "constant vector/tensor attribute">;
 
+class DenseTypedElementsAttrBase : ElementsAttrBase<
+    CPred<"::llvm::isa<::mlir::DenseTypedElementsAttr>($_self)">,
+    "dense typed elements attribute"> {
+  let storageType = [{ ::mlir::DenseTypedElementsAttr }];
+  let returnType = [{ ::mlir::DenseTypedElementsAttr }];
+  let convertFromStorage = "$_self";
+}
+
+def DenseTypedElementsAttr : DenseTypedElementsAttrBase;
+
+// Compatibility alias for old ODS constraints name.
+def DenseIntOrFPElementsAttr : DenseTypedElementsAttrBase;
+
 class IntElementsAttrBase<Pred condition, string summary> :
     ElementsAttrBase<And<[CPred<"::llvm::isa<::mlir::DenseIntElementsAttr>($_self)">,
                           condition]>,
diff --git a/mlir/lib/AsmParser/AttributeParser.cpp b/mlir/lib/AsmParser/AttributeParser.cpp
index dc9744a42b730..d7075b795ccb9 100644
--- a/mlir/lib/AsmParser/AttributeParser.cpp
+++ b/mlir/lib/AsmParser/AttributeParser.cpp
@@ -732,7 +732,7 @@ DenseElementsAttr TensorLiteralParser::getHexAttr(SMLoc loc, ShapedType type) {
     // machines.
     SmallVector<char, 64> outDataVec(rawData.size());
     MutableArrayRef<char> convRawData(outDataVec);
-    DenseIntOrFPElementsAttr::convertEndianOfArrayRefForBEmachine(
+    DenseTypedElementsAttr::convertEndianOfArrayRefForBEmachine(
         rawData, convRawData, type);
     return DenseElementsAttr::getFromRawBuffer(type, convRawData);
   }
diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp
index 997f16978fa58..3d3aa2e01d6c1 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -1329,14 +1329,13 @@ nb::object denseArrayAttributeCaster(PyAttribute &pyAttribute) {
   throw nb::type_error(msg.c_str());
 }
 
-nb::object denseIntOrFPElementsAttributeCaster(PyAttribute &pyAttribute) {
+nb::object denseTypedElementsAttributeCaster(PyAttribute &pyAttribute) {
   if (PyDenseFPElementsAttribute::isaFunction(pyAttribute))
     return nb::cast(PyDenseFPElementsAttribute(pyAttribute));
   if (PyDenseIntElementsAttribute::isaFunction(pyAttribute))
     return nb::cast(PyDenseIntElementsAttribute(pyAttribute));
   std::string msg =
-      std::string(
-          "Can't cast unknown element type DenseIntOrFPElementsAttr (") +
+      std::string("Can't cast unknown element type DenseTypedElementsAttr (") +
       nb::cast<std::string>(nb::repr(nb::cast(pyAttribute))) + ")";
   throw nb::type_error(msg.c_str());
 }
@@ -1512,10 +1511,9 @@ void populateIRAttributes(nb::module_ &m) {
   PyDenseElementsAttribute::bind(m, PyDenseElementsAttribute::slots);
   PyDenseFPElementsAttribute::bind(m);
   PyDenseIntElementsAttribute::bind(m);
-  PyGlobals::get().registerTypeCaster(
-      mlirDenseIntOrFPElementsAttrGetTypeID(),
-      nb::cast<nb::callable>(
-          nb::cpp_function(denseIntOrFPElementsAttributeCaster)));
+  PyGlobals::get().registerTypeCaster(mlirDenseTypedElementsAttrGetTypeID(),
+                                      nb::cast<nb::callable>(nb::cpp_function(
+                                          denseTypedElementsAttributeCaster)));
   PyDenseResourceElementsAttribute::bind(m);
 
   PyDictAttribute::bind(m);
diff --git a/mlir/lib/CAPI/IR/BuiltinAttributes.cpp b/mlir/lib/CAPI/IR/BuiltinAttributes.cpp
index 44a3deaf57db5..c1595be5d04e0 100644
--- a/mlir/lib/CAPI/IR/BuiltinAttributes.cpp
+++ b/mlir/lib/CAPI/IR/BuiltinAttributes.cpp
@@ -559,8 +559,8 @@ bool mlirAttributeIsADenseFPElements(MlirAttribute attr) {
   return llvm::isa<DenseFPElementsAttr>(unwrap(attr));
 }
 
-MlirTypeID mlirDenseIntOrFPElementsAttrGetTypeID(void) {
-  return wrap(DenseIntOrFPElementsAttr::getTypeID());
+MlirTypeID mlirDenseTypedElementsAttrGetTypeID(void) {
+  return wrap(DenseTypedElementsAttr::getTypeID());
 }
 
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/Arith/Transforms/ShardingInterfaceImpl.cpp b/mlir/lib/Dialect/Arith/Transforms/ShardingInterfaceImpl.cpp
index 3e34246f66f2c..cbfb157915c38 100644
--- a/mlir/lib/Dialect/Arith/Transforms/ShardingInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Arith/Transforms/ShardingInterfaceImpl.cpp
@@ -73,7 +73,7 @@ struct ConstantShardingInterface
                           SymbolTableCollection &symbolTable,
                           OpBuilder &builder) const {
     auto cOp = cast<ConstantOp>(op);
-    if (auto value = dyn_cast<DenseIntOrFPElementsAttr>(cOp.getValue())) {
+    if (auto value = dyn_cast<DenseTypedElementsAttr>(cOp.getValue())) {
       if (!value.isSplat() || !resultShardings[0]) {
         // Currently non-splat constants are not supported.
         return failure();
diff --git a/mlir/lib/Dialect/Linalg/Transforms/ConstantFold.cpp b/mlir/lib/Dialect/Linalg/Transforms/ConstantFold.cpp
index 0c53cd2589f42..ba763ec2137e7 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/ConstantFold.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/ConstantFold.cpp
@@ -115,7 +115,7 @@ class FoldConstantBase : public OpInterfaceRewritePattern<LinalgOp> {
 
     // All inputs should be constants.
     int numInputs = linalgOp.getNumDpsInputs();
-    SmallVector<DenseIntOrFPElementsAttr> inputValues(numInputs);
+    SmallVector<DenseTypedElementsAttr> inputValues(numInputs);
     for (const auto &en : llvm::enumerate(linalgOp.getDpsInputOperands())) {
       if (!matchPattern(en.value()->get(),
                         m_Constant(&inputValues[en.index()])))
diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
index 34e06bf52f70d..2c97fcf91ac88 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
@@ -575,7 +575,7 @@ static LogicalResult verifyConstantType(spirv::ConstantOp op, Attribute value,
              << opType << ") does not match value type (" << valueType << ")";
     return success();
   }
-  if (isa<DenseIntOrFPElementsAttr, SparseElementsAttr>(value)) {
+  if (isa<DenseTypedElementsAttr, SparseElementsAttr>(value)) {
     auto valueType = cast<TypedAttr>(value).getType();
     if (valueType == opType)
       return success();
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index b3242f838fc1d..3460028c57d9e 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -510,8 +510,7 @@ class AsmPrinter::Impl {
   /// Print a dense elements attribute in the literal-first syntax. If
   /// 'allowHex' is true, a hex string is used instead of individual elements
   /// when the elements attr is large.
-  void printDenseIntOrFPElementsAttr(DenseIntOrFPElementsAttr attr,
-                                     bool allowHex);
+  void printDenseTypedElementsAttr(DenseTypedElementsAttr attr, bool allowHex);
 
   /// Print a dense elements attribute using the type-first syntax and the
   /// DenseElementTypeInterface, which provides the attribute printer for each
@@ -2509,7 +2508,7 @@ void AsmPrinter::Impl::printAttributeImpl(Attribute attr,
     }
 
   } else if (auto intOrFpEltAttr =
-                 llvm::dyn_cast<DenseIntOrFPElementsAttr>(attr)) {
+                 llvm::dyn_cast<DenseTypedElementsAttr>(attr)) {
     if (printerFlags.shouldElideElementsAttr(intOrFpEltAttr)) {
       printElidedElementsAttr(os);
     } else {
@@ -2519,7 +2518,7 @@ void AsmPrinter::Impl::printAttributeImpl(Attribute attr,
       // the existing printing format for backwards compatibility.
       Type eltType = intOrFpEltAttr.getElementType();
       if (isa<FloatType, IntegerType, IndexType, ComplexType>(eltType)) {
-        printDenseIntOrFPElementsAttr(intOrFpEltAttr, /*allowHex=*/true);
+        printDenseTypedElementsAttr(intOrFpEltAttr, /*allowHex=*/true);
       } else {
         printTypeFirstDenseElementsAttr(intOrFpEltAttr,
                                         cast<DenseElementType>(eltType));
@@ -2545,7 +2544,7 @@ void AsmPrinter::Impl::printAttributeImpl(Attribute attr,
       os << "sparse<";
       DenseIntElementsAttr indices = sparseEltAttr.getIndices();
       if (indices.getNumElements() != 0) {
-        printDenseIntOrFPElementsAttr(indices, /*allowHex=*/false);
+        printDenseTypedElementsAttr(indices, /*allowHex=*/false);
         os << ", ";
         printDenseElementsAttr(sparseEltAttr.getValues(), /*allowHex=*/true);
       }
@@ -2648,12 +2647,12 @@ void AsmPrinter::Impl::printDenseElementsAttr(DenseElementsAttr attr,
   if (auto stringAttr = llvm::dyn_cast<DenseStringElementsAttr>(attr))
     return printDenseStringElementsAttr(stringAttr);
 
-  printDenseIntOrFPElementsAttr(llvm::cast<DenseIntOrFPElementsAttr>(attr),
-                                allowHex);
+  printDenseTypedElementsAttr(llvm::cast<DenseTypedElementsAttr>(attr),
+                              allowHex);
 }
 
-void AsmPrinter::Impl::printDenseIntOrFPElementsAttr(
-    DenseIntOrFPElementsAttr attr, bool allowHex) {
+void AsmPrinter::Impl::printDenseTypedElementsAttr(DenseTypedElementsAttr attr,
+                                                   bool allowHex) {
   auto type = attr.getType();
   auto elementType = type.getElementType();
 
@@ -2665,7 +2664,7 @@ void AsmPrinter::Impl::printDenseIntOrFPElementsAttr(
       // machines. It is converted here to print in LE format.
       SmallVector<char, 64> outDataVec(rawData.size());
       MutableArrayRef<char> convRawData(outDataVec);
-      DenseIntOrFPElementsAttr::convertEndianOfArrayRefForBEmachine(
+      DenseTypedElementsAttr::convertEndianOfArrayRefForBEmachine(
           rawData, convRawData, type);
       printHexString(convRawData);
     } else {
diff --git a/mlir/lib/IR/AttributeDetail.h b/mlir/lib/IR/AttributeDetail.h
index 8505149afdd9c..4b7e7dd5677e8 100644
--- a/mlir/lib/IR/AttributeDetail.h
+++ b/mlir/lib/IR/AttributeDetail.h
@@ -47,8 +47,8 @@ struct DenseElementsAttributeStorage : public AttributeStorage {
 };
 
 /// An attribute representing a reference to a dense vector or tensor object.
-struct DenseIntOrFPElementsAttrStorage : public DenseElementsAttributeStorage {
-  DenseIntOrFPElementsAttrStorage(ShapedType ty, ArrayRef<char> data)
+struct DenseTypedElementsAttrStorage : public DenseElementsAttributeStorage {
+  DenseTypedElementsAttrStorage(ShapedType ty, ArrayRef<char> data)
       : DenseElementsAttributeStorage(ty), data(data) {}
 
   struct KeyTy {
@@ -108,7 +108,7 @@ struct DenseIntOrFPElementsAttrStorage : public DenseElementsAttributeStorage {
   }
 
   /// Construct a new storage instance.
-  static DenseIntOrFPElementsAttrStorage *
+  static DenseTypedElementsAttrStorage *
   construct(AttributeStorageAllocator &allocator, KeyTy key) {
     // If the data buffer is non-empty, we copy it into the allocator with a
     // 64-bit alignment.
@@ -120,8 +120,8 @@ struct DenseIntOrFPElementsAttrStorage : public DenseElementsAttributeStorage {
       copy = ArrayRef<char>(rawData, data.size());
     }
 
-    return new (allocator.allocate<DenseIntOrFPElementsAttrStorage>())
-        DenseIntOrFPElementsAttrStorage(key.type, copy);
+    return new (allocator.allocate<DenseTypedElementsAttrStorage>())
+        DenseTypedElementsAttrStorage(key.type, copy);
   }
 
   ArrayRef<char> data;
diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp
index bbbc9198a68ab..c06ae5b178624 100644
--- a/mlir/lib/IR/BuiltinAttributes.cpp
+++ b/mlir/lib/IR/BuiltinAttributes.cpp
@@ -481,13 +481,13 @@ static void copyAPIntToArrayForBEmachine(APInt value, size_t numBytes,
   // ex. last word of `value` (BE): |------ij|  ==> `valueLE` (LE): |ji------|
   size_t lastWordPos = numFilledWords;
   SmallVector<char, 8> valueLE(APInt::APINT_WORD_SIZE);
-  DenseIntOrFPElementsAttr::convertEndianOfCharForBEmachine(
+  DenseTypedElementsAttr::convertEndianOfCharForBEmachine(
       reinterpret_cast<const char *>(value.getRawData()) + lastWordPos,
       valueLE.begin(), APInt::APINT_BITS_PER_WORD, 1);
   // Extract actual APInt data from `valueLE`, convert endianness to BE format,
   // and store it in `result`.
   // ex. `valueLE` (LE): |ji------|  ==> `result` (BE): |abcdefgh|ij|
-  DenseIntOrFPElementsAttr::convertEndianOfCharForBEmachine(
+  DenseTypedElementsAttr::convertEndianOfCharForBEmachine(
       valueLE.begin(), result + lastWordPos,
       (numBytes - lastWordPos) * CHAR_BIT, 1);
 }
@@ -514,13 +514,13 @@ static void copyArrayToAPIntForBEmachine(const char *inArray, size_t numBytes,
   // ex. `inArray` (last two bytes, BE): |ij|  ==> `inArrayLE` (LE): |ji------|
   size_t lastWordPos = numFilledWords;
   SmallVector<char, 8> inArrayLE(APInt::APINT_WORD_SIZE);
-  DenseIntOrFPElementsAttr::convertEndianOfCharForBEmachine(
+  DenseTypedElementsAttr::convertEndianOfCharForBEmachine(
       inArray + lastWordPos, inArrayLE.begin...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/185687


More information about the Mlir-commits mailing list