diff options
| author | Mahesh Ravishankar <ravishankarm@google.com> | 2019-09-19 14:49:29 -0700 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-09-19 14:50:05 -0700 |
| commit | 9a4f5d2ee324f536cede769c10022d1ce7b875f1 (patch) | |
| tree | d9ed6d52b0ea1bf45dc170b370ef252fff97cadd /mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp | |
| parent | 2df646bef6e7665fdb8523613d82e7d4a5013217 (diff) | |
| download | bcm5719-llvm-9a4f5d2ee324f536cede769c10022d1ce7b875f1.tar.gz bcm5719-llvm-9a4f5d2ee324f536cede769c10022d1ce7b875f1.zip | |
Allow specification of decorators on SPIR-V StructType members.
Allow specification of decorators on SPIR-V StructType members. If the
struct has layout information, these decorations are to be specified
after the offset specification of the member. These decorations are
emitted as OpMemberDecorate instructions on the struct <id>. Update
(de)serialization to handle these decorations.
PiperOrigin-RevId: 270130136
Diffstat (limited to 'mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp')
| -rw-r--r-- | mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp index 28e68eac15d..34bc0e657ac 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -167,7 +167,7 @@ private: /// Process member decoration LogicalResult processMemberDecoration(uint32_t structID, uint32_t memberNum, spirv::Decoration decorationType, - uint32_t value); + ArrayRef<uint32_t> values = {}); //===--------------------------------------------------------------------===// // Types @@ -532,9 +532,12 @@ LogicalResult Serializer::processTypeDecoration<spirv::ArrayType>( LogicalResult Serializer::processMemberDecoration(uint32_t structID, uint32_t memberIndex, spirv::Decoration decorationType, - uint32_t value) { + ArrayRef<uint32_t> values) { SmallVector<uint32_t, 4> args( - {structID, memberIndex, static_cast<uint32_t>(decorationType), value}); + {structID, memberIndex, static_cast<uint32_t>(decorationType)}); + if (!values.empty()) { + args.append(values.begin(), values.end()); + } return encodeInstructionInto(decorations, spirv::Opcode::OpMemberDecorate, args); } @@ -793,11 +796,21 @@ Serializer::prepareBasicType(Location loc, Type type, uint32_t resultID, resultID, elementIndex, spirv::Decoration::Offset, static_cast<uint32_t>(structType.getOffset(elementIndex))))) { return emitError(loc, "cannot decorate ") - << elementIndex << "-th member of : " << structType - << "with its offset"; + << elementIndex << "-th member of " << structType + << " with its offset"; } } } + SmallVector<spirv::StructType::MemberDecorationInfo, 4> memberDecorations; + structType.getMemberDecorations(memberDecorations); + for (auto &memberDecoration : memberDecorations) { + if (failed(processMemberDecoration(resultID, memberDecoration.first, + memberDecoration.second))) { + return emitError(loc, "cannot decorate ") + << memberDecoration.first << "-th member of " << structType + << " with " << stringifyDecoration(memberDecoration.second); + } + } typeEnum = spirv::Opcode::OpTypeStruct; return success(); } |

