Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,21 @@ LogicalResult spirv::Deserializer::setFunctionArgAttrs(
foundDecorationAttr = spirv::DecorationAttr::get(context, decoration);
break;
}

if (decAttr.getName() == getSymbolDecoration(stringifyDecoration(
spirv::Decoration::RelaxedPrecision))) {
// TODO: Current implementation supports only one decoration per function
// parameter so RelaxedPrecision cannot be applied at the same time as,
// for example, Aliased/Restrict/etc. This should be relaxed to allow any
// combination of decoration allowed by the spec to be supported.
if (foundDecorationAttr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This follows the old behavior which restricts it to only support one decoration per function parameter; we should relax this. But fine to do it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to know, I was wondering whether I missed something. I will leave the PR as it is, but I added a TODO, so it can be addressed in the future.

return emitError(unknownLoc, "already found a decoration for function "
"argument with result <id> ")
<< argID;

foundDecorationAttr = spirv::DecorationAttr::get(
context, spirv::Decoration::RelaxedPrecision);
}
}

if (!foundDecorationAttr)
Expand Down
9 changes: 9 additions & 0 deletions mlir/test/Target/SPIRV/decorations.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,12 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [CacheControlsINTEL], [SP
spirv.Return
}
}

// -----

spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
// CHECK: spirv.func @relaxed_precision_arg({{%.*}}: !spirv.ptr<f32, Function> {spirv.decoration = #spirv.decoration<RelaxedPrecision>}) "None" attributes {relaxed_precision} {
spirv.func @relaxed_precision_arg(%arg0: !spirv.ptr<f32, Function> {spirv.decoration = #spirv.decoration<RelaxedPrecision>}) -> () "None" attributes {relaxed_precision} {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing // CHECK line here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's indeed missing. Fixed now.

spirv.Return
}
}