//===- Serializer.h - MLIR SPIR-V Serializer ------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file declares the MLIR SPIR-V module to SPIR-V binary serializer. // //===----------------------------------------------------------------------===// #ifndef MLIR_LIB_TARGET_SPIRV_SERIALIZATION_SERIALIZER_H #define MLIR_LIB_TARGET_SPIRV_SERIALIZATION_SERIALIZER_H #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" #include "mlir/IR/Builders.h" #include "mlir/Target/SPIRV/Serialization.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/raw_ostream.h" namespace mlir { namespace spirv { void encodeInstructionInto(SmallVectorImpl<uint32_t> &binary, spirv::Opcode op, ArrayRef<uint32_t> operands); /// A SPIR-V module serializer. /// /// A SPIR-V binary module is a single linear stream of instructions; each /// instruction is composed of 32-bit words with the layout: /// /// | <word-count>|<opcode> | <operand> | <operand> | ... | /// | <------ word -------> | <-- word --> | <-- word --> | ... | /// /// For the first word, the 16 high-order bits are the word count of the /// instruction, the 16 low-order bits are the opcode enumerant. The /// instructions then belong to different sections, which must be laid out in /// the particular order as specified in "2.4 Logical Layout of a Module" of /// the SPIR-V spec. class Serializer { … }; } // namespace spirv } // namespace mlir #endif // MLIR_LIB_TARGET_SPIRV_SERIALIZATION_SERIALIZER_H