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