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);
244 StringAttr getSymbolDecoration(StringRef decorationName) {
245 auto attrName = llvm::convertToSnakeFromCamelCase(decorationName);
254 Type getType(uint32_t
id) {
return typeMap.lookup(
id); }
257 Type getUndefType(uint32_t
id) {
return undefMap.lookup(
id); }
260 bool isVoidType(
Type type)
const {
return isa<NoneType>(type); }
317 Value materializeSpecConstantOperation(uint32_t resultID,
318 spirv::Opcode enclosedOpcode,
319 uint32_t resultTypeID,
331 void clearDebugLine();
347 Block *getBlock(uint32_t
id)
const {
return blockMap.lookup(
id); }
395 Block *getOrCreateBlock(uint32_t
id);
432 Value getValue(uint32_t
id);
440 std::optional<spirv::Opcode> expectedOpcode = std::nullopt);
451 bool deferInstructions =
true);
458 StringRef opName,
bool hasResult,
459 unsigned numOperands);
469 LogicalResult dispatchToAutogenDeserialization(spirv::Opcode opcode,
482 dispatchToExtensionSetAutogenDeserialization(StringRef extensionSetName,
483 uint32_t instructionID,
489 template <
typename OpTy>
491 return emitError(unknownLoc,
"unsupported deserialization for ")
492 << OpTy::getOperationName() <<
" op";
501 std::optional<DebugLine> debugLine;
504 unsigned curOffset = 0;
516 std::optional<spirv::FuncOp> curFunction;
519 Block *curBlock =
nullptr;
523 spirv::Version version = spirv::Version::V_1_0;
526 llvm::SmallSetVector<spirv::Capability, 4> capabilities;
529 llvm::SmallSetVector<spirv::Extension, 2> extensions;
553 specConstOperationMap;
612 deferredInstructions;
623 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)
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.
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