|
MLIR 22.0.0git
|
A SPIR-V module serializer. More...
#include "Target/SPIRV/Deserialization/Deserializer.h"
Public Types | |
| using | BlockPhiInfo |
| For OpPhi instructions, we use block arguments to represent them. | |
Public Member Functions | |
| LogicalResult | processFunction (ArrayRef< uint32_t > operands) |
| Creates a deserializer for the given SPIR-V binary module. | |
| LogicalResult | processFunctionEnd (ArrayRef< uint32_t > operands) |
| Processes OpFunctionEnd and finalizes function. | |
| std::optional< std::pair< Attribute, Type > > | getConstant (uint32_t id) |
| Gets the constant's attribute and type associated with the given <id>. | |
| std::optional< std::pair< Attribute, Type > > | getConstantCompositeReplicate (uint32_t id) |
| Gets the replicated composite constant's attribute and type associated with the given <id>. | |
| std::optional< SpecConstOperationMaterializationInfo > | getSpecConstantOperation (uint32_t id) |
| Gets the info needed to materialize the spec constant operation op associated with the given <id>. | |
| IntegerAttr | getConstantInt (uint32_t id) |
| Gets the constant's integer attribute with the given <id>. | |
| std::string | getFunctionSymbol (uint32_t id) |
| Returns a symbol to be used for the function name with the given result <id>. | |
| std::string | getGraphSymbol (uint32_t id) |
| Returns a symbol to be used for the graph name with the given result <id>. | |
| std::string | getSpecConstantSymbol (uint32_t id) |
| Returns a symbol to be used for the specialization constant with the given result <id>. | |
| spirv::SpecConstantOp | getSpecConstant (uint32_t id) |
| Gets the specialization constant with the given result <id>. | |
| spirv::SpecConstantCompositeOp | getSpecConstantComposite (uint32_t id) |
| Gets the composite specialization constant with the given result <id>. | |
| spirv::EXTSpecConstantCompositeReplicateOp | getSpecConstantCompositeReplicate (uint32_t id) |
| Gets the replicated composite specialization constant with the given result <id>. | |
| spirv::SpecConstantOp | createSpecConstant (Location loc, uint32_t resultID, TypedAttr defaultValue) |
| Creates a spirv::SpecConstantOp. | |
| std::optional< spirv::GraphConstantARMOpMaterializationInfo > | getGraphConstantARM (uint32_t id) |
| Gets the GraphConstantARM ID attribute and result type with the given result <id>. | |
| LogicalResult | processGlobalVariable (ArrayRef< uint32_t > operands) |
| Processes the OpVariable instructions at current offset into binary. | |
| spirv::GlobalVariableOp | getGlobalVariable (uint32_t id) |
| Gets the global variable associated with a result <id> of OpVariable. | |
| LogicalResult | setFunctionArgAttrs (uint32_t argID, SmallVectorImpl< Attribute > &argAttrs, size_t argIndex) |
| Sets the function argument's attributes. | |
| StringAttr | getSymbolDecoration (StringRef decorationName) |
| Gets the symbol name from the name of decoration. | |
| LogicalResult | splitSelectionHeader () |
| Move a conditional branch or a switch into a separate basic block to avoid unnecessary sinking of defs that may be required outside a selection region. | |
| Type | getType (uint32_t id) |
| Gets type for a given result <id>. | |
| Type | getUndefType (uint32_t id) |
| Get the type associated with the result <id> of an OpUndef. | |
| bool | isVoidType (Type type) const |
| Returns true if the given type is for SPIR-V void type. | |
| LogicalResult | processType (spirv::Opcode opcode, ArrayRef< uint32_t > operands) |
| Processes a SPIR-V type instruction with given opcode and operands and registers the type into module. | |
| LogicalResult | processOpTypePointer (ArrayRef< uint32_t > operands) |
| LogicalResult | processArrayType (ArrayRef< uint32_t > operands) |
| LogicalResult | processCooperativeMatrixTypeKHR (ArrayRef< uint32_t > operands) |
| LogicalResult | processCooperativeMatrixTypeNV (ArrayRef< uint32_t > operands) |
| LogicalResult | processFunctionType (ArrayRef< uint32_t > operands) |
| LogicalResult | processImageType (ArrayRef< uint32_t > operands) |
| LogicalResult | processSampledImageType (ArrayRef< uint32_t > operands) |
| LogicalResult | processRuntimeArrayType (ArrayRef< uint32_t > operands) |
| LogicalResult | processStructType (ArrayRef< uint32_t > operands) |
| LogicalResult | processMatrixType (ArrayRef< uint32_t > operands) |
| LogicalResult | processTensorARMType (ArrayRef< uint32_t > operands) |
| LogicalResult | processGraphTypeARM (ArrayRef< uint32_t > operands) |
| LogicalResult | processGraphEntryPointARM (ArrayRef< uint32_t > operands) |
| LogicalResult | processGraphARM (ArrayRef< uint32_t > operands) |
| LogicalResult | processOpGraphSetOutputARM (ArrayRef< uint32_t > operands) |
| LogicalResult | processGraphEndARM (ArrayRef< uint32_t > operands) |
| LogicalResult | processTypeForwardPointer (ArrayRef< uint32_t > operands) |
| LogicalResult | processConstant (ArrayRef< uint32_t > operands, bool isSpec) |
| Processes a SPIR-V Op{|Spec}Constant instruction with the given operands. | |
| LogicalResult | processConstantBool (bool isTrue, ArrayRef< uint32_t > operands, bool isSpec) |
| Processes a SPIR-V Op{|Spec}Constant{True|False} instruction with the given operands. | |
| LogicalResult | processConstantComposite (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpConstantComposite instruction with the given operands. | |
| LogicalResult | processConstantCompositeReplicateEXT (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpConstantCompositeReplicateEXT instruction with the given operands. | |
| LogicalResult | processSpecConstantComposite (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpSpecConstantComposite instruction with the given operands. | |
| LogicalResult | processSpecConstantCompositeReplicateEXT (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpSpecConstantCompositeReplicateEXT instruction with the given operands. | |
| LogicalResult | processSpecConstantOperation (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpSpecConstantOp instruction with the given operands. | |
| Value | materializeSpecConstantOperation (uint32_t resultID, spirv::Opcode enclosedOpcode, uint32_t resultTypeID, ArrayRef< uint32_t > enclosedOpOperands) |
| Materializes/emits an OpSpecConstantOp instruction. | |
| LogicalResult | processConstantNull (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpConstantNull instruction with the given operands. | |
| LogicalResult | processGraphConstantARM (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpGraphConstantARM instruction with the given operands. | |
| void | clearDebugLine () |
| Discontinues any source-level location information that might be active from a previous OpLine instruction. | |
| Location | createFileLineColLoc (OpBuilder opBuilder) |
| Creates a FileLineColLoc with the OpLine location information. | |
| LogicalResult | processDebugLine (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpLine instruction with the given operands. | |
| LogicalResult | processDebugString (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpString instruction with the given operands. | |
| Block * | getBlock (uint32_t id) const |
| Returns the block for the given label <id>. | |
| Block * | getOrCreateBlock (uint32_t id) |
| Gets or creates the block corresponding to the given label <id>. | |
| LogicalResult | processBranch (ArrayRef< uint32_t > operands) |
| LogicalResult | processBranchConditional (ArrayRef< uint32_t > operands) |
| LogicalResult | processLabel (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpLabel instruction with the given operands. | |
| LogicalResult | processSelectionMerge (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpSelectionMerge instruction with the given operands. | |
| LogicalResult | processLoopMerge (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpLoopMerge instruction with the given operands. | |
| LogicalResult | processPhi (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpPhi instruction with the given operands. | |
| LogicalResult | processSwitch (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpSwitch instruction with the given operands. | |
| LogicalResult | wireUpBlockArgument () |
| Creates block arguments on predecessors previously recorded when handling OpPhi instructions. | |
| LogicalResult | structurizeControlFlow () |
| Extracts blocks belonging to a structured selection/loop into a spirv.mlir.selection/spirv.mlir.loop op. | |
| LogicalResult | createGraphBlock (uint32_t graphID) |
| Creates a block for graph with the given graphID. | |
| Value | getValue (uint32_t id) |
| Get the Value associated with a result <id>. | |
| LogicalResult | sliceInstruction (spirv::Opcode &opcode, ArrayRef< uint32_t > &operands, std::optional< spirv::Opcode > expectedOpcode=std::nullopt) |
| Slices the first instruction out of binary and returns its opcode and operands via opcode and operands respectively. | |
| LogicalResult | processInstruction (spirv::Opcode opcode, ArrayRef< uint32_t > operands, bool deferInstructions=true) |
| Processes a SPIR-V instruction with the given opcode and operands. | |
| LogicalResult | processOpWithoutGrammarAttr (ArrayRef< uint32_t > words, StringRef opName, bool hasResult, unsigned numOperands) |
| Processes a SPIR-V instruction from the given operands. | |
| LogicalResult | processUndef (ArrayRef< uint32_t > operands) |
| Processes a OpUndef instruction. | |
| LogicalResult | dispatchToAutogenDeserialization (spirv::Opcode opcode, ArrayRef< uint32_t > words) |
| Method to dispatch to the specialized deserialization function for an operation in SPIR-V dialect that is a mirror of an instruction in the SPIR-V spec. | |
| LogicalResult | processExtInst (ArrayRef< uint32_t > operands) |
| Processes a SPIR-V OpExtInst with given operands. | |
| LogicalResult | dispatchToExtensionSetAutogenDeserialization (StringRef extensionSetName, uint32_t instructionID, ArrayRef< uint32_t > words) |
| Dispatches the deserialization of extended instruction set operation based on the extended instruction set name, and instruction opcode. | |
| template<typename OpTy> | |
| LogicalResult | processOp (ArrayRef< uint32_t > words) |
| Method to deserialize an operation in the SPIR-V dialect that is a mirror of an instruction in the SPIR-V spec. | |
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. The first word of an instruction records the total number of words of that instruction using the 16 higher-order bits. So this deserializer uses that to get instruction boundary and parse instructions and build a SPIR-V ModuleOp gradually.
Definition at line 131 of file Deserializer.h.
For OpPhi instructions, we use block arguments to represent them.
OpPhi encodes a list of (value, predecessor) pairs. At the time of handling the block containing an OpPhi instruction, the predecessor block might not be processed yet, also the value sent by it. So we need to defer handling the block argument from the predecessors. We use the following approach:
Definition at line 454 of file Deserializer.h.
| void spirv::Deserializer::clearDebugLine | ( | ) |
Discontinues any source-level location information that might be active from a previous OpLine instruction.
Definition at line 3021 of file Deserializer.cpp.
Referenced by processBranch(), processBranchConditional(), processInstruction(), and processOpWithoutGrammarAttr().
Creates a FileLineColLoc with the OpLine location information.
Definition at line 2997 of file Deserializer.cpp.
References mlir::FileLineColLoc::get().
Referenced by materializeSpecConstantOperation(), processBranch(), processBranchConditional(), processGlobalVariable(), processLoopMerge(), processOpWithoutGrammarAttr(), processSelectionMerge(), and processSwitch().
| LogicalResult spirv::Deserializer::createGraphBlock | ( | uint32_t | graphID | ) |
Creates a block for graph with the given graphID.
Definition at line 2193 of file Deserializer.cpp.
References mlir::emitError(), mlir::Block::empty(), getOrCreateBlock(), and success().
Referenced by processGraphARM().
| spirv::SpecConstantOp spirv::Deserializer::createSpecConstant | ( | Location | loc, |
| uint32_t | resultID, | ||
| TypedAttr | defaultValue ) |
Creates a spirv::SpecConstantOp.
Definition at line 916 of file Deserializer.cpp.
References getSpecConstantSymbol().
Referenced by processConstant(), and processConstantBool().
| LogicalResult mlir::spirv::Deserializer::dispatchToAutogenDeserialization | ( | spirv::Opcode | opcode, |
| ArrayRef< uint32_t > | words ) |
Method to dispatch to the specialized deserialization function for an operation in SPIR-V dialect that is a mirror of an instruction in the SPIR-V spec.
This is auto-generated from ODS. Dispatch is handled for all operations in SPIR-V dialect that have hasOpcode == 1.
Referenced by processInstruction().
| LogicalResult mlir::spirv::Deserializer::dispatchToExtensionSetAutogenDeserialization | ( | StringRef | extensionSetName, |
| uint32_t | instructionID, | ||
| ArrayRef< uint32_t > | words ) |
Dispatches the deserialization of extended instruction set operation based on the extended instruction set name, and instruction opcode.
This is autogenerated from ODS.
Referenced by processExtInst().
|
inline |
Returns the block for the given label <id>.
Definition at line 411 of file Deserializer.h.
Referenced by getOrCreateBlock().
Gets the constant's attribute and type associated with the given <id>.
Definition at line 868 of file Deserializer.cpp.
Referenced by getConstantInt(), getValue(), processArrayType(), processConstantComposite(), processConstantCompositeReplicateEXT(), and processTensorARMType().
| std::optional< std::pair< Attribute, Type > > spirv::Deserializer::getConstantCompositeReplicate | ( | uint32_t | id | ) |
Gets the replicated composite constant's attribute and type associated with the given <id>.
Definition at line 876 of file Deserializer.cpp.
Referenced by getValue(), and processConstantCompositeReplicateEXT().
| IntegerAttr spirv::Deserializer::getConstantInt | ( | uint32_t | id | ) |
Gets the constant's integer attribute with the given <id>.
Returns a null IntegerAttr if the given is not registered or does not correspond to an integer constant.
Definition at line 1016 of file Deserializer.cpp.
References getConstant().
Referenced by processCooperativeMatrixTypeKHR(), processGraphARM(), processOpGraphSetOutputARM(), and processTensorARMType().
| std::string spirv::Deserializer::getFunctionSymbol | ( | uint32_t | id | ) |
Returns a symbol to be used for the function name with the given result <id>.
This tries to use the function's OpName if exists; otherwise creates one based on the <id>.
Definition at line 891 of file Deserializer.cpp.
Referenced by processFunction().
|
inline |
Gets the global variable associated with a result <id> of OpVariable.
Definition at line 266 of file Deserializer.h.
Referenced by getValue(), processGlobalVariable(), and processGraphEntryPointARM().
| std::optional< spirv::GraphConstantARMOpMaterializationInfo > spirv::Deserializer::getGraphConstantARM | ( | uint32_t | id | ) |
Gets the GraphConstantARM ID attribute and result type with the given result <id>.
Definition at line 930 of file Deserializer.cpp.
Referenced by getValue().
| std::string spirv::Deserializer::getGraphSymbol | ( | uint32_t | id | ) |
Returns a symbol to be used for the graph name with the given result <id>.
This tries to use the graph's OpName if exists; otherwise creates one based on the <id>.
Definition at line 899 of file Deserializer.cpp.
Referenced by processGraphARM().
| Block * spirv::Deserializer::getOrCreateBlock | ( | uint32_t | id | ) |
Gets or creates the block corresponding to the given label <id>.
The newly created block will always be placed at the end of the current function.
Definition at line 2100 of file Deserializer.cpp.
References getBlock().
Referenced by createGraphBlock(), processBranch(), processBranchConditional(), processLabel(), processLoopMerge(), processPhi(), processSelectionMerge(), and processSwitch().
|
inline |
Gets the specialization constant with the given result <id>.
Definition at line 234 of file Deserializer.h.
Referenced by getValue(), processGlobalVariable(), processSpecConstantComposite(), and processSpecConstantCompositeReplicateEXT().
|
inline |
Gets the composite specialization constant with the given result <id>.
Definition at line 239 of file Deserializer.h.
Referenced by getValue(), and processGlobalVariable().
|
inline |
Gets the replicated composite specialization constant with the given result <id>.
Definition at line 246 of file Deserializer.h.
Referenced by getValue().
| std::optional< spirv::SpecConstOperationMaterializationInfo > spirv::Deserializer::getSpecConstantOperation | ( | uint32_t | id | ) |
Gets the info needed to materialize the spec constant operation op associated with the given <id>.
Definition at line 884 of file Deserializer.cpp.
Referenced by getValue().
| std::string spirv::Deserializer::getSpecConstantSymbol | ( | uint32_t | id | ) |
Returns a symbol to be used for the specialization constant with the given result <id>.
This tries to use the specialization constant's OpName if exists; otherwise creates one based on the <id>.
Definition at line 907 of file Deserializer.cpp.
Referenced by createSpecConstant(), processSpecConstantComposite(), and processSpecConstantCompositeReplicateEXT().
|
inline |
Gets the symbol name from the name of decoration.
Definition at line 278 of file Deserializer.h.
Referenced by setFunctionArgAttrs().
|
inline |
Gets type for a given result <id>.
Definition at line 294 of file Deserializer.h.
|
inline |
Get the type associated with the result <id> of an OpUndef.
Definition at line 297 of file Deserializer.h.
Referenced by getValue().
| Value spirv::Deserializer::getValue | ( | uint32_t | id | ) |
Get the Value associated with a result <id>.
This method materializes normal constants and inserts "casting" ops (spirv.mlir.addressof and spirv.mlir.referenceof) to turn an symbol into a SSA value for handling uses of module scope constants/variables in functions.
Definition at line 42 of file DeserializeOps.cpp.
References getConstant(), getConstantCompositeReplicate(), getGlobalVariable(), getGraphConstantARM(), getSpecConstant(), getSpecConstantComposite(), getSpecConstantCompositeReplicate(), getSpecConstantOperation(), getUndefType(), and materializeSpecConstantOperation().
Referenced by processBranchConditional(), processFunction(), processGraphARM(), processOpGraphSetOutputARM(), processOpWithoutGrammarAttr(), processSwitch(), and wireUpBlockArgument().
Returns true if the given type is for SPIR-V void type.
Definition at line 300 of file Deserializer.h.
Referenced by processFunction(), and processFunctionType().
| Value spirv::Deserializer::materializeSpecConstantOperation | ( | uint32_t | resultID, |
| spirv::Opcode | enclosedOpcode, | ||
| uint32_t | resultTypeID, | ||
| ArrayRef< uint32_t > | enclosedOpOperands ) |
Materializes/emits an OpSpecConstantOp instruction.
Definition at line 1978 of file Deserializer.cpp.
References mlir::Region::back(), createFileLineColLoc(), mlir::Region::end(), mlir::Block::front(), mlir::Region::getBlocks(), mlir::Operation::getResult(), mlir::getType(), processInstruction(), and mlir::Block::splitBlock().
Referenced by getValue().
| LogicalResult spirv::Deserializer::processArrayType | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1222 of file Deserializer.cpp.
References mlir::emitError(), mlir::spirv::ArrayType::get(), getConstant(), mlir::getType(), and success().
Referenced by processType().
| LogicalResult spirv::Deserializer::processBranch | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 2116 of file Deserializer.cpp.
References clearDebugLine(), createFileLineColLoc(), mlir::emitError(), getOrCreateBlock(), success(), and target.
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processBranchConditional | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 2137 of file Deserializer.cpp.
References clearDebugLine(), createFileLineColLoc(), mlir::emitError(), getOrCreateBlock(), getValue(), and success().
Referenced by processInstruction().
Processes a SPIR-V Op{|Spec}Constant instruction with the given operands.
isSpec indicates whether this is a specialization constant.
Definition at line 1636 of file Deserializer.cpp.
References createSpecConstant(), mlir::emitError(), mlir::getType(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processConstantBool | ( | bool | isTrue, |
| ArrayRef< uint32_t > | operands, | ||
| bool | isSpec ) |
Processes a SPIR-V Op{|Spec}Constant{True|False} instruction with the given operands.
isSpec indicates whether this is a specialization constant.
Definition at line 1754 of file Deserializer.cpp.
References createSpecConstant(), mlir::emitError(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processConstantComposite | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpConstantComposite instruction with the given operands.
Definition at line 1777 of file Deserializer.cpp.
References mlir::emitError(), mlir::DenseElementsAttr::get(), getConstant(), mlir::getType(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processConstantCompositeReplicateEXT | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpConstantCompositeReplicateEXT instruction with the given operands.
Definition at line 1833 of file Deserializer.cpp.
References mlir::emitError(), getConstant(), getConstantCompositeReplicate(), mlir::getType(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processConstantNull | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpConstantNull instruction with the given operands.
Definition at line 2036 of file Deserializer.cpp.
References mlir::emitError(), mlir::DenseElementsAttr::get(), mlir::getType(), mlir::Type::isIntOrFloat(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processCooperativeMatrixTypeKHR | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1280 of file Deserializer.cpp.
References mlir::emitError(), mlir::spirv::CooperativeMatrixType::get(), getConstantInt(), mlir::getType(), and success().
Referenced by processType().
| LogicalResult mlir::spirv::Deserializer::processCooperativeMatrixTypeNV | ( | ArrayRef< uint32_t > | operands | ) |
| LogicalResult spirv::Deserializer::processDebugLine | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpLine instruction with the given operands.
Definition at line 3009 of file Deserializer.cpp.
References mlir::emitError(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processDebugString | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpString instruction with the given operands.
Definition at line 3024 of file Deserializer.cpp.
References mlir::debugString(), mlir::spirv::decodeStringLiteral(), mlir::emitError(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processExtInst | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpExtInst with given operands.
This slices the entries of operands that specify the extended instruction set <id> and the instruction opcode. The op deserializer is then invoked using the other entries.
Definition at line 353 of file DeserializeOps.cpp.
References dispatchToExtensionSetAutogenDeserialization(), and mlir::emitError().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processFunction | ( | ArrayRef< uint32_t > | operands | ) |
Creates a deserializer for the given SPIR-V binary module.
The SPIR-V ModuleOp will be created into `context. explicit Deserializer(ArrayRef<uint32_t> binary, MLIRContext *context, const DeserializationOptions &options);
/ Deserializes the remembered SPIR-V binary module. LogicalResult deserialize();
/ Collects the final SPIR-V ModuleOp. OwningOpRef<spirv::ModuleOp> collect();
private: ===-----------------------------------------------------------------—===// Module structure ===-----------------------------------------------------------------—===//
/ Initializes the module ModuleOp in this deserializer instance. OwningOpRef<spirv::ModuleOp> createModuleOp();
/ Processes SPIR-V module header in binary. LogicalResult processHeader();
/ Processes the SPIR-V OpCapability with operands and updates bookkeeping / in the deserializer. LogicalResult processCapability(ArrayRef<uint32_t> operands);
/ Processes the SPIR-V OpExtension with operands and updates bookkeeping / in the deserializer. LogicalResult processExtension(ArrayRef<uint32_t> words);
/ Processes the SPIR-V OpExtInstImport with operands and updates / bookkeeping in the deserializer. LogicalResult processExtInstImport(ArrayRef<uint32_t> words);
/ Attaches (version, capabilities, extensions) triple to module as an / attribute. void attachVCETriple();
/ Processes the SPIR-V OpMemoryModel with operands and updates module. LogicalResult processMemoryModel(ArrayRef<uint32_t> operands);
/ Process SPIR-V OpName with operands. LogicalResult processName(ArrayRef<uint32_t> operands);
/ Processes an OpDecorate instruction. LogicalResult processDecoration(ArrayRef<uint32_t> words);
Processes an OpMemberDecorate instruction. LogicalResult processMemberDecoration(ArrayRef<uint32_t> words);
/ Processes an OpMemberName instruction. LogicalResult processMemberName(ArrayRef<uint32_t> words);
/ Gets the function op associated with a result <id> of OpFunction. spirv::FuncOp getFunction(uint32_t id) { return funcMap.lookup(id); }
/ Processes the SPIR-V function at the current offset into binary. / The operands to the OpFunction instruction is passed in as `operands. This method processes each instruction inside the function and dispatches them to their handler method accordingly.
Definition at line 481 of file Deserializer.cpp.
References mlir::emitError(), getFunctionSymbol(), mlir::getType(), getValue(), isVoidType(), processFunctionEnd(), processInstruction(), processLabel(), setFunctionArgAttrs(), and sliceInstruction().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processFunctionEnd | ( | ArrayRef< uint32_t > | operands | ) |
Processes OpFunctionEnd and finalizes function.
This wires up block argument created from OpPhi instructions and also structurizes control flow.
Definition at line 649 of file Deserializer.cpp.
References mlir::emitError(), structurizeControlFlow(), success(), and wireUpBlockArgument().
Referenced by processFunction().
| LogicalResult spirv::Deserializer::processFunctionType | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1255 of file Deserializer.cpp.
References mlir::emitError(), mlir::getType(), isVoidType(), and success().
Referenced by processType().
| LogicalResult spirv::Deserializer::processGlobalVariable | ( | ArrayRef< uint32_t > | operands | ) |
Processes the OpVariable instructions at current offset into binary.
It is expected that this method is used for variables that are to be defined at module scope and will be deserialized into a spirv.GlobalVariable instruction.
Definition at line 938 of file Deserializer.cpp.
References createFileLineColLoc(), mlir::emitError(), getGlobalVariable(), getSpecConstant(), getSpecConstantComposite(), mlir::getType(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processGraphARM | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 714 of file Deserializer.cpp.
References createGraphBlock(), mlir::emitError(), getConstantInt(), getGraphSymbol(), mlir::getType(), getValue(), processInstruction(), sliceInstruction(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processGraphConstantARM | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpGraphConstantARM instruction with the given operands.
Definition at line 2069 of file Deserializer.cpp.
References mlir::emitError(), mlir::getType(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processGraphEndARM | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 846 of file Deserializer.cpp.
References mlir::emitError(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processGraphEntryPointARM | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 674 of file Deserializer.cpp.
References mlir::spirv::decodeStringLiteral(), mlir::emitError(), getGlobalVariable(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processGraphTypeARM | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1528 of file Deserializer.cpp.
References mlir::emitError(), mlir::getType(), and success().
Referenced by processType().
| LogicalResult spirv::Deserializer::processImageType | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1570 of file Deserializer.cpp.
References mlir::emitError(), mlir::spirv::ImageType::get(), mlir::getType(), and success().
Referenced by processType().
| LogicalResult spirv::Deserializer::processInstruction | ( | spirv::Opcode | opcode, |
| ArrayRef< uint32_t > | operands, | ||
| bool | deferInstructions = true ) |
Processes a SPIR-V instruction with the given opcode and operands.
This method is the main entrance for handling SPIR-V instruction; it checks the instruction opcode and dispatches to the corresponding handler. Processing of Some instructions (like OpEntryPoint and OpExecutionMode) might need to be deferred, since they contain forward references to <id>s in the deserialized binary, but module in SPIR-V dialect expects these to be ssa-uses.
Definition at line 128 of file DeserializeOps.cpp.
References clearDebugLine(), dispatchToAutogenDeserialization(), processBranch(), processBranchConditional(), processConstant(), processConstantBool(), processConstantComposite(), processConstantCompositeReplicateEXT(), processConstantNull(), processDebugLine(), processDebugString(), processExtInst(), processFunction(), processGlobalVariable(), processGraphARM(), processGraphConstantARM(), processGraphEndARM(), processGraphEntryPointARM(), processLabel(), processLoopMerge(), processOpGraphSetOutputARM(), processPhi(), processSelectionMerge(), processSpecConstantComposite(), processSpecConstantCompositeReplicateEXT(), processSpecConstantOperation(), processSwitch(), processType(), processTypeForwardPointer(), processUndef(), and success().
Referenced by materializeSpecConstantOperation(), processFunction(), and processGraphARM().
| LogicalResult spirv::Deserializer::processLabel | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpLabel instruction with the given operands.
Definition at line 2170 of file Deserializer.cpp.
References mlir::emitError(), getOrCreateBlock(), and success().
Referenced by processFunction(), and processInstruction().
| LogicalResult spirv::Deserializer::processLoopMerge | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpLoopMerge instruction with the given operands.
Definition at line 2238 of file Deserializer.cpp.
References createFileLineColLoc(), mlir::emitError(), getOrCreateBlock(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processMatrixType | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1459 of file Deserializer.cpp.
References mlir::emitError(), mlir::spirv::MatrixType::get(), mlir::getType(), and success().
Referenced by processType().
|
inline |
Method to deserialize an operation in the SPIR-V dialect that is a mirror of an instruction in the SPIR-V spec.
This is auto generated if hasOpcode == 1 and autogenSerialization == 1 in ODS.
Definition at line 560 of file Deserializer.h.
References mlir::emitError().
Referenced by mlir::spirv::Deserializer::processOp< spirv::CopyMemoryOp >(), mlir::spirv::Deserializer::processOp< spirv::EntryPointOp >(), mlir::spirv::Deserializer::processOp< spirv::ExecutionModeOp >(), mlir::spirv::Deserializer::processOp< spirv::FunctionCallOp >(), and mlir::spirv::Deserializer::processOp< spirv::GenericCastToPtrExplicitOp >().
| LogicalResult spirv::Deserializer::processOpGraphSetOutputARM | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 822 of file Deserializer.cpp.
References mlir::emitError(), getConstantInt(), getValue(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processOpTypePointer | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1167 of file Deserializer.cpp.
References mlir::emitError(), mlir::spirv::PointerType::get(), mlir::getType(), and success().
Referenced by processType().
| LogicalResult spirv::Deserializer::processOpWithoutGrammarAttr | ( | ArrayRef< uint32_t > | words, |
| StringRef | opName, | ||
| bool | hasResult, | ||
| unsigned | numOperands ) |
Processes a SPIR-V instruction from the given operands.
It should deserialize into an op with the given opName and numOperands. This method is a generic one for dispatching any SPIR-V ops without variadic operands and attributes in TableGen definitions.
Definition at line 261 of file DeserializeOps.cpp.
References mlir::OperationState::addAttributes(), mlir::OperationState::addOperands(), mlir::OperationState::addTypes(), clearDebugLine(), mlir::Operation::create(), createFileLineColLoc(), mlir::emitError(), mlir::Operation::getResult(), mlir::getType(), getValue(), mlir::Operation::hasTrait(), and success().
| LogicalResult spirv::Deserializer::processPhi | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpPhi instruction with the given operands.
Definition at line 2264 of file Deserializer.cpp.
References mlir::emitError(), getOrCreateBlock(), mlir::getType(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processRuntimeArrayType | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1341 of file Deserializer.cpp.
References mlir::emitError(), mlir::spirv::RuntimeArrayType::get(), mlir::getType(), and success().
Referenced by processType().
| LogicalResult spirv::Deserializer::processSampledImageType | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1618 of file Deserializer.cpp.
References mlir::emitError(), mlir::spirv::SampledImageType::get(), mlir::getType(), and success().
Referenced by processType().
| LogicalResult spirv::Deserializer::processSelectionMerge | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpSelectionMerge instruction with the given operands.
Definition at line 2212 of file Deserializer.cpp.
References createFileLineColLoc(), mlir::emitError(), getOrCreateBlock(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processSpecConstantComposite | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpSpecConstantComposite instruction with the given operands.
Definition at line 1881 of file Deserializer.cpp.
References mlir::emitError(), getSpecConstant(), getSpecConstantSymbol(), mlir::getType(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processSpecConstantCompositeReplicateEXT | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpSpecConstantCompositeReplicateEXT instruction with the given operands.
Definition at line 1916 of file Deserializer.cpp.
References mlir::emitError(), getSpecConstant(), getSpecConstantSymbol(), mlir::getType(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processSpecConstantOperation | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpSpecConstantOp instruction with the given operands.
Definition at line 1952 of file Deserializer.cpp.
References mlir::emitError(), mlir::getType(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processStructType | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1357 of file Deserializer.cpp.
References mlir::emitError(), mlir::spirv::StructType::get(), mlir::spirv::StructType::getEmpty(), mlir::spirv::StructType::getIdentified(), mlir::getType(), and success().
Referenced by processType().
| LogicalResult spirv::Deserializer::processSwitch | ( | ArrayRef< uint32_t > | operands | ) |
Processes a SPIR-V OpSwitch instruction with the given operands.
Definition at line 2296 of file Deserializer.cpp.
References createFileLineColLoc(), mlir::emitError(), getOrCreateBlock(), getValue(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processTensorARMType | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1479 of file Deserializer.cpp.
References mlir::emitError(), mlir::spirv::TensorArmType::get(), getConstant(), getConstantInt(), mlir::getType(), and success().
Referenced by processType().
| LogicalResult spirv::Deserializer::processType | ( | spirv::Opcode | opcode, |
| ArrayRef< uint32_t > | operands ) |
Processes a SPIR-V type instruction with given opcode and operands and registers the type into module.
TODO: Types might be forward declared in some instructions and need to be handled appropriately.
Definition at line 1046 of file Deserializer.cpp.
References mlir::emitError(), mlir::getType(), processArrayType(), processCooperativeMatrixTypeKHR(), processFunctionType(), processGraphTypeARM(), processImageType(), processMatrixType(), processOpTypePointer(), processRuntimeArrayType(), processSampledImageType(), processStructType(), processTensorARMType(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processTypeForwardPointer | ( | ArrayRef< uint32_t > | operands | ) |
Definition at line 1557 of file Deserializer.cpp.
References mlir::emitError(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::processUndef | ( | ArrayRef< uint32_t > | operands | ) |
Processes a OpUndef instruction.
Adds a spirv.Undef operation at the current insertion point.
Definition at line 341 of file DeserializeOps.cpp.
References mlir::emitError(), mlir::getType(), and success().
Referenced by processInstruction().
| LogicalResult spirv::Deserializer::setFunctionArgAttrs | ( | uint32_t | argID, |
| SmallVectorImpl< Attribute > & | argAttrs, | ||
| size_t | argIndex ) |
Sets the function argument's attributes.
|argID| is the function argument's result <id>, and |argIndex| is its index in the function's argument list.
Definition at line 425 of file Deserializer.cpp.
References mlir::emitError(), getSymbolDecoration(), and success().
Referenced by processFunction().
| LogicalResult spirv::Deserializer::sliceInstruction | ( | spirv::Opcode & | opcode, |
| ArrayRef< uint32_t > & | operands, | ||
| std::optional< spirv::Opcode > | expectedOpcode = std::nullopt ) |
Slices the first instruction out of binary and returns its opcode and operands via opcode and operands respectively.
Returns failure if there is no more remaining instructions (expectedOpcode will be used to compose the error message) or the next instruction is malformed.
Definition at line 99 of file DeserializeOps.cpp.
References mlir::emitError(), extractOpcode(), and success().
Referenced by processFunction(), and processGraphARM().
| LogicalResult spirv::Deserializer::splitSelectionHeader | ( | ) |
Move a conditional branch or a switch into a separate basic block to avoid unnecessary sinking of defs that may be required outside a selection region.
This function also ensures that a single block cannot be a header block of one selection construct and the merge block of another.
Definition at line 2872 of file Deserializer.cpp.
References mlir::Block::splitBlock(), and success().
Referenced by structurizeControlFlow().
| LogicalResult spirv::Deserializer::structurizeControlFlow | ( | ) |
Extracts blocks belonging to a structured selection/loop into a spirv.mlir.selection/spirv.mlir.loop op.
This method iterates until all blocks declared as selection/loop headers are handled.
Definition at line 2918 of file Deserializer.cpp.
References mlir::Block::args_empty(), mlir::Block::begin(), mlir::spirv::BlockMergeInfo::continueBlock, mlir::spirv::BlockMergeInfo::control, mlir::emitError(), mlir::Block::erase(), mlir::spirv::BlockMergeInfo::loc, mlir::spirv::BlockMergeInfo::mergeBlock, mlir::Block::print(), splitSelectionHeader(), and success().
Referenced by processFunctionEnd().
| LogicalResult spirv::Deserializer::wireUpBlockArgument | ( | ) |
Creates block arguments on predecessors previously recorded when handling OpPhi instructions.
Definition at line 2775 of file Deserializer.cpp.
References mlir::emitError(), mlir::Block::getParentOp(), mlir::Block::getTerminator(), getValue(), mlir::Operation::print(), success(), and target.
Referenced by processFunctionEnd().