This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Allow derived rewrite patterns to define a non-virtual `initialize` hook
ClosedPublic

Authored by rriddle on May 13 2021, 1:54 PM.

Details

Summary

This is a hook that allows for providing custom initialization of the pattern, e.g. if it has bounded recursion, setting the debug name, etc., without needing to define a custom constructor. A non-virtual hook was chosen to avoid polluting the vtable with code that we really just want to be inlined when constructing the pattern. The alternative to this would be to just define a constructor for each pattern, this unfortunately creates a lot of otherwise unnecessary boiler plate for a lot of patterns and a hook provides a much simpler/cleaner interface for the very common case.

Depends On D102439

Diff Detail

Event Timeline

rriddle created this revision.May 13 2021, 1:54 PM
rriddle requested review of this revision.May 13 2021, 1:54 PM
aartbik added inline comments.May 13 2021, 1:59 PM
mlir/docs/PatternRewriter.md
145

nit: safely handles

mlir/include/mlir/IR/PatternMatch.h
283

nit: its

ftynse accepted this revision.May 17 2021, 7:34 AM
This revision is now accepted and ready to land.May 17 2021, 7:34 AM
This revision was landed with ongoing or failed builds.May 18 2021, 2:41 PM
This revision was automatically updated to reflect the committed changes.
rriddle marked 2 inline comments as done.