1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
|
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
//===----------------------------------------------------------------------===//
// pdl::ApplyNativeConstraintOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
%op = operation "foo.op"
// expected-error@below {{expected at least one argument}}
"pdl.apply_native_constraint"() {name = "foo"} : () -> ()
rewrite %op with "rewriter"
}
// -----
//===----------------------------------------------------------------------===//
// pdl::ApplyNativeRewriteOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
%op = operation "foo.op"
rewrite %op {
// expected-error@below {{expected at least one argument}}
"pdl.apply_native_rewrite"() {name = "foo"} : () -> ()
}
}
// -----
//===----------------------------------------------------------------------===//
// pdl::AttributeOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
%type = type
// expected-error@below {{expected only one of [`type`, `value`] to be set}}
%attr = attribute : %type = 10
%op = operation "foo.op" {"attr" = %attr} -> (%type : !pdl.type)
rewrite %op with "rewriter"
}
// -----
pdl.pattern : benefit(1) {
%op = operation "foo.op"
rewrite %op {
%type = type
// expected-error@below {{expected constant value when specified within a `pdl.rewrite`}}
%attr = attribute : %type
}
}
// -----
pdl.pattern : benefit(1) {
%op = operation "foo.op"
rewrite %op {
// expected-error@below {{expected constant value when specified within a `pdl.rewrite`}}
%attr = attribute
}
}
// -----
pdl.pattern : benefit(1) {
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
%unused = attribute
%op = operation "foo.op"
rewrite %op with "rewriter"
}
// -----
//===----------------------------------------------------------------------===//
// pdl::OperandOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
%unused = operand
%op = operation "foo.op"
rewrite %op with "rewriter"
}
// -----
//===----------------------------------------------------------------------===//
// pdl::OperandsOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
%unused = operands
%op = operation "foo.op"
rewrite %op with "rewriter"
}
// -----
//===----------------------------------------------------------------------===//
// pdl::OperationOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
%op = operation "foo.op"
rewrite %op {
// expected-error@below {{must have an operation name when nested within a `pdl.rewrite`}}
%newOp = operation
}
}
// -----
pdl.pattern : benefit(1) {
// expected-error@below {{expected the same number of attribute values and attribute names, got 1 names and 0 values}}
%op = "pdl.operation"() {
attributeValueNames = ["attr"],
operandSegmentSizes = array<i32: 0, 0, 0>
} : () -> (!pdl.operation)
rewrite %op with "rewriter"
}
// -----
pdl.pattern : benefit(1) {
%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 = operation "builtin.unrealized_conversion_cast" -> (%type : !pdl.type)
}
}
// -----
// Unused operation only necessary to ensure the func dialect is loaded.
func.func private @unusedOpToLoadFuncDialect()
pdl.pattern : benefit(1) {
%op = operation "foo.op"
rewrite %op {
// expected-error@below {{op must have inferable or constrained result types when nested within `pdl.rewrite`}}
// expected-note@below {{operation is created in a non-inferrable context, but 'func.constant' does not implement InferTypeOpInterface}}
%newOp = operation "func.constant"
}
}
// -----
pdl.pattern : benefit(1) {
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
%unused = operation "foo.op"
%op = operation "foo.op"
rewrite %op with "rewriter"
}
// -----
//===----------------------------------------------------------------------===//
// pdl::PatternOp
//===----------------------------------------------------------------------===//
// expected-error@below {{expected body to terminate with `pdl.rewrite`}}
pdl.pattern : benefit(1) {
// expected-note@below {{see terminator defined here}}
"test.finish" () : () -> ()
}
// -----
// expected-error@below {{the pattern must contain at least one `pdl.operation`}}
pdl.pattern : benefit(1) {
rewrite with "foo"
}
// -----
// expected-error@below {{expected only `pdl` operations within the pattern body}}
pdl.pattern : benefit(1) {
// expected-note@below {{see non-`pdl` operation defined here}}
"test.foo.other_op"() : () -> ()
%root = operation "foo.op"
rewrite %root with "foo"
}
// -----
// expected-error@below {{the operations must form a connected component}}
pdl.pattern : benefit(1) {
%op1 = operation "foo.op"
%op2 = operation "bar.op"
// expected-note@below {{see a disconnected value / operation here}}
%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 = 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 = operation "baz.op"
rewrite {
erase %op1
erase %op2
erase %op3
}
}
// -----
pdl.pattern : benefit(1) {
%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) {
operandSegmentSizes = array<i32: 1, 1, 1>
} : (!pdl.operation, !pdl.operation, !pdl.value) -> ()
}
}
// -----
//===----------------------------------------------------------------------===//
// pdl::RangeOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
%operand = pdl.operand
%resultType = pdl.type
%root = pdl.operation "baz.op"(%operand : !pdl.value) -> (%resultType : !pdl.type)
rewrite %root {
// expected-error @below {{expected operand to have element type '!pdl.value', but got '!pdl.type'}}
%range = pdl.range %operand, %resultType : !pdl.value, !pdl.type
}
}
// -----
//===----------------------------------------------------------------------===//
// pdl::ResultsOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
%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
rewrite %root with "rewriter"
}
// -----
//===----------------------------------------------------------------------===//
// pdl::RewriteOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
%op = operation "foo.op"
// expected-error@below {{expected rewrite region to be non-empty if external name is not specified}}
"pdl.rewrite"(%op) ({}) {
operandSegmentSizes = array<i32: 1,0>
} : (!pdl.operation) -> ()
}
// -----
pdl.pattern : benefit(1) {
%op = operation "foo.op"
// expected-error@below {{expected no external arguments when the rewrite is specified inline}}
"pdl.rewrite"(%op, %op) ({
^bb1:
}) {
operandSegmentSizes = array<i32: 1, 1>
}: (!pdl.operation, !pdl.operation) -> ()
}
// -----
pdl.pattern : benefit(1) {
%op = operation "foo.op"
// expected-error@below {{expected rewrite region to be empty when rewrite is external}}
"pdl.rewrite"(%op) ({
^bb1:
}) {
name = "foo",
operandSegmentSizes = array<i32: 1,0>
} : (!pdl.operation) -> ()
}
// -----
//===----------------------------------------------------------------------===//
// pdl::TypeOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
%unused = type
%op = operation "foo.op"
rewrite %op with "rewriter"
}
// -----
//===----------------------------------------------------------------------===//
// pdl::TypesOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
// expected-error@below {{expected a bindable user when defined in the matcher body of a `pdl.pattern`}}
%unused = types
%op = operation "foo.op"
rewrite %op with "rewriter"
}
|