xref: /llvm-project/mlir/test/Dialect/EmitC/invalid_types.mlir (revision 0bd07652524ebacdee166eb609fef48c50769b09)
1// RUN: mlir-opt %s -split-input-file -verify-diagnostics
2
3func.func @illegal_opaque_type_1() {
4    // expected-error @+1 {{expected non empty string in !emitc.opaque type}}
5    %1 = "emitc.variable"(){value = "42" : !emitc.opaque<"">} : () -> !emitc.opaque<"mytype">
6}
7
8// -----
9
10func.func @illegal_opaque_type_2() {
11    // expected-error @+1 {{pointer not allowed as outer type with !emitc.opaque, use !emitc.ptr instead}}
12    %1 = "emitc.variable"(){value = "nullptr" : !emitc.opaque<"int32_t*">} : () -> !emitc.opaque<"int32_t*">
13}
14
15// -----
16
17func.func @illegal_array_missing_spec(
18    // expected-error @+1 {{expected non-function type}}
19    %arg0: !emitc.array<>) {
20}
21
22// -----
23
24func.func @illegal_array_missing_shape(
25    // expected-error @+1 {{shape must not be empty}}
26    %arg9: !emitc.array<i32>) {
27}
28
29// -----
30
31func.func @illegal_array_missing_x(
32    // expected-error @+1 {{expected 'x' in dimension list}}
33    %arg0: !emitc.array<10>
34) {
35}
36
37// -----
38
39func.func @illegal_array_missing_type(
40    // expected-error @+1 {{expected non-function type}}
41    %arg0: !emitc.array<10x>
42) {
43}
44
45// -----
46
47func.func @illegal_array_dynamic_shape(
48    // expected-error @+1 {{expected static shape}}
49    %arg0: !emitc.array<10x?xi32>
50) {
51}
52
53// -----
54
55func.func @illegal_array_unranked(
56    // expected-error @+1 {{expected non-function type}}
57    %arg0: !emitc.array<*xi32>
58) {
59}
60
61// -----
62
63func.func @illegal_array_with_array_element_type(
64    // expected-error @+1 {{invalid array element type}}
65    %arg0: !emitc.array<4x!emitc.array<4xi32>>
66) {
67}
68
69// -----
70
71func.func @illegal_array_with_tensor_element_type(
72    // expected-error @+1 {{invalid array element type}}
73    %arg0: !emitc.array<4xtensor<4xi32>>
74) {
75}
76
77// -----
78
79func.func @illegal_array_with_lvalue_element_type(
80    // expected-error @+1 {{invalid array element type}}
81    %arg0: !emitc.array<4x!emitc.lvalue<i32>>
82) {
83}
84
85// -----
86
87func.func @illegal_integer_type(%arg0: i11, %arg1: i11) -> i11 {
88    // 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 'i11'}}
89    %mul = "emitc.mul" (%arg0, %arg1) : (i11, i11) -> i11
90    return
91}
92
93// -----
94
95func.func @illegal_float_type(%arg0: f80, %arg1: f80) {
96    // 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 'f80'}}
97    %mul = "emitc.mul" (%arg0, %arg1) : (f80, f80) -> f80
98    return
99}
100
101// -----
102
103func.func @illegal_lvalue_type_1() {
104    // expected-error @+1 {{!emitc.lvalue cannot wrap !emitc.array type}}
105    %v = "emitc.variable"(){value = #emitc.opaque<"">} : () -> !emitc.lvalue<!emitc.array<1xi32>>
106    return
107}
108
109// -----
110
111func.func @illegal_lvalue_type_2() {
112    // expected-error @+1 {{!emitc.lvalue must wrap supported emitc type, but got '!emitc.lvalue<i32>'}}
113    %v = "emitc.variable"(){value = #emitc.opaque<"">} : () -> !emitc.lvalue<!emitc.lvalue<i32>>
114    return
115}
116
117// -----
118
119func.func @illegal_lvalue_type_3() {
120    // expected-error @+1 {{!emitc.lvalue must wrap supported emitc type, but got 'i17'}}
121    %v = "emitc.variable"(){value = #emitc.opaque<"">} : () -> !emitc.lvalue<i17>
122    return
123}
124
125// -----
126
127func.func @illegal_pointee_type_1() {
128    // expected-error @+1 {{'emitc.constant' op result #0 must be type supported by EmitC, but got '!emitc.ptr<i11>'}}
129    %v = "emitc.constant"(){value = #emitc.opaque<"{}">} : () -> !emitc.ptr<i11>
130    return
131}
132
133// -----
134
135func.func @illegal_pointee_type_2() {
136    // expected-error @+1 {{pointers to lvalues are not allowed}}
137    %v = "emitc.constant"(){value = #emitc.opaque<"NULL">} : () -> !emitc.ptr<!emitc.lvalue<i32>>
138    return
139}
140
141// -----
142
143func.func @illegal_non_static_tensor_shape_type() {
144    // expected-error @+1 {{'emitc.constant' op result #0 must be type supported by EmitC, but got 'tensor<?xf32>'}}
145    %v = "emitc.constant"(){value = #emitc.opaque<"{}">} : () -> tensor<?xf32>
146    return
147}
148
149// -----
150
151func.func @illegal_tensor_array_element_type() {
152    // expected-error @+1 {{'emitc.constant' op result #0 must be type supported by EmitC, but got 'tensor<!emitc.array<9xi16>>'}}
153    %v = "emitc.constant"(){value = #emitc.opaque<"{}">} : () -> tensor<!emitc.array<9xi16>>
154    return
155}
156
157// -----
158
159func.func @illegal_tensor_integer_element_type() {
160    // expected-error @+1 {{'emitc.constant' op result #0 must be type supported by EmitC, but got 'tensor<9xi11>'}}
161    %v = "emitc.constant"(){value = #emitc.opaque<"{}">} : () -> tensor<9xi11>
162    return
163}
164
165// -----
166
167func.func @illegal_tuple_array_element_type() {
168    // expected-error @+1 {{'emitc.constant' op result #0 must be type supported by EmitC, but got 'tuple<!emitc.array<9xf32>, f32>'}}
169    %v = "emitc.constant"(){value = #emitc.opaque<"{}">} : () -> tuple<!emitc.array<9xf32>, f32>
170    return
171}
172
173// -----
174
175func.func @illegal_tuple_float_element_type() {
176    // expected-error @+1 {{'emitc.constant' op result #0 must be type supported by EmitC, but got 'tuple<i32, f80>'}}
177    %v = "emitc.constant"(){value = #emitc.opaque<"{}">} : () -> tuple<i32, f80>
178    return
179}
180