MLIR  22.0.0git
Namespaces | Macros | Functions
Serializer.cpp File Reference
#include "Serializer.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
#include "mlir/Target/SPIRV/SPIRVBinaryUtils.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/ADT/bit.h"
#include "llvm/Support/Debug.h"
#include <cstdint>
#include <optional>

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 
 mlir::spirv
 

Macros

#define DEBUG_TYPE   "spirv-serialization"
 

Functions

static BlockgetStructuredControlFlowOpMergeBlock (Operation *op)
 Returns the merge block if the given op is a structured control flow op. More...
 
static BlockgetPhiIncomingBlock (Block *block)
 Given a predecessor block for a block with arguments, returns the block that should be used as the parent block for SPIR-V OpPhi instructions corresponding to the block arguments. More...
 
static bool isZeroValue (Attribute attr)
 
static void moveFuncDeclarationsToTop (spirv::ModuleOp moduleOp)
 Move all functions declaration before functions definitions. More...
 
void mlir::spirv::encodeInstructionInto (SmallVectorImpl< uint32_t > &binary, spirv::Opcode op, ArrayRef< uint32_t > operands)
 Encodes an SPIR-V instruction with the given opcode and operands into the given binary vector. More...
 
static std::string mlir::spirv::getDecorationName (StringRef attrName)
 
template<typename AttrTy , typename EmitF >
static LogicalResult mlir::spirv::processDecorationList (Location loc, Decoration decoration, Attribute attrList, StringRef attrName, EmitF emitter)
 
template<>
LogicalResult mlir::spirv::Serializer::processTypeDecoration< spirv::ArrayType > (Location loc, spirv::ArrayType type, uint32_t resultID)
 
template<>
LogicalResult mlir::spirv::Serializer::processTypeDecoration< spirv::RuntimeArrayType > (Location loc, spirv::RuntimeArrayType type, uint32_t resultID)
 
static Type mlir::spirv::getValueType (Attribute attr)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "spirv-serialization"

Definition at line 30 of file Serializer.cpp.

Function Documentation

◆ getPhiIncomingBlock()

static Block* getPhiIncomingBlock ( Block block)
static

Given a predecessor block for a block with arguments, returns the block that should be used as the parent block for SPIR-V OpPhi instructions corresponding to the block arguments.

Definition at line 47 of file Serializer.cpp.

References mlir::Operation::getBlock(), mlir::Block::getOperations(), mlir::Block::getParentOp(), getStructuredControlFlowOpMergeBlock(), and mlir::Block::isEntryBlock().

◆ getStructuredControlFlowOpMergeBlock()

static Block* getStructuredControlFlowOpMergeBlock ( Operation op)
static

Returns the merge block if the given op is a structured control flow op.

Otherwise returns nullptr.

Definition at line 36 of file Serializer.cpp.

Referenced by getPhiIncomingBlock().

◆ isZeroValue()

static bool isZeroValue ( Attribute  attr)
static

Definition at line 73 of file Serializer.cpp.

◆ moveFuncDeclarationsToTop()

static void moveFuncDeclarationsToTop ( spirv::ModuleOp  moduleOp)
static

Move all functions declaration before functions definitions.

In SPIR-V "declarations" are functions without a body and "definitions" functions with a body. This is stronger than necessary. It should be sufficient to ensure any declarations precede their uses and not all definitions, however this allows to avoid analysing every function in the module this way.

Definition at line 97 of file Serializer.cpp.

References mlir::Operation::moveBefore().

Referenced by mlir::spirv::Serializer::serialize().