1 // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s
3 //===----------------------------------------------------------------------===//
5 //===----------------------------------------------------------------------===//
7 // CHECK-LABEL: @return
8 spv.func @return() "None" {
13 //===----------------------------------------------------------------------===//
15 //===----------------------------------------------------------------------===//
17 // CHECK-LABEL: @return_value
18 spv.func @return_value(%arg: i32) -> i32 "None" {
19 // CHECK: llvm.return %{{.*}} : i32
20 spv.ReturnValue %arg : i32
23 //===----------------------------------------------------------------------===//
25 //===----------------------------------------------------------------------===//
27 // CHECK-LABEL: llvm.func @none()
28 spv.func @none() "None" {
32 // CHECK-LABEL: llvm.func @inline() attributes {passthrough = ["alwaysinline"]}
33 spv.func @inline() "Inline" {
37 // CHECK-LABEL: llvm.func @dont_inline() attributes {passthrough = ["noinline"]}
38 spv.func @dont_inline() "DontInline" {
42 // CHECK-LABEL: llvm.func @pure() attributes {passthrough = ["readonly"]}
43 spv.func @pure() "Pure" {
47 // CHECK-LABEL: llvm.func @const() attributes {passthrough = ["readnone"]}
48 spv.func @const() "Const" {
52 // CHECK-LABEL: llvm.func @scalar_types(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: f32)
53 spv.func @scalar_types(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: f32) "None" {
57 // CHECK-LABEL: llvm.func @vector_types(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64>
58 spv.func @vector_types(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> "None" {
59 %0 = spv.IAdd %arg0, %arg1 : vector<2xi64>
60 spv.ReturnValue %0 : vector<2xi64>
63 //===----------------------------------------------------------------------===//
65 //===----------------------------------------------------------------------===//
67 // CHECK-LABEL: llvm.func @function_calls
68 // CHECK-SAME: %[[ARG0:.*]]: i32, %[[ARG1:.*]]: i1, %[[ARG2:.*]]: f64, %[[ARG3:.*]]: vector<2xi64>, %[[ARG4:.*]]: vector<2xf32>
69 spv.func @function_calls(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: vector<2xi64>, %arg4: vector<2xf32>) "None" {
70 // CHECK: llvm.call @void_1() : () -> ()
71 // CHECK: llvm.call @void_2(%[[ARG3]]) : (vector<2xi64>) -> ()
72 // CHECK: llvm.call @value_scalar(%[[ARG0]], %[[ARG1]], %[[ARG2]]) : (i32, i1, f64) -> i32
73 // CHECK: llvm.call @value_vector(%[[ARG3]], %[[ARG4]]) : (vector<2xi64>, vector<2xf32>) -> vector<2xf32>
74 spv.FunctionCall @void_1() : () -> ()
75 spv.FunctionCall @void_2(%arg3) : (vector<2xi64>) -> ()
76 %0 = spv.FunctionCall @value_scalar(%arg0, %arg1, %arg2) : (i32, i1, f64) -> i32
77 %1 = spv.FunctionCall @value_vector(%arg3, %arg4) : (vector<2xi64>, vector<2xf32>) -> vector<2xf32>
81 spv.func @void_1() "None" {
85 spv.func @void_2(%arg0: vector<2xi64>) "None" {
89 spv.func @value_scalar(%arg0: i32, %arg1: i1, %arg2: f64) -> i32 "None" {
90 spv.ReturnValue %arg0: i32
93 spv.func @value_vector(%arg0: vector<2xi64>, %arg1: vector<2xf32>) -> vector<2xf32> "None" {
94 spv.ReturnValue %arg1: vector<2xf32>