1 // RUN: mlir-translate -verify-diagnostics -split-input-file -mlir-to-llvmir %s
3 // expected-error @below{{cannot be converted to LLVM IR}}
10 llvm.func @vector_with_non_vector_type() -> f32 {
11 // expected-error @below{{expected vector or array type}}
12 %cst = llvm.mlir.constant(dense<100.0> : vector<1xf64>) : f32
13 llvm.return %cst : f32
18 llvm.func @non_array_attr_for_struct() -> !llvm.array<2 x array<2 x array<2 x struct<(i32)>>>> {
19 // expected-error @below{{expected an array attribute for a struct constant}}
20 %0 = llvm.mlir.constant(dense<[[[1, 2], [3, 4]], [[42, 43], [44, 45]]]> : tensor<2x2x2xi32>) : !llvm.array<2 x array<2 x array<2 x struct<(i32)>>>>
21 llvm.return %0 : !llvm.array<2 x array<2 x array<2 x struct<(i32)>>>>
26 llvm.func @non_array_attr_for_struct() -> !llvm.array<2 x array<2 x array<2 x struct<(i32, i32, i32)>>>> {
27 // expected-error @below{{expected an array attribute for a struct constant}}
28 %0 = llvm.mlir.constant(dense<[[[1, 2], [3, 4]], [[42, 43], [44, 45]]]> : tensor<2x2x2xi32>) : !llvm.array<2 x array<2 x array<2 x struct<(i32, i32, i32)>>>>
29 llvm.return %0 : !llvm.array<2 x array<2 x array<2 x struct<(i32, i32, i32)>>>>
34 llvm.func @invalid_struct_element_type() -> !llvm.struct<(f64, array<2 x i32>)> {
35 // expected-error @below{{expected struct element types to be floating point type or integer type}}
36 %0 = llvm.mlir.constant([1.0 : f64, dense<[1, 2]> : tensor<2xi32>]) : !llvm.struct<(f64, array<2 x i32>)>
37 llvm.return %0 : !llvm.struct<(f64, array<2 x i32>)>
42 llvm.func @wrong_struct_element_attr_type() -> !llvm.struct<(f64, f64)> {
43 // expected-error @below{{expected struct element attribute types to be floating point type or integer type}}
44 %0 = llvm.mlir.constant([dense<[1, 2]> : tensor<2xi32>, 2.0 : f64]) : !llvm.struct<(f64, f64)>
45 llvm.return %0 : !llvm.struct<(f64, f64)>
50 llvm.func @struct_wrong_attribute_element_type() -> !llvm.struct<(f64, f64)> {
51 // expected-error @below{{struct element at index 0 is of wrong type}}
52 %0 = llvm.mlir.constant([1.0 : f32, 1.0 : f32]) : !llvm.struct<(f64, f64)>
53 llvm.return %0 : !llvm.struct<(f64, f64)>
58 llvm.func @integer_with_float_type() -> f32 {
59 // expected-error @+1 {{expected integer type}}
60 %0 = llvm.mlir.constant(1 : index) : f32
66 llvm.func @incompatible_float_attribute_type() -> f32 {
67 // expected-error @below{{expected float type of width 64}}
68 %cst = llvm.mlir.constant(1.0 : f64) : f32
69 llvm.return %cst : f32
74 llvm.func @incompatible_integer_type_for_float_attr() -> i32 {
75 // expected-error @below{{expected integer type of width 16}}
76 %cst = llvm.mlir.constant(1.0 : f16) : i32
77 llvm.return %cst : i32
82 // expected-error @below{{unsupported constant value}}
83 llvm.mlir.global internal constant @test([2.5, 7.4]) : !llvm.array<2 x f64>
87 // expected-error @below{{LLVM attribute 'readonly' does not expect a value}}
88 llvm.func @passthrough_unexpected_value() attributes {passthrough = [["readonly", "42"]]}
92 // expected-error @below{{LLVM attribute 'alignstack' expects a value}}
93 llvm.func @passthrough_expected_value() attributes {passthrough = ["alignstack"]}
97 // expected-error @below{{expected 'passthrough' to contain string or array attributes}}
98 llvm.func @passthrough_wrong_type() attributes {passthrough = [42]}
102 // expected-error @below{{expected arrays within 'passthrough' to contain two strings}}
103 llvm.func @passthrough_wrong_type() attributes {
104 passthrough = [[ 42, 42 ]]
109 llvm.func @unary_float_intr_wrong_type(%arg0 : i32) -> i32 {
110 // expected-error @below{{op operand #0 must be floating point LLVM type or LLVM dialect-compatible vector of floating point LLVM type}}
111 %0 = "llvm.intr.exp"(%arg0) : (i32) -> i32
117 llvm.func @binary_float_intr_wrong_type(%arg0 : f32, %arg1 : i32) -> i32 {
118 // expected-error @below{{op operand #1 must be floating point LLVM type or LLVM dialect-compatible vector of floating point LLVM type}}
119 %0 = "llvm.intr.pow"(%arg0, %arg1) : (f32, i32) -> i32
125 llvm.func @unary_int_intr_wrong_type(%arg0 : f32) -> f32 {
126 // expected-error @below{{op operand #0 must be signless integer or LLVM dialect-compatible vector of signless integer}}
127 %0 = "llvm.intr.ctpop"(%arg0) : (f32) -> f32
133 llvm.func @binary_int_intr_wrong_type(%arg0 : i32, %arg1 : f32) -> f32 {
134 // expected-error @below{{op operand #1 must be signless integer or LLVM dialect-compatible vector of signless integer}}
135 %0 = "llvm.intr.smax"(%arg0, %arg1) : (i32, f32) -> f32
141 llvm.func @ternary_float_intr_wrong_type(%arg0 : f32, %arg1 : f32, %arg2 : i32) -> f32 {
142 // expected-error @below{{op operand #2 must be floating point LLVM type or LLVM dialect-compatible vector of floating point LLVM type}}
143 %0 = "llvm.intr.fma"(%arg0, %arg1, %arg2) : (f32, f32, i32) -> f32
149 llvm.func @powi_intr_wrong_type(%arg0 : f32, %arg1 : f32) -> f32 {
150 // expected-error @below{{op operand #1 must be signless integer, but got 'f32'}}
151 %0 = "llvm.intr.powi"(%arg0, %arg1) : (f32, f32) -> f32
157 llvm.func @memcpy_intr_wrong_type(%src : i64, %dst : i64, %len : i64) {
158 // expected-error @below{{op operand #0 must be LLVM pointer type, but got 'i64'}}
159 "llvm.intr.memcpy"(%src, %dst, %len) <{isVolatile = false}> : (i64, i64, i64) -> ()
165 llvm.func @memmove_intr_wrong_type(%src : !llvm.ptr, %dst : i64, %len : i64) {
166 // expected-error @below{{op operand #1 must be LLVM pointer type, but got 'i64'}}
167 "llvm.intr.memmove"(%src, %dst, %len) <{isVolatile = false}> : (!llvm.ptr, i64, i64) -> ()
173 llvm.func @memset_intr_wrong_type(%dst : !llvm.ptr, %val : i32, %len : i64) {
174 // expected-error @below{{op operand #1 must be 8-bit signless integer, but got 'i32'}}
175 "llvm.intr.memset"(%dst, %val, %len) <{isVolatile = false}> : (!llvm.ptr, i32, i64) -> ()
181 llvm.func @sadd_overflow_intr_wrong_type(%arg0 : i32, %arg1 : f32) -> !llvm.struct<(i32, i1)> {
182 // expected-error @below{{op operand #1 must be signless integer or LLVM dialect-compatible vector of signless integer, but got 'f32'}}
183 %0 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i32, f32) -> !llvm.struct<(i32, i1)>
184 llvm.return %0 : !llvm.struct<(i32, i1)>
189 llvm.func @assume_intr_wrong_type(%cond : i16) {
190 // expected-error @below{{op operand #0 must be 1-bit signless integer, but got 'i16'}}
191 llvm.intr.assume %cond : i16
197 llvm.func @vec_reduce_add_intr_wrong_type(%arg0 : vector<4xi32>) -> f32 {
198 // expected-error @below{{op requires the same element type for all operands and results}}
199 %0 = "llvm.intr.vector.reduce.add"(%arg0) : (vector<4xi32>) -> f32
205 llvm.func @vec_reduce_fmax_intr_wrong_type(%arg0 : vector<4xi32>) -> i32 {
206 // expected-error @below{{op operand #0 must be LLVM dialect-compatible vector of floating-point}}
207 %0 = llvm.intr.vector.reduce.fmax(%arg0) : (vector<4xi32>) -> i32
213 llvm.func @matrix_load_intr_wrong_type(%ptr : !llvm.ptr, %stride : i32) -> f32 {
214 // expected-error @below{{op result #0 must be LLVM dialect-compatible vector type, but got 'f32'}}
215 %0 = llvm.intr.matrix.column.major.load %ptr, <stride=%stride>
216 { isVolatile = 0: i1, rows = 3: i32, columns = 16: i32} : f32 from !llvm.ptr stride i32
222 llvm.func @matrix_store_intr_wrong_type(%matrix : vector<48xf32>, %ptr : i32, %stride : i64) {
223 // expected-error @below {{op operand #1 must be LLVM pointer type, but got 'i32'}}
224 llvm.intr.matrix.column.major.store %matrix, %ptr, <stride=%stride>
225 { isVolatile = 0: i1, rows = 3: i32, columns = 16: i32} : vector<48xf32> to i32 stride i64
231 llvm.func @matrix_multiply_intr_wrong_type(%arg0 : vector<64xf32>, %arg1 : f32) -> vector<12xf32> {
232 // expected-error @below{{op operand #1 must be LLVM dialect-compatible vector type, but got 'f32'}}
233 %0 = llvm.intr.matrix.multiply %arg0, %arg1
234 { lhs_rows = 4: i32, lhs_columns = 16: i32 , rhs_columns = 3: i32} : (vector<64xf32>, f32) -> vector<12xf32>
235 llvm.return %0 : vector<12xf32>
240 llvm.func @matrix_transpose_intr_wrong_type(%matrix : f32) -> vector<48xf32> {
241 // expected-error @below{{op operand #0 must be LLVM dialect-compatible vector type, but got 'f32'}}
242 %0 = llvm.intr.matrix.transpose %matrix {rows = 3: i32, columns = 16: i32} : f32 into vector<48xf32>
243 llvm.return %0 : vector<48xf32>
248 llvm.func @active_lane_intr_wrong_type(%base : i64, %n : vector<7xi64>) -> vector<7xi1> {
249 // expected-error @below{{invalid kind of type specified}}
250 %0 = llvm.intr.get.active.lane.mask %base, %n : i64, vector<7xi64> to vector<7xi1>
251 llvm.return %0 : vector<7xi1>
256 llvm.func @masked_load_intr_wrong_type(%ptr : i64, %mask : vector<7xi1>) -> vector<7xf32> {
257 // expected-error @below{{op operand #0 must be LLVM pointer type, but got 'i64'}}
258 %0 = llvm.intr.masked.load %ptr, %mask { alignment = 1: i32} : (i64, vector<7xi1>) -> vector<7xf32>
259 llvm.return %0 : vector<7xf32>
264 llvm.func @masked_store_intr_wrong_type(%vec : vector<7xf32>, %ptr : !llvm.ptr, %mask : vector<7xi32>) {
265 // expected-error @below{{op operand #2 must be LLVM dialect-compatible vector of 1-bit signless integer, but got 'vector<7xi32>}}
266 llvm.intr.masked.store %vec, %ptr, %mask { alignment = 1: i32} : vector<7xf32>, vector<7xi32> into !llvm.ptr
272 llvm.func @masked_gather_intr_wrong_type(%ptrs : vector<7xf32>, %mask : vector<7xi1>) -> vector<7xf32> {
273 // expected-error @below{{op operand #0 must be LLVM dialect-compatible vector of LLVM pointer type, but got 'vector<7xf32>'}}
274 %0 = llvm.intr.masked.gather %ptrs, %mask { alignment = 1: i32} : (vector<7xf32>, vector<7xi1>) -> vector<7xf32>
275 llvm.return %0 : vector<7xf32>
280 llvm.func @masked_gather_intr_wrong_type_scalable(%ptrs : !llvm.vec<7 x ptr>, %mask : vector<[7]xi1>) -> vector<[7]xf32> {
281 // expected-error @below{{expected operand #1 type to be '!llvm.vec<? x 7 x ptr>'}}
282 %0 = llvm.intr.masked.gather %ptrs, %mask { alignment = 1: i32} : (!llvm.vec<7 x ptr>, vector<[7]xi1>) -> vector<[7]xf32>
283 llvm.return %0 : vector<[7]xf32>
288 llvm.func @masked_scatter_intr_wrong_type(%vec : f32, %ptrs : !llvm.vec<7xptr>, %mask : vector<7xi1>) {
289 // expected-error @below{{op operand #0 must be LLVM dialect-compatible vector type, but got 'f32'}}
290 llvm.intr.masked.scatter %vec, %ptrs, %mask { alignment = 1: i32} : f32, vector<7xi1> into !llvm.vec<7xptr>
296 llvm.func @masked_scatter_intr_wrong_type_scalable(%vec : vector<[7]xf32>, %ptrs : !llvm.vec<7xptr>, %mask : vector<[7]xi1>) {
297 // expected-error @below{{expected operand #2 type to be '!llvm.vec<? x 7 x ptr>'}}
298 llvm.intr.masked.scatter %vec, %ptrs, %mask { alignment = 1: i32} : vector<[7]xf32>, vector<[7]xi1> into !llvm.vec<7xptr>
304 llvm.func @stepvector_intr_wrong_type() -> vector<7xf32> {
305 // expected-error @below{{op result #0 must be LLVM dialect-compatible vector of signless integer, but got 'vector<7xf32>'}}
306 %0 = llvm.intr.stepvector : vector<7xf32>
307 llvm.return %0 : vector<7xf32>
312 // expected-error @below{{target features can not contain ','}}
313 llvm.func @invalid_target_feature() attributes { target_features = #llvm.target_features<["+bad,feature", "+test"]> }
319 // expected-error @below{{target features must start with '+' or '-'}}
320 llvm.func @missing_target_feature_prefix() attributes { target_features = #llvm.target_features<["sme"]> }
326 // expected-error @below{{target features can not be null or empty}}
327 llvm.func @empty_target_feature() attributes { target_features = #llvm.target_features<["", "+sve"]> }
333 llvm.comdat @__llvm_comdat {
334 llvm.comdat_selector @foo any
337 llvm.comdat @__llvm_comdat_1 {
338 // expected-error @below{{comdat selection symbols must be unique even in different comdat regions}}
339 llvm.comdat_selector @foo any
345 // expected-error @below{{must appear at the module level}}
346 llvm.linker_options ["test"]
351 module @does_not_exist {
352 // expected-error @below{{resource does not exist}}
353 llvm.mlir.global internal constant @constant(dense_resource<test0> : tensor<4xf32>) : !llvm.array<4 x f32>
358 module @raw_data_does_not_match_element_type_size {
359 // expected-error @below{{raw data size does not match element type size}}
360 llvm.mlir.global internal constant @constant(dense_resource<test1> : tensor<5xf32>) : !llvm.array<4 x f32>
366 test1: "0x0800000054A3B53ED6C0B33E55D1A2BDE5D2BB3E"
373 module @does_not_exist {
374 // expected-error @below{{unsupported dense_resource type}}
375 llvm.mlir.global internal constant @constant(dense_resource<test1> : memref<4xf32>) : !llvm.array<4 x f32>
381 test1: "0x0800000054A3B53ED6C0B33E55D1A2BDE5D2BB3E"
388 module @no_known_conversion_innermost_eltype {
389 // expected-error @below{{no known conversion for innermost element type}}
390 llvm.mlir.global internal constant @constant(dense_resource<test0> : tensor<4xi4>) : !llvm.array<4 x i4>
396 test1: "0x0800000054A3B53ED6C0B33E55D1A2BDE5D2BB3E"