[Mlir-commits] [mlir] 2d70091 - [mlir][spirv][nfc] Refactor deserialization of decorations (#181700)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Feb 16 11:21:55 PST 2026
Author: moscickimilosz
Date: 2026-02-16T14:21:50-05:00
New Revision: 2d70091f517c03f473f8a7f2f2960fcc9e19f0bc
URL: https://github.com/llvm/llvm-project/commit/2d70091f517c03f473f8a7f2f2960fcc9e19f0bc
DIFF: https://github.com/llvm/llvm-project/commit/2d70091f517c03f473f8a7f2f2960fcc9e19f0bc.diff
LOG: [mlir][spirv][nfc] Refactor deserialization of decorations (#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
Added:
Modified:
mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
Removed:
################################################################################
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