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"
141 LogicalResult processHeader();
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);
239 LogicalResult setFunctionArgAttrs(uint32_t argID,
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); }
315 Value materializeSpecConstantOperation(uint32_t resultID,
316 spirv::Opcode enclosedOpcode,
317 uint32_t resultTypeID,
329 void clearDebugLine();
345 Block *getBlock(uint32_t
id)
const {
return blockMap.lookup(
id); }
393 Block *getOrCreateBlock(uint32_t
id);
413 LogicalResult wireUpBlockArgument();
418 LogicalResult structurizeControlFlow();
430 Value getValue(uint32_t
id);
438 std::optional<spirv::Opcode> expectedOpcode = std::nullopt);
447 LogicalResult processInstruction(spirv::Opcode opcode,
449 bool deferInstructions =
true);
456 StringRef opName,
bool hasResult,
457 unsigned numOperands);
467 LogicalResult dispatchToAutogenDeserialization(spirv::Opcode opcode,
480 dispatchToExtensionSetAutogenDeserialization(StringRef extensionSetName,
481 uint32_t instructionID,
487 template <
typename OpTy>
489 return emitError(unknownLoc,
"unsupported deserialization for ")
490 << OpTy::getOperationName() <<
" op";
499 std::optional<DebugLine> debugLine;
502 unsigned curOffset = 0;
514 std::optional<spirv::FuncOp> curFunction;
517 Block *curBlock =
nullptr;
521 spirv::Version version = spirv::Version::V_1_0;
524 llvm::SmallSetVector<spirv::Capability, 4> capabilities;
527 llvm::SmallSetVector<spirv::Extension, 2> extensions;
551 specConstOperationMap;
610 deferredInstructions;
621 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.
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