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 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
|
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
func.func @const_attribute_str() {
// expected-error @+1 {{'emitc.constant' op string attributes are not supported, use #emitc.opaque instead}}
%c0 = "emitc.constant"(){value = "NULL"} : () -> !emitc.ptr<i32>
return
}
// -----
func.func @const_attribute_return_type_1() {
// expected-error @+1 {{'emitc.constant' op requires attribute to either be an #emitc.opaque attribute or it's type ('i64') to match the op's result type ('i32')}}
%c0 = "emitc.constant"(){value = 42: i64} : () -> i32
return
}
// -----
func.func @const_attribute_return_type_2() {
// expected-error @+1 {{'emitc.constant' op attribute 'value' failed to satisfy constraint: An opaque attribute or TypedAttr instance}}
%c0 = "emitc.constant"(){value = unit} : () -> i32
return
}
// -----
func.func @empty_constant() {
// expected-error @+1 {{'emitc.constant' op value must not be empty}}
%c0 = "emitc.constant"(){value = #emitc.opaque<"">} : () -> i32
return
}
// -----
func.func @index_args_out_of_range_1() {
// expected-error @+1 {{'emitc.call_opaque' op index argument is out of range}}
emitc.call_opaque "test" () {args = [0 : index]} : () -> ()
return
}
// -----
func.func @index_args_out_of_range_2(%arg : i32) {
// expected-error @+1 {{'emitc.call_opaque' op index argument is out of range}}
emitc.call_opaque "test" (%arg, %arg) {args = [2 : index]} : (i32, i32) -> ()
return
}
// -----
func.func @empty_callee() {
// expected-error @+1 {{'emitc.call_opaque' op callee must not be empty}}
emitc.call_opaque "" () : () -> ()
return
}
// -----
func.func @nonetype_arg(%arg : i32) {
// expected-error @+1 {{'emitc.call_opaque' op array argument has no type}}
emitc.call_opaque "nonetype_arg"(%arg) {args = [0 : index, [0, 1, 2]]} : (i32) -> i32
return
}
// -----
func.func @array_template_arg(%arg : i32) {
// expected-error @+1 {{'emitc.call_opaque' op template argument has invalid type}}
emitc.call_opaque "nonetype_template_arg"(%arg) {template_args = [[0, 1, 2]]} : (i32) -> i32
return
}
// -----
func.func @dense_template_argument(%arg : i32) {
// expected-error @+1 {{'emitc.call_opaque' op template argument has invalid type}}
emitc.call_opaque "dense_template_argument"(%arg) {template_args = [dense<[1.0, 1.0]> : tensor<2xf32>]} : (i32) -> i32
return
}
// -----
func.func @array_result() {
// expected-error @+1 {{'emitc.call_opaque' op cannot return array type}}
emitc.call_opaque "array_result"() : () -> !emitc.array<4xi32>
return
}
// -----
func.func @empty_operator(%arg : i32) {
// expected-error @+1 {{'emitc.apply' op applicable operator must not be empty}}
%2 = emitc.apply ""(%arg) : (i32) -> !emitc.ptr<i32>
return
}
// -----
func.func @illegal_operator(%arg : i32) {
// expected-error @+1 {{'emitc.apply' op applicable operator is illegal}}
%2 = emitc.apply "+"(%arg) : (i32) -> !emitc.ptr<i32>
return
}
// -----
func.func @illegal_operand() {
%1 = "emitc.constant"(){value = 42: i32} : () -> i32
// expected-error @+1 {{'emitc.apply' op cannot apply to constant}}
%2 = emitc.apply "&"(%1) : (i32) -> !emitc.ptr<i32>
return
}
// -----
func.func @var_attribute_return_type_1() {
// expected-error @+1 {{'emitc.variable' op requires attribute to either be an #emitc.opaque attribute or it's type ('i64') to match the op's result type ('i32')}}
%c0 = "emitc.variable"(){value = 42: i64} : () -> i32
return
}
// -----
func.func @var_attribute_return_type_2() {
// expected-error @+1 {{'emitc.variable' op attribute 'value' failed to satisfy constraint: An opaque attribute or TypedAttr instance}}
%c0 = "emitc.variable"(){value = unit} : () -> i32
return
}
// -----
func.func @cast_tensor(%arg : tensor<f32>) {
// expected-error @+1 {{'emitc.cast' op operand type 'tensor<f32>' and result type 'tensor<f32>' are cast incompatible}}
%1 = emitc.cast %arg: tensor<f32> to tensor<f32>
return
}
// -----
func.func @cast_array(%arg : !emitc.array<4xf32>) {
// expected-error @+1 {{'emitc.cast' op operand type '!emitc.array<4xf32>' and result type '!emitc.array<4xf32>' are cast incompatible}}
%1 = emitc.cast %arg: !emitc.array<4xf32> to !emitc.array<4xf32>
return
}
// -----
func.func @add_two_pointers(%arg0: !emitc.ptr<f32>, %arg1: !emitc.ptr<f32>) {
// expected-error @+1 {{'emitc.add' op requires that at most one operand is a pointer}}
%1 = "emitc.add" (%arg0, %arg1) : (!emitc.ptr<f32>, !emitc.ptr<f32>) -> !emitc.ptr<f32>
return
}
// -----
func.func @add_pointer_float(%arg0: !emitc.ptr<f32>, %arg1: f32) {
// expected-error @+1 {{'emitc.add' op requires that one operand is an integer or of opaque type if the other is a pointer}}
%1 = "emitc.add" (%arg0, %arg1) : (!emitc.ptr<f32>, f32) -> !emitc.ptr<f32>
return
}
// -----
func.func @add_float_pointer(%arg0: f32, %arg1: !emitc.ptr<f32>) {
// expected-error @+1 {{'emitc.add' op requires that one operand is an integer or of opaque type if the other is a pointer}}
%1 = "emitc.add" (%arg0, %arg1) : (f32, !emitc.ptr<f32>) -> !emitc.ptr<f32>
return
}
// -----
func.func @div_tensor(%arg0: tensor<i32>, %arg1: tensor<i32>) {
// expected-error @+1 {{'emitc.div' op operand #0 must be floating-point type supported by EmitC or integer, index or opaque type supported by EmitC, but got 'tensor<i32>'}}
%1 = "emitc.div" (%arg0, %arg1) : (tensor<i32>, tensor<i32>) -> tensor<i32>
return
}
// -----
func.func @mul_tensor(%arg0: tensor<i32>, %arg1: tensor<i32>) {
// expected-error @+1 {{'emitc.mul' op operand #0 must be floating-point type supported by EmitC or integer, index or opaque type supported by EmitC, but got 'tensor<i32>'}}
%1 = "emitc.mul" (%arg0, %arg1) : (tensor<i32>, tensor<i32>) -> tensor<i32>
return
}
// -----
func.func @rem_tensor(%arg0: tensor<i32>, %arg1: tensor<i32>) {
// expected-error @+1 {{'emitc.rem' op operand #0 must be integer, index or opaque type supported by EmitC, but got 'tensor<i32>'}}
%1 = "emitc.rem" (%arg0, %arg1) : (tensor<i32>, tensor<i32>) -> tensor<i32>
return
}
// -----
func.func @rem_float(%arg0: f32, %arg1: f32) {
// expected-error @+1 {{'emitc.rem' op operand #0 must be integer, index or opaque type supported by EmitC, but got 'f32'}}
%1 = "emitc.rem" (%arg0, %arg1) : (f32, f32) -> f32
return
}
// -----
func.func @sub_int_pointer(%arg0: i32, %arg1: !emitc.ptr<f32>) {
// expected-error @+1 {{'emitc.sub' op rhs can only be a pointer if lhs is a pointer}}
%1 = "emitc.sub" (%arg0, %arg1) : (i32, !emitc.ptr<f32>) -> !emitc.ptr<f32>
return
}
// -----
func.func @sub_pointer_float(%arg0: !emitc.ptr<f32>, %arg1: f32) {
// expected-error @+1 {{'emitc.sub' op requires that rhs is an integer, pointer or of opaque type if lhs is a pointer}}
%1 = "emitc.sub" (%arg0, %arg1) : (!emitc.ptr<f32>, f32) -> !emitc.ptr<f32>
return
}
// -----
func.func @sub_pointer_pointer(%arg0: !emitc.ptr<f32>, %arg1: !emitc.ptr<f32>) {
// expected-error @+1 {{'emitc.sub' op requires that the result is an integer or of opaque type if lhs and rhs are pointers}}
%1 = "emitc.sub" (%arg0, %arg1) : (!emitc.ptr<f32>, !emitc.ptr<f32>) -> !emitc.ptr<f32>
return
}
// -----
func.func @test_misplaced_yield() {
// expected-error @+1 {{'emitc.yield' op expects parent op to be one of 'emitc.expression, emitc.if, emitc.for'}}
emitc.yield
return
}
// -----
func.func @test_assign_to_non_variable(%arg1: f32, %arg2: f32) {
// expected-error @+1 {{'emitc.assign' op requires first operand (<block argument> of type 'f32' at index: 1) to be a get_global, member, member of pointer, subscript or variable}}
emitc.assign %arg1 : f32 to %arg2 : f32
return
}
// -----
func.func @test_assign_type_mismatch(%arg1: f32) {
%v = "emitc.variable"() <{value = #emitc.opaque<"">}> : () -> i32
// expected-error @+1 {{'emitc.assign' op requires value's type ('f32') to match variable's type ('i32')}}
emitc.assign %arg1 : f32 to %v : i32
return
}
// -----
func.func @test_assign_to_array(%arg1: !emitc.array<4xi32>) {
%v = "emitc.variable"() <{value = #emitc.opaque<"">}> : () -> !emitc.array<4xi32>
// expected-error @+1 {{'emitc.assign' op cannot assign to array type}}
emitc.assign %arg1 : !emitc.array<4xi32> to %v : !emitc.array<4xi32>
return
}
// -----
func.func @test_expression_no_yield() -> i32 {
// expected-error @+1 {{'emitc.expression' op must yield a value at termination}}
%r = emitc.expression : i32 {
%c7 = "emitc.constant"(){value = 7 : i32} : () -> i32
}
return %r : i32
}
// -----
func.func @test_expression_illegal_op(%arg0 : i1) -> i32 {
// expected-error @+1 {{'emitc.expression' op contains an unsupported operation}}
%r = emitc.expression : i32 {
%x = "emitc.variable"() <{value = #emitc.opaque<"">}> : () -> i32
emitc.yield %x : i32
}
return %r : i32
}
// -----
func.func @test_expression_no_use(%arg0: i32, %arg1: i32) -> i32 {
// expected-error @+1 {{'emitc.expression' op requires exactly one use for each operation}}
%r = emitc.expression : i32 {
%a = emitc.add %arg0, %arg1 : (i32, i32) -> i32
%b = emitc.rem %arg0, %arg1 : (i32, i32) -> i32
emitc.yield %a : i32
}
return %r : i32
}
// -----
func.func @test_expression_multiple_uses(%arg0: i32, %arg1: i32) -> i32 {
// expected-error @+1 {{'emitc.expression' op requires exactly one use for each operation}}
%r = emitc.expression : i32 {
%a = emitc.rem %arg0, %arg1 : (i32, i32) -> i32
%b = emitc.add %a, %arg0 : (i32, i32) -> i32
%c = emitc.mul %arg1, %a : (i32, i32) -> i32
emitc.yield %a : i32
}
return %r : i32
}
// -----
func.func @test_expression_multiple_results(%arg0: i32) -> i32 {
// expected-error @+1 {{'emitc.expression' op requires exactly one result for each operation}}
%r = emitc.expression : i32 {
%a:2 = emitc.call_opaque "bar" (%arg0) : (i32) -> (i32, i32)
emitc.yield %a : i32
}
return %r : i32
}
// -----
// expected-error @+1 {{'emitc.func' op requires zero or exactly one result, but has 2}}
emitc.func @multiple_results(%0: i32) -> (i32, i32) {
emitc.return %0 : i32
}
// -----
emitc.func @resulterror() -> i32 {
^bb42:
emitc.return // expected-error {{'emitc.return' op has 0 operands, but enclosing function (@resulterror) returns 1}}
}
// -----
emitc.func @return_type_mismatch() -> i32 {
%0 = emitc.call_opaque "foo()"(): () -> f32
emitc.return %0 : f32 // expected-error {{type of the return operand ('f32') doesn't match function result type ('i32') in function @return_type_mismatch}}
}
// -----
// expected-error@+1 {{'emitc.func' op cannot return array type}}
emitc.func @return_type_array(%arg : !emitc.array<4xi32>) -> !emitc.array<4xi32> {
emitc.return %arg : !emitc.array<4xi32>
}
// -----
func.func @return_inside_func.func(%0: i32) -> (i32) {
// expected-error@+1 {{'emitc.return' op expects parent op 'emitc.func'}}
emitc.return %0 : i32
}
// -----
// expected-error@+1 {{expected non-function type}}
emitc.func @func_variadic(...)
// -----
// expected-error@+1 {{'emitc.declare_func' op 'bar' does not reference a valid function}}
emitc.declare_func @bar
// -----
// expected-error@+1 {{'emitc.declare_func' op requires attribute 'sym_name'}}
"emitc.declare_func"() : () -> ()
// -----
func.func @logical_and_resulterror(%arg0: i32, %arg1: i32) {
// expected-error @+1 {{'emitc.logical_and' op result #0 must be 1-bit signless integer, but got 'i32'}}
%0 = "emitc.logical_and"(%arg0, %arg1) : (i32, i32) -> i32
return
}
// -----
func.func @logical_not_resulterror(%arg0: i32) {
// expected-error @+1 {{'emitc.logical_not' op result #0 must be 1-bit signless integer, but got 'i32'}}
%0 = "emitc.logical_not"(%arg0) : (i32) -> i32
return
}
// -----
func.func @logical_or_resulterror(%arg0: i32, %arg1: i32) {
// expected-error @+1 {{'emitc.logical_or' op result #0 must be 1-bit signless integer, but got 'i32'}}
%0 = "emitc.logical_or"(%arg0, %arg1) : (i32, i32) -> i32
return
}
// -----
func.func @test_subscript_array_indices_mismatch(%arg0: !emitc.array<4x8xf32>, %arg1: index) {
// expected-error @+1 {{'emitc.subscript' op on array operand requires number of indices (1) to match the rank of the array type (2)}}
%0 = emitc.subscript %arg0[%arg1] : (!emitc.array<4x8xf32>, index) -> f32
return
}
// -----
func.func @test_subscript_array_index_type_mismatch(%arg0: !emitc.array<4x8xf32>, %arg1: index, %arg2: f32) {
// expected-error @+1 {{'emitc.subscript' op on array operand requires index operand 1 to be integer-like, but got 'f32'}}
%0 = emitc.subscript %arg0[%arg1, %arg2] : (!emitc.array<4x8xf32>, index, f32) -> f32
return
}
// -----
func.func @test_subscript_array_type_mismatch(%arg0: !emitc.array<4x8xf32>, %arg1: index, %arg2: index) {
// expected-error @+1 {{'emitc.subscript' op on array operand requires element type ('f32') and result type ('i32') to match}}
%0 = emitc.subscript %arg0[%arg1, %arg2] : (!emitc.array<4x8xf32>, index, index) -> i32
return
}
// -----
func.func @test_subscript_ptr_indices_mismatch(%arg0: !emitc.ptr<f32>, %arg1: index) {
// expected-error @+1 {{'emitc.subscript' op on pointer operand requires one index operand, but got 2}}
%0 = emitc.subscript %arg0[%arg1, %arg1] : (!emitc.ptr<f32>, index, index) -> f32
return
}
// -----
func.func @test_subscript_ptr_index_type_mismatch(%arg0: !emitc.ptr<f32>, %arg1: f64) {
// expected-error @+1 {{'emitc.subscript' op on pointer operand requires index operand to be integer-like, but got 'f64'}}
%0 = emitc.subscript %arg0[%arg1] : (!emitc.ptr<f32>, f64) -> f32
return
}
// -----
func.func @test_subscript_ptr_type_mismatch(%arg0: !emitc.ptr<f32>, %arg1: index) {
// expected-error @+1 {{'emitc.subscript' op on pointer operand requires pointee type ('f32') and result type ('f64') to match}}
%0 = emitc.subscript %arg0[%arg1] : (!emitc.ptr<f32>, index) -> f64
return
}
// -----
// expected-error @+1 {{'emitc.global' op cannot have both static and extern specifiers}}
emitc.global extern static @uninit : i32
// -----
emitc.global @myglobal : !emitc.array<2xf32>
func.func @use_global() {
// expected-error @+1 {{'emitc.get_global' op result type 'f32' does not match type '!emitc.array<2xf32>' of the global @myglobal}}
%0 = emitc.get_global @myglobal : f32
return
}
// -----
func.func @member(%arg0: i32) {
// expected-error @+1 {{'emitc.member' op operand #0 must be EmitC opaque type, but got 'i32'}}
%0 = "emitc.member" (%arg0) {member = "a"} : (i32) -> i32
return
}
// -----
func.func @member_of_ptr(%arg0: i32) {
// expected-error @+1 {{'emitc.member_of_ptr' op operand #0 must be EmitC opaque type or EmitC pointer type, but got 'i32}}
%0 = "emitc.member_of_ptr" (%arg0) {member = "a"} : (i32) -> i32
return
}
|