Changeset View
Changeset View
Standalone View
Standalone View
mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-matcher.mlir
Show All 18 Lines | module @simple { | ||||
// CHECK: ^bb3: | // CHECK: ^bb3: | ||||
// CHECK: pdl_interp.check_result_count of %[[ROOT]] is 0 -> ^bb4, ^bb1 | // CHECK: pdl_interp.check_result_count of %[[ROOT]] is 0 -> ^bb4, ^bb1 | ||||
// CHECK: ^bb4: | // CHECK: ^bb4: | ||||
// CHECK: pdl_interp.record_match @rewriters::@pdl_generated_rewriter | // CHECK: pdl_interp.record_match @rewriters::@pdl_generated_rewriter | ||||
// CHECK-SAME: benefit(1), loc([%[[ROOT]]]), root("foo.op") -> ^bb1 | // CHECK-SAME: benefit(1), loc([%[[ROOT]]]), root("foo.op") -> ^bb1 | ||||
// CHECK: module @rewriters | // CHECK: module @rewriters | ||||
// CHECK: func @pdl_generated_rewriter(%[[REWRITE_ROOT:.*]]: !pdl.operation) | // CHECK: func @pdl_generated_rewriter(%[[REWRITE_ROOT:.*]]: !pdl.operation) | ||||
// CHECK: pdl_interp.apply_rewrite "rewriter" on %[[REWRITE_ROOT]] | // CHECK: pdl_interp.apply_rewrite "rewriter"(%[[REWRITE_ROOT]] | ||||
// CHECK: pdl_interp.finalize | // CHECK: pdl_interp.finalize | ||||
pdl.pattern : benefit(1) { | pdl.pattern : benefit(1) { | ||||
%root = pdl.operation "foo.op"() | %root = pdl.operation "foo.op"() | ||||
pdl.rewrite %root with "rewriter" | pdl.rewrite %root with "rewriter" | ||||
} | } | ||||
} | } | ||||
// ----- | // ----- | ||||
Show All 31 Lines | module @constraints { | ||||
// CHECK: pdl_interp.apply_constraint "multi_constraint" [true](%[[INPUT]], %[[INPUT1]], %[[RESULT]] | // CHECK: pdl_interp.apply_constraint "multi_constraint" [true](%[[INPUT]], %[[INPUT1]], %[[RESULT]] | ||||
pdl.pattern : benefit(1) { | pdl.pattern : benefit(1) { | ||||
%input0 = pdl.operand | %input0 = pdl.operand | ||||
%input1 = pdl.operand | %input1 = pdl.operand | ||||
%root = pdl.operation(%input0, %input1) | %root = pdl.operation(%input0, %input1) | ||||
%result0 = pdl.result 0 of %root | %result0 = pdl.result 0 of %root | ||||
pdl.apply_constraint "multi_constraint"[true](%input0, %input1, %result0 : !pdl.value, !pdl.value, !pdl.value) | pdl.apply_native_constraint "multi_constraint"[true](%input0, %input1, %result0 : !pdl.value, !pdl.value, !pdl.value) | ||||
pdl.rewrite %root with "rewriter" | pdl.rewrite %root with "rewriter" | ||||
} | } | ||||
} | } | ||||
// ----- | // ----- | ||||
// CHECK-LABEL: module @inputs | // CHECK-LABEL: module @inputs | ||||
module @inputs { | module @inputs { | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | module @predicate_ordering { | ||||
// CHECK: func @matcher(%[[ROOT:.*]]: !pdl.operation) | // CHECK: func @matcher(%[[ROOT:.*]]: !pdl.operation) | ||||
// CHECK: %[[RESULT:.*]] = pdl_interp.get_result 0 of %[[ROOT]] | // CHECK: %[[RESULT:.*]] = pdl_interp.get_result 0 of %[[ROOT]] | ||||
// CHECK-NEXT: pdl_interp.is_not_null %[[RESULT]] | // CHECK-NEXT: pdl_interp.is_not_null %[[RESULT]] | ||||
// CHECK: %[[RESULT_TYPE:.*]] = pdl_interp.get_value_type of %[[RESULT]] | // CHECK: %[[RESULT_TYPE:.*]] = pdl_interp.get_value_type of %[[RESULT]] | ||||
// CHECK: pdl_interp.apply_constraint "typeConstraint" [](%[[RESULT_TYPE]] | // CHECK: pdl_interp.apply_constraint "typeConstraint" [](%[[RESULT_TYPE]] | ||||
pdl.pattern : benefit(1) { | pdl.pattern : benefit(1) { | ||||
%resultType = pdl.type | %resultType = pdl.type | ||||
pdl.apply_constraint "typeConstraint"[](%resultType : !pdl.type) | pdl.apply_native_constraint "typeConstraint"[](%resultType : !pdl.type) | ||||
%root = pdl.operation -> %resultType | %root = pdl.operation -> %resultType | ||||
pdl.rewrite %root with "rewriter" | pdl.rewrite %root with "rewriter" | ||||
} | } | ||||
pdl.pattern : benefit(1) { | pdl.pattern : benefit(1) { | ||||
%resultType = pdl.type | %resultType = pdl.type | ||||
%apply = pdl.operation -> %resultType | %apply = pdl.operation -> %resultType | ||||
pdl.rewrite %apply with "rewriter" | pdl.rewrite %apply with "rewriter" | ||||
} | } | ||||
} | } |