[mlir] Add a new AttrTypeReplacer class to simplify sub element replacements
authorRiver Riddle <riddleriver@gmail.com>
Thu, 10 Nov 2022 04:59:40 +0000 (20:59 -0800)
committerRiver Riddle <riddleriver@gmail.com>
Sat, 12 Nov 2022 22:38:45 +0000 (14:38 -0800)
commite50941b8d7bad9af091286afe45403b554824ce3
tree536c49002ab125bafbba3593721164764782a1b5
parentdf5ea69105189e71b47aaa96a9060863c4101109
[mlir] Add a new AttrTypeReplacer class to simplify sub element replacements

We currently only have the SubElement interface API for attribute/type
replacement, but this suffers from several issues; namely that it doesn't
allow caching across multiple replacements (very common), and also
creates a somewhat awkward/limited API. The new AttrTypeReplacer class
allows for registering replacements using a much cleaner API, similarly to
the TypeConverter class, removes a lot of manual interaction with the
sub element interfaces, and also better enables large scale replacements.

Differential Revision: https://reviews.llvm.org/D137764
mlir/include/mlir/IR/SubElementInterfaces.h
mlir/include/mlir/IR/SubElementInterfaces.td
mlir/lib/IR/SubElementInterfaces.cpp
mlir/lib/IR/SymbolTable.cpp