[Mlir-commits] [mlir] [mlir][spirv][nfc] Refactor deserialization of decorations (PR #181700)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Feb 16 08:45:03 PST 2026


https://github.com/moscickimilosz created https://github.com/llvm/llvm-project/pull/181700

Move all single integer literal decorations into a common case in spirv deserializer. There was an unnnecessary duplication of switch cases that served the same purpose.

Change OpDecoration -> OpDecorate as that is the correct name of the op

>From cfeb0953e7240283c66d5d3310ffc1c6cd2b8def Mon Sep 17 00:00:00 2001
From: Milosz Moscicki <Milosz.Moscicki at imgtec.com>
Date: Mon, 16 Feb 2026 15:53:40 +0000
Subject: [PATCH] [mlir][spirv][nfc] Refactor deserialization of decorations

Move all single integer literal decorations into a common case in spirv
deserializer. There was an unnnecessary duplication of switch cases that
served the same purpose.

Change OpDecoration -> OpDecorate as that is the correct name of the op
---
 .../SPIRV/Deserialization/Deserializer.cpp    | 21 +++++++------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
index 3ceaa9189898d..933433bcaa57a 100644
--- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
@@ -234,8 +234,8 @@ static LogicalResult deserializeCacheControlDecoration(
     DenseMap<uint32_t, NamedAttrList> &decorations, ArrayRef<uint32_t> words,
     StringAttr symbol, StringRef decorationName, StringRef cacheControlKind) {
   if (words.size() != 4) {
-    return emitError(loc, "OpDecoration with ")
-           << decorationName << "needs a cache control integer literal and a "
+    return emitError(loc, "OpDecorate with ")
+           << decorationName << " needs a cache control integer literal and a "
            << cacheControlKind << " cache control literal";
   }
   unsigned cacheLevel = words[2];
@@ -285,6 +285,9 @@ LogicalResult spirv::Deserializer::processDecoration(ArrayRef<uint32_t> words) {
     break;
   case spirv::Decoration::DescriptorSet:
   case spirv::Decoration::Binding:
+  case spirv::Decoration::Location:
+  case spirv::Decoration::SpecId:
+  case spirv::Decoration::Index:
     if (words.size() != 3) {
       return emitError(unknownLoc, "OpDecorate with ")
              << decorationName << " needs a single integer literal";
@@ -348,21 +351,11 @@ LogicalResult spirv::Deserializer::processDecoration(ArrayRef<uint32_t> words) {
   case spirv::Decoration::Patch:
   case spirv::Decoration::Coherent:
     if (words.size() != 2) {
-      return emitError(unknownLoc, "OpDecoration with ")
-             << decorationName << "needs a single target <id>";
+      return emitError(unknownLoc, "OpDecorate with ")
+             << decorationName << " needs a single target <id>";
     }
     decorations[words[0]].set(symbol, opBuilder.getUnitAttr());
     break;
-  case spirv::Decoration::Location:
-  case spirv::Decoration::SpecId:
-  case spirv::Decoration::Index:
-    if (words.size() != 3) {
-      return emitError(unknownLoc, "OpDecoration with ")
-             << decorationName << "needs a single integer literal";
-    }
-    decorations[words[0]].set(
-        symbol, opBuilder.getI32IntegerAttr(static_cast<int32_t>(words[2])));
-    break;
   case spirv::Decoration::CacheControlLoadINTEL: {
     LogicalResult res = deserializeCacheControlDecoration<
         CacheControlLoadINTELAttr, LoadCacheControlAttr, LoadCacheControl>(



More information about the Mlir-commits mailing list