[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:38 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-spirv
Author: None (moscickimilosz)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/181700.diff
1 Files Affected:
- (modified) mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp (+7-14)
``````````diff
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>(
``````````
</details>
https://github.com/llvm/llvm-project/pull/181700
More information about the Mlir-commits
mailing list