forked from OSchip/llvm-project
[mlir][pdl] Make `pdl` the default dialect when parsing/printing
PDLDialect being a somewhat user-facing dialect and whose ops contain exclusively other PDL ops in their regions can take advantage of `OpAsmOpInterface` to provide nicer IR. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D117828
This commit is contained in:
parent
7c471b56f2
commit
e99835ffed
|
@ -15,6 +15,7 @@
|
|||
|
||||
include "mlir/Dialect/PDL/IR/PDLTypes.td"
|
||||
include "mlir/Interfaces/SideEffectInterfaces.td"
|
||||
include "mlir/IR/OpAsmInterface.td"
|
||||
include "mlir/IR/SymbolInterfaces.td"
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -402,7 +403,8 @@ def PDL_OperationOp : PDL_Op<"operation", [AttrSizedOperandSegments]> {
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def PDL_PatternOp : PDL_Op<"pattern", [
|
||||
IsolatedFromAbove, SingleBlock, Symbol
|
||||
IsolatedFromAbove, SingleBlock, Symbol,
|
||||
DeclareOpInterfaceMethods<OpAsmOpInterface, ["getDefaultDialect"]>
|
||||
]> {
|
||||
let summary = "Define a rewrite pattern";
|
||||
let description = [{
|
||||
|
@ -573,7 +575,8 @@ def PDL_ResultsOp : PDL_Op<"results", [NoSideEffect]> {
|
|||
|
||||
def PDL_RewriteOp : PDL_Op<"rewrite", [
|
||||
Terminator, HasParent<"pdl::PatternOp">, NoTerminator, NoRegionArguments,
|
||||
SingleBlock, AttrSizedOperandSegments
|
||||
SingleBlock, AttrSizedOperandSegments,
|
||||
DeclareOpInterfaceMethods<OpAsmOpInterface, ["getDefaultDialect"]>
|
||||
]> {
|
||||
let summary = "Specify the rewrite of a matched pattern";
|
||||
let description = [{
|
||||
|
|
|
@ -355,6 +355,11 @@ RewriteOp PatternOp::getRewriter() {
|
|||
return cast<RewriteOp>(body().front().getTerminator());
|
||||
}
|
||||
|
||||
/// The default dialect is `pdl`.
|
||||
StringRef PatternOp::getDefaultDialect() {
|
||||
return PDLDialect::getDialectNamespace();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// pdl::ReplaceOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -431,6 +436,11 @@ static LogicalResult verify(RewriteOp op) {
|
|||
return success();
|
||||
}
|
||||
|
||||
/// The default dialect is `pdl`.
|
||||
StringRef RewriteOp::getDefaultDialect() {
|
||||
return PDLDialect::getDialectNamespace();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// pdl::TypeOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -27,8 +27,8 @@ module @simple {
|
|||
// CHECK: pdl_interp.apply_rewrite "rewriter"(%[[REWRITE_ROOT]]
|
||||
// CHECK: pdl_interp.finalize
|
||||
pdl.pattern : benefit(1) {
|
||||
%root = pdl.operation "foo.op"
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%root = operation "foo.op"
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,11 +48,11 @@ module @attributes {
|
|||
// CHECK-DAG: %[[ATTR1_TYPE:.*]] = pdl_interp.get_attribute_type of %[[ATTR1]]
|
||||
// CHECK-DAG: pdl_interp.check_type %[[ATTR1_TYPE]] is i64
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type : i64
|
||||
%attr = pdl.attribute 10 : i64
|
||||
%attr1 = pdl.attribute : %type
|
||||
%root = pdl.operation {"attr" = %attr, "attr1" = %attr1}
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%type = type : i64
|
||||
%attr = attribute 10 : i64
|
||||
%attr1 = attribute : %type
|
||||
%root = operation {"attr" = %attr, "attr1" = %attr1}
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,13 +67,13 @@ module @constraints {
|
|||
// CHECK: pdl_interp.apply_constraint "multi_constraint" [true](%[[INPUT]], %[[INPUT1]], %[[RESULT]]
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%input0 = pdl.operand
|
||||
%input1 = pdl.operand
|
||||
%root = pdl.operation(%input0, %input1 : !pdl.value, !pdl.value)
|
||||
%result0 = pdl.result 0 of %root
|
||||
%input0 = operand
|
||||
%input1 = operand
|
||||
%root = operation(%input0, %input1 : !pdl.value, !pdl.value)
|
||||
%result0 = result 0 of %root
|
||||
|
||||
pdl.apply_native_constraint "multi_constraint"[true](%input0, %input1, %result0 : !pdl.value, !pdl.value, !pdl.value)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,10 +94,10 @@ module @inputs {
|
|||
// CHECK-DAG: %[[INPUT1:.*]] = pdl_interp.get_operand 1 of %[[ROOT]]
|
||||
// CHECK-DAG: pdl_interp.are_equal %[[INPUT]], %[[INPUT1]] : !pdl.value
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type : i64
|
||||
%input = pdl.operand : %type
|
||||
%root = pdl.operation(%input, %input : !pdl.value, !pdl.value)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%type = type : i64
|
||||
%input = operand : %type
|
||||
%root = operation(%input, %input : !pdl.value, !pdl.value)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,11 +124,11 @@ module @variadic_inputs {
|
|||
// CHECK-DAG: %[[INPUT2:.*]] = pdl_interp.get_operands 2 of %[[ROOT]] : !pdl.value
|
||||
// CHECK-DAG: pdl_interp.are_equal %[[INPUT]], %[[INPUT2]] : !pdl.value
|
||||
pdl.pattern : benefit(1) {
|
||||
%types = pdl.types : [i64]
|
||||
%inputs = pdl.operands : %types
|
||||
%input = pdl.operand
|
||||
%root = pdl.operation(%input, %inputs, %input : !pdl.value, !pdl.range<value>, !pdl.value)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%types = types : [i64]
|
||||
%inputs = operands : %types
|
||||
%input = operand
|
||||
%root = operation(%input, %inputs, %input : !pdl.value, !pdl.range<value>, !pdl.value)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,10 +147,10 @@ module @single_operand_range {
|
|||
// The operand count is unknown, so there is no need to check for it.
|
||||
// CHECK-NOT: pdl_interp.check_operand_count
|
||||
pdl.pattern : benefit(1) {
|
||||
%types = pdl.types : [i64]
|
||||
%operands = pdl.operands : %types
|
||||
%root = pdl.operation(%operands : !pdl.range<value>)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%types = types : [i64]
|
||||
%operands = operands : %types
|
||||
%root = operation(%operands : !pdl.range<value>)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,10 +171,10 @@ module @results {
|
|||
// access for it.
|
||||
// CHECK-NOT: pdl_interp.get_result 1 of %[[ROOT]]
|
||||
pdl.pattern : benefit(1) {
|
||||
%type1 = pdl.type : i32
|
||||
%type2 = pdl.type
|
||||
%root = pdl.operation -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%type1 = type : i32
|
||||
%type2 = type
|
||||
%root = operation -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,10 +201,10 @@ module @variadic_results {
|
|||
// CHECK-DAG: %[[RESULT2:.*]] = pdl_interp.get_results 2 of %[[ROOT]] : !pdl.value
|
||||
// CHECK-DAG: pdl_interp.is_not_null %[[RESULT2]] : !pdl.value
|
||||
pdl.pattern : benefit(1) {
|
||||
%types = pdl.types : [i64]
|
||||
%type = pdl.type
|
||||
%root = pdl.operation -> (%type, %types, %type : !pdl.type, !pdl.range<type>, !pdl.type)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%types = types : [i64]
|
||||
%type = type
|
||||
%root = operation -> (%type, %types, %type : !pdl.type, !pdl.range<type>, !pdl.type)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,9 +223,9 @@ module @single_result_range {
|
|||
// The result count is unknown, so there is no need to check for it.
|
||||
// CHECK-NOT: pdl_interp.check_result_count
|
||||
pdl.pattern : benefit(1) {
|
||||
%types = pdl.types : [i64]
|
||||
%root = pdl.operation -> (%types : !pdl.range<type>)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%types = types : [i64]
|
||||
%root = operation -> (%types : !pdl.range<type>)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,14 +251,14 @@ module @results_as_operands {
|
|||
// CHECK-DAG: pdl_interp.are_equal %[[DEF_OP_0]], %[[DEF_OP_1]]
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%type1 = pdl.type : i32
|
||||
%type2 = pdl.type
|
||||
%inputOp = pdl.operation -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
%result1 = pdl.result 0 of %inputOp
|
||||
%result2 = pdl.result 1 of %inputOp
|
||||
%type1 = type : i32
|
||||
%type2 = type
|
||||
%inputOp = operation -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
%result1 = result 0 of %inputOp
|
||||
%result2 = result 1 of %inputOp
|
||||
|
||||
%root = pdl.operation(%result1, %result2 : !pdl.value, !pdl.value)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%root = operation(%result1, %result2 : !pdl.value, !pdl.value)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,12 +274,12 @@ module @single_result_range_as_operands {
|
|||
// CHECK-DAG: pdl_interp.are_equal %[[RESULTS]], %[[OPERANDS]] : !pdl.range<value>
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%types = pdl.types
|
||||
%inputOp = pdl.operation -> (%types : !pdl.range<type>)
|
||||
%results = pdl.results of %inputOp
|
||||
%types = types
|
||||
%inputOp = operation -> (%types : !pdl.range<type>)
|
||||
%results = results of %inputOp
|
||||
|
||||
%root = pdl.operation(%results : !pdl.range<value>)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%root = operation(%results : !pdl.range<value>)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,14 +292,14 @@ module @switch_single_result_type {
|
|||
// CHECK: %[[RESULT_TYPE:.*]] = pdl_interp.get_value_type of %[[RESULT]]
|
||||
// CHECK: pdl_interp.switch_type %[[RESULT_TYPE]] to [i32, i64]
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type : i32
|
||||
%root = pdl.operation -> (%type : !pdl.type)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%type = type : i32
|
||||
%root = operation -> (%type : !pdl.type)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type : i64
|
||||
%root = pdl.operation -> (%type : !pdl.type)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%type = type : i64
|
||||
%root = operation -> (%type : !pdl.type)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,14 +312,14 @@ module @switch_result_types {
|
|||
// CHECK: %[[RESULT_TYPES:.*]] = pdl_interp.get_value_type of %[[RESULTS]]
|
||||
// CHECK: pdl_interp.switch_types %[[RESULT_TYPES]] to {{\[\[}}i32], [i64, i32]]
|
||||
pdl.pattern : benefit(1) {
|
||||
%types = pdl.types : [i32]
|
||||
%root = pdl.operation -> (%types : !pdl.range<type>)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%types = types : [i32]
|
||||
%root = operation -> (%types : !pdl.range<type>)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
pdl.pattern : benefit(1) {
|
||||
%types = pdl.types : [i64, i32]
|
||||
%root = pdl.operation -> (%types : !pdl.range<type>)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%types = types : [i64, i32]
|
||||
%root = operation -> (%types : !pdl.range<type>)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,17 +337,17 @@ module @switch_operand_count_at_least {
|
|||
// CHECK: ^[[PATTERN_1_NEXT_BLOCK]]:
|
||||
// CHECK-NEXT: {{.*}} -> ^{{.*}}, ^bb2
|
||||
pdl.pattern : benefit(1) {
|
||||
%operand = pdl.operand
|
||||
%operands = pdl.operands
|
||||
%root = pdl.operation(%operand, %operands : !pdl.value, !pdl.range<value>)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%operand = operand
|
||||
%operands = operands
|
||||
%root = operation(%operand, %operands : !pdl.value, !pdl.range<value>)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
pdl.pattern : benefit(1) {
|
||||
%operand = pdl.operand
|
||||
%operand2 = pdl.operand
|
||||
%operands = pdl.operands
|
||||
%root = pdl.operation(%operand, %operand2, %operands : !pdl.value, !pdl.value, !pdl.range<value>)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%operand = operand
|
||||
%operand2 = operand
|
||||
%operands = operands
|
||||
%root = operation(%operand, %operand2, %operands : !pdl.value, !pdl.value, !pdl.range<value>)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -366,17 +366,17 @@ module @switch_result_count_at_least {
|
|||
// CHECK-NEXT: pdl_interp.get_result
|
||||
// CHECK-NEXT: pdl_interp.is_not_null {{.*}} -> ^{{.*}}, ^[[PATTERN_2_BLOCK]]
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type
|
||||
%types = pdl.types
|
||||
%root = pdl.operation -> (%type, %types : !pdl.type, !pdl.range<type>)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%type = type
|
||||
%types = types
|
||||
%root = operation -> (%type, %types : !pdl.type, !pdl.range<type>)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type
|
||||
%type2 = pdl.type
|
||||
%types = pdl.types
|
||||
%root = pdl.operation -> (%type, %type2, %types : !pdl.type, !pdl.type, !pdl.range<type>)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%type = type
|
||||
%type2 = type
|
||||
%types = types
|
||||
%root = operation -> (%type, %type2, %types : !pdl.type, !pdl.type, !pdl.range<type>)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,16 +396,16 @@ module @predicate_ordering {
|
|||
// CHECK: pdl_interp.apply_constraint "typeConstraint" [](%[[RESULT_TYPE]]
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%resultType = pdl.type
|
||||
%resultType = type
|
||||
pdl.apply_native_constraint "typeConstraint"[](%resultType : !pdl.type)
|
||||
%root = pdl.operation -> (%resultType : !pdl.type)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%root = operation -> (%resultType : !pdl.type)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%resultType = pdl.type
|
||||
%apply = pdl.operation -> (%resultType : !pdl.type)
|
||||
pdl.rewrite %apply with "rewriter"
|
||||
%resultType = type
|
||||
%apply = operation -> (%resultType : !pdl.type)
|
||||
rewrite %apply with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -435,16 +435,16 @@ module @multi_root {
|
|||
// CHECK-DAG: pdl_interp.is_not_null %[[ROOT2]] : !pdl.operation
|
||||
|
||||
pdl.pattern @rewrite_multi_root : benefit(1) {
|
||||
%input1 = pdl.operand
|
||||
%input2 = pdl.operand
|
||||
%type = pdl.type
|
||||
%op1 = pdl.operation(%input1 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val1 = pdl.result 0 of %op1
|
||||
%root1 = pdl.operation(%val1 : !pdl.value)
|
||||
%op2 = pdl.operation(%input2 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val2 = pdl.result 0 of %op2
|
||||
%root2 = pdl.operation(%val1, %val2 : !pdl.value, !pdl.value)
|
||||
pdl.rewrite %root1 with "rewriter"(%root2 : !pdl.operation)
|
||||
%input1 = operand
|
||||
%input2 = operand
|
||||
%type = type
|
||||
%op1 = operation(%input1 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val1 = result 0 of %op1
|
||||
%root1 = operation(%val1 : !pdl.value)
|
||||
%op2 = operation(%input2 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val2 = result 0 of %op2
|
||||
%root2 = operation(%val1, %val2 : !pdl.value, !pdl.value)
|
||||
rewrite %root1 with "rewriter"(%root2 : !pdl.operation)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -467,13 +467,13 @@ module @overlapping_roots {
|
|||
// CHECK-DAG: pdl_interp.is_not_null %[[INPUT2]] : !pdl.value
|
||||
|
||||
pdl.pattern @rewrite_overlapping_roots : benefit(1) {
|
||||
%input1 = pdl.operand
|
||||
%input2 = pdl.operand
|
||||
%type = pdl.type
|
||||
%op = pdl.operation(%input1, %input2 : !pdl.value, !pdl.value) -> (%type : !pdl.type)
|
||||
%val = pdl.result 0 of %op
|
||||
%root = pdl.operation(%val : !pdl.value)
|
||||
pdl.rewrite with "rewriter"(%root : !pdl.operation)
|
||||
%input1 = operand
|
||||
%input2 = operand
|
||||
%type = type
|
||||
%op = operation(%input1, %input2 : !pdl.value, !pdl.value) -> (%type : !pdl.type)
|
||||
%val = result 0 of %op
|
||||
%root = operation(%val : !pdl.value)
|
||||
rewrite with "rewriter"(%root : !pdl.operation)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,13 +499,13 @@ module @force_overlapped_root {
|
|||
// CHECK-DAG: pdl_interp.check_operand_count of %[[OP]] is 1
|
||||
|
||||
pdl.pattern @rewrite_forced_overlapped_root : benefit(1) {
|
||||
%input1 = pdl.operand
|
||||
%input2 = pdl.operand
|
||||
%type = pdl.type
|
||||
%root = pdl.operation(%input1, %input2 : !pdl.value, !pdl.value) -> (%type : !pdl.type)
|
||||
%val = pdl.result 0 of %root
|
||||
%op = pdl.operation(%val : !pdl.value)
|
||||
pdl.rewrite %root with "rewriter"(%op : !pdl.operation)
|
||||
%input1 = operand
|
||||
%input2 = operand
|
||||
%type = type
|
||||
%root = operation(%input1, %input2 : !pdl.value, !pdl.value) -> (%type : !pdl.type)
|
||||
%val = result 0 of %root
|
||||
%op = operation(%val : !pdl.value)
|
||||
rewrite %root with "rewriter"(%op : !pdl.operation)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,11 +527,11 @@ module @variadic_results_all {
|
|||
// CHECK-DAG: pdl_interp.is_not_null %[[OP]]
|
||||
// CHECK-DAG: pdl_interp.check_result_count of %[[OP]] is 0
|
||||
pdl.pattern @variadic_results_all : benefit(1) {
|
||||
%types = pdl.types
|
||||
%root = pdl.operation -> (%types : !pdl.range<type>)
|
||||
%vals = pdl.results of %root
|
||||
%op = pdl.operation(%vals : !pdl.range<value>)
|
||||
pdl.rewrite %root with "rewriter"(%op : !pdl.operation)
|
||||
%types = types
|
||||
%root = operation -> (%types : !pdl.range<type>)
|
||||
%vals = results of %root
|
||||
%op = operation(%vals : !pdl.range<value>)
|
||||
rewrite %root with "rewriter"(%op : !pdl.operation)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,14 +562,14 @@ module @variadic_results_at {
|
|||
// CHECK-DAG: pdl_interp.check_operand_count of %[[OP]] is 0
|
||||
// CHECK-DAG: pdl_interp.check_result_count of %[[OP]] is at_least 1
|
||||
pdl.pattern @variadic_results_at : benefit(1) {
|
||||
%type = pdl.type
|
||||
%types = pdl.types
|
||||
%val = pdl.operand
|
||||
%op = pdl.operation -> (%types, %type : !pdl.range<type>, !pdl.type)
|
||||
%vals = pdl.results 0 of %op -> !pdl.range<value>
|
||||
%root1 = pdl.operation(%vals, %val : !pdl.range<value>, !pdl.value)
|
||||
%root2 = pdl.operation(%val, %vals : !pdl.value, !pdl.range<value>)
|
||||
pdl.rewrite with "rewriter"(%root1, %root2 : !pdl.operation, !pdl.operation)
|
||||
%type = type
|
||||
%types = types
|
||||
%val = operand
|
||||
%op = operation -> (%types, %type : !pdl.range<type>, !pdl.type)
|
||||
%vals = results 0 of %op -> !pdl.range<value>
|
||||
%root1 = operation(%vals, %val : !pdl.range<value>, !pdl.value)
|
||||
%root2 = operation(%val, %vals : !pdl.value, !pdl.range<value>)
|
||||
rewrite with "rewriter"(%root1, %root2 : !pdl.operation, !pdl.operation)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -583,11 +583,11 @@ module @attribute_literal {
|
|||
|
||||
// Check the correct lowering of an attribute that hasn't been bound.
|
||||
pdl.pattern : benefit(1) {
|
||||
%attr = pdl.attribute 10
|
||||
%attr = attribute 10
|
||||
pdl.apply_native_constraint "constraint"(%attr: !pdl.attribute)
|
||||
|
||||
%root = pdl.operation
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%root = operation
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -602,12 +602,12 @@ module @type_literal {
|
|||
|
||||
// Check the correct lowering of a type that hasn't been bound.
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type : i32
|
||||
%types = pdl.types : [i32, i64]
|
||||
%type = type : i32
|
||||
%types = types : [i32, i64]
|
||||
pdl.apply_native_constraint "constraint"(%type, %types: !pdl.type, !pdl.range<type>)
|
||||
|
||||
%root = pdl.operation
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%root = operation
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -638,16 +638,16 @@ module @common_connector {
|
|||
// CHECK-DAG: pdl_interp.are_equal %[[ROOTB_OP]], %[[VAL0]] : !pdl.value
|
||||
// CHECK-DAG } -> ^[[CONTA:.*]]
|
||||
pdl.pattern @common_connector : benefit(1) {
|
||||
%type = pdl.type
|
||||
%op = pdl.operation -> (%type, %type : !pdl.type, !pdl.type)
|
||||
%val0 = pdl.result 0 of %op
|
||||
%val1 = pdl.result 1 of %op
|
||||
%rootA = pdl.operation (%val0 : !pdl.value)
|
||||
%rootB = pdl.operation (%val0 : !pdl.value)
|
||||
%inter = pdl.operation (%val1 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val2 = pdl.result 0 of %inter
|
||||
%rootC = pdl.operation (%val2 : !pdl.value)
|
||||
pdl.rewrite with "rewriter"(%rootA, %rootB, %rootC : !pdl.operation, !pdl.operation, !pdl.operation)
|
||||
%type = type
|
||||
%op = operation -> (%type, %type : !pdl.type, !pdl.type)
|
||||
%val0 = result 0 of %op
|
||||
%val1 = result 1 of %op
|
||||
%rootA = operation (%val0 : !pdl.value)
|
||||
%rootB = operation (%val0 : !pdl.value)
|
||||
%inter = operation (%val1 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val2 = result 0 of %inter
|
||||
%rootC = operation (%val2 : !pdl.value)
|
||||
rewrite with "rewriter"(%rootA, %rootB, %rootC : !pdl.operation, !pdl.operation, !pdl.operation)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -679,15 +679,15 @@ module @common_connector_range {
|
|||
// CHECK-DAG: pdl_interp.are_equal %[[ROOTB_OPS]], %[[VALS0]] : !pdl.range<value>
|
||||
// CHECK-DAG } -> ^[[CONTA:.*]]
|
||||
pdl.pattern @common_connector_range : benefit(1) {
|
||||
%types = pdl.types
|
||||
%op = pdl.operation -> (%types, %types : !pdl.range<type>, !pdl.range<type>)
|
||||
%vals0 = pdl.results 0 of %op -> !pdl.range<value>
|
||||
%vals1 = pdl.results 1 of %op -> !pdl.range<value>
|
||||
%rootA = pdl.operation (%vals0 : !pdl.range<value>)
|
||||
%rootB = pdl.operation (%vals0 : !pdl.range<value>)
|
||||
%inter = pdl.operation (%vals1 : !pdl.range<value>) -> (%types : !pdl.range<type>)
|
||||
%vals2 = pdl.results of %inter
|
||||
%rootC = pdl.operation (%vals2 : !pdl.range<value>)
|
||||
pdl.rewrite with "rewriter"(%rootA, %rootB, %rootC : !pdl.operation, !pdl.operation, !pdl.operation)
|
||||
%types = types
|
||||
%op = operation -> (%types, %types : !pdl.range<type>, !pdl.range<type>)
|
||||
%vals0 = results 0 of %op -> !pdl.range<value>
|
||||
%vals1 = results 1 of %op -> !pdl.range<value>
|
||||
%rootA = operation (%vals0 : !pdl.range<value>)
|
||||
%rootB = operation (%vals0 : !pdl.range<value>)
|
||||
%inter = operation (%vals1 : !pdl.range<value>) -> (%types : !pdl.range<type>)
|
||||
%vals2 = results of %inter
|
||||
%rootC = operation (%vals2 : !pdl.range<value>)
|
||||
rewrite with "rewriter"(%rootA, %rootB, %rootC : !pdl.operation, !pdl.operation, !pdl.operation)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ module @external {
|
|||
// CHECK: func @pdl_generated_rewriter(%[[ROOT:.*]]: !pdl.operation, %[[INPUT:.*]]: !pdl.value)
|
||||
// CHECK: pdl_interp.apply_rewrite "rewriter" [true](%[[ROOT]], %[[INPUT]] : !pdl.operation, !pdl.value)
|
||||
pdl.pattern : benefit(1) {
|
||||
%input = pdl.operand
|
||||
%root = pdl.operation "foo.op"(%input : !pdl.value)
|
||||
pdl.rewrite %root with "rewriter"[true](%input : !pdl.value)
|
||||
%input = operand
|
||||
%root = operation "foo.op"(%input : !pdl.value)
|
||||
rewrite %root with "rewriter"[true](%input : !pdl.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,9 @@ module @erase {
|
|||
// CHECK: pdl_interp.erase %[[ROOT]]
|
||||
// CHECK: pdl_interp.finalize
|
||||
pdl.pattern : benefit(1) {
|
||||
%root = pdl.operation "foo.op"
|
||||
pdl.rewrite %root {
|
||||
pdl.erase %root
|
||||
%root = operation "foo.op"
|
||||
rewrite %root {
|
||||
erase %root
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,12 +39,12 @@ module @operation_attributes {
|
|||
// CHECK: %[[ATTR1:.*]] = pdl_interp.create_attribute true
|
||||
// CHECK: pdl_interp.create_operation "foo.op" {"attr" = %[[ATTR]], "attr1" = %[[ATTR1]]}
|
||||
pdl.pattern : benefit(1) {
|
||||
%attr = pdl.attribute
|
||||
%root = pdl.operation "foo.op" {"attr" = %attr}
|
||||
pdl.rewrite %root {
|
||||
%attr1 = pdl.attribute true
|
||||
%newOp = pdl.operation "foo.op" {"attr" = %attr, "attr1" = %attr1}
|
||||
pdl.erase %root
|
||||
%attr = attribute
|
||||
%root = operation "foo.op" {"attr" = %attr}
|
||||
rewrite %root {
|
||||
%attr1 = attribute true
|
||||
%newOp = operation "foo.op" {"attr" = %attr, "attr1" = %attr1}
|
||||
erase %root
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,14 +59,14 @@ module @operation_operands {
|
|||
// CHECK: %[[OPERAND1:.*]] = pdl_interp.get_result 0 of %[[NEWOP]]
|
||||
// CHECK: pdl_interp.create_operation "foo.op2"(%[[OPERAND1]] : !pdl.value)
|
||||
pdl.pattern : benefit(1) {
|
||||
%operand = pdl.operand
|
||||
%root = pdl.operation "foo.op"(%operand : !pdl.value)
|
||||
pdl.rewrite %root {
|
||||
%type = pdl.type : i32
|
||||
%newOp = pdl.operation "foo.op"(%operand : !pdl.value) -> (%type : !pdl.type)
|
||||
%result = pdl.result 0 of %newOp
|
||||
%newOp1 = pdl.operation "foo.op2"(%result : !pdl.value)
|
||||
pdl.erase %root
|
||||
%operand = operand
|
||||
%root = operation "foo.op"(%operand : !pdl.value)
|
||||
rewrite %root {
|
||||
%type = type : i32
|
||||
%newOp = operation "foo.op"(%operand : !pdl.value) -> (%type : !pdl.type)
|
||||
%result = result 0 of %newOp
|
||||
%newOp1 = operation "foo.op2"(%result : !pdl.value)
|
||||
erase %root
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,13 +81,13 @@ module @operation_infer_types_from_replaceop {
|
|||
// CHECK: %[[RESULT_TYPES:.*]] = pdl_interp.get_value_type of %[[RESULTS]]
|
||||
// CHECK: pdl_interp.create_operation "foo.op" -> (%[[RESULT_TYPES]] : !pdl.range<type>)
|
||||
pdl.pattern : benefit(1) {
|
||||
%rootType = pdl.type
|
||||
%rootType1 = pdl.type
|
||||
%root = pdl.operation "foo.op" -> (%rootType, %rootType1 : !pdl.type, !pdl.type)
|
||||
pdl.rewrite %root {
|
||||
%newType1 = pdl.type
|
||||
%newOp = pdl.operation "foo.op" -> (%rootType, %newType1 : !pdl.type, !pdl.type)
|
||||
pdl.replace %root with %newOp
|
||||
%rootType = type
|
||||
%rootType1 = type
|
||||
%root = operation "foo.op" -> (%rootType, %rootType1 : !pdl.type, !pdl.type)
|
||||
rewrite %root {
|
||||
%newType1 = type
|
||||
%newOp = operation "foo.op" -> (%rootType, %newType1 : !pdl.type, !pdl.type)
|
||||
replace %root with %newOp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,11 +100,11 @@ module @operation_infer_types_from_otherop_individual_results {
|
|||
// CHECK: func @pdl_generated_rewriter(%[[TYPE:.*]]: !pdl.type, %[[TYPES:.*]]: !pdl.range<type>
|
||||
// CHECK: pdl_interp.create_operation "foo.op" -> (%[[TYPE]], %[[TYPES]] : !pdl.type, !pdl.range<type>)
|
||||
pdl.pattern : benefit(1) {
|
||||
%rootType = pdl.type
|
||||
%rootTypes = pdl.types
|
||||
%root = pdl.operation "foo.op" -> (%rootType, %rootTypes : !pdl.type, !pdl.range<type>)
|
||||
pdl.rewrite %root {
|
||||
%newOp = pdl.operation "foo.op" -> (%rootType, %rootTypes : !pdl.type, !pdl.range<type>)
|
||||
%rootType = type
|
||||
%rootTypes = types
|
||||
%root = operation "foo.op" -> (%rootType, %rootTypes : !pdl.type, !pdl.range<type>)
|
||||
rewrite %root {
|
||||
%newOp = operation "foo.op" -> (%rootType, %rootTypes : !pdl.type, !pdl.range<type>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,10 +117,10 @@ module @operation_infer_types_from_otherop_results {
|
|||
// CHECK: func @pdl_generated_rewriter(%[[TYPES:.*]]: !pdl.range<type>
|
||||
// CHECK: pdl_interp.create_operation "foo.op" -> (%[[TYPES]] : !pdl.range<type>)
|
||||
pdl.pattern : benefit(1) {
|
||||
%rootTypes = pdl.types
|
||||
%root = pdl.operation "foo.op" -> (%rootTypes : !pdl.range<type>)
|
||||
pdl.rewrite %root {
|
||||
%newOp = pdl.operation "foo.op" -> (%rootTypes : !pdl.range<type>)
|
||||
%rootTypes = types
|
||||
%root = operation "foo.op" -> (%rootTypes : !pdl.range<type>)
|
||||
rewrite %root {
|
||||
%newOp = operation "foo.op" -> (%rootTypes : !pdl.range<type>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,11 +135,11 @@ module @replace_with_op {
|
|||
// CHECK: %[[RESULTS:.*]] = pdl_interp.get_results of %[[NEWOP]]
|
||||
// CHECK: pdl_interp.replace %[[ROOT]] with (%[[RESULTS]] : !pdl.range<value>)
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type : i32
|
||||
%root = pdl.operation "foo.op" -> (%type : !pdl.type)
|
||||
pdl.rewrite %root {
|
||||
%newOp = pdl.operation "foo.op" -> (%type : !pdl.type)
|
||||
pdl.replace %root with %newOp
|
||||
%type = type : i32
|
||||
%root = operation "foo.op" -> (%type : !pdl.type)
|
||||
rewrite %root {
|
||||
%newOp = operation "foo.op" -> (%type : !pdl.type)
|
||||
replace %root with %newOp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,14 +156,14 @@ module @replace_with_values {
|
|||
// CHECK: %[[RESULTS_2:.*]] = pdl_interp.get_results 2 of %[[NEWOP]] : !pdl.value
|
||||
// CHECK: pdl_interp.replace %[[ROOT]] with (%[[RESULT]], %[[RESULTS]], %[[RESULTS_2]] : !pdl.value, !pdl.range<value>, !pdl.value)
|
||||
pdl.pattern : benefit(1) {
|
||||
%types = pdl.types
|
||||
%root = pdl.operation "foo.op" -> (%types : !pdl.range<type>)
|
||||
pdl.rewrite %root {
|
||||
%newOp = pdl.operation "foo.op" -> (%types : !pdl.range<type>)
|
||||
%newResult = pdl.result 0 of %newOp
|
||||
%newResults = pdl.results 1 of %newOp -> !pdl.range<value>
|
||||
%newResults2 = pdl.results 2 of %newOp -> !pdl.value
|
||||
pdl.replace %root with (%newResult, %newResults, %newResults2 : !pdl.value, !pdl.range<value>, !pdl.value)
|
||||
%types = types
|
||||
%root = operation "foo.op" -> (%types : !pdl.range<type>)
|
||||
rewrite %root {
|
||||
%newOp = operation "foo.op" -> (%types : !pdl.range<type>)
|
||||
%newResult = result 0 of %newOp
|
||||
%newResults = results 1 of %newOp -> !pdl.range<value>
|
||||
%newResults2 = results 2 of %newOp -> !pdl.value
|
||||
replace %root with (%newResult, %newResults, %newResults2 : !pdl.value, !pdl.range<value>, !pdl.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,10 +177,10 @@ module @replace_with_no_results {
|
|||
// CHECK: pdl_interp.create_operation "foo.op"
|
||||
// CHECK: pdl_interp.erase %[[ROOT]]
|
||||
pdl.pattern : benefit(1) {
|
||||
%root = pdl.operation "foo.op"
|
||||
pdl.rewrite %root {
|
||||
%newOp = pdl.operation "foo.op"
|
||||
pdl.replace %root with %newOp
|
||||
%root = operation "foo.op"
|
||||
rewrite %root {
|
||||
%newOp = operation "foo.op"
|
||||
replace %root with %newOp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,11 +194,11 @@ module @apply_native_rewrite {
|
|||
// CHECK: %[[TYPE:.*]] = pdl_interp.apply_rewrite "functor" [true](%[[ROOT]] : !pdl.operation) : !pdl.type
|
||||
// CHECK: pdl_interp.create_operation "foo.op" -> (%[[TYPE]] : !pdl.type)
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type
|
||||
%root = pdl.operation "foo.op" -> (%type : !pdl.type)
|
||||
pdl.rewrite %root {
|
||||
%newType = pdl.apply_native_rewrite "functor"[true](%root : !pdl.operation) : !pdl.type
|
||||
%newOp = pdl.operation "foo.op" -> (%newType : !pdl.type)
|
||||
%type = type
|
||||
%root = operation "foo.op" -> (%type : !pdl.type)
|
||||
rewrite %root {
|
||||
%newType = apply_native_rewrite "functor"[true](%root : !pdl.operation) : !pdl.type
|
||||
%newOp = operation "foo.op" -> (%newType : !pdl.type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -212,9 +212,9 @@ module @unbound_rewrite_op {
|
|||
// CHECK: %[[UNUSED:.*]] = pdl_interp.create_operation "bar.op"
|
||||
// CHECK: pdl_interp.finalize
|
||||
pdl.pattern : benefit(1) {
|
||||
%root = pdl.operation "foo.op"
|
||||
pdl.rewrite %root {
|
||||
%unused = pdl.operation "bar.op"
|
||||
%root = operation "foo.op"
|
||||
rewrite %root {
|
||||
%unused = operation "bar.op"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// RUN: mlir-opt -canonicalize %s | FileCheck %s
|
||||
|
||||
pdl.pattern @operation_op : benefit(1) {
|
||||
%root = pdl.operation "foo.op"
|
||||
pdl.rewrite %root {
|
||||
// CHECK: pdl.operation "bar.unused"
|
||||
%unused_rewrite = pdl.operation "bar.unused"
|
||||
pdl.erase %root
|
||||
%root = operation "foo.op"
|
||||
rewrite %root {
|
||||
// CHECK: operation "bar.unused"
|
||||
%unused_rewrite = operation "bar.unused"
|
||||
erase %root
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%op = pdl.operation "foo.op"
|
||||
%op = operation "foo.op"
|
||||
|
||||
// expected-error@below {{expected at least one argument}}
|
||||
"pdl.apply_native_constraint"() {name = "foo", params = []} : () -> ()
|
||||
pdl.rewrite %op with "rewriter"
|
||||
rewrite %op with "rewriter"
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -19,8 +19,8 @@ pdl.pattern : benefit(1) {
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%op = pdl.operation "foo.op"
|
||||
pdl.rewrite %op {
|
||||
%op = operation "foo.op"
|
||||
rewrite %op {
|
||||
// expected-error@below {{expected at least one argument}}
|
||||
"pdl.apply_native_rewrite"() {name = "foo", params = []} : () -> ()
|
||||
}
|
||||
|
@ -33,34 +33,34 @@ pdl.pattern : benefit(1) {
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type
|
||||
%type = type
|
||||
|
||||
// expected-error@below {{expected only one of [`type`, `value`] to be set}}
|
||||
%attr = pdl.attribute : %type 10
|
||||
%attr = attribute : %type 10
|
||||
|
||||
%op = pdl.operation "foo.op" {"attr" = %attr} -> (%type : !pdl.type)
|
||||
pdl.rewrite %op with "rewriter"
|
||||
%op = operation "foo.op" {"attr" = %attr} -> (%type : !pdl.type)
|
||||
rewrite %op with "rewriter"
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%op = pdl.operation "foo.op"
|
||||
pdl.rewrite %op {
|
||||
%type = pdl.type
|
||||
%op = operation "foo.op"
|
||||
rewrite %op {
|
||||
%type = type
|
||||
|
||||
// expected-error@below {{expected constant value when specified within a `pdl.rewrite`}}
|
||||
%attr = pdl.attribute : %type
|
||||
%attr = attribute : %type
|
||||
}
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%op = pdl.operation "foo.op"
|
||||
pdl.rewrite %op {
|
||||
%op = operation "foo.op"
|
||||
rewrite %op {
|
||||
// expected-error@below {{expected constant value when specified within a `pdl.rewrite`}}
|
||||
%attr = pdl.attribute
|
||||
%attr = attribute
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,10 +68,10 @@ pdl.pattern : benefit(1) {
|
|||
|
||||
pdl.pattern : benefit(1) {
|
||||
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
|
||||
%unused = pdl.attribute
|
||||
%unused = attribute
|
||||
|
||||
%op = pdl.operation "foo.op"
|
||||
pdl.rewrite %op with "rewriter"
|
||||
%op = operation "foo.op"
|
||||
rewrite %op with "rewriter"
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -82,10 +82,10 @@ pdl.pattern : benefit(1) {
|
|||
|
||||
pdl.pattern : benefit(1) {
|
||||
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
|
||||
%unused = pdl.operand
|
||||
%unused = operand
|
||||
|
||||
%op = pdl.operation "foo.op"
|
||||
pdl.rewrite %op with "rewriter"
|
||||
%op = operation "foo.op"
|
||||
rewrite %op with "rewriter"
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -96,10 +96,10 @@ pdl.pattern : benefit(1) {
|
|||
|
||||
pdl.pattern : benefit(1) {
|
||||
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
|
||||
%unused = pdl.operands
|
||||
%unused = operands
|
||||
|
||||
%op = pdl.operation "foo.op"
|
||||
pdl.rewrite %op with "rewriter"
|
||||
%op = operation "foo.op"
|
||||
rewrite %op with "rewriter"
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -109,10 +109,10 @@ pdl.pattern : benefit(1) {
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%op = pdl.operation "foo.op"
|
||||
pdl.rewrite %op {
|
||||
%op = operation "foo.op"
|
||||
rewrite %op {
|
||||
// expected-error@below {{must have an operation name when nested within a `pdl.rewrite`}}
|
||||
%newOp = pdl.operation
|
||||
%newOp = operation
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,19 +124,19 @@ pdl.pattern : benefit(1) {
|
|||
attributeNames = ["attr"],
|
||||
operand_segment_sizes = dense<0> : vector<3xi32>
|
||||
} : () -> (!pdl.operation)
|
||||
pdl.rewrite %op with "rewriter"
|
||||
rewrite %op with "rewriter"
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%op = pdl.operation "foo.op"
|
||||
pdl.rewrite %op {
|
||||
%type = pdl.type
|
||||
%op = operation "foo.op"
|
||||
rewrite %op {
|
||||
%type = type
|
||||
|
||||
// expected-error@below {{op must have inferable or constrained result types when nested within `pdl.rewrite`}}
|
||||
// expected-note@below {{result type #0 was not constrained}}
|
||||
%newOp = pdl.operation "foo.op" -> (%type : !pdl.type)
|
||||
%newOp = operation "foo.op" -> (%type : !pdl.type)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,10 +144,10 @@ pdl.pattern : benefit(1) {
|
|||
|
||||
pdl.pattern : benefit(1) {
|
||||
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
|
||||
%unused = pdl.operation "foo.op"
|
||||
%unused = operation "foo.op"
|
||||
|
||||
%op = pdl.operation "foo.op"
|
||||
pdl.rewrite %op with "rewriter"
|
||||
%op = operation "foo.op"
|
||||
rewrite %op with "rewriter"
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -166,7 +166,7 @@ pdl.pattern : benefit(1) {
|
|||
|
||||
// expected-error@below {{the pattern must contain at least one `pdl.operation`}}
|
||||
pdl.pattern : benefit(1) {
|
||||
pdl.rewrite with "foo"
|
||||
rewrite with "foo"
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -175,44 +175,44 @@ pdl.pattern : benefit(1) {
|
|||
// expected-note@below {{see non-`pdl` operation defined here}}
|
||||
"test.foo.other_op"() : () -> ()
|
||||
|
||||
%root = pdl.operation "foo.op"
|
||||
pdl.rewrite %root with "foo"
|
||||
%root = operation "foo.op"
|
||||
rewrite %root with "foo"
|
||||
}
|
||||
|
||||
// -----
|
||||
// expected-error@below {{the operations must form a connected component}}
|
||||
pdl.pattern : benefit(1) {
|
||||
%op1 = pdl.operation "foo.op"
|
||||
%op2 = pdl.operation "bar.op"
|
||||
%op1 = operation "foo.op"
|
||||
%op2 = operation "bar.op"
|
||||
// expected-note@below {{see a disconnected value / operation here}}
|
||||
%val = pdl.result 0 of %op2
|
||||
pdl.rewrite %op1 with "foo"(%val : !pdl.value)
|
||||
%val = result 0 of %op2
|
||||
rewrite %op1 with "foo"(%val : !pdl.value)
|
||||
}
|
||||
|
||||
// -----
|
||||
// expected-error@below {{the operations must form a connected component}}
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type
|
||||
%op1 = pdl.operation "foo.op" -> (%type : !pdl.type)
|
||||
%val = pdl.result 0 of %op1
|
||||
%op2 = pdl.operation "bar.op"(%val : !pdl.value)
|
||||
%type = type
|
||||
%op1 = operation "foo.op" -> (%type : !pdl.type)
|
||||
%val = result 0 of %op1
|
||||
%op2 = operation "bar.op"(%val : !pdl.value)
|
||||
// expected-note@below {{see a disconnected value / operation here}}
|
||||
%op3 = pdl.operation "baz.op"
|
||||
pdl.rewrite {
|
||||
pdl.erase %op1
|
||||
pdl.erase %op2
|
||||
pdl.erase %op3
|
||||
%op3 = operation "baz.op"
|
||||
rewrite {
|
||||
erase %op1
|
||||
erase %op2
|
||||
erase %op3
|
||||
}
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%type = pdl.type : i32
|
||||
%root = pdl.operation "foo.op" -> (%type : !pdl.type)
|
||||
pdl.rewrite %root {
|
||||
%newOp = pdl.operation "foo.op" -> (%type : !pdl.type)
|
||||
%newResult = pdl.result 0 of %newOp
|
||||
%type = type : i32
|
||||
%root = operation "foo.op" -> (%type : !pdl.type)
|
||||
rewrite %root {
|
||||
%newOp = operation "foo.op" -> (%type : !pdl.type)
|
||||
%newResult = result 0 of %newOp
|
||||
|
||||
// expected-error@below {{expected no replacement values to be provided when the replacement operation is present}}
|
||||
"pdl.replace"(%root, %newOp, %newResult) {
|
||||
|
@ -228,10 +228,10 @@ pdl.pattern : benefit(1) {
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%root = pdl.operation "foo.op"
|
||||
%root = operation "foo.op"
|
||||
// expected-error@below {{expected `pdl.range<value>` result type when no index is specified, but got: '!pdl.value'}}
|
||||
%results = "pdl.results"(%root) : (!pdl.operation) -> !pdl.value
|
||||
pdl.rewrite %root with "rewriter"
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -241,7 +241,7 @@ pdl.pattern : benefit(1) {
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%op = pdl.operation "foo.op"
|
||||
%op = operation "foo.op"
|
||||
|
||||
// expected-error@below {{expected rewrite region to be non-empty if external name is not specified}}
|
||||
"pdl.rewrite"(%op) ({}) {
|
||||
|
@ -252,7 +252,7 @@ pdl.pattern : benefit(1) {
|
|||
// -----
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%op = pdl.operation "foo.op"
|
||||
%op = operation "foo.op"
|
||||
|
||||
// expected-error@below {{expected no external arguments when the rewrite is specified inline}}
|
||||
"pdl.rewrite"(%op, %op) ({
|
||||
|
@ -265,7 +265,7 @@ pdl.pattern : benefit(1) {
|
|||
// -----
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%op = pdl.operation "foo.op"
|
||||
%op = operation "foo.op"
|
||||
|
||||
// expected-error@below {{expected no external constant parameters when the rewrite is specified inline}}
|
||||
"pdl.rewrite"(%op) ({
|
||||
|
@ -278,7 +278,7 @@ pdl.pattern : benefit(1) {
|
|||
// -----
|
||||
|
||||
pdl.pattern : benefit(1) {
|
||||
%op = pdl.operation "foo.op"
|
||||
%op = operation "foo.op"
|
||||
|
||||
// expected-error@below {{expected rewrite region to be empty when rewrite is external}}
|
||||
"pdl.rewrite"(%op) ({
|
||||
|
@ -297,10 +297,10 @@ pdl.pattern : benefit(1) {
|
|||
|
||||
pdl.pattern : benefit(1) {
|
||||
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
|
||||
%unused = pdl.type
|
||||
%unused = type
|
||||
|
||||
%op = pdl.operation "foo.op"
|
||||
pdl.rewrite %op with "rewriter"
|
||||
%op = operation "foo.op"
|
||||
rewrite %op with "rewriter"
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -311,8 +311,8 @@ pdl.pattern : benefit(1) {
|
|||
|
||||
pdl.pattern : benefit(1) {
|
||||
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
|
||||
%unused = pdl.types
|
||||
%unused = types
|
||||
|
||||
%op = pdl.operation "foo.op"
|
||||
pdl.rewrite %op with "rewriter"
|
||||
%op = operation "foo.op"
|
||||
rewrite %op with "rewriter"
|
||||
}
|
||||
|
|
|
@ -6,68 +6,68 @@
|
|||
|
||||
pdl.pattern @operations : benefit(1) {
|
||||
// Operation with attributes and results.
|
||||
%attribute = pdl.attribute
|
||||
%type = pdl.type
|
||||
%op0 = pdl.operation {"attr" = %attribute} -> (%type : !pdl.type)
|
||||
%attribute = attribute
|
||||
%type = type
|
||||
%op0 = operation {"attr" = %attribute} -> (%type : !pdl.type)
|
||||
%op0_result = pdl.result 0 of %op0
|
||||
|
||||
// Operation with input.
|
||||
%input = pdl.operand
|
||||
%root = pdl.operation(%op0_result, %input : !pdl.value, !pdl.value)
|
||||
pdl.rewrite %root with "rewriter"
|
||||
%input = operand
|
||||
%root = operation(%op0_result, %input : !pdl.value, !pdl.value)
|
||||
rewrite %root with "rewriter"
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
pdl.pattern @rewrite_with_args : benefit(1) {
|
||||
%input = pdl.operand
|
||||
%root = pdl.operation(%input : !pdl.value)
|
||||
pdl.rewrite %root with "rewriter"(%input : !pdl.value)
|
||||
%input = operand
|
||||
%root = operation(%input : !pdl.value)
|
||||
rewrite %root with "rewriter"(%input : !pdl.value)
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
pdl.pattern @rewrite_with_params : benefit(1) {
|
||||
%root = pdl.operation
|
||||
pdl.rewrite %root with "rewriter"["I am param"]
|
||||
%root = operation
|
||||
rewrite %root with "rewriter"["I am param"]
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
pdl.pattern @rewrite_with_args_and_params : benefit(1) {
|
||||
%input = pdl.operand
|
||||
%root = pdl.operation(%input : !pdl.value)
|
||||
pdl.rewrite %root with "rewriter"["I am param"](%input : !pdl.value)
|
||||
%input = operand
|
||||
%root = operation(%input : !pdl.value)
|
||||
rewrite %root with "rewriter"["I am param"](%input : !pdl.value)
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
pdl.pattern @rewrite_multi_root_optimal : benefit(2) {
|
||||
%input1 = pdl.operand
|
||||
%input2 = pdl.operand
|
||||
%type = pdl.type
|
||||
%op1 = pdl.operation(%input1 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val1 = pdl.result 0 of %op1
|
||||
%root1 = pdl.operation(%val1 : !pdl.value)
|
||||
%op2 = pdl.operation(%input2 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val2 = pdl.result 0 of %op2
|
||||
%root2 = pdl.operation(%val1, %val2 : !pdl.value, !pdl.value)
|
||||
pdl.rewrite with "rewriter"["I am param"](%root1, %root2 : !pdl.operation, !pdl.operation)
|
||||
%input1 = operand
|
||||
%input2 = operand
|
||||
%type = type
|
||||
%op1 = operation(%input1 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val1 = result 0 of %op1
|
||||
%root1 = operation(%val1 : !pdl.value)
|
||||
%op2 = operation(%input2 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val2 = result 0 of %op2
|
||||
%root2 = operation(%val1, %val2 : !pdl.value, !pdl.value)
|
||||
rewrite with "rewriter"["I am param"](%root1, %root2 : !pdl.operation, !pdl.operation)
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
pdl.pattern @rewrite_multi_root_forced : benefit(2) {
|
||||
%input1 = pdl.operand
|
||||
%input2 = pdl.operand
|
||||
%type = pdl.type
|
||||
%op1 = pdl.operation(%input1 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val1 = pdl.result 0 of %op1
|
||||
%root1 = pdl.operation(%val1 : !pdl.value)
|
||||
%op2 = pdl.operation(%input2 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val2 = pdl.result 0 of %op2
|
||||
%root2 = pdl.operation(%val1, %val2 : !pdl.value, !pdl.value)
|
||||
pdl.rewrite %root1 with "rewriter"["I am param"](%root2 : !pdl.operation)
|
||||
%input1 = operand
|
||||
%input2 = operand
|
||||
%type = type
|
||||
%op1 = operation(%input1 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val1 = result 0 of %op1
|
||||
%root1 = operation(%val1 : !pdl.value)
|
||||
%op2 = operation(%input2 : !pdl.value) -> (%type : !pdl.type)
|
||||
%val2 = result 0 of %op2
|
||||
%root2 = operation(%val1, %val2 : !pdl.value, !pdl.value)
|
||||
rewrite %root1 with "rewriter"["I am param"](%root2 : !pdl.operation)
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -75,13 +75,13 @@ pdl.pattern @rewrite_multi_root_forced : benefit(2) {
|
|||
// Check that the result type of an operation within a rewrite can be inferred
|
||||
// from a pdl.replace.
|
||||
pdl.pattern @infer_type_from_operation_replace : benefit(1) {
|
||||
%type1 = pdl.type : i32
|
||||
%type2 = pdl.type
|
||||
%root = pdl.operation -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
pdl.rewrite %root {
|
||||
%type3 = pdl.type
|
||||
%newOp = pdl.operation "foo.op" -> (%type1, %type3 : !pdl.type, !pdl.type)
|
||||
pdl.replace %root with %newOp
|
||||
%type1 = type : i32
|
||||
%type2 = type
|
||||
%root = operation -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
rewrite %root {
|
||||
%type3 = type
|
||||
%newOp = operation "foo.op" -> (%type1, %type3 : !pdl.type, !pdl.type)
|
||||
replace %root with %newOp
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,11 +90,11 @@ pdl.pattern @infer_type_from_operation_replace : benefit(1) {
|
|||
// Check that the result type of an operation within a rewrite can be inferred
|
||||
// from the result types of an operation within the match block.
|
||||
pdl.pattern @infer_type_from_type_used_in_match : benefit(1) {
|
||||
%type1 = pdl.type : i32
|
||||
%type2 = pdl.type
|
||||
%root = pdl.operation -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
pdl.rewrite %root {
|
||||
%newOp = pdl.operation "foo.op" -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
%type1 = type : i32
|
||||
%type2 = type
|
||||
%root = operation -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
rewrite %root {
|
||||
%newOp = operation "foo.op" -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,11 +103,11 @@ pdl.pattern @infer_type_from_type_used_in_match : benefit(1) {
|
|||
// Check that the result type of an operation within a rewrite can be inferred
|
||||
// from the result types of an operation within the match block.
|
||||
pdl.pattern @infer_type_from_type_used_in_match : benefit(1) {
|
||||
%types = pdl.types
|
||||
%root = pdl.operation -> (%types : !pdl.range<type>)
|
||||
pdl.rewrite %root {
|
||||
%otherTypes = pdl.types : [i32, i64]
|
||||
%newOp = pdl.operation "foo.op" -> (%types, %otherTypes : !pdl.range<type>, !pdl.range<type>)
|
||||
%types = types
|
||||
%root = operation -> (%types : !pdl.range<type>)
|
||||
rewrite %root {
|
||||
%otherTypes = types : [i32, i64]
|
||||
%newOp = operation "foo.op" -> (%types, %otherTypes : !pdl.range<type>, !pdl.range<type>)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,13 +116,13 @@ pdl.pattern @infer_type_from_type_used_in_match : benefit(1) {
|
|||
// Check that the result type of an operation within a rewrite can be inferred
|
||||
// from the type of an operand within the match block.
|
||||
pdl.pattern @infer_type_from_type_used_in_match : benefit(1) {
|
||||
%type1 = pdl.type
|
||||
%type2 = pdl.type
|
||||
%operand1 = pdl.operand : %type1
|
||||
%operand2 = pdl.operand : %type2
|
||||
%root = pdl.operation (%operand1, %operand2 : !pdl.value, !pdl.value)
|
||||
pdl.rewrite %root {
|
||||
%newOp = pdl.operation "foo.op" -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
%type1 = type
|
||||
%type2 = type
|
||||
%operand1 = operand : %type1
|
||||
%operand2 = operand : %type2
|
||||
%root = operation (%operand1, %operand2 : !pdl.value, !pdl.value)
|
||||
rewrite %root {
|
||||
%newOp = operation "foo.op" -> (%type1, %type2 : !pdl.type, !pdl.type)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,29 +131,29 @@ pdl.pattern @infer_type_from_type_used_in_match : benefit(1) {
|
|||
// Check that the result type of an operation within a rewrite can be inferred
|
||||
// from the types of operands within the match block.
|
||||
pdl.pattern @infer_type_from_type_used_in_match : benefit(1) {
|
||||
%types = pdl.types
|
||||
%operands = pdl.operands : %types
|
||||
%root = pdl.operation (%operands : !pdl.range<value>)
|
||||
pdl.rewrite %root {
|
||||
%newOp = pdl.operation "foo.op" -> (%types : !pdl.range<type>)
|
||||
%types = types
|
||||
%operands = operands : %types
|
||||
%root = operation (%operands : !pdl.range<value>)
|
||||
rewrite %root {
|
||||
%newOp = operation "foo.op" -> (%types : !pdl.range<type>)
|
||||
}
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
pdl.pattern @apply_rewrite_with_no_results : benefit(1) {
|
||||
%root = pdl.operation
|
||||
pdl.rewrite %root {
|
||||
pdl.apply_native_rewrite "NativeRewrite"(%root : !pdl.operation)
|
||||
%root = operation
|
||||
rewrite %root {
|
||||
apply_native_rewrite "NativeRewrite"(%root : !pdl.operation)
|
||||
}
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
pdl.pattern @attribute_with_dict : benefit(1) {
|
||||
%root = pdl.operation
|
||||
pdl.rewrite %root {
|
||||
%attr = pdl.attribute {some_unit_attr} attributes {pdl.special_attribute}
|
||||
pdl.apply_native_rewrite "NativeRewrite"(%attr : !pdl.attribute)
|
||||
%root = operation
|
||||
rewrite %root {
|
||||
%attr = attribute {some_unit_attr} attributes {pdl.special_attribute}
|
||||
apply_native_rewrite "NativeRewrite"(%attr : !pdl.attribute)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,13 +16,13 @@ def constructAndPrintInModule(f):
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @operations : benefit(1) {
|
||||
# CHECK: %0 = pdl.attribute
|
||||
# CHECK: %1 = pdl.type
|
||||
# CHECK: %2 = pdl.operation {"attr" = %0} -> (%1 : !pdl.type)
|
||||
# CHECK: %3 = pdl.result 0 of %2
|
||||
# CHECK: %4 = pdl.operand
|
||||
# CHECK: %5 = pdl.operation(%3, %4 : !pdl.value, !pdl.value)
|
||||
# CHECK: pdl.rewrite %5 with "rewriter"
|
||||
# CHECK: %0 = attribute
|
||||
# CHECK: %1 = type
|
||||
# CHECK: %2 = operation {"attr" = %0} -> (%1 : !pdl.type)
|
||||
# CHECK: %3 = result 0 of %2
|
||||
# CHECK: %4 = operand
|
||||
# CHECK: %5 = operation(%3, %4 : !pdl.value, !pdl.value)
|
||||
# CHECK: rewrite %5 with "rewriter"
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
@constructAndPrintInModule
|
||||
|
@ -40,9 +40,9 @@ def test_operations():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @rewrite_with_args : benefit(1) {
|
||||
# CHECK: %0 = pdl.operand
|
||||
# CHECK: %1 = pdl.operation(%0 : !pdl.value)
|
||||
# CHECK: pdl.rewrite %1 with "rewriter"(%0 : !pdl.value)
|
||||
# CHECK: %0 = operand
|
||||
# CHECK: %1 = operation(%0 : !pdl.value)
|
||||
# CHECK: rewrite %1 with "rewriter"(%0 : !pdl.value)
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
@constructAndPrintInModule
|
||||
|
@ -55,8 +55,8 @@ def test_rewrite_with_args():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @rewrite_with_params : benefit(1) {
|
||||
# CHECK: %0 = pdl.operation
|
||||
# CHECK: pdl.rewrite %0 with "rewriter" ["I am param"]
|
||||
# CHECK: %0 = operation
|
||||
# CHECK: rewrite %0 with "rewriter" ["I am param"]
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
@constructAndPrintInModule
|
||||
|
@ -68,9 +68,9 @@ def test_rewrite_with_params():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @rewrite_with_args_and_params : benefit(1) {
|
||||
# CHECK: %0 = pdl.operand
|
||||
# CHECK: %1 = pdl.operation(%0 : !pdl.value)
|
||||
# CHECK: pdl.rewrite %1 with "rewriter" ["I am param"](%0 : !pdl.value)
|
||||
# CHECK: %0 = operand
|
||||
# CHECK: %1 = operation(%0 : !pdl.value)
|
||||
# CHECK: rewrite %1 with "rewriter" ["I am param"](%0 : !pdl.value)
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
@constructAndPrintInModule
|
||||
|
@ -83,16 +83,16 @@ def test_rewrite_with_args_and_params():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @rewrite_multi_root_optimal : benefit(1) {
|
||||
# CHECK: %0 = pdl.operand
|
||||
# CHECK: %1 = pdl.operand
|
||||
# CHECK: %2 = pdl.type
|
||||
# CHECK: %3 = pdl.operation(%0 : !pdl.value) -> (%2 : !pdl.type)
|
||||
# CHECK: %4 = pdl.result 0 of %3
|
||||
# CHECK: %5 = pdl.operation(%4 : !pdl.value)
|
||||
# CHECK: %6 = pdl.operation(%1 : !pdl.value) -> (%2 : !pdl.type)
|
||||
# CHECK: %7 = pdl.result 0 of %6
|
||||
# CHECK: %8 = pdl.operation(%4, %7 : !pdl.value, !pdl.value)
|
||||
# CHECK: pdl.rewrite with "rewriter" ["I am param"](%5, %8 : !pdl.operation, !pdl.operation)
|
||||
# CHECK: %0 = operand
|
||||
# CHECK: %1 = operand
|
||||
# CHECK: %2 = type
|
||||
# CHECK: %3 = operation(%0 : !pdl.value) -> (%2 : !pdl.type)
|
||||
# CHECK: %4 = result 0 of %3
|
||||
# CHECK: %5 = operation(%4 : !pdl.value)
|
||||
# CHECK: %6 = operation(%1 : !pdl.value) -> (%2 : !pdl.type)
|
||||
# CHECK: %7 = result 0 of %6
|
||||
# CHECK: %8 = operation(%4, %7 : !pdl.value, !pdl.value)
|
||||
# CHECK: rewrite with "rewriter" ["I am param"](%5, %8 : !pdl.operation, !pdl.operation)
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
@constructAndPrintInModule
|
||||
|
@ -112,16 +112,16 @@ def test_rewrite_multi_root_optimal():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @rewrite_multi_root_forced : benefit(1) {
|
||||
# CHECK: %0 = pdl.operand
|
||||
# CHECK: %1 = pdl.operand
|
||||
# CHECK: %2 = pdl.type
|
||||
# CHECK: %3 = pdl.operation(%0 : !pdl.value) -> (%2 : !pdl.type)
|
||||
# CHECK: %4 = pdl.result 0 of %3
|
||||
# CHECK: %5 = pdl.operation(%4 : !pdl.value)
|
||||
# CHECK: %6 = pdl.operation(%1 : !pdl.value) -> (%2 : !pdl.type)
|
||||
# CHECK: %7 = pdl.result 0 of %6
|
||||
# CHECK: %8 = pdl.operation(%4, %7 : !pdl.value, !pdl.value)
|
||||
# CHECK: pdl.rewrite %5 with "rewriter" ["I am param"](%8 : !pdl.operation)
|
||||
# CHECK: %0 = operand
|
||||
# CHECK: %1 = operand
|
||||
# CHECK: %2 = type
|
||||
# CHECK: %3 = operation(%0 : !pdl.value) -> (%2 : !pdl.type)
|
||||
# CHECK: %4 = result 0 of %3
|
||||
# CHECK: %5 = operation(%4 : !pdl.value)
|
||||
# CHECK: %6 = operation(%1 : !pdl.value) -> (%2 : !pdl.type)
|
||||
# CHECK: %7 = result 0 of %6
|
||||
# CHECK: %8 = operation(%4, %7 : !pdl.value, !pdl.value)
|
||||
# CHECK: rewrite %5 with "rewriter" ["I am param"](%8 : !pdl.operation)
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
@constructAndPrintInModule
|
||||
|
@ -141,13 +141,13 @@ def test_rewrite_multi_root_forced():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @rewrite_add_body : benefit(1) {
|
||||
# CHECK: %0 = pdl.type : i32
|
||||
# CHECK: %1 = pdl.type
|
||||
# CHECK: %2 = pdl.operation -> (%0, %1 : !pdl.type, !pdl.type)
|
||||
# CHECK: pdl.rewrite %2 {
|
||||
# CHECK: %3 = pdl.type
|
||||
# CHECK: %4 = pdl.operation "foo.op" -> (%0, %3 : !pdl.type, !pdl.type)
|
||||
# CHECK: pdl.replace %2 with %4
|
||||
# CHECK: %0 = type : i32
|
||||
# CHECK: %1 = type
|
||||
# CHECK: %2 = operation -> (%0, %1 : !pdl.type, !pdl.type)
|
||||
# CHECK: rewrite %2 {
|
||||
# CHECK: %3 = type
|
||||
# CHECK: %4 = operation "foo.op" -> (%0, %3 : !pdl.type, !pdl.type)
|
||||
# CHECK: replace %2 with %4
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
|
@ -166,11 +166,11 @@ def test_rewrite_add_body():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @rewrite_type : benefit(1) {
|
||||
# CHECK: %0 = pdl.type : i32
|
||||
# CHECK: %1 = pdl.type
|
||||
# CHECK: %2 = pdl.operation -> (%0, %1 : !pdl.type, !pdl.type)
|
||||
# CHECK: pdl.rewrite %2 {
|
||||
# CHECK: %3 = pdl.operation "foo.op" -> (%0, %1 : !pdl.type, !pdl.type)
|
||||
# CHECK: %0 = type : i32
|
||||
# CHECK: %1 = type
|
||||
# CHECK: %2 = operation -> (%0, %1 : !pdl.type, !pdl.type)
|
||||
# CHECK: rewrite %2 {
|
||||
# CHECK: %3 = operation "foo.op" -> (%0, %1 : !pdl.type, !pdl.type)
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
|
@ -187,11 +187,11 @@ def test_rewrite_type():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @rewrite_types : benefit(1) {
|
||||
# CHECK: %0 = pdl.types
|
||||
# CHECK: %1 = pdl.operation -> (%0 : !pdl.range<type>)
|
||||
# CHECK: pdl.rewrite %1 {
|
||||
# CHECK: %2 = pdl.types : [i32, i64]
|
||||
# CHECK: %3 = pdl.operation "foo.op" -> (%0, %2 : !pdl.range<type>, !pdl.range<type>)
|
||||
# CHECK: %0 = types
|
||||
# CHECK: %1 = operation -> (%0 : !pdl.range<type>)
|
||||
# CHECK: rewrite %1 {
|
||||
# CHECK: %2 = types : [i32, i64]
|
||||
# CHECK: %3 = operation "foo.op" -> (%0, %2 : !pdl.range<type>, !pdl.range<type>)
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
|
@ -208,11 +208,11 @@ def test_rewrite_types():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @rewrite_operands : benefit(1) {
|
||||
# CHECK: %0 = pdl.types
|
||||
# CHECK: %1 = pdl.operands : %0
|
||||
# CHECK: %2 = pdl.operation(%1 : !pdl.range<value>)
|
||||
# CHECK: pdl.rewrite %2 {
|
||||
# CHECK: %3 = pdl.operation "foo.op" -> (%0 : !pdl.range<type>)
|
||||
# CHECK: %0 = types
|
||||
# CHECK: %1 = operands : %0
|
||||
# CHECK: %2 = operation(%1 : !pdl.range<value>)
|
||||
# CHECK: rewrite %2 {
|
||||
# CHECK: %3 = operation "foo.op" -> (%0 : !pdl.range<type>)
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
|
@ -229,9 +229,9 @@ def test_rewrite_operands():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @native_rewrite : benefit(1) {
|
||||
# CHECK: %0 = pdl.operation
|
||||
# CHECK: pdl.rewrite %0 {
|
||||
# CHECK: pdl.apply_native_rewrite "NativeRewrite"(%0 : !pdl.operation)
|
||||
# CHECK: %0 = operation
|
||||
# CHECK: rewrite %0 {
|
||||
# CHECK: apply_native_rewrite "NativeRewrite"(%0 : !pdl.operation)
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
|
@ -246,10 +246,10 @@ def test_native_rewrite():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @attribute_with_value : benefit(1) {
|
||||
# CHECK: %0 = pdl.operation
|
||||
# CHECK: pdl.rewrite %0 {
|
||||
# CHECK: %1 = pdl.attribute "value"
|
||||
# CHECK: pdl.apply_native_rewrite "NativeRewrite"(%1 : !pdl.attribute)
|
||||
# CHECK: %0 = operation
|
||||
# CHECK: rewrite %0 {
|
||||
# CHECK: %1 = attribute "value"
|
||||
# CHECK: apply_native_rewrite "NativeRewrite"(%1 : !pdl.attribute)
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
|
@ -265,9 +265,9 @@ def test_attribute_with_value():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @erase : benefit(1) {
|
||||
# CHECK: %0 = pdl.operation
|
||||
# CHECK: pdl.rewrite %0 {
|
||||
# CHECK: pdl.erase %0
|
||||
# CHECK: %0 = operation
|
||||
# CHECK: rewrite %0 {
|
||||
# CHECK: erase %0
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
|
@ -282,11 +282,11 @@ def test_erase():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern @operation_results : benefit(1) {
|
||||
# CHECK: %0 = pdl.types
|
||||
# CHECK: %1 = pdl.operation -> (%0 : !pdl.range<type>)
|
||||
# CHECK: %2 = pdl.results of %1
|
||||
# CHECK: %3 = pdl.operation(%2 : !pdl.range<value>)
|
||||
# CHECK: pdl.rewrite %3 with "rewriter"
|
||||
# CHECK: %0 = types
|
||||
# CHECK: %1 = operation -> (%0 : !pdl.range<type>)
|
||||
# CHECK: %2 = results of %1
|
||||
# CHECK: %3 = operation(%2 : !pdl.range<value>)
|
||||
# CHECK: rewrite %3 with "rewriter"
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
@constructAndPrintInModule
|
||||
|
@ -302,10 +302,10 @@ def test_operation_results():
|
|||
|
||||
# CHECK: module {
|
||||
# CHECK: pdl.pattern : benefit(1) {
|
||||
# CHECK: %0 = pdl.type
|
||||
# CHECK: pdl.apply_native_constraint "typeConstraint" [](%0 : !pdl.type)
|
||||
# CHECK: %1 = pdl.operation -> (%0 : !pdl.type)
|
||||
# CHECK: pdl.rewrite %1 with "rewrite"
|
||||
# CHECK: %0 = type
|
||||
# CHECK: apply_native_constraint "typeConstraint" [](%0 : !pdl.type)
|
||||
# CHECK: %1 = operation -> (%0 : !pdl.type)
|
||||
# CHECK: rewrite %1 with "rewrite"
|
||||
# CHECK: }
|
||||
# CHECK: }
|
||||
@constructAndPrintInModule
|
||||
|
|
Loading…
Reference in New Issue