Skip to content

Commit 87de48d

Browse files
authored
[mlir][spirv] Add spirv validation for module.mlir target test (#153227)
Creating this patch as an example on using the new `mlir-translate` flag. Eventually all tests will be updated to validate SPIR-V modules.
1 parent d3bbdc7 commit 87de48d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

mlir/test/Target/SPIRV/module.mlir

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
// RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip -split-input-file %s | FileCheck %s
1+
// RUN: mlir-translate --no-implicit-module --test-spirv-roundtrip --split-input-file %s | FileCheck %s
2+
3+
// REQUIRES: shell
4+
// RUN: %if spirv-tools %{ rm -rf %t %}
5+
// RUN: %if spirv-tools %{ mkdir %t %}
6+
// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
7+
// RUN: %if spirv-tools %{ ls %t/module*.spv | xargs -I{} spirv-val {} %}
28

39
// CHECK: spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
410
// CHECK-NEXT: spirv.func @foo() "Inline" {
511
// CHECK-NEXT: spirv.Return
612
// CHECK-NEXT: }
13+
// CHECK-NEXT: spirv.EntryPoint "Vertex" @foo
714
// CHECK-NEXT: }
815

916
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
1017
spirv.func @foo() -> () "Inline" {
1118
spirv.Return
1219
}
20+
spirv.EntryPoint "Vertex" @foo
1321
}
1422

1523
// -----
1624

1725
// CHECK: v1.5
18-
spirv.module Logical GLSL450 requires #spirv.vce<v1.5, [Shader], []> {
26+
spirv.module Logical GLSL450 requires #spirv.vce<v1.5, [Shader, Linkage], []> {
1927
}
2028

2129
// -----
@@ -26,13 +34,13 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.6, [Shader, Linkage], []> {
2634

2735
// -----
2836

29-
// CHECK: [Shader, Float16]
30-
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Float16], []> {
37+
// CHECK: [Shader, Float16, Linkage]
38+
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Float16, Linkage], []> {
3139
}
3240

3341
// -----
3442

3543
// CHECK: [SPV_KHR_float_controls, SPV_KHR_subgroup_vote]
36-
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], [SPV_KHR_float_controls, SPV_KHR_subgroup_vote]> {
44+
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], [SPV_KHR_float_controls, SPV_KHR_subgroup_vote]> {
3745
}
3846

0 commit comments

Comments
 (0)