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);
253 LogicalResult splitConditionalBlocks();
260 Type getType(uint32_t
id) {
return typeMap.lookup(
id); }
263 Type getUndefType(uint32_t
id) {
return undefMap.lookup(
id); }
266 bool isVoidType(
Type type)
const {
return isa<NoneType>(type); }
321 Value materializeSpecConstantOperation(uint32_t resultID,
322 spirv::Opcode enclosedOpcode,
323 uint32_t resultTypeID,
335 void clearDebugLine();
351 Block *getBlock(uint32_t
id)
const {
return blockMap.lookup(
id); }
399 Block *getOrCreateBlock(uint32_t
id);
419 LogicalResult wireUpBlockArgument();
424 LogicalResult structurizeControlFlow();
436 Value getValue(uint32_t
id);
444 std::optional<spirv::Opcode> expectedOpcode = std::nullopt);
453 LogicalResult processInstruction(spirv::Opcode opcode,
455 bool deferInstructions =
true);
462 StringRef opName,
bool hasResult,
463 unsigned numOperands);
473 LogicalResult dispatchToAutogenDeserialization(spirv::Opcode opcode,
486 dispatchToExtensionSetAutogenDeserialization(StringRef extensionSetName,
487 uint32_t instructionID,
493 template <
typename OpTy>
495 return emitError(unknownLoc,
"unsupported deserialization for ")
496 << OpTy::getOperationName() <<
" op";
505 std::optional<DebugLine> debugLine;
508 unsigned curOffset = 0;
520 std::optional<spirv::FuncOp> curFunction;
523 Block *curBlock =
nullptr;
527 spirv::Version version = spirv::Version::V_1_0;
530 llvm::SmallSetVector<spirv::Capability, 4> capabilities;
533 llvm::SmallSetVector<spirv::Extension, 2> extensions;
557 specConstOperationMap;
616 deferredInstructions;
627 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