MLIR  19.0.0git
Classes | Public Member Functions | List of all members
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. More...
 
LogicalResult serialize ()
 Serializes the remembered SPIR-V module. More...
 
void collect (SmallVectorImpl< uint32_t > &binary)
 Collects the final SPIR-V binary. More...
 
void printValueIDMap (raw_ostream &os)
 (For debugging) prints each value and its corresponding result <id>. More...
 

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 86 of file Serializer.cpp.

Member Function Documentation

◆ collect()

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

Collects the final SPIR-V binary.

Definition at line 114 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 140 of file Serializer.cpp.

◆ serialize()

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

Serializes the remembered SPIR-V module.

Definition at line 90 of file Serializer.cpp.

References mlir::failed(), and mlir::failure().


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