1// RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s 2 3//===----------------------------------------------------------------------===// 4// spirv.Return 5//===----------------------------------------------------------------------===// 6 7// CHECK-LABEL: @return 8spirv.func @return() "None" { 9 // CHECK: llvm.return 10 spirv.Return 11} 12 13//===----------------------------------------------------------------------===// 14// spirv.ReturnValue 15//===----------------------------------------------------------------------===// 16 17// CHECK-LABEL: @return_value 18spirv.func @return_value(%arg: i32) -> i32 "None" { 19 // CHECK: llvm.return %{{.*}} : i32 20 spirv.ReturnValue %arg : i32 21} 22 23//===----------------------------------------------------------------------===// 24// spirv.func 25//===----------------------------------------------------------------------===// 26 27// CHECK-LABEL: llvm.func @none() 28spirv.func @none() "None" { 29 spirv.Return 30} 31 32// CHECK-LABEL: llvm.func @inline() attributes {always_inline} 33spirv.func @inline() "Inline" { 34 spirv.Return 35} 36 37// CHECK-LABEL: llvm.func @dont_inline() attributes {no_inline} 38spirv.func @dont_inline() "DontInline" { 39 spirv.Return 40} 41 42// CHECK-LABEL: llvm.func @pure() attributes {passthrough = ["readonly"]} 43spirv.func @pure() "Pure" { 44 spirv.Return 45} 46 47// CHECK-LABEL: llvm.func @const() attributes {passthrough = ["readnone"]} 48spirv.func @const() "Const" { 49 spirv.Return 50} 51 52// CHECK-LABEL: llvm.func @scalar_types(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: f32) 53spirv.func @scalar_types(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: f32) "None" { 54 spirv.Return 55} 56 57// CHECK-LABEL: llvm.func @vector_types(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> 58spirv.func @vector_types(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> "None" { 59 %0 = spirv.IAdd %arg0, %arg1 : vector<2xi64> 60 spirv.ReturnValue %0 : vector<2xi64> 61} 62 63//===----------------------------------------------------------------------===// 64// spirv.FunctionCall 65//===----------------------------------------------------------------------===// 66 67// CHECK-LABEL: llvm.func @function_calls 68// CHECK-SAME: %[[ARG0:.*]]: i32, %[[ARG1:.*]]: i1, %[[ARG2:.*]]: f64, %[[ARG3:.*]]: vector<2xi64>, %[[ARG4:.*]]: vector<2xf32> 69spirv.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 spirv.FunctionCall @void_1() : () -> () 75 spirv.FunctionCall @void_2(%arg3) : (vector<2xi64>) -> () 76 %0 = spirv.FunctionCall @value_scalar(%arg0, %arg1, %arg2) : (i32, i1, f64) -> i32 77 %1 = spirv.FunctionCall @value_vector(%arg3, %arg4) : (vector<2xi64>, vector<2xf32>) -> vector<2xf32> 78 spirv.Return 79} 80 81spirv.func @void_1() "None" { 82 spirv.Return 83} 84 85spirv.func @void_2(%arg0: vector<2xi64>) "None" { 86 spirv.Return 87} 88 89spirv.func @value_scalar(%arg0: i32, %arg1: i1, %arg2: f64) -> i32 "None" { 90 spirv.ReturnValue %arg0: i32 91} 92 93spirv.func @value_vector(%arg0: vector<2xi64>, %arg1: vector<2xf32>) -> vector<2xf32> "None" { 94 spirv.ReturnValue %arg1: vector<2xf32> 95} 96