diff options
| author | Mehdi Amini <joker.eph@gmail.com> | 2021-03-11 23:58:02 +0000 |
|---|---|---|
| committer | Mehdi Amini <joker.eph@gmail.com> | 2021-03-25 03:59:03 +0000 |
| commit | 973ddb7d6e96e744a785ba64c065b592987a005f (patch) | |
| tree | 448766c0870f91f09d874384d2e15deddfb58149 /mlir/test/lib/Dialect/Test/TestPatterns.cpp | |
| parent | 0f99c6c56e73ef2265cb278ab8128eec5b30fee1 (diff) | |
Define a `NoTerminator` traits that allows operations with a single block region to not provide a terminator
In particular for Graph Regions, the terminator needs is just a
historical artifact of the generalization of MLIR from CFG region.
Operations like Module don't need a terminator, and before Module
migrated to be an operation with region there wasn't any needed.
To validate the feature, the ModuleOp is migrated to use this trait and
the ModuleTerminator operation is deleted.
This patch is likely to break clients, if you're in this case:
- you may iterate on a ModuleOp with `getBody()->without_terminator()`,
the solution is simple: just remove the ->without_terminator!
- you created a builder with `Builder::atBlockTerminator(module_body)`,
just use `Builder::atBlockEnd(module_body)` instead.
- you were handling ModuleTerminator: it isn't needed anymore.
- for generic code, a `Block::mayNotHaveTerminator()` may be used.
Differential Revision: https://reviews.llvm.org/D98468
Diffstat (limited to 'mlir/test/lib/Dialect/Test/TestPatterns.cpp')
| -rw-r--r-- | mlir/test/lib/Dialect/Test/TestPatterns.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp index ec85b7e38c43..1cc0c62b8691 100644 --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -573,7 +573,7 @@ struct TestLegalizePatternDriver // Define the conversion target used for the test. ConversionTarget target(getContext()); - target.addLegalOp<ModuleOp, ModuleTerminatorOp>(); + target.addLegalOp<ModuleOp>(); target.addLegalOp<LegalOpA, LegalOpB, TestCastOp, TestValidOp, TerminatorOp>(); target @@ -702,7 +702,7 @@ struct TestRemappedValue patterns.add<OneVResOneVOperandOp1Converter>(&getContext()); mlir::ConversionTarget target(getContext()); - target.addLegalOp<ModuleOp, ModuleTerminatorOp, FuncOp, TestReturnOp>(); + target.addLegalOp<ModuleOp, FuncOp, TestReturnOp>(); // We make OneVResOneVOperandOp1 legal only when it has more that one // operand. This will trigger the conversion that will replace one-operand // OneVResOneVOperandOp1 with two-operand OneVResOneVOperandOp1. @@ -969,9 +969,8 @@ struct TestMergeBlocksPatternDriver patterns.add<TestMergeBlock, TestUndoBlocksMerge, TestMergeSingleBlockOps>( context); ConversionTarget target(*context); - target.addLegalOp<FuncOp, ModuleOp, ModuleTerminatorOp, TerminatorOp, - TestBranchOp, TestTypeConsumerOp, TestTypeProducerOp, - TestReturnOp>(); + target.addLegalOp<FuncOp, ModuleOp, TerminatorOp, TestBranchOp, + TestTypeConsumerOp, TestTypeProducerOp, TestReturnOp>(); target.addIllegalOp<ILLegalOpF>(); /// Expect the op to have a single block after legalization. |
