1 // RUN: mlir-opt -split-input-file -convert-func-to-spirv -verify-diagnostics %s | FileCheck %s
3 //===----------------------------------------------------------------------===//
5 //===----------------------------------------------------------------------===//
8 spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [], []>, #spirv.resource_limits<>>
11 // CHECK-LABEL: spirv.func @return_none_val
12 func.func @return_none_val() {
13 // CHECK: spirv.Return
17 // CHECK-LABEL: spirv.func @return_one_val
18 // CHECK-SAME: (%[[ARG:.+]]: f32)
19 func.func @return_one_val(%arg0: f32) -> f32 {
20 // CHECK: spirv.ReturnValue %[[ARG]] : f32
24 // Check that multiple-return functions are not converted.
25 // CHECK-LABEL: func @return_multi_val
26 func.func @return_multi_val(%arg0: f32) -> (f32, f32) {
28 return %arg0, %arg0: f32, f32
31 // CHECK-LABEL: spirv.func @return_one_index
32 // CHECK-SAME: (%[[ARG:.+]]: i32)
33 func.func @return_one_index(%arg0: index) -> index {
34 // CHECK: spirv.ReturnValue %[[ARG]] : i32
38 // CHECK-LABEL: spirv.func @call_functions
39 // CHECK-SAME: (%[[ARG:.+]]: i32)
40 func.func @call_functions(%arg0: index) -> index {
41 // CHECK: spirv.FunctionCall @return_none_val() : () -> ()
42 call @return_none_val(): () -> ()
43 // CHECK: {{%.*}} = spirv.FunctionCall @return_one_index(%[[ARG]]) : (i32) -> i32
44 %0 = call @return_one_index(%arg0): (index) -> index
45 // CHECK: spirv.ReturnValue {{%.*}} : i32
53 func.func @dim_index_out_of_bounds() {
54 %c6 = arith.constant 6 : index
55 %alloc_4 = memref.alloc() : memref<4xi64>
56 %dim = memref.dim %alloc_4, %c6 : memref<4xi64>
57 %alloca_100 = memref.alloca() : memref<100xi64>
58 // expected-error@+1 {{'affine.vector_load' op index must be a valid dimension or symbol identifier}}
59 %70 = affine.vector_load %alloca_100[%dim] : memref<100xi64>, vector<31xi64>