78 lines · plain
1// RUN: mlir-opt -split-input-file -convert-pdl-to-pdl-interp %s | FileCheck %s2 3// Ensuse that the dependency between add & less4// causes them to be in the correct order.5// CHECK-LABEL: matcher6// CHECK: apply_constraint "return_attr_constraint"7// CHECK: apply_constraint "use_attr_constraint"8 9module {10 pdl.pattern : benefit(1) {11 %0 = attribute12 %1 = types13 %2 = operation "tosa.mul" {"shift" = %0} -> (%1 : !pdl.range<type>)14 %3 = attribute = 0 : i3215 %4 = attribute = 1 : i3216 %5 = apply_native_constraint "return_attr_constraint"(%3, %4 : !pdl.attribute, !pdl.attribute) : !pdl.attribute17 apply_native_constraint "use_attr_constraint"(%0, %5 : !pdl.attribute, !pdl.attribute)18 rewrite %2 with "rewriter"19 }20}21 22// -----23 24// CHECK-LABEL: matcher25// CHECK: %[[ATTR:.*]] = pdl_interp.get_attribute "attr" of26// CHECK: %[[CONSTRAINT:.*]] = pdl_interp.apply_constraint "return_attr_constraint"27// CHECK: pdl_interp.are_equal %[[ATTR:.*]], %[[CONSTRAINT:.*]]28 29pdl.pattern : benefit(1) {30 %inputOp = operation31 %result = result 0 of %inputOp32 %attr = pdl.apply_native_constraint "return_attr_constraint"(%inputOp : !pdl.operation) : !pdl.attribute33 %root = operation(%result : !pdl.value) {"attr" = %attr}34 rewrite %root with "rewriter"(%attr : !pdl.attribute)35}36 37// -----38 39// CHECK-LABEL: matcher40// CHECK: %[[CONSTRAINT:.*]] = pdl_interp.apply_constraint "return_value_constr"41// CHECK: %[[VALUE:.*]] = pdl_interp.get_operand 042// CHECK: pdl_interp.are_equal %[[VALUE:.*]], %[[CONSTRAINT:.*]]43 44pdl.pattern : benefit(1) {45 %attr = attribute = 1046 %value = pdl.apply_native_constraint "return_value_constr"(%attr: !pdl.attribute) : !pdl.value47 %root = operation(%value : !pdl.value)48 rewrite %root with "rewriter"49}50 51// -----52 53// CHECK-LABEL: matcher54// CHECK: %[[CONSTRAINT:.*]] = pdl_interp.apply_constraint "return_type_constr"55// CHECK: %[[TYPE:.*]] = pdl_interp.get_value_type of56// CHECK: pdl_interp.are_equal %[[TYPE:.*]], %[[CONSTRAINT:.*]]57 58pdl.pattern : benefit(1) {59 %attr = attribute = 1060 %type = pdl.apply_native_constraint "return_type_constr"(%attr: !pdl.attribute) : !pdl.type61 %root = operation -> (%type : !pdl.type)62 rewrite %root with "rewriter"63}64 65// -----66 67// CHECK-LABEL: matcher68// CHECK: %[[CONSTRAINT:.*]] = pdl_interp.apply_constraint "return_type_range_constr"69// CHECK: %[[TYPE:.*]] = pdl_interp.get_value_type of70// CHECK: pdl_interp.are_equal %[[TYPE:.*]], %[[CONSTRAINT:.*]]71 72pdl.pattern : benefit(1) {73 %attr = attribute = 1074 %types = pdl.apply_native_constraint "return_type_range_constr"(%attr: !pdl.attribute) : !pdl.range<type>75 %root = operation -> (%types : !pdl.range<type>)76 rewrite %root with "rewriter"77}78