[PATCH] D80837: [MLIR][SPIRV] Add flat, location, and noperspective decorations
Lei Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 06:03:11 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc2349e3cf0e: [MLIR][SPIRV] Support flat, location, and noperspective decorations (authored by Hazem, committed by antiagainst).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80837/new/
https://reviews.llvm.org/D80837
Files:
mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
mlir/test/Dialect/SPIRV/Serialization/decorations.mlir
Index: mlir/test/Dialect/SPIRV/Serialization/decorations.mlir
===================================================================
--- /dev/null
+++ mlir/test/Dialect/SPIRV/Serialization/decorations.mlir
@@ -0,0 +1,21 @@
+// RUN: mlir-translate -split-input-file -test-spirv-roundtrip %s | FileCheck %s
+
+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.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
+ // CHECK: no_perspective
+ spv.globalVariable @var1 {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>
+}
+
Index: mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
===================================================================
--- mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
+++ mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
@@ -672,8 +672,9 @@
}
SmallVector<uint32_t, 1> args;
switch (decoration.getValue()) {
- case spirv::Decoration::DescriptorSet:
case spirv::Decoration::Binding:
+ case spirv::Decoration::DescriptorSet:
+ case spirv::Decoration::Location:
if (auto intAttr = attr.second.dyn_cast<IntegerAttr>()) {
args.push_back(intAttr.getValue().getZExtValue());
break;
@@ -690,6 +691,13 @@
<< attrName << " attribute " << strAttr.getValue();
}
return emitError(loc, "expected string attribute for ") << attrName;
+ case spirv::Decoration::Flat:
+ 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
+ break;
+ }
+ return emitError(loc, "expected unit attribute for ") << attrName;
default:
return emitError(loc, "unhandled decoration ") << decorationName;
}
Index: mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
===================================================================
--- mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
+++ mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
@@ -717,6 +717,8 @@
break;
case spirv::Decoration::Block:
case spirv::Decoration::BufferBlock:
+ case spirv::Decoration::Flat:
+ case spirv::Decoration::NoPerspective:
if (words.size() != 2) {
return emitError(unknownLoc, "OpDecoration with ")
<< decorationName << "needs a single target <id>";
@@ -727,6 +729,7 @@
// it is needed for many validation rules.
decorations[words[0]].set(symbol, opBuilder.getUnitAttr());
break;
+ case spirv::Decoration::Location:
case spirv::Decoration::SpecId:
if (words.size() != 3) {
return emitError(unknownLoc, "OpDecoration with ")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80837.268765.patch
Type: text/x-patch
Size: 2915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200605/d5af198a/attachment-0001.bin>
More information about the llvm-commits
mailing list