[Mlir-commits] [mlir] d5bf727 - [mlir][spirv] Support for a few more decorations in (de)serialization
Lei Zhang
llvmlistbot at llvm.org
Tue Nov 3 05:33:37 PST 2020
Author: Lei Zhang
Date: 2020-11-03T08:11:19-05:00
New Revision: d5bf727bcd503ccbf2fbe9d15d82856729e45e77
URL: https://github.com/llvm/llvm-project/commit/d5bf727bcd503ccbf2fbe9d15d82856729e45e77
DIFF: https://github.com/llvm/llvm-project/commit/d5bf727bcd503ccbf2fbe9d15d82856729e45e77.diff
LOG: [mlir][spirv] Support for a few more decorations in (de)serialization
Reviewed By: mravishankar
Differential Revision: https://reviews.llvm.org/D90655
Added:
Modified:
mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
mlir/test/Dialect/SPIRV/Serialization/decorations.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
index 0c56d7efb6a6..f63d436e94d1 100644
--- a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
+++ b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
@@ -780,10 +780,14 @@ LogicalResult Deserializer::processDecoration(ArrayRef<uint32_t> words) {
}
typeDecorations[words[0]] = words[2];
break;
+ case spirv::Decoration::Aliased:
case spirv::Decoration::Block:
case spirv::Decoration::BufferBlock:
case spirv::Decoration::Flat:
+ case spirv::Decoration::NonReadable:
+ case spirv::Decoration::NonWritable:
case spirv::Decoration::NoPerspective:
+ case spirv::Decoration::Restrict:
if (words.size() != 2) {
return emitError(unknownLoc, "OpDecoration with ")
<< decorationName << "needs a single target <id>";
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
index 2f7403cfecd5..4b80802e8dac 100644
--- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
+++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
@@ -751,12 +751,15 @@ LogicalResult Serializer::processDecoration(Location loc, uint32_t resultID,
<< attrName << " attribute " << strAttr.getValue();
}
return emitError(loc, "expected string attribute for ") << attrName;
+ case spirv::Decoration::Aliased:
case spirv::Decoration::Flat:
+ case spirv::Decoration::NonReadable:
+ case spirv::Decoration::NonWritable:
case spirv::Decoration::NoPerspective:
- if (auto unitAttr = attr.second.dyn_cast<UnitAttr>()) {
- // For unit attributes, the args list has no values so we do nothing
+ case spirv::Decoration::Restrict:
+ // For unit attributes, the args list has no values so we do nothing
+ if (auto unitAttr = attr.second.dyn_cast<UnitAttr>())
break;
- }
return emitError(loc, "expected unit attribute for ") << attrName;
default:
return emitError(loc, "unhandled decoration ") << decorationName;
diff --git a/mlir/test/Dialect/SPIRV/Serialization/decorations.mlir b/mlir/test/Dialect/SPIRV/Serialization/decorations.mlir
index 427f03f69fea..9004ab4d8b3b 100644
--- a/mlir/test/Dialect/SPIRV/Serialization/decorations.mlir
+++ b/mlir/test/Dialect/SPIRV/Serialization/decorations.mlir
@@ -2,20 +2,50 @@
spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
// CHECK: location = 0 : i32
- spv.globalVariable @var1 {location = 0 : i32} : !spv.ptr<vector<4xf32>, Input>
+ spv.globalVariable @var {location = 0 : i32} : !spv.ptr<vector<4xf32>, Input>
}
// -----
spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
// CHECK: no_perspective
- spv.globalVariable @var1 {no_perspective} : !spv.ptr<vector<4xf32>, Input>
+ spv.globalVariable @var {no_perspective} : !spv.ptr<vector<4xf32>, Input>
}
// -----
spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
// CHECK: flat
- spv.globalVariable @var2 {flat} : !spv.ptr<si32, Input>
+ spv.globalVariable @var {flat} : !spv.ptr<si32, Input>
+}
+
+// -----
+
+spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
+ // CHECK: aliased
+ // CHECK: aliased
+ spv.globalVariable @var1 bind(0, 0) {aliased} : !spv.ptr<!spv.struct<(!spv.array<4xf32, stride=4>[0])>, StorageBuffer>
+ spv.globalVariable @var2 bind(0, 0) {aliased} : !spv.ptr<!spv.struct<(vector<4xf32>[0])>, StorageBuffer>
+}
+
+// -----
+
+spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
+ // CHECK: non_readable
+ spv.globalVariable @var bind(0, 0) {non_readable} : !spv.ptr<!spv.struct<(!spv.array<4xf32, stride=4>[0])>, StorageBuffer>
+}
+
+// -----
+
+spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
+ // CHECK: non_writable
+ spv.globalVariable @var bind(0, 0) {non_writable} : !spv.ptr<!spv.struct<(!spv.array<4xf32, stride=4>[0])>, StorageBuffer>
+}
+
+// -----
+
+spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
+ // CHECK: restrict
+ spv.globalVariable @var bind(0, 0) {restrict} : !spv.ptr<!spv.struct<(!spv.array<4xf32, stride=4>[0])>, StorageBuffer>
}
More information about the Mlir-commits
mailing list