#include "Deserializer.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/Location.h"
#include "mlir/Target/SPIRV/SPIRVBinaryUtils.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/bit.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
usingnamespacemlir;
#define DEBUG_TYPE …
static inline bool isFnEntryBlock(Block *block) { … }
spirv::Deserializer::Deserializer(ArrayRef<uint32_t> binary,
MLIRContext *context)
: … { … }
LogicalResult spirv::Deserializer::deserialize() { … }
OwningOpRef<spirv::ModuleOp> spirv::Deserializer::collect() { … }
OwningOpRef<spirv::ModuleOp> spirv::Deserializer::createModuleOp() { … }
LogicalResult spirv::Deserializer::processHeader() { … }
LogicalResult
spirv::Deserializer::processCapability(ArrayRef<uint32_t> operands) { … }
LogicalResult spirv::Deserializer::processExtension(ArrayRef<uint32_t> words) { … }
LogicalResult
spirv::Deserializer::processExtInstImport(ArrayRef<uint32_t> words) { … }
void spirv::Deserializer::attachVCETriple() { … }
LogicalResult
spirv::Deserializer::processMemoryModel(ArrayRef<uint32_t> operands) { … }
LogicalResult spirv::Deserializer::processDecoration(ArrayRef<uint32_t> words) { … }
LogicalResult
spirv::Deserializer::processMemberDecoration(ArrayRef<uint32_t> words) { … }
LogicalResult spirv::Deserializer::processMemberName(ArrayRef<uint32_t> words) { … }
LogicalResult spirv::Deserializer::setFunctionArgAttrs(
uint32_t argID, SmallVectorImpl<Attribute> &argAttrs, size_t argIndex) { … }
LogicalResult
spirv::Deserializer::processFunction(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processFunctionEnd(ArrayRef<uint32_t> operands) { … }
std::optional<std::pair<Attribute, Type>>
spirv::Deserializer::getConstant(uint32_t id) { … }
std::optional<spirv::SpecConstOperationMaterializationInfo>
spirv::Deserializer::getSpecConstantOperation(uint32_t id) { … }
std::string spirv::Deserializer::getFunctionSymbol(uint32_t id) { … }
std::string spirv::Deserializer::getSpecConstantSymbol(uint32_t id) { … }
spirv::SpecConstantOp
spirv::Deserializer::createSpecConstant(Location loc, uint32_t resultID,
TypedAttr defaultValue) { … }
LogicalResult
spirv::Deserializer::processGlobalVariable(ArrayRef<uint32_t> operands) { … }
IntegerAttr spirv::Deserializer::getConstantInt(uint32_t id) { … }
LogicalResult spirv::Deserializer::processName(ArrayRef<uint32_t> operands) { … }
LogicalResult spirv::Deserializer::processType(spirv::Opcode opcode,
ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processOpTypePointer(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processArrayType(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processFunctionType(ArrayRef<uint32_t> operands) { … }
LogicalResult spirv::Deserializer::processCooperativeMatrixTypeKHR(
ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processRuntimeArrayType(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processStructType(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processMatrixType(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processTypeForwardPointer(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processImageType(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processSampledImageType(ArrayRef<uint32_t> operands) { … }
LogicalResult spirv::Deserializer::processConstant(ArrayRef<uint32_t> operands,
bool isSpec) { … }
LogicalResult spirv::Deserializer::processConstantBool(
bool isTrue, ArrayRef<uint32_t> operands, bool isSpec) { … }
LogicalResult
spirv::Deserializer::processConstantComposite(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processSpecConstantComposite(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processSpecConstantOperation(ArrayRef<uint32_t> operands) { … }
Value spirv::Deserializer::materializeSpecConstantOperation(
uint32_t resultID, spirv::Opcode enclosedOpcode, uint32_t resultTypeID,
ArrayRef<uint32_t> enclosedOpOperands) { … }
LogicalResult
spirv::Deserializer::processConstantNull(ArrayRef<uint32_t> operands) { … }
Block *spirv::Deserializer::getOrCreateBlock(uint32_t id) { … }
LogicalResult spirv::Deserializer::processBranch(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processBranchConditional(ArrayRef<uint32_t> operands) { … }
LogicalResult spirv::Deserializer::processLabel(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processSelectionMerge(ArrayRef<uint32_t> operands) { … }
LogicalResult
spirv::Deserializer::processLoopMerge(ArrayRef<uint32_t> operands) { … }
LogicalResult spirv::Deserializer::processPhi(ArrayRef<uint32_t> operands) { … }
namespace {
class ControlFlowStructurizer { … };
}
spirv::SelectionOp
ControlFlowStructurizer::createSelectionOp(uint32_t selectionControl) { … }
spirv::LoopOp ControlFlowStructurizer::createLoopOp(uint32_t loopControl) { … }
void ControlFlowStructurizer::collectBlocksInConstruct() { … }
LogicalResult ControlFlowStructurizer::structurize() { … }
LogicalResult spirv::Deserializer::wireUpBlockArgument() { … }
LogicalResult spirv::Deserializer::structurizeControlFlow() { … }
Location spirv::Deserializer::createFileLineColLoc(OpBuilder opBuilder) { … }
LogicalResult
spirv::Deserializer::processDebugLine(ArrayRef<uint32_t> operands) { … }
void spirv::Deserializer::clearDebugLine() { … }
LogicalResult
spirv::Deserializer::processDebugString(ArrayRef<uint32_t> operands) { … }