summaryrefslogtreecommitdiffstats
path: root/mlir/test/Transforms
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2019-10-28 10:03:57 -0700
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-10-28 10:04:34 -0700
commit2f4d0c085a9849fb48b8b55e10f013ac851e470e (patch)
tree1b1c286a9aba000227a3f0f4c9cf4184d7e9f8fe /mlir/test/Transforms
parente38fe4a7af03f504b1a51b39fba2a3f07aad46f6 (diff)
downloadbcm5719-llvm-2f4d0c085a9849fb48b8b55e10f013ac851e470e.tar.gz
bcm5719-llvm-2f4d0c085a9849fb48b8b55e10f013ac851e470e.zip
Add support for marking an operation as recursively legal.
In some cases, it may be desirable to mark entire regions of operations as legal. This provides an additional granularity of context to the concept of "legal". The `ConversionTarget` supports marking operations, that were previously added as `Legal` or `Dynamic`, as `recursively` legal. Recursive legality means that if an operation instance is legal, either statically or dynamically, all of the operations nested within are also considered legal. An operation can be marked via `markOpRecursivelyLegal<>`: ```c++ ConversionTarget &target = ...; /// The operation must first be marked as `Legal` or `Dynamic`. target.addLegalOp<MyOp>(...); target.addDynamicallyLegalOp<MySecondOp>(...); /// Mark the operation as always recursively legal. target.markOpRecursivelyLegal<MyOp>(); /// Mark optionally with a callback to allow selective marking. target.markOpRecursivelyLegal<MyOp, MySecondOp>([](Operation *op) { ... }); /// Mark optionally with a callback to allow selective marking. target.markOpRecursivelyLegal<MyOp>([](MyOp op) { ... }); ``` PiperOrigin-RevId: 277086382
Diffstat (limited to 'mlir/test/Transforms')
-rw-r--r--mlir/test/Transforms/test-legalizer-full.mlir18
1 files changed, 18 insertions, 0 deletions
diff --git a/mlir/test/Transforms/test-legalizer-full.mlir b/mlir/test/Transforms/test-legalizer-full.mlir
index 2cf981b0db9..0b658688ba1 100644
--- a/mlir/test/Transforms/test-legalizer-full.mlir
+++ b/mlir/test/Transforms/test-legalizer-full.mlir
@@ -29,6 +29,24 @@ func @replace_non_root_illegal_op() {
// -----
+// Test that children of recursively legal operations are ignored.
+func @recursively_legal_invalid_op() {
+ /// Operation that is statically legal.
+ module attributes {test.recursively_legal} {
+ %ignored = "test.illegal_op_f"() : () -> (i32)
+ }
+ /// Operation that is dynamically legal, i.e. the function has a pattern
+ /// applied to legalize the argument type before it becomes recursively legal.
+ func @dynamic_func(%arg: i64) attributes {test.recursively_legal} {
+ %ignored = "test.illegal_op_f"() : () -> (i32)
+ "test.return"() : () -> ()
+ }
+
+ "test.return"() : () -> ()
+}
+
+// -----
+
// Test that region cloning can be properly undone.
func @test_undo_region_clone() {
"test.region"() ({
OpenPOWER on IntegriCloud