13 #ifndef MLIR_TARGET_SPIRV_DESERIALIZER_H
14 #define MLIR_TARGET_SPIRV_DESERIALIZER_H
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/SetVector.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/Support/ScopedPrinter.h"
157 void attachVCETriple();
175 spirv::FuncOp getFunction(uint32_t
id) {
return funcMap.lookup(
id); }
189 std::optional<std::pair<Attribute, Type>> getConstant(uint32_t
id);
193 std::optional<SpecConstOperationMaterializationInfo>
194 getSpecConstantOperation(uint32_t
id);
199 IntegerAttr getConstantInt(uint32_t
id);
204 std::string getFunctionSymbol(uint32_t
id);
209 std::string getSpecConstantSymbol(uint32_t
id);
212 spirv::SpecConstantOp getSpecConstant(uint32_t
id) {
213 return specConstMap.lookup(
id);
217 spirv::SpecConstantCompositeOp getSpecConstantComposite(uint32_t
id) {
218 return specConstCompositeMap.lookup(
id);
222 spirv::SpecConstantOp createSpecConstant(
Location loc, uint32_t resultID,
223 TypedAttr defaultValue);
232 spirv::GlobalVariableOp getGlobalVariable(uint32_t
id) {
233 return globalVariableMap.lookup(
id);
241 Type getType(uint32_t
id) {
return typeMap.lookup(
id); }
244 Type getUndefType(uint32_t
id) {
return undefMap.lookup(
id); }
247 bool isVoidType(
Type type)
const {
return isa<NoneType>(type); }
304 Value materializeSpecConstantOperation(uint32_t resultID,
305 spirv::Opcode enclosedOpcode,
306 uint32_t resultTypeID,
318 void clearDebugLine();
334 Block *getBlock(uint32_t
id)
const {
return blockMap.lookup(
id); }
382 Block *getOrCreateBlock(uint32_t
id);
419 Value getValue(uint32_t
id);
427 std::optional<spirv::Opcode> expectedOpcode = std::nullopt);
438 bool deferInstructions =
true);
445 StringRef opName,
bool hasResult,
446 unsigned numOperands);
456 LogicalResult dispatchToAutogenDeserialization(spirv::Opcode opcode,
469 dispatchToExtensionSetAutogenDeserialization(StringRef extensionSetName,
470 uint32_t instructionID,
476 template <
typename OpTy>
478 return emitError(unknownLoc,
"unsupported deserialization for ")
479 << OpTy::getOperationName() <<
" op";
488 std::optional<DebugLine> debugLine;
491 unsigned curOffset = 0;
503 std::optional<spirv::FuncOp> curFunction;
506 Block *curBlock =
nullptr;
510 spirv::Version version = spirv::Version::V_1_0;
513 llvm::SmallSetVector<spirv::Capability, 4> capabilities;
516 llvm::SmallSetVector<spirv::Extension, 2> extensions;
540 specConstOperationMap;
599 deferredInstructions;
610 llvm::ScopedPrinter logger;
Block represents an ordered list of Operations.
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)
Creates a deserializer for the given SPIR-V binary module.
OwningOpRef< spirv::ModuleOp > collect()
Collects the final SPIR-V ModuleOp.
This header declares functions that assist transformations in the MemRef dialect.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
This class represents an efficient way to signal success or failure.
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