MLIR 22.0.0git
mlir::spirv::Serializer Class Reference

A SPIR-V module serializer. More...

#include "Target/SPIRV/Serialization/Serializer.h"

Public Member Functions

 Serializer (spirv::ModuleOp module, const SerializationOptions &options)
 Creates a serializer for the given SPIR-V module.
LogicalResult serialize ()
 Serializes the remembered SPIR-V module.
void collect (SmallVectorImpl< uint32_t > &binary)
 Collects the final SPIR-V binary.
void printValueIDMap (raw_ostream &os)
 (For debugging) prints each value and its corresponding result <id>.

Detailed Description

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.

Definition at line 42 of file Serializer.h.

Constructor & Destructor Documentation

◆ Serializer()

mlir::spirv::Serializer::Serializer ( spirv::ModuleOp module,
const SerializationOptions & options )
explicit

Creates a serializer for the given SPIR-V module.

Definition at line 120 of file Serializer.cpp.

References getContext().

Member Function Documentation

◆ collect()

void mlir::spirv::Serializer::collect ( SmallVectorImpl< uint32_t > & binary)

Collects the final SPIR-V binary.

Definition at line 152 of file Serializer.cpp.

References mlir::spirv::appendModuleHeader(), and mlir::spirv::kHeaderWordCount.

◆ printValueIDMap()

void mlir::spirv::Serializer::printValueIDMap ( raw_ostream & os)

(For debugging) prints each value and its corresponding result <id>.

Definition at line 179 of file Serializer.cpp.

References mlir::Value::getDefiningOp(), mlir::Operation::getName(), and mlir::Block::getParentOp().

◆ serialize()

LogicalResult mlir::spirv::Serializer::serialize ( )

Serializes the remembered SPIR-V module.

Definition at line 124 of file Serializer.cpp.

References moveFuncDeclarationsToTop(), and success().


The documentation for this class was generated from the following files: