1 // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s
3 // expected-error @+1 {{found unsupported 'spirv.something' attribute on operation}}
4 func.func @unknown_attr_on_op() attributes {
10 // expected-error @+1 {{found unsupported 'spirv.something' attribute on region argument}}
11 func.func @unknown_attr_on_region(%arg: i32 {spirv.something}) {
17 // expected-error @+1 {{cannot attach SPIR-V attributes to region result}}
18 func.func @unknown_attr_on_region() -> (i32 {spirv.something}) {
19 %0 = arith.constant 10.0 : f32
25 //===----------------------------------------------------------------------===//
26 // spirv.entry_point_abi
27 //===----------------------------------------------------------------------===//
29 // expected-error @+1 {{'spirv.entry_point_abi' attribute must be an entry point ABI attribute}}
30 func.func @spv_entry_point() attributes {
31 spirv.entry_point_abi = 64
36 func.func @spv_entry_point() attributes {
37 // expected-error @+2 {{failed to parse SPIRV_EntryPointABIAttr parameter 'workgroup_size' which is to be a `DenseI32ArrayAttr`}}
38 // expected-error @+1 {{expected '['}}
39 spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = 64>
44 func.func @spv_entry_point() attributes {
45 // CHECK: {spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = [64, 1, 1]>}
46 spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = [64, 1, 1]>
51 //===----------------------------------------------------------------------===//
52 // spirv.interface_var_abi
53 //===----------------------------------------------------------------------===//
55 // expected-error @+1 {{'spirv.interface_var_abi' must be a spirv::InterfaceVarABIAttr}}
56 func.func @interface_var(
57 %arg0 : f32 {spirv.interface_var_abi = 64}
62 func.func @interface_var(
63 // expected-error @+1 {{missing descriptor set}}
64 %arg0 : f32 {spirv.interface_var_abi = #spirv.interface_var_abi<()>}
69 func.func @interface_var(
70 // expected-error @+1 {{missing binding}}
71 %arg0 : f32 {spirv.interface_var_abi = #spirv.interface_var_abi<(1,)>}
76 func.func @interface_var(
77 // expected-error @+1 {{unknown storage class: }}
78 %arg0 : f32 {spirv.interface_var_abi = #spirv.interface_var_abi<(1,2), Foo>}
83 // CHECK: {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1), Uniform>}
84 func.func @interface_var(
85 %arg0 : f32 {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1), Uniform>}
90 // CHECK: {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1)>}
91 func.func @interface_var(
92 %arg0 : f32 {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1)>}
97 // expected-error @+1 {{'spirv.interface_var_abi' attribute cannot specify storage class when attaching to a non-scalar value}}
98 func.func @interface_var(
99 %arg0 : memref<4xf32> {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1), Uniform>}
104 //===----------------------------------------------------------------------===//
105 // spirv.resource_limits
106 //===----------------------------------------------------------------------===//
108 // CHECK-LABEL: func @resource_limits_all_default()
109 func.func @resource_limits_all_default() attributes {
110 // CHECK-SAME: #spirv.resource_limits<>
111 limits = #spirv.resource_limits<>
116 // CHECK-LABEL: func @resource_limits_min_max_subgroup_size()
117 func.func @resource_limits_min_max_subgroup_size() attributes {
118 // CHECK-SAME: #spirv.resource_limits<min_subgroup_size = 32, max_subgroup_size = 64>
119 limits = #spirv.resource_limits<min_subgroup_size = 32, max_subgroup_size=64>
124 //===----------------------------------------------------------------------===//
126 //===----------------------------------------------------------------------===//
128 func.func @target_env() attributes {
129 // CHECK: spirv.target_env = #spirv.target_env<
130 // CHECK-SAME: #spirv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>,
131 // CHECK-SAME: #spirv.resource_limits<max_compute_workgroup_size = [128, 64, 64]>>
132 spirv.target_env = #spirv.target_env<
133 #spirv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>,
134 #spirv.resource_limits<
135 max_compute_workgroup_size = [128, 64, 64]
141 func.func @target_env_client_api() attributes {
142 // CHECK: spirv.target_env = #spirv.target_env<
143 // CHECK-SAME: #spirv.vce<v1.0, [], []>,
144 // CHECK-SAME: api=Metal,
145 // CHECK-SAME: #spirv.resource_limits<>>
146 spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [], []>, api=Metal, #spirv.resource_limits<>>
151 func.func @target_env_client_api() attributes {
152 // CHECK: spirv.target_env = #spirv.target_env
154 spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [], []>, api=Unknown, #spirv.resource_limits<>>
159 func.func @target_env_vendor_id() attributes {
160 // CHECK: spirv.target_env = #spirv.target_env<
161 // CHECK-SAME: #spirv.vce<v1.0, [], []>,
162 // CHECK-SAME: NVIDIA,
163 // CHECK-SAME: #spirv.resource_limits<>>
164 spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [], []>, NVIDIA, #spirv.resource_limits<>>
169 func.func @target_env_vendor_id_device_type() attributes {
170 // CHECK: spirv.target_env = #spirv.target_env<
171 // CHECK-SAME: #spirv.vce<v1.0, [], []>,
172 // CHECK-SAME: AMD:DiscreteGPU,
173 // CHECK-SAME: #spirv.resource_limits<>>
174 spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [], []>, AMD:DiscreteGPU, #spirv.resource_limits<>>
179 func.func @target_env_vendor_id_device_type_device_id() attributes {
180 // CHECK: spirv.target_env = #spirv.target_env<
181 // CHECK-SAME: #spirv.vce<v1.0, [], []>,
182 // CHECK-SAME: Qualcomm:IntegratedGPU:100925441,
183 // CHECK-SAME: #spirv.resource_limits<>>
184 spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [], []>, Qualcomm:IntegratedGPU:0x6040001, #spirv.resource_limits<>>
189 func.func @target_env_client_api_vendor_id_device_type_device_id() attributes {
190 // CHECK: spirv.target_env = #spirv.target_env<
191 // CHECK-SAME: #spirv.vce<v1.0, [], []>,
192 // CHECK-SAME: api=Vulkan,
193 // CHECK-SAME: Qualcomm:IntegratedGPU:100925441,
194 // CHECK-SAME: #spirv.resource_limits<>>
195 spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [], []>, api=Vulkan, Qualcomm:IntegratedGPU:0x6040001, #spirv.resource_limits<>>
200 func.func @target_env_extra_fields() attributes {
201 // expected-error @+3 {{expected '>'}}
202 spirv.target_env = #spirv.target_env<
203 #spirv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>,
204 #spirv.resource_limits<>,
211 func.func @target_env_cooperative_matrix_khr() attributes{
212 // CHECK: spirv.target_env = #spirv.target_env<
213 // CHECK-SAME: SPV_KHR_cooperative_matrix
214 // CHECK-SAME: #spirv.coop_matrix_props_khr<
215 // CHECK-SAME: m_size = 8, n_size = 8, k_size = 32,
216 // CHECK-SAME: a_type = i8, b_type = i8, c_type = i32,
217 // CHECK-SAME: result_type = i32, acc_sat = true, scope = <Subgroup>>
218 // CHECK-SAME: #spirv.coop_matrix_props_khr<
219 // CHECK-SAME: m_size = 8, n_size = 8, k_size = 16,
220 // CHECK-SAME: a_type = f16, b_type = f16, c_type = f16,
221 // CHECK-SAME: result_type = f16, acc_sat = false, scope = <Subgroup>>
222 spirv.target_env = #spirv.target_env<
223 #spirv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class,
224 SPV_KHR_cooperative_matrix]>,
225 #spirv.resource_limits<
226 cooperative_matrix_properties_khr = [#spirv.coop_matrix_props_khr<
235 scope = #spirv.scope<Subgroup>
236 >, #spirv.coop_matrix_props_khr<
245 scope = #spirv.scope<Subgroup>
252 func.func @target_env_cooperative_matrix_nv() attributes{
253 // CHECK: spirv.target_env = #spirv.target_env<
254 // CHECK-SAME: SPV_NV_cooperative_matrix
255 // CHECK-SAME: #spirv.coop_matrix_props_nv<
256 // CHECK-SAME: m_size = 8, n_size = 8, k_size = 32,
257 // CHECK-SAME: a_type = i8, b_type = i8, c_type = i32,
258 // CHECK-SAME: result_type = i32, scope = <Subgroup>>
259 // CHECK-SAME: #spirv.coop_matrix_props_nv<
260 // CHECK-SAME: m_size = 8, n_size = 8, k_size = 16,
261 // CHECK-SAME: a_type = f16, b_type = f16, c_type = f16,
262 // CHECK-SAME: result_type = f16, scope = <Subgroup>>
263 spirv.target_env = #spirv.target_env<
264 #spirv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class,
265 SPV_NV_cooperative_matrix]>,
266 #spirv.resource_limits<
267 cooperative_matrix_properties_nv = [#spirv.coop_matrix_props_nv<
275 scope = #spirv.scope<Subgroup>
276 >, #spirv.coop_matrix_props_nv<
284 scope = #spirv.scope<Subgroup>
291 //===----------------------------------------------------------------------===//
293 //===----------------------------------------------------------------------===//
295 func.func @vce_wrong_type() attributes {
296 // expected-error @+1 {{expected valid keyword}}
302 func.func @vce_missing_fields() attributes {
303 // expected-error @+1 {{expected ','}}
304 vce = #spirv.vce<v1.0>
309 func.func @vce_wrong_version() attributes {
310 // expected-error @+1 {{unknown version: V_x_y}}
311 vce = #spirv.vce<V_x_y, []>
316 func.func @vce_wrong_extension_type() attributes {
317 // expected-error @+1 {{expected valid keyword}}
318 vce = #spirv.vce<v1.0, [32: i32], [Shader]>
323 func.func @vce_wrong_extension() attributes {
324 // expected-error @+1 {{unknown extension: SPIRV_Something}}
325 vce = #spirv.vce<v1.0, [Shader], [SPIRV_Something]>
330 func.func @vce_wrong_capability() attributes {
331 // expected-error @+1 {{unknown capability: Something}}
332 vce = #spirv.vce<v1.0, [Something], []>
337 func.func @vce() attributes {
338 // CHECK: #spirv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>
339 vce = #spirv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>