13 #ifndef MLIR_TARGET_SPIRV_DESERIALIZER_H
14 #define MLIR_TARGET_SPIRV_DESERIALIZER_H
20 #include "llvm/ADT/ArrayRef.h"
21 #include "llvm/ADT/SetVector.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/Support/ScopedPrinter.h"
143 LogicalResult processHeader();
159 void attachVCETriple();
177 spirv::FuncOp getFunction(uint32_t
id) {
return funcMap.lookup(
id); }
191 std::optional<std::pair<Attribute, Type>> getConstant(uint32_t
id);
195 std::optional<SpecConstOperationMaterializationInfo>
196 getSpecConstantOperation(uint32_t
id);
201 IntegerAttr getConstantInt(uint32_t
id);
206 std::string getFunctionSymbol(uint32_t
id);
211 std::string getSpecConstantSymbol(uint32_t
id);
214 spirv::SpecConstantOp getSpecConstant(uint32_t
id) {
215 return specConstMap.lookup(
id);
219 spirv::SpecConstantCompositeOp getSpecConstantComposite(uint32_t
id) {
220 return specConstCompositeMap.lookup(
id);
224 spirv::SpecConstantOp createSpecConstant(
Location loc, uint32_t resultID,
225 TypedAttr defaultValue);
234 spirv::GlobalVariableOp getGlobalVariable(uint32_t
id) {
235 return globalVariableMap.lookup(
id);
241 LogicalResult setFunctionArgAttrs(uint32_t argID,
246 StringAttr getSymbolDecoration(StringRef decorationName) {
247 auto attrName = llvm::convertToSnakeFromCamelCase(decorationName);
255 LogicalResult splitConditionalBlocks();
262 Type getType(uint32_t
id) {
return typeMap.lookup(
id); }
265 Type getUndefType(uint32_t
id) {
return undefMap.lookup(
id); }
268 bool isVoidType(
Type type)
const {
return isa<NoneType>(type); }
323 Value materializeSpecConstantOperation(uint32_t resultID,
324 spirv::Opcode enclosedOpcode,
325 uint32_t resultTypeID,
337 void clearDebugLine();
353 Block *getBlock(uint32_t
id)
const {
return blockMap.lookup(
id); }
401 Block *getOrCreateBlock(uint32_t
id);
421 LogicalResult wireUpBlockArgument();
426 LogicalResult structurizeControlFlow();
438 Value getValue(uint32_t
id);
446 std::optional<spirv::Opcode> expectedOpcode = std::nullopt);
455 LogicalResult processInstruction(spirv::Opcode opcode,
457 bool deferInstructions =
true);
464 StringRef opName,
bool hasResult,
465 unsigned numOperands);
475 LogicalResult dispatchToAutogenDeserialization(spirv::Opcode opcode,
488 dispatchToExtensionSetAutogenDeserialization(StringRef extensionSetName,
489 uint32_t instructionID,
495 template <
typename OpTy>
497 return emitError(unknownLoc,
"unsupported deserialization for ")
498 << OpTy::getOperationName() <<
" op";
507 std::optional<DebugLine> debugLine;
510 unsigned curOffset = 0;
522 std::optional<spirv::FuncOp> curFunction;
525 Block *curBlock =
nullptr;
529 spirv::Version version = spirv::Version::V_1_0;
532 llvm::SmallSetVector<spirv::Capability, 4> capabilities;
535 llvm::SmallSetVector<spirv::Extension, 2> extensions;
559 specConstOperationMap;
618 deferredInstructions;
632 llvm::ScopedPrinter logger;
Block represents an ordered list of Operations.
StringAttr getStringAttr(const Twine &bytes)
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
This class helps build Operations.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
A SPIR-V module serializer.
LogicalResult deserialize()
Deserializes the remembered SPIR-V binary module.
Deserializer(ArrayRef< uint32_t > binary, MLIRContext *context, const DeserializationOptions &options)
Creates a deserializer for the given SPIR-V binary module.
OwningOpRef< spirv::ModuleOp > collect()
Collects the final SPIR-V ModuleOp.
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
A struct for containing a header block's merge and continue targets.
BlockMergeInfo(Location location, uint32_t control, Block *m, Block *c=nullptr)
BlockMergeInfo(Location location, uint32_t control)
A struct for containing OpLine instruction information.
A "deferred struct type" is a struct type with one or more member types not known when the Deserializ...
spirv::StructType deferredStructType
SmallVector< spirv::StructType::MemberDecorationInfo, 0 > memberDecorationsInfo
SmallVector< spirv::StructType::OffsetInfo, 0 > offsetInfo
SmallVector< Type, 4 > memberTypes
SmallVector< std::pair< uint32_t, unsigned >, 0 > unresolvedMemberTypes
A struct that collects the info needed to materialize/emit a SpecConstantOperation op.
SmallVector< uint32_t > enclosedOpOperands
spirv::Opcode enclodesOpcode