diff options
Diffstat (limited to 'mlir/test')
-rw-r--r-- | mlir/test/Dialect/SPIRV/Serialization/terminator.mlir | 21 | ||||
-rw-r--r-- | mlir/test/Dialect/SPIRV/ops.mlir | 41 | ||||
-rw-r--r-- | mlir/test/Dialect/SPIRV/structure-ops.mlir | 14 |
3 files changed, 72 insertions, 4 deletions
diff --git a/mlir/test/Dialect/SPIRV/Serialization/terminator.mlir b/mlir/test/Dialect/SPIRV/Serialization/terminator.mlir new file mode 100644 index 00000000000..35d2f972b55 --- /dev/null +++ b/mlir/test/Dialect/SPIRV/Serialization/terminator.mlir @@ -0,0 +1,21 @@ +// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s + +func @spirv_terminator() -> () { + spv.module "Logical" "GLSL450" { + // CHECK-LABEL: @ret + func @ret() -> () { + // CHECK: spv.Return + spv.Return + } + + // CHECK-LABEL: @ret_val + func @ret_val() -> (i32) { + %0 = spv.Variable : !spv.ptr<i32, Function> + %1 = spv.Load "Function" %0 : i32 + // CHECK: spv.ReturnValue {{.*}} : i32 + spv.ReturnValue %1 : i32 + } + } + return +} + diff --git a/mlir/test/Dialect/SPIRV/ops.mlir b/mlir/test/Dialect/SPIRV/ops.mlir index 052dc687167..167b6d81343 100644 --- a/mlir/test/Dialect/SPIRV/ops.mlir +++ b/mlir/test/Dialect/SPIRV/ops.mlir @@ -327,7 +327,7 @@ spv.module "Logical" "VulkanKHR" { spv.module "Logical" "VulkanKHR" { func @do_nothing() -> () { - // expected-error @+1 {{'spv.EntryPoint' op failed to verify that op can only be used in a 'spv.module' block}} + // expected-error @+1 {{op must appear in a 'spv.module' block}} spv.EntryPoint "GLCompute" @do_something } } @@ -451,7 +451,7 @@ spv.module "Logical" "VulkanKHR" { spv.module "Logical" "VulkanKHR" { func @foo() { - // expected-error @+1 {{op failed to verify that op can only be used in a 'spv.module' block}} + // expected-error @+1 {{op must appear in a 'spv.module' block}} spv.globalVariable !spv.ptr<f32, Input> @var0 spv.Return } @@ -767,7 +767,7 @@ spv.module "Logical" "VulkanKHR" { //===----------------------------------------------------------------------===// "foo.function"() ({ - // expected-error @+1 {{must appear in a 'func' op}} + // expected-error @+1 {{op must appear in a 'func' block}} spv.Return }) : () -> () @@ -784,6 +784,41 @@ spv.module "Logical" "VulkanKHR" { // ----- //===----------------------------------------------------------------------===// +// spv.ReturnValue +//===----------------------------------------------------------------------===// + +func @ret_val() -> (i32) { + %0 = spv.constant 42 : i32 + spv.ReturnValue %0 : i32 +} + +// ----- + +"foo.function"() ({ + %0 = spv.constant true + // expected-error @+1 {{op must appear in a 'func' block}} + spv.ReturnValue %0 : i1 +}) : () -> () + +// ----- + +func @value_count_mismatch() -> () { + %0 = spv.constant 42 : i32 + // expected-error @+1 {{op returns 1 value but enclosing function requires 0 results}} + spv.ReturnValue %0 : i32 +} + +// ----- + +func @value_type_mismatch() -> (f32) { + %0 = spv.constant 42 : i32 + // expected-error @+1 {{return value's type ('i32') mismatch with function's result type ('f32')}} + spv.ReturnValue %0 : i32 +} + +// ----- + +//===----------------------------------------------------------------------===// // spv.SDiv //===----------------------------------------------------------------------===// diff --git a/mlir/test/Dialect/SPIRV/structure-ops.mlir b/mlir/test/Dialect/SPIRV/structure-ops.mlir index db51b175b03..e398be6656e 100644 --- a/mlir/test/Dialect/SPIRV/structure-ops.mlir +++ b/mlir/test/Dialect/SPIRV/structure-ops.mlir @@ -1,6 +1,18 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// +// spv._address_of +//===----------------------------------------------------------------------===// + +spv.module "Logical" "GLSL450" { + spv.globalVariable !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Input> @var + // expected-error @+1 {{op must appear in a 'func' block}} + %1 = spv._address_of @var : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Input> +} + +// ----- + +//===----------------------------------------------------------------------===// // spv.constant //===----------------------------------------------------------------------===// @@ -171,6 +183,6 @@ spv.module "Logical" "VulkanKHR" { //===----------------------------------------------------------------------===// func @module_end_not_in_module() -> () { - // expected-error @+1 {{can only be used in a 'spv.module' block}} + // expected-error @+1 {{op must appear in a 'spv.module' block}} spv._module_end } |