Skip to content

Commit 40d0012

Browse files
IgWod-IMGkrishna2803
authored andcommitted
[mlir][spirv] Add support for Invariant and Patch decorations (llvm#152301)
New tests were validated with `spriv-val`.
1 parent 5d47ea8 commit 40d0012

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ LogicalResult spirv::Deserializer::processDecoration(ArrayRef<uint32_t> words) {
344344
case spirv::Decoration::RestrictPointer:
345345
case spirv::Decoration::NoContraction:
346346
case spirv::Decoration::Constant:
347+
case spirv::Decoration::Invariant:
348+
case spirv::Decoration::Patch:
347349
if (words.size() != 2) {
348350
return emitError(unknownLoc, "OpDecoration with ")
349351
<< decorationName << "needs a single target <id>";

mlir/lib/Target/SPIRV/Serialization/Serializer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ LogicalResult Serializer::processDecorationAttr(Location loc, uint32_t resultID,
338338
case spirv::Decoration::NoContraction:
339339
case spirv::Decoration::Constant:
340340
case spirv::Decoration::Block:
341+
case spirv::Decoration::Invariant:
342+
case spirv::Decoration::Patch:
341343
// For unit attributes and decoration attributes, the args list
342344
// has no values so we do nothing.
343345
if (isa<UnitAttr, DecorationAttr>(attr))

mlir/test/Target/SPIRV/decorations.mlir

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
5858

5959
// -----
6060

61+
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Tessellation, Linkage], []> {
62+
// CHECK: patch
63+
spirv.GlobalVariable @var {patch} : !spirv.ptr<vector<4xf32>, Input>
64+
}
65+
66+
// -----
67+
68+
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {
69+
// CHECK: invariant
70+
spirv.GlobalVariable @var {invariant} : !spirv.ptr<vector<2xf32>, Output>
71+
}
72+
73+
// -----
74+
6175
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {
6276
// CHECK: linkage_attributes = #spirv.linkage_attributes<linkage_name = "outSideGlobalVar1", linkage_type = <Import>>
6377
spirv.GlobalVariable @var1 {

0 commit comments

Comments
 (0)