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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/IR/SubElementInterfaces.h | ||
---|---|---|
36–38 | 🤔 | |
71 | I would like to file a feature request that walkSubElements etc get the same ability to specify WalkResult | |
mlir/lib/IR/SubElementInterfaces.cpp | ||
116 | ||
mlir/lib/IR/SymbolTable.cpp | ||
880 | Should visiting locations be optional? Now all replacements will have to walk nested locations, but the vast majority of use cases don't want that (because Locations only recently got SubElementInterface implementations). |
mlir/include/mlir/IR/SubElementInterfaces.h | ||
---|---|---|
36–38 | We've got some use cases that want to replace attributes/etc within types during a conversion pass. Right now we have some chained together lambdas that work together for the replacement(manually interacting through sub element interfaces), but having something with a better API makes it much easier. | |
71 | I'll look at revamping the walk stuff in a followup! | |
mlir/lib/IR/SubElementInterfaces.cpp | ||
116 | Nice catch! | |
mlir/lib/IR/SymbolTable.cpp | ||
880 | Yeah, I can make it optional for now. I ran into some cases that broke when I stared putting interesting stuff in locations, but we can see how widely that applies before making this the default. |
🤔