1// RUN: mlir-opt %s -split-input-file -verify-diagnostics 2 3func.func @const_attribute_return_type_1() { 4 // expected-error @+1 {{'emitc.constant' op requires attribute's type ('i64') to match op's return type ('i32')}} 5 %c0 = "emitc.constant"(){value = 42: i64} : () -> i32 6 return 7} 8 9// ----- 10 11func.func @const_attribute_return_type_2() { 12 // expected-error @+1 {{'emitc.constant' op requires attribute's type ('!emitc.opaque<"char">') to match op's return type ('!emitc.opaque<"mychar">')}} 13 %c0 = "emitc.constant"(){value = "CHAR_MIN" : !emitc.opaque<"char">} : () -> !emitc.opaque<"mychar"> 14 return 15} 16 17// ----- 18 19func.func @index_args_out_of_range_1() { 20 // expected-error @+1 {{'emitc.call' op index argument is out of range}} 21 emitc.call "test" () {args = [0 : index]} : () -> () 22 return 23} 24 25// ----- 26 27func.func @index_args_out_of_range_2(%arg : i32) { 28 // expected-error @+1 {{'emitc.call' op index argument is out of range}} 29 emitc.call "test" (%arg, %arg) {args = [2 : index]} : (i32, i32) -> () 30 return 31} 32 33// ----- 34 35func.func @empty_callee() { 36 // expected-error @+1 {{'emitc.call' op callee must not be empty}} 37 emitc.call "" () : () -> () 38 return 39} 40 41// ----- 42 43func.func @nonetype_arg(%arg : i32) { 44 // expected-error @+1 {{'emitc.call' op array argument has no type}} 45 emitc.call "nonetype_arg"(%arg) {args = [0 : index, [0, 1, 2]]} : (i32) -> i32 46 return 47} 48 49// ----- 50 51func.func @array_template_arg(%arg : i32) { 52 // expected-error @+1 {{'emitc.call' op template argument has invalid type}} 53 emitc.call "nonetype_template_arg"(%arg) {template_args = [[0, 1, 2]]} : (i32) -> i32 54 return 55} 56 57// ----- 58 59func.func @dense_template_argument(%arg : i32) { 60 // expected-error @+1 {{'emitc.call' op template argument has invalid type}} 61 emitc.call "dense_template_argument"(%arg) {template_args = [dense<[1.0, 1.0]> : tensor<2xf32>]} : (i32) -> i32 62 return 63} 64 65// ----- 66 67func.func @empty_operator(%arg : i32) { 68 // expected-error @+1 {{'emitc.apply' op applicable operator must not be empty}} 69 %2 = emitc.apply ""(%arg) : (i32) -> !emitc.ptr<i32> 70 return 71} 72 73// ----- 74 75func.func @illegal_operator(%arg : i32) { 76 // expected-error @+1 {{'emitc.apply' op applicable operator is illegal}} 77 %2 = emitc.apply "+"(%arg) : (i32) -> !emitc.ptr<i32> 78 return 79} 80 81// ----- 82 83func.func @var_attribute_return_type_1() { 84 // expected-error @+1 {{'emitc.variable' op requires attribute's type ('i64') to match op's return type ('i32')}} 85 %c0 = "emitc.variable"(){value = 42: i64} : () -> i32 86 return 87} 88 89// ----- 90 91func.func @var_attribute_return_type_2() { 92 // expected-error @+1 {{'emitc.variable' op requires attribute's type ('!emitc.ptr<i64>') to match op's return type ('!emitc.ptr<i32>')}} 93 %c0 = "emitc.variable"(){value = "nullptr" : !emitc.ptr<i64>} : () -> !emitc.ptr<i32> 94 return 95} 96 97// ----- 98 99func.func @cast_tensor(%arg : tensor<f32>) { 100 // expected-error @+1 {{'emitc.cast' op operand type 'tensor<f32>' and result type 'tensor<f32>' are cast incompatible}} 101 %1 = emitc.cast %arg: tensor<f32> to tensor<f32> 102 return 103} 104