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

Amr Hesham llvmlistbot at llvm.org
Sat Aug 17 01:45:46 PDT 2024


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

>From 450604b36c3600dc3d7afb6d53c22b734011f97b 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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp b/mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp
index 3c8f64419d379e..159dd045d72095 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,8 +51,8 @@ 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(kGeneratorNumber);
+  header.push_back((majorVersion << 8) | minorVersion);
+  header.push_back((kGeneratorNumber << 16) | LLVM_VERSION_MAJOR);
   header.push_back(idBound); // <id> bound
   header.push_back(0);       // Schema (reserved word)
 }



More information about the Mlir-commits mailing list