File tree Expand file tree Collapse file tree 4 files changed +61
-0
lines changed
Conversion/PDLToPDLInterp Expand file tree Collapse file tree 4 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,20 @@ module @constraint_with_result_multiple {
130
130
131
131
// -----
132
132
133
+ // CHECK-LABEL: module @negated_constraint
134
+ module @negated_constraint {
135
+ // CHECK: func @matcher(%[[ROOT:.*]]: !pdl.operation)
136
+ // CHECK: pdl_interp.apply_constraint "constraint"(%[[ROOT]] : !pdl.operation) {isNegated = true}
137
+ // CHECK: pdl_interp.record_match @rewriters::@pdl_generated_rewriter(%[[ROOT]] : !pdl.operation)
138
+ pdl.pattern : benefit (1 ) {
139
+ %root = operation
140
+ pdl.apply_native_constraint " constraint" (%root : !pdl.operation ) {isNegated = true }
141
+ rewrite %root with " rewriter"
142
+ }
143
+ }
144
+
145
+ // -----
146
+
133
147
// CHECK-LABEL: module @inputs
134
148
module @inputs {
135
149
// CHECK: func @matcher(%[[ROOT:.*]]: !pdl.operation)
Original file line number Diff line number Diff line change @@ -103,6 +103,38 @@ module @ir attributes { test.apply_constraint_3 } {
103
103
104
104
// -----
105
105
106
+ // Test support for negated constraints.
107
+ module @patterns {
108
+ pdl_interp.func @matcher (%root : !pdl.operation ) {
109
+ pdl_interp.apply_constraint " single_entity_constraint" (%root : !pdl.operation ) {isNegated = true } -> ^pat , ^end
110
+
111
+ ^pat :
112
+ pdl_interp.record_match @rewriters ::@success (%root : !pdl.operation ) : benefit (1 ), loc ([%root ]) -> ^end
113
+
114
+ ^end :
115
+ pdl_interp.finalize
116
+ }
117
+
118
+ module @rewriters {
119
+ pdl_interp.func @success (%root : !pdl.operation ) {
120
+ %op = pdl_interp.create_operation " test.replaced_by_pattern"
121
+ pdl_interp.erase %root
122
+ pdl_interp.finalize
123
+ }
124
+ }
125
+ }
126
+
127
+ // CHECK-LABEL: test.apply_constraint_4
128
+ // CHECK-NOT: "test.replaced_by_pattern"
129
+ // CHECK: "test.replaced_by_pattern"
130
+
131
+ module @ir attributes { test.apply_constraint_4 } {
132
+ " test.op" () : () -> ()
133
+ " test.foo" () : () -> ()
134
+ }
135
+
136
+ // -----
137
+
106
138
//===----------------------------------------------------------------------===//
107
139
// pdl_interp::ApplyRewriteOp
108
140
//===----------------------------------------------------------------------===//
Original file line number Diff line number Diff line change @@ -36,6 +36,20 @@ Pattern TestExternalCall => replace root: Op with TestRewrite(root);
36
36
37
37
// -----
38
38
39
+ // CHECK: pdl.pattern @TestExternalNegatedCall
40
+ // CHECK: %[[ROOT:.*]] = operation
41
+ // CHECK: apply_native_constraint "TestConstraint"(%[[ROOT]] : !pdl.operation) {isNegated = true}
42
+ // CHECK: rewrite %[[ROOT]]
43
+ // CHECK: erase %[[ROOT]]
44
+ Constraint TestConstraint(op: Op);
45
+ Pattern TestExternalNegatedCall with benefit(1) {
46
+ let root = op : Op;
47
+ !TestConstraint(root);
48
+ erase root;
49
+ }
50
+
51
+ // -----
52
+
39
53
//===----------------------------------------------------------------------===//
40
54
// MemberAccessExpr
41
55
//===----------------------------------------------------------------------===//
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ Pattern {
90
90
!checkOp(inputOp);
91
91
erase inputOp;
92
92
}
93
+
93
94
// -----
94
95
95
96
//===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments