[mlir] Refactor SubElementInterface replace support
authorRiver Riddle <riddleriver@gmail.com>
Tue, 26 Jul 2022 20:22:19 +0000 (13:22 -0700)
committerRiver Riddle <riddleriver@gmail.com>
Tue, 26 Jul 2022 21:51:22 +0000 (14:51 -0700)
commit01eedbc7c14859c273bbd98693c67f35c59e8d85
tree61e5608d4c43e0bcbaa5300f8ccddd2320770079
parent6d0b42745e55c703b779740f5316adbac8ef2f25
[mlir] Refactor SubElementInterface replace support

The current support was essentially the amount necessary
to support replacing SymbolRefAttrs, but suffers from various
deficiencies (both ergonomic and functional):

* Replace crashes if unsupported
 This makes it really hard to use safely, given that you don't know
 if you are going to crash or not when using it.

* Types aren't supported
This seems like a simple missed addition when the attribute replacement
support was originally added.

* The ergonomics are weird
It currently uses an index based replacement, which makes the implementations
quite clunky.

This commit refactors support to be a bit more ergonomic, and also
adds support for types in the process. This was also a great oppurtunity
to greatly simplify how replacement is done in the symbol table.

Fixes #56355

Differential Revision: https://reviews.llvm.org/D130589
mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
mlir/include/mlir/IR/BuiltinAttributes.td
mlir/include/mlir/IR/SubElementInterfaces.td
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
mlir/lib/IR/BuiltinAttributes.cpp
mlir/lib/IR/BuiltinTypes.cpp
mlir/lib/IR/SubElementInterfaces.cpp
mlir/lib/IR/SymbolTable.cpp
mlir/test/lib/Dialect/Test/TestAttrDefs.td
mlir/test/lib/Dialect/Test/TestAttributes.cpp
mlir/test/lib/Dialect/Test/TestTypes.h