[mlir] Remove TypedAttr and ElementsAttr from DenseArrayAttr
authorJeff Niu <jeff@modular.com>
Tue, 8 Nov 2022 04:20:59 +0000 (20:20 -0800)
committerJeff Niu <jeff@modular.com>
Mon, 5 Dec 2022 21:27:55 +0000 (13:27 -0800)
commitc48e0cf03a50bb8a2043ac4bb5e9a83ff135247a
tree7f273682719e128f039ccdc4eb731fe2d30a446d
parentf2bfe0f84a222ce1fabddfef039d7f14bccd7c8a
[mlir] Remove TypedAttr and ElementsAttr from DenseArrayAttr

This patch removes the implementation of TypedAttr and ElementsAttr
from DenseArrayAttr and, in doing so, removes the need store a shaped
type. The attribute now stores a size (number of elements), an MLIR type
as a discriminator, and a raw byte array.

The intent of DenseArrayAttr was not to be a drop-in replacement for DenseElementsAttr. It was meant to be a simple container of integers or floats that map to C++ types. The ElementsAttr implementation on DenseArrayAttr had many holes in it, and fixing those holes would require evolving DenseArrayAttr in a way that is incompatible with its original purpose.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D137606
mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
mlir/include/mlir/IR/BuiltinAttributes.td
mlir/lib/AsmParser/AttributeParser.cpp
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/BuiltinAttributes.cpp
mlir/lib/IR/BuiltinDialectBytecode.cpp
mlir/test/IR/attribute.mlir
mlir/test/IR/elements-attr-interface.mlir
mlir/test/IR/invalid-builtin-attributes.mlir
mlir/test/lib/IR/TestBuiltinAttributeInterfaces.cpp