[Mlir-commits] [mlir] [mlir][spirv] Fix incorrect metadata in SPIR-V Header (PR #104242)

Amr Hesham llvmlistbot at llvm.org
Sat Aug 17 01:28:40 PDT 2024


https://github.com/AmrDeveloper updated https://github.com/llvm/llvm-project/pull/104242

>From 4713240dc823163b65c6e8e66220860b2cbd6a0e Mon Sep 17 00:00:00 2001
From: AmrDeveloper <amr96 at programmer.net>
Date: Wed, 14 Aug 2024 23:18:07 +0200
Subject: [PATCH] [mlir][spirv] Fix incorrect metadata in SPIR-V Header

SRIP-V Generator Magic Number is a 32 bit word: The high order 16
bits are a tool ID. The low order 16 bits are for verion number,
So fix the metadata generator to put the version major and minor in
the low 16 bits
---
 mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp b/mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp
index 3c8f64419d379e..ee75639fa016e4 100644
--- a/mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp
+++ b/mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp
@@ -42,7 +42,7 @@ void spirv::appendModuleHeader(SmallVectorImpl<uint32_t> &header,
   // +-------------------------------------------------------------------------+
   // | Magic number                                                            |
   // +-------------------------------------------------------------------------+
-  // | Version number (bytes: 0 | major number | minor number | 0)             |
+  // | Version number (bytes: 0 | 0 | major number | minor number)             |
   // +-------------------------------------------------------------------------+
   // | Generator magic number                                                  |
   // +-------------------------------------------------------------------------+
@@ -51,7 +51,7 @@ void spirv::appendModuleHeader(SmallVectorImpl<uint32_t> &header,
   // | 0 (reserved for instruction schema)                                     |
   // +-------------------------------------------------------------------------+
   header.push_back(spirv::kMagicNumber);
-  header.push_back((majorVersion << 16) | (minorVersion << 8));
+  header.push_back((majorVersion << 8) | minorVersion);
   header.push_back(kGeneratorNumber);
   header.push_back(idBound); // <id> bound
   header.push_back(0);       // Schema (reserved word)



More information about the Mlir-commits mailing list