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 @no_non_complex_struct() -> !llvm.array<2 x array<2 x array<2 x struct<(i32)>>>> {
11 // expected-error @below{{expected struct type to be a complex number}}
12 %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)>>>>
13 llvm.return %0 : !llvm.array<2 x array<2 x array<2 x struct<(i32)>>>>
18 llvm.func @no_non_complex_struct() -> !llvm.array<2 x array<2 x array<2 x struct<(i32, i32, i32)>>>> {
19 // expected-error @below{{expected struct type to be a complex number}}
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, i32, i32)>>>>
21 llvm.return %0 : !llvm.array<2 x array<2 x array<2 x struct<(i32, i32, i32)>>>>
26 llvm.func @struct_wrong_attribute_element_type() -> !llvm.struct<(f64, f64)> {
27 // expected-error @below{{FloatAttr does not match expected type of the constant}}
28 %0 = llvm.mlir.constant([1.0 : f32, 1.0 : f32]) : !llvm.struct<(f64, f64)>
29 llvm.return %0 : !llvm.struct<(f64, f64)>
34 // expected-error @below{{unsupported constant value}}
35 llvm.mlir.global internal constant @test([2.5, 7.4]) : !llvm.array<2 x f64>
39 // expected-error @below{{LLVM attribute 'noinline' does not expect a value}}
40 llvm.func @passthrough_unexpected_value() attributes {passthrough = [["noinline", "42"]]}
44 // expected-error @below{{LLVM attribute 'alignstack' expects a value}}
45 llvm.func @passthrough_expected_value() attributes {passthrough = ["alignstack"]}
49 // expected-error @below{{expected 'passthrough' to contain string or array attributes}}
50 llvm.func @passthrough_wrong_type() attributes {passthrough = [42]}
54 // expected-error @below{{expected arrays within 'passthrough' to contain two strings}}
55 llvm.func @passthrough_wrong_type() attributes {
56 passthrough = [[ 42, 42 ]]
61 llvm.func @unary_float_intr_wrong_type(%arg0 : i32) -> i32 {
62 // expected-error @below{{op operand #0 must be floating point LLVM type or LLVM dialect-compatible vector of floating point LLVM type}}
63 %0 = "llvm.intr.exp"(%arg0) : (i32) -> i32
69 llvm.func @binary_float_intr_wrong_type(%arg0 : f32, %arg1 : i32) -> i32 {
70 // expected-error @below{{op operand #1 must be floating point LLVM type or LLVM dialect-compatible vector of floating point LLVM type}}
71 %0 = "llvm.intr.pow"(%arg0, %arg1) : (f32, i32) -> i32
77 llvm.func @unary_int_intr_wrong_type(%arg0 : f32) -> f32 {
78 // expected-error @below{{op operand #0 must be signless integer or LLVM dialect-compatible vector of signless integer}}
79 %0 = "llvm.intr.ctpop"(%arg0) : (f32) -> f32
85 llvm.func @binary_int_intr_wrong_type(%arg0 : i32, %arg1 : f32) -> f32 {
86 // expected-error @below{{op operand #1 must be signless integer or LLVM dialect-compatible vector of signless integer}}
87 %0 = "llvm.intr.smax"(%arg0, %arg1) : (i32, f32) -> f32
93 llvm.func @ternary_float_intr_wrong_type(%arg0 : f32, %arg1 : f32, %arg2 : i32) -> f32 {
94 // expected-error @below{{op operand #2 must be floating-point or LLVM dialect-compatible vector of floating-point}}
95 %0 = "llvm.intr.fma"(%arg0, %arg1, %arg2) : (f32, f32, i32) -> f32
101 llvm.func @powi_intr_wrong_type(%arg0 : f32, %arg1 : f32) -> f32 {
102 // expected-error @below{{op operand #1 must be signless integer, but got 'f32'}}
103 %0 = "llvm.intr.powi"(%arg0, %arg1) : (f32, f32) -> f32
109 llvm.func @ctlz_intr_wrong_type(%arg0 : i32, %arg1 : i32) -> i32 {
110 // expected-error @below{{op operand #1 must be 1-bit signless integer, but got 'i32'}}
111 %0 = "llvm.intr.ctlz"(%arg0, %arg1) : (i32, i32) -> i32
117 llvm.func @memcpy_intr_wrong_type(%src : i64, %dst : i64, %len : i64, %volatile : i1) {
118 // expected-error @below{{op operand #0 must be LLVM pointer type, but got 'i64'}}
119 "llvm.intr.memcpy"(%src, %dst, %len, %volatile) : (i64, i64, i64, i1) -> ()
125 llvm.func @memcpy_inline_intr_wrong_type(%src : !llvm.ptr, %dst : !llvm.ptr, %len : i64, %volatile : i32) {
126 // expected-error @below{{op operand #3 must be 1-bit signless integer, but got 'i32'}}
127 "llvm.intr.memcpy.inline"(%src, %dst, %len, %volatile) : (!llvm.ptr, !llvm.ptr, i64, i32) -> ()
133 llvm.func @memmove_intr_wrong_type(%src : !llvm.ptr, %dst : i64, %len : i64, %volatile : i1) {
134 // expected-error @below{{op operand #1 must be LLVM pointer type, but got 'i64'}}
135 "llvm.intr.memmove"(%src, %dst, %len, %volatile) : (!llvm.ptr, i64, i64, i1) -> ()
141 llvm.func @memset_intr_wrong_type(%dst : !llvm.ptr, %val : i32, %len : i64, %volatile : i1) {
142 // expected-error @below{{op operand #1 must be 8-bit signless integer, but got 'i32'}}
143 "llvm.intr.memset"(%dst, %val, %len, %volatile) : (!llvm.ptr, i32, i64, i1) -> ()
149 llvm.func @sadd_overflow_intr_wrong_type(%arg0 : i32, %arg1 : f32) -> !llvm.struct<(i32, i1)> {
150 // expected-error @below{{op operand #1 must be signless integer or LLVM dialect-compatible vector of signless integer, but got 'f32'}}
151 %0 = "llvm.intr.sadd.with.overflow"(%arg0, %arg1) : (i32, f32) -> !llvm.struct<(i32, i1)>
152 llvm.return %0 : !llvm.struct<(i32, i1)>
157 llvm.func @assume_intr_wrong_type(%cond : i16) {
158 // expected-error @below{{op operand #0 must be 1-bit signless integer, but got 'i16'}}
159 "llvm.intr.assume"(%cond) : (i16) -> ()
165 llvm.func @vec_reduce_add_intr_wrong_type(%arg0 : vector<4xi32>) -> f32 {
166 // expected-error @below{{op requires the same element type for all operands and results}}
167 %0 = "llvm.intr.vector.reduce.add"(%arg0) : (vector<4xi32>) -> f32
173 llvm.func @vec_reduce_fmax_intr_wrong_type(%arg0 : vector<4xi32>) -> i32 {
174 // expected-error @below{{op operand #0 must be LLVM dialect-compatible vector of floating-point}}
175 %0 = "llvm.intr.vector.reduce.fmax"(%arg0) : (vector<4xi32>) -> i32
181 llvm.func @matrix_load_intr_wrong_type(%ptr : !llvm.ptr, %stride : i32) -> f32 {
182 // expected-error @below{{op result #0 must be LLVM dialect-compatible vector type, but got 'f32'}}
183 %0 = llvm.intr.matrix.column.major.load %ptr, <stride=%stride>
184 { isVolatile = 0: i1, rows = 3: i32, columns = 16: i32} : f32 from !llvm.ptr stride i32
190 llvm.func @matrix_store_intr_wrong_type(%matrix : vector<48xf32>, %ptr : i32, %stride : i64) {
191 // expected-error @below {{op operand #1 must be LLVM pointer type, but got 'i32'}}
192 llvm.intr.matrix.column.major.store %matrix, %ptr, <stride=%stride>
193 { isVolatile = 0: i1, rows = 3: i32, columns = 16: i32} : vector<48xf32> to i32 stride i64
199 llvm.func @matrix_multiply_intr_wrong_type(%arg0 : vector<64xf32>, %arg1 : f32) -> vector<12xf32> {
200 // expected-error @below{{op operand #1 must be LLVM dialect-compatible vector type, but got 'f32'}}
201 %0 = llvm.intr.matrix.multiply %arg0, %arg1
202 { lhs_rows = 4: i32, lhs_columns = 16: i32 , rhs_columns = 3: i32} : (vector<64xf32>, f32) -> vector<12xf32>
203 llvm.return %0 : vector<12xf32>
208 llvm.func @matrix_transpose_intr_wrong_type(%matrix : f32) -> vector<48xf32> {
209 // expected-error @below{{op operand #0 must be LLVM dialect-compatible vector type, but got 'f32'}}
210 %0 = llvm.intr.matrix.transpose %matrix {rows = 3: i32, columns = 16: i32} : f32 into vector<48xf32>
211 llvm.return %0 : vector<48xf32>
216 llvm.func @active_lane_intr_wrong_type(%base : i64, %n : vector<7xi64>) -> vector<7xi1> {
217 // expected-error @below{{invalid kind of type specified}}
218 %0 = llvm.intr.get.active.lane.mask %base, %n : i64, vector<7xi64> to vector<7xi1>
219 llvm.return %0 : vector<7xi1>
224 llvm.func @masked_load_intr_wrong_type(%ptr : i64, %mask : vector<7xi1>) -> vector<7xf32> {
225 // expected-error @below{{op operand #0 must be LLVM pointer type, but got 'i64'}}
226 %0 = llvm.intr.masked.load %ptr, %mask { alignment = 1: i32} : (i64, vector<7xi1>) -> vector<7xf32>
227 llvm.return %0 : vector<7xf32>
232 llvm.func @masked_store_intr_wrong_type(%vec : vector<7xf32>, %ptr : !llvm.ptr, %mask : vector<7xi32>) {
233 // expected-error @below{{op operand #2 must be LLVM dialect-compatible vector of 1-bit signless integer, but got 'vector<7xi32>}}
234 llvm.intr.masked.store %vec, %ptr, %mask { alignment = 1: i32} : vector<7xf32>, vector<7xi32> into !llvm.ptr
240 llvm.func @masked_gather_intr_wrong_type(%ptrs : vector<7xf32>, %mask : vector<7xi1>) -> vector<7xf32> {
241 // expected-error @below{{op operand #0 must be LLVM dialect-compatible vector of LLVM pointer type, but got 'vector<7xf32>'}}
242 %0 = llvm.intr.masked.gather %ptrs, %mask { alignment = 1: i32} : (vector<7xf32>, vector<7xi1>) -> vector<7xf32>
243 llvm.return %0 : vector<7xf32>
248 llvm.func @masked_scatter_intr_wrong_type(%vec : f32, %ptrs : !llvm.vec<7xptr<f32>>, %mask : vector<7xi1>) {
249 // expected-error @below{{op operand #0 must be LLVM dialect-compatible vector type, but got 'f32'}}
250 llvm.intr.masked.scatter %vec, %ptrs, %mask { alignment = 1: i32} : f32, vector<7xi1> into !llvm.vec<7xptr<f32>>
256 llvm.func @stepvector_intr_wrong_type() -> vector<7xf32> {
257 // expected-error @below{{op result #0 must be LLVM dialect-compatible vector of signless integer, but got 'vector<7xf32>'}}
258 %0 = llvm.intr.experimental.stepvector : vector<7xf32>
259 llvm.return %0 : vector<7xf32>