This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add transform.foreach_match
ClosedPublic

Authored by ftynse on Apr 11 2023, 7:13 AM.

Details

Summary

Add a new transform op combinator that implements an "if-then-else"
style of mechanism for applying transformations. Its main purpose is to
serve as a higher-level driver when applying multiple transform scripts
to potentially overlapping pieces of the payload IR. This is similar to
how the various rewrite drivers operate in C++, but at a higher level
and with more declarative expressions. This is not intended to replace
existing pattern-based rewrites, but to to drive more complex
transformations that are exposed in the transform dialect and are too
complex to be expressed as simple declarative rewrites.

Diff Detail

Event Timeline

ftynse created this revision.Apr 11 2023, 7:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 7:13 AM
ftynse published this revision for review.Apr 12 2023, 12:54 AM
springerm accepted this revision.Apr 12 2023, 1:25 AM
springerm added inline comments.
mlir/include/mlir/Dialect/Transform/IR/MatchInterfaces.td
10–14

This should be fixed with D147689.

mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
127

closing parenthesis

130

remove

133

succeeds

136

Is this preorder or postorder?

158

remove

165

an

mlir/lib/Dialect/Transform/IR/TransformOps.cpp
505–508

Could this be done in the op verifier?

571–575

Isn't this already caught by the op verifier/parser?

mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
218

with

This revision is now accepted and ready to land.Apr 12 2023, 1:25 AM
ftynse updated this revision to Diff 512726.Apr 12 2023, 2:41 AM
ftynse marked 9 inline comments as done.

Address review.

mlir/include/mlir/Dialect/Transform/IR/MatchInterfaces.td
10–14

Nice, thanks for fixing!

mlir/lib/Dialect/Transform/IR/TransformOps.cpp
505–508

We actually allow for external symbols in the verifier. During application, we can "resolve" them by inlining definitions from other files, see https://reviews.llvm.org/D146961. If that didn't happen, this will complain.

571–575

This gets called from the trait verifier, which runs before op verifier, so we unfortunately need to duplicate some conditions to avoid hard failures.

This revision was landed with ongoing or failed builds.Apr 12 2023, 4:02 AM
This revision was automatically updated to reflect the committed changes.