Skip to content

[mlir][spirv] Support SPIR-V 1.6 in deserializer #151958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2025

Conversation

IgWod-IMG
Copy link
Contributor

After skimming through the changes in the spec, there does not seem to be anything that will cause issues. A new roundtrip test has been added and validate with spirv-val just in case.

After skimming through the changes in spec, there does not seem
to be anything that will cause issues. A new roundtrip test has
been added and validate with `spirv-val` just in case.
@llvmbot
Copy link
Member

llvmbot commented Aug 4, 2025

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-spirv

Author: Igor Wodiany (IgWod-IMG)

Changes

After skimming through the changes in the spec, there does not seem to be anything that will cause issues. A new roundtrip test has been added and validate with spirv-val just in case.


Full diff: https://github.com/llvm/llvm-project/pull/151958.diff

2 Files Affected:

  • (modified) mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp (+1)
  • (modified) mlir/test/Target/SPIRV/module.mlir (+6)
diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
index 88931b53a6889..33cac1663deb1 100644
--- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
@@ -138,6 +138,7 @@ LogicalResult spirv::Deserializer::processHeader() {
       MIN_VERSION_CASE(3);
       MIN_VERSION_CASE(4);
       MIN_VERSION_CASE(5);
+      MIN_VERSION_CASE(6);
 #undef MIN_VERSION_CASE
     default:
       return emitError(unknownLoc, "unsupported SPIR-V minor version: ")
diff --git a/mlir/test/Target/SPIRV/module.mlir b/mlir/test/Target/SPIRV/module.mlir
index 165412485a088..dcdcab8097e41 100644
--- a/mlir/test/Target/SPIRV/module.mlir
+++ b/mlir/test/Target/SPIRV/module.mlir
@@ -20,6 +20,12 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.5, [Shader], []> {
 
 // -----
 
+// CHECK: v1.6
+spirv.module Logical GLSL450 requires #spirv.vce<v1.6, [Shader, Linkage], []> {
+}
+
+// -----
+
 // CHECK: [Shader, Float16]
 spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Float16], []> {
 }

Copy link
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also add a (conditional) RUN line that pipes the binary to spirv-val?

@kuhar
Copy link
Member

kuhar commented Aug 4, 2025

Example:

// RUN: %if spirv-tools %{ mlir-translate -no-implicit-module --split-input-file -serialize-spirv %s | spirv-val %}

@IgWod-IMG
Copy link
Contributor Author

Will it actually work? Locally I've never managed to pipe mlir-translate and spirv-val when there are multiple modules or --split-input-file. I've just tried it again running:

mlir-translate --serialize-spirv --no-implicit-module --split-input-file llvm-project/mlir/test/Target/SPIRV/module.mlir | spirv-val

And I get:

error: file size should be a multiple of 4; file '(null)' corrupt

@kuhar
Copy link
Member

kuhar commented Aug 4, 2025

Oh, good point. Nvm then.

@IgWod-IMG IgWod-IMG merged commit 2cf276d into llvm:main Aug 4, 2025
12 checks passed
@IgWod-IMG IgWod-IMG deleted the img_spv1.6 branch August 4, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants