xref: /llvm-project/mlir/test/Dialect/DLTI/invalid.mlir (revision 5c1752e368585e55c0335a7d7651fe43d42af282)
1// RUN: mlir-opt -split-input-file -verify-diagnostics %s
2
3// expected-error@below {{attribute 'dlti.unknown' not supported by dialect}}
4"test.unknown_op"() { dlti.unknown } : () -> ()
5
6// -----
7
8// expected-error@below {{'dlti.map' is expected to be a #dlti.map attribute}}
9"test.unknown_op"() { dlti.map = 42 } : () -> ()
10
11// -----
12
13// expected-error@below {{'dlti.dl_spec' is expected to be a #dlti.dl_spec attribute}}
14"test.unknown_op"() { dlti.dl_spec = 42 } : () -> ()
15
16// -----
17
18// expected-error@below {{invalid kind of attribute specified}}
19"test.unknown_op"() { dlti.dl_spec = #dlti.dl_spec<[]> } : () -> ()
20
21// -----
22
23// expected-error@below {{expected a type or a quoted string}}
24"test.unknown_op"() { test.unknown_attr = #dlti.dl_entry<42, 42> } : () -> ()
25
26// -----
27
28// expected-error@below {{empty string as DLTI key is not allowed}}
29"test.unknown_op"() { test.unknown_attr = #dlti.map<"" = 42> } : () -> ()
30
31// -----
32
33// expected-error@below {{repeated DLTI key: "test.id"}}
34"test.unknown_op"() { test.unknown_attr = #dlti.dl_spec<
35  #dlti.dl_entry<"test.id", 42>,
36  #dlti.dl_entry<"test.id", 43>
37>} : () -> ()
38
39// -----
40
41// expected-error@below {{repeated DLTI key: i32}}
42"test.unknown_op"() { test.unknown_attr = #dlti.map<
43  #dlti.dl_entry<i32, 42>,
44  #dlti.dl_entry<i32, 42>
45>} : () -> ()
46
47// -----
48
49// expected-error@below {{repeated DLTI key: i32}}
50"test.unknown_op"() { test.unknown_attr = #dlti.dl_spec<
51  #dlti.dl_entry<i32, 42>,
52  #dlti.dl_entry<i32, 42>
53>} : () -> ()
54
55// -----
56
57// expected-error@below {{unknown attribute `unknown` in dialect `dlti`}}
58"test.unknown_op"() { test.unknown_attr = #dlti.unknown } : () -> ()
59
60// -----
61
62// expected-error@below {{unknown data layout entry name: dlti.unknown_id}}
63"test.op_with_data_layout"() ({
64}) { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"dlti.unknown_id", 42>> } : () -> ()
65
66// -----
67
68// expected-error@below {{'dlti.endianness' data layout entry is expected to be either 'big' or 'little'}}
69"test.op_with_data_layout"() ({
70}) { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"dlti.endianness", "some">> } : () -> ()
71
72// -----
73
74// Mismatching entries don't combine.
75"test.op_with_data_layout"() ({
76  // expected-error@below {{data layout does not combine with layouts of enclosing ops}}
77  // expected-note@above {{enclosing op with data layout}}
78  "test.op_with_data_layout"() { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"unknown.unknown", 32>> } : () -> ()
79  "test.maybe_terminator_op"() : () -> ()
80}) { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"unknown.unknown", 33>> } : () -> ()
81
82// -----
83
84// Layout not supported some built-in types.
85// expected-error@below {{unexpected data layout for a built-in type}}
86"test.op_with_data_layout"() { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<tensor<f32>, 32>> } : () -> ()
87
88// -----
89
90// expected-error@below {{data layout specified for a type that does not support it}}
91"test.op_with_data_layout"() { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<!test.test_type, 32>> } : () -> ()
92
93// -----
94
95// Mismatching entries are checked on module ops as well.
96module attributes { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"unknown.unknown", 33>>} {
97  // expected-error@below {{data layout does not combine with layouts of enclosing ops}}
98  // expected-note@above {{enclosing op with data layout}}
99  module attributes { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"unknown.unknown", 32>>} {
100  }
101}
102
103// -----
104
105// Mismatching entries are checked on a combination of modules and other ops.
106module attributes { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"unknown.unknown", 33>>} {
107  // expected-error@below {{data layout does not combine with layouts of enclosing ops}}
108  // expected-note@above {{enclosing op with data layout}}
109  "test.op_with_data_layout"() { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"unknown.unknown", 32>>} : () -> ()
110}
111
112// -----
113
114// expected-error@below {{'dlti.target_system_spec' is expected to be a #dlti.target_system_spec attribute}}
115"test.unknown_op"() { dlti.target_system_spec = 42 } : () -> ()
116
117// -----
118
119// expected-error@below {{invalid kind of attribute specified}}
120"test.unknown_op"() { dlti.target_system_spec = #dlti.target_system_spec<[]> } : () -> ()
121
122// -----
123
124module attributes {
125  // Device ID is missing
126  //
127  // expected-error@below {{expected attribute value}}
128  dlti.target_system_spec = #dlti.target_system_spec<
129    = #dlti.target_device_spec<
130      #dlti.dl_entry<"L1_cache_size_in_bytes", 4096 : i32>>
131  >} {}
132
133// -----
134
135module attributes {
136  // Device ID is wrong type
137  //
138  // expected-error@+2 {{invalid kind of attribute specified}}
139  dlti.target_system_spec = #dlti.target_system_spec<
140    0 = #dlti.target_device_spec<
141        #dlti.dl_entry<"L1_cache_size_in_bytes", 4096 : i32>>
142  >} {}
143
144// -----
145
146module attributes {
147  // Repeated Device ID
148  //
149  // expected-error@+1 {{repeated device ID in dlti.target_system_spec: "CPU}}
150  dlti.target_system_spec = #dlti.target_system_spec<
151    "CPU" = #dlti.target_device_spec<
152            #dlti.dl_entry<"L1_cache_size_in_bytes", 4096>>,
153    "CPU" = #dlti.target_device_spec<
154            #dlti.dl_entry<"L1_cache_size_in_bytes", 8192>>
155  >} {}
156
157// -----
158
159module attributes {
160  // Repeated DLTI entry
161  //
162  // expected-error@+2 {{repeated DLTI key: "L1_cache_size_in_bytes"}}
163  dlti.target_system_spec = #dlti.target_system_spec<
164    "CPU" = #dlti.target_device_spec<"L1_cache_size_in_bytes" = 4096,
165                                     "L1_cache_size_in_bytes" = 8192>
166  >} {}
167