[mlir] Add support for filtering patterns based on debug names and labels
authorRiver Riddle <riddleriver@gmail.com>
Wed, 2 Jun 2021 18:43:01 +0000 (11:43 -0700)
committerRiver Riddle <riddleriver@gmail.com>
Wed, 2 Jun 2021 19:05:25 +0000 (12:05 -0700)
commit0289a2692e0e1b6b846f0627262d15daa58160ac
treebd0e1ec619620895065d5011c6ee093637fae5e2
parent0718ac706d4df719a0f019d1c0c3050c96ac2b8b
[mlir] Add support for filtering patterns based on debug names and labels

This revision allows for attaching "debug labels" to patterns, and provides to FrozenRewritePatternSet for  filtering patterns based on these labels (in addition to the debug name of the pattern). This will greatly simplify the ability to write tests targeted towards specific patterns (in cases where many patterns may interact),  will also simplify debugging pattern application by observing how application changes when enabling/disabling specific patterns.

To enable better reuse of pattern rewrite options between passes, this revision also adds a new PassUtil.td file to the Rewrite/ library that will allow for passes to easily hook into a common interface for pattern debugging. Two options are used to seed this utility, `disable-patterns` and `enable-patterns`, which are used to enable the filtering behavior indicated above.

Differential Revision: https://reviews.llvm.org/D102441
mlir/docs/PatternRewriter.md
mlir/include/mlir/IR/PatternMatch.h
mlir/include/mlir/Pass/PassOptions.h
mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h
mlir/include/mlir/Rewrite/PassUtil.td [new file with mode: 0644]
mlir/include/mlir/Transforms/Passes.td
mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
mlir/lib/Transforms/Canonicalizer.cpp
mlir/test/Pass/pipeline-options-parsing.mlir
mlir/test/Transforms/test-canonicalize-filter.mlir [new file with mode: 0644]
mlir/test/lib/Dialect/Test/TestDialect.cpp