21#include "llvm/ADT/STLExtras.h"
22#include "llvm/ADT/SmallVector.h"
23#include "llvm/Support/Debug.h"
28#define DEBUG_TYPE "spirv-deserialization"
36 return static_cast<spirv::Opcode
>(word & 0xffff);
49 if (std::optional<std::pair<Attribute, Type>> constCompositeReplicateInfo =
51 Value &value = blockConstantMap[{opBuilder.getInsertionBlock(),
id}];
53 value = spirv::EXTConstantCompositeReplicateOp::create(
54 opBuilder, unknownLoc, constCompositeReplicateInfo->second,
55 constCompositeReplicateInfo->first);
60 Value &value = blockConstantMap[{opBuilder.getInsertionBlock(),
id}];
65 value = spirv::ConstantOp::create(opBuilder, loc, constInfo->second,
72 spirv::AddressOfOp::create(opBuilder, unknownLoc, varOp.getType(),
73 SymbolRefAttr::get(varOp.getOperation()));
74 return addressOfOp.getPointer();
77 auto referenceOfOp = spirv::ReferenceOfOp::create(
78 opBuilder, unknownLoc, constOp.getDefaultValue().getType(),
79 SymbolRefAttr::get(constOp.getOperation()));
80 return referenceOfOp.getReference();
82 if (SpecConstantCompositeOp specConstCompositeOp =
84 auto referenceOfOp = spirv::ReferenceOfOp::create(
85 opBuilder, unknownLoc, specConstCompositeOp.getType(),
86 SymbolRefAttr::get(specConstCompositeOp.getOperation()));
87 return referenceOfOp.getReference();
89 if (
auto specConstCompositeReplicateOp =
91 auto referenceOfOp = spirv::ReferenceOfOp::create(
92 opBuilder, unknownLoc, specConstCompositeReplicateOp.getType(),
93 SymbolRefAttr::get(specConstCompositeReplicateOp.getOperation()));
94 return referenceOfOp.getReference();
98 id, specConstOperationInfo->enclodesOpcode,
99 specConstOperationInfo->resultTypeID,
100 specConstOperationInfo->enclosedOpOperands);
103 Value &value = blockConstantMap[{opBuilder.getInsertionBlock(),
id}];
105 value = spirv::UndefOp::create(opBuilder, unknownLoc, undef);
108 if (std::optional<spirv::GraphConstantARMOpMaterializationInfo>
110 IntegerAttr graphConstantID = graphConstantARMInfo->graphConstantID;
111 Type resultType = graphConstantARMInfo->resultType;
112 return spirv::GraphConstantARMOp::create(opBuilder, unknownLoc, resultType,
115 return valueMap.lookup(
id);
120 std::optional<spirv::Opcode> expectedOpcode) {
121 auto binarySize = binary.size();
122 if (curOffset >= binarySize) {
123 return emitError(unknownLoc,
"expected ")
124 << (expectedOpcode ? spirv::stringifyOpcode(*expectedOpcode)
132 uint32_t wordCount = binary[curOffset] >> 16;
135 return emitError(unknownLoc,
"word count cannot be zero");
137 uint32_t nextOffset = curOffset + wordCount;
138 if (nextOffset > binarySize)
139 return emitError(unknownLoc,
"insufficient words for the last instruction");
142 operands = binary.slice(curOffset + 1, wordCount - 1);
143 curOffset = nextOffset;
154 size_t binarySize = binary.size();
155 auto isNextContinuation = [&]() {
156 if (curOffset >= binarySize)
158 uint32_t wordCount = binary[curOffset] >> 16;
159 if (wordCount == 0 || curOffset + wordCount > binarySize)
164 if (!isNextContinuation())
167 mergedStorage.assign(operands);
169 spirv::Opcode contOpcode;
173 llvm::append_range(mergedStorage, contOperands);
174 }
while (isNextContinuation());
175 operands = mergedStorage;
180 LLVM_DEBUG(logger.startLine() <<
"[inst] processing instruction "
181 << spirv::stringifyOpcode(opcode) <<
"\n");
189 case spirv::Opcode::OpCapability:
190 return processCapability(operands);
191 case spirv::Opcode::OpExtension:
192 return processExtension(operands);
193 case spirv::Opcode::OpExtInst: {
195 operands.size() >= 4 ? extendedInstSets.find(operands[2])
196 : extendedInstSets.end();
197 if (setIt != extendedInstSets.end() && setIt->second ==
extDebugInfo)
201 case spirv::Opcode::OpExtInstImport:
202 return processExtInstImport(operands);
203 case spirv::Opcode::OpMemberName:
204 return processMemberName(operands);
205 case spirv::Opcode::OpMemoryModel:
206 return processMemoryModel(operands);
207 case spirv::Opcode::OpEntryPoint:
208 case spirv::Opcode::OpExecutionMode:
209 case spirv::Opcode::OpExecutionModeId:
210 if (deferInstructions) {
211 deferredInstructions.emplace_back(opcode, operands);
215 case spirv::Opcode::OpVariable:
216 if (isa<spirv::ModuleOp>(opBuilder.getBlock()->getParentOp())) {
220 case spirv::Opcode::OpLine:
222 case spirv::Opcode::OpNoLine:
225 case spirv::Opcode::OpName:
226 return processName(operands);
227 case spirv::Opcode::OpString:
229 case spirv::Opcode::OpModuleProcessed:
230 case spirv::Opcode::OpSource:
231 case spirv::Opcode::OpSourceContinued:
232 case spirv::Opcode::OpSourceExtension:
236 case spirv::Opcode::OpTypeVoid:
237 case spirv::Opcode::OpTypeBool:
238 case spirv::Opcode::OpTypeInt:
239 case spirv::Opcode::OpTypeFloat:
240 case spirv::Opcode::OpTypeVector:
241 case spirv::Opcode::OpTypeMatrix:
242 case spirv::Opcode::OpTypeArray:
243 case spirv::Opcode::OpTypeFunction:
244 case spirv::Opcode::OpTypeImage:
245 case spirv::Opcode::OpTypeSampler:
246 case spirv::Opcode::OpTypeNamedBarrier:
247 case spirv::Opcode::OpTypeSampledImage:
248 case spirv::Opcode::OpTypeRuntimeArray:
249 case spirv::Opcode::OpTypeStruct:
250 case spirv::Opcode::OpTypePointer:
251 case spirv::Opcode::OpTypeTensorARM:
252 case spirv::Opcode::OpTypeGraphARM:
253 case spirv::Opcode::OpTypeCooperativeMatrixKHR:
255 case spirv::Opcode::OpTypeForwardPointer:
257 case spirv::Opcode::OpConstant:
259 case spirv::Opcode::OpSpecConstant:
261 case spirv::Opcode::OpConstantComposite:
263 case spirv::Opcode::OpConstantCompositeReplicateEXT:
265 case spirv::Opcode::OpSpecConstantComposite:
267 case spirv::Opcode::OpSpecConstantCompositeReplicateEXT:
269 case spirv::Opcode::OpSpecConstantOp:
271 case spirv::Opcode::OpConstantTrue:
273 case spirv::Opcode::OpSpecConstantTrue:
275 case spirv::Opcode::OpConstantFalse:
277 case spirv::Opcode::OpSpecConstantFalse:
279 case spirv::Opcode::OpConstantNull:
281 case spirv::Opcode::OpGraphConstantARM:
283 case spirv::Opcode::OpDecorate:
284 case spirv::Opcode::OpDecorateId:
285 return processDecoration(operands);
286 case spirv::Opcode::OpMemberDecorate:
287 return processMemberDecoration(operands);
288 case spirv::Opcode::OpFunction:
290 case spirv::Opcode::OpGraphEntryPointARM:
291 if (deferInstructions) {
292 deferredInstructions.emplace_back(opcode, operands);
296 case spirv::Opcode::OpGraphARM:
298 case spirv::Opcode::OpGraphSetOutputARM:
300 case spirv::Opcode::OpGraphEndARM:
302 case spirv::Opcode::OpLabel:
304 case spirv::Opcode::OpBranch:
306 case spirv::Opcode::OpBranchConditional:
308 case spirv::Opcode::OpSelectionMerge:
310 case spirv::Opcode::OpLoopMerge:
312 case spirv::Opcode::OpPhi:
314 case spirv::Opcode::OpSwitch:
316 case spirv::Opcode::OpUndef:
326 unsigned numOperands) {
328 uint32_t valueID = 0;
330 size_t wordIndex = 0;
332 if (wordIndex >= words.size())
334 "expected result type <id> while deserializing for ")
338 auto type =
getType(words[wordIndex]);
340 return emitError(unknownLoc,
"unknown type result <id>: ")
342 resultTypes.push_back(type);
346 if (wordIndex >= words.size())
348 "expected result <id> while deserializing for ")
350 valueID = words[wordIndex];
358 size_t operandIndex = 0;
359 for (; operandIndex < numOperands && wordIndex < words.size();
360 ++operandIndex, ++wordIndex) {
361 auto arg =
getValue(words[wordIndex]);
363 return emitError(unknownLoc,
"unknown result <id>: ") << words[wordIndex];
364 operands.push_back(arg);
366 if (operandIndex != numOperands) {
369 "found less operands than expected when deserializing for ")
370 << opName <<
"; only " << operandIndex <<
" of " << numOperands
373 if (wordIndex != words.size()) {
376 "found more operands than expected when deserializing for ")
377 << opName <<
"; only " << wordIndex <<
" of " << words.size()
382 if (decorations.count(valueID)) {
383 auto attrs = decorations[valueID].getAttrs();
384 attributes.append(attrs.begin(), attrs.end());
405 if (operands.size() != 2) {
406 return emitError(unknownLoc,
"OpUndef instruction must have two operands");
408 auto type =
getType(operands[0]);
410 return emitError(unknownLoc,
"unknown type <id> with OpUndef instruction");
412 undefMap[operands[1]] = type;
418 bool deferInstructions) {
419 if (deferInstructions) {
420 deferredInstructions.emplace_back(spirv::Opcode::OpExtInst, operands);
424 if (operands.size() < 4) {
426 "OpExtInst must have at least 4 operands, result type "
427 "<id>, result <id>, set <id> and instruction opcode");
433 "DebugInfo instructions must have OpTypeVoid result type");
435 auto getDebugLoc = [&](uint32_t stringID) -> FailureOr<Location> {
437 debugInfoMap.find(stringID);
438 if (stringIt == debugInfoMap.end()) {
439 return emitError(unknownLoc,
"undefined string <id> ")
440 << stringID <<
" in DebugInfo";
446 return emitError(unknownLoc,
"unknown DebugInfo instruction opcode: ")
450 switch (instructionID) {
452 if (operands.size() < 6)
453 return emitError(unknownLoc,
"DebugGraph must have graph and string IDs");
454 uint32_t graphID = operands[4];
455 uint32_t stringID = operands[5];
457 graphMap.find(graphID);
458 if (graphIt == graphMap.end())
459 return emitError(unknownLoc,
"undefined graph <id> ")
460 << graphID <<
" in DebugGraph";
461 FailureOr<Location> loc = getDebugLoc(stringID);
464 graphIt->second->setLoc(*loc);
468 if (operands.size() < 7)
469 return emitError(unknownLoc,
"DebugOperation must have graph, string and "
471 uint32_t stringID = operands[5];
472 FailureOr<Location> loc = getDebugLoc(stringID);
476 operationIDs.append(std::next(operands.begin(), 6), operands.end());
477 for (uint32_t operationID : operationIDs) {
479 if (valueIt == valueMap.end())
480 return emitError(unknownLoc,
"undefined operation <id> ")
481 << operationID <<
" in DebugOperation";
482 valueIt->second.setLoc(*loc);
487 if (operands.size() < 6)
489 "DebugTensor must have tensor and string IDs");
490 uint32_t stringID = operands[5];
491 uint32_t tensorID = operands[4];
492 FailureOr<Location> loc = getDebugLoc(stringID);
495 if (constantMap.contains(tensorID)) {
496 constantLocMap[tensorID] = *loc;
500 if (valueIt == valueMap.end())
501 return emitError(unknownLoc,
"undefined tensor <id> ")
502 << tensorID <<
" in DebugTensor";
503 valueIt->second.setLoc(*loc);
512 if (operands.size() < 4) {
514 "OpExtInst must have at least 4 operands, result type "
515 "<id>, result <id>, set <id> and instruction opcode");
517 if (!extendedInstSets.count(operands[2])) {
518 return emitError(unknownLoc,
"undefined set <id> in OpExtInst");
521 slicedOperands.append(operands.begin(), std::next(operands.begin(), 2));
522 slicedOperands.append(std::next(operands.begin(), 4), operands.end());
524 extendedInstSets[operands[2]], operands[3], slicedOperands);
533 unsigned wordIndex = 0;
534 if (wordIndex >= words.size()) {
536 "missing Execution Model specification in OpEntryPoint");
538 auto execModel = spirv::ExecutionModelAttr::get(
539 context,
static_cast<spirv::ExecutionModel
>(words[wordIndex++]));
540 if (wordIndex >= words.size()) {
541 return emitError(unknownLoc,
"missing <id> in OpEntryPoint");
544 auto fnID = words[wordIndex++];
548 auto parsedFunc = getFunction(fnID);
550 return emitError(unknownLoc,
"no function matching <id> ") << fnID;
552 if (parsedFunc.getName() != fnName) {
556 if (!parsedFunc.getName().starts_with(
"spirv_fn_"))
558 "function name mismatch between OpEntryPoint "
559 "and OpFunction with <id> ")
560 << fnID <<
": " << fnName <<
" vs. " << parsedFunc.getName();
561 parsedFunc.setName(fnName);
564 while (wordIndex < words.size()) {
565 auto arg = getGlobalVariable(words[wordIndex]);
567 return emitError(unknownLoc,
"undefined result <id> ")
568 << words[wordIndex] <<
" while decoding OpEntryPoint";
570 interface.push_back(SymbolRefAttr::get(arg.getOperation()));
573 spirv::EntryPointOp::create(
574 opBuilder, unknownLoc, execModel,
575 SymbolRefAttr::get(opBuilder.getContext(), fnName),
576 opBuilder.getArrayAttr(interface));
583 unsigned wordIndex = 0;
584 if (wordIndex >= words.size()) {
586 "missing function result <id> in OpExecutionMode");
589 auto fnID = words[wordIndex++];
590 auto fn = getFunction(fnID);
592 return emitError(unknownLoc,
"no function matching <id> ") << fnID;
595 if (wordIndex >= words.size()) {
596 return emitError(unknownLoc,
"missing Execution Mode in OpExecutionMode");
598 auto execMode = spirv::ExecutionModeAttr::get(
599 context,
static_cast<spirv::ExecutionMode
>(words[wordIndex++]));
603 while (wordIndex < words.size()) {
604 attrListElems.push_back(opBuilder.getI32IntegerAttr(words[wordIndex++]));
606 auto values = opBuilder.getArrayAttr(attrListElems);
607 spirv::ExecutionModeOp::create(
608 opBuilder, unknownLoc,
609 SymbolRefAttr::get(opBuilder.getContext(), fn.getName()), execMode,
617 unsigned wordIndex = 0;
618 unsigned const wordsSize = words.size();
619 if (wordIndex >= wordsSize)
621 "missing function result <id> in OpExecutionModeId");
624 uint32_t fnID = words[wordIndex++];
625 FuncOp fn = getFunction(fnID);
627 return emitError(unknownLoc,
"no function matching <id> ") << fnID;
630 if (wordIndex >= wordsSize)
631 return emitError(unknownLoc,
"missing Execution Mode in OpExecutionModeId");
633 ExecutionModeAttr execMode = spirv::ExecutionModeAttr::get(
634 context,
static_cast<spirv::ExecutionMode
>(words[wordIndex++]));
638 while (wordIndex < words.size()) {
639 std::string
id = getSpecConstantSymbol(words[wordIndex++]);
642 ArrayAttr values = opBuilder.getArrayAttr(attrListElems);
643 spirv::ExecutionModeIdOp::create(
644 opBuilder, unknownLoc,
645 SymbolRefAttr::get(opBuilder.getContext(), fn.getName()), execMode,
653 if (operands.size() < 3) {
655 "OpFunctionCall must have at least 3 operands");
660 return emitError(unknownLoc,
"undefined result type from <id> ")
665 if (isVoidType(resultType))
666 resultType =
nullptr;
668 auto resultID = operands[1];
669 auto functionID = operands[2];
671 auto functionName = getFunctionSymbol(functionID);
674 for (
auto operand : llvm::drop_begin(operands, 3)) {
675 auto value = getValue(operand);
677 return emitError(unknownLoc,
"unknown <id> ")
678 << operand <<
" used by OpFunctionCall";
680 arguments.push_back(value);
683 auto opFunctionCall = spirv::FunctionCallOp::create(
684 opBuilder, unknownLoc, resultType,
685 SymbolRefAttr::get(opBuilder.getContext(), functionName), arguments);
687 if (
auto it = decorations.find(resultID); it != decorations.end())
692 valueMap[resultID] = opFunctionCall.getResult(0);
700 size_t wordIndex = 0;
704 if (wordIndex < words.size()) {
705 auto arg = getValue(words[wordIndex]);
708 return emitError(unknownLoc,
"unknown result <id> : ")
712 operands.push_back(arg);
716 if (wordIndex < words.size()) {
717 auto arg = getValue(words[wordIndex]);
720 return emitError(unknownLoc,
"unknown result <id> : ")
724 operands.push_back(arg);
728 bool isAlignedAttr =
false;
730 if (wordIndex < words.size()) {
731 auto attrValue = words[wordIndex++];
732 auto attr = opBuilder.getAttr<spirv::MemoryAccessAttr>(
733 static_cast<spirv::MemoryAccess
>(attrValue));
734 attributes.push_back(
736 isAlignedAttr = (attrValue == 2);
739 if (isAlignedAttr && wordIndex < words.size()) {
740 attributes.push_back(opBuilder.getNamedAttr(
741 "alignment", opBuilder.getI32IntegerAttr(words[wordIndex++])));
744 if (wordIndex < words.size()) {
745 auto attrValue = words[wordIndex++];
746 auto attr = opBuilder.getAttr<spirv::MemoryAccessAttr>(
747 static_cast<spirv::MemoryAccess
>(attrValue));
748 attributes.push_back(opBuilder.getNamedAttr(
"source_memory_access", attr));
751 if (wordIndex < words.size()) {
752 attributes.push_back(opBuilder.getNamedAttr(
753 "source_alignment", opBuilder.getI32IntegerAttr(words[wordIndex++])));
756 if (wordIndex != words.size()) {
758 "found more operands than expected when deserializing "
759 "spirv::CopyMemoryOp, only ")
760 << wordIndex <<
" of " << words.size() <<
" processed";
763 Location loc = createFileLineColLoc(opBuilder);
764 spirv::CopyMemoryOp::Properties properties{};
765 spirv::CopyMemoryOp::populateDefaultProperties(
767 opBuilder.getContext()),
769 if (failed(spirv::CopyMemoryOp::setPropertiesFromAttr(
770 properties, opBuilder.getDictionaryAttr(attributes),
771 [&]() { return emitError(loc); })))
773 spirv::CopyMemoryOp::create(opBuilder, loc, resultTypes, operands, properties,
782 if (words.size() != 4) {
784 "expected 4 words in GenericCastToPtrExplicitOp"
790 uint32_t valueID = 0;
794 return emitError(unknownLoc,
"unknown type result <id> : ") << words[0];
795 resultTypes.push_back(type);
799 auto arg = getValue(words[2]);
801 return emitError(unknownLoc,
"unknown result <id> : ") << words[2];
802 operands.push_back(arg);
804 Location loc = createFileLineColLoc(opBuilder);
805 Operation *op = spirv::GenericCastToPtrExplicitOp::create(
806 opBuilder, loc, resultTypes, operands);
813#define GET_DESERIALIZATION_FNS
814#include "mlir/Dialect/SPIRV/IR/SPIRVSerialization.inc"
static spirv::Opcode extractOpcode(uint32_t word)
Extracts the opcode from the given first word of a SPIR-V instruction.
static NameLoc getLocFromDebugInfoString(OpBuilder &builder, StringRef source)
Returns a NameLoc location from the given debug info string.
StringAttr getStringAttr(const Twine &bytes)
static FlatSymbolRefAttr get(StringAttr value)
Construct a symbol reference for the given value name.
Location objects represent source locations information in MLIR.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
NamedAttribute represents a combination of a name and an Attribute value.
StringAttr getName() const
Return the name of the attribute.
Attribute getValue() const
Return the value of the attribute.
This class helps build Operations.
This class provides the API for ops that are known to be terminators.
Operation is the basic unit of execution within MLIR.
bool hasTrait()
Returns true if the operation was registered with a particular trait, e.g.
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
static Operation * create(Location location, OperationName name, TypeRange resultTypes, ValueRange operands, NamedAttrList &&attributes, PropertyRef properties, BlockRange successors, unsigned numRegions)
Create a new Operation with the specific fields.
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...
Value materializeSpecConstantOperation(uint32_t resultID, spirv::Opcode enclosedOpcode, uint32_t resultTypeID, ArrayRef< uint32_t > enclosedOpOperands)
Materializes/emits an OpSpecConstantOp instruction.
Value getValue(uint32_t id)
Get the Value associated with a result <id>.
LogicalResult processGlobalVariable(ArrayRef< uint32_t > operands)
Processes the OpVariable instructions at current offset into binary.
std::optional< SpecConstOperationMaterializationInfo > getSpecConstantOperation(uint32_t id)
Gets the info needed to materialize the spec constant operation op associated with the given <id>.
LogicalResult processDebugInfoExtInst(ArrayRef< uint32_t > operands, bool deferInstructions)
Processes a SPIR-V OpExtInst with given operands for a DebugInfo extension instruction.
LogicalResult processConstantNull(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpConstantNull instruction with the given operands.
LogicalResult processSpecConstantComposite(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpSpecConstantComposite instruction with the given operands.
LogicalResult processInstruction(spirv::Opcode opcode, ArrayRef< uint32_t > operands, bool deferInstructions=true)
Processes a SPIR-V instruction with the given opcode and operands.
LogicalResult processBranchConditional(ArrayRef< uint32_t > operands)
spirv::GlobalVariableOp getGlobalVariable(uint32_t id)
Gets the global variable associated with a result <id> of OpVariable.
LogicalResult processGraphARM(ArrayRef< uint32_t > operands)
LogicalResult processLabel(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpLabel instruction with the given operands.
LogicalResult processExtInst(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpExtInst with given operands.
std::optional< spirv::GraphConstantARMOpMaterializationInfo > getGraphConstantARM(uint32_t id)
Gets the GraphConstantARM ID attribute and result type with the given result <id>.
std::optional< std::pair< Attribute, Type > > getConstant(uint32_t id)
Gets the constant's attribute and type associated with the given <id>.
LogicalResult processType(spirv::Opcode opcode, ArrayRef< uint32_t > operands)
Processes a SPIR-V type instruction with given opcode and operands and registers the type into module...
LogicalResult processLoopMerge(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpLoopMerge instruction with the given operands.
LogicalResult dispatchToExtensionSetAutogenDeserialization(StringRef extensionSetName, uint32_t instructionID, ArrayRef< uint32_t > words)
Dispatches the deserialization of extended instruction set operation based on the extended instructio...
LogicalResult sliceInstruction(spirv::Opcode &opcode, ArrayRef< uint32_t > &operands, std::optional< spirv::Opcode > expectedOpcode=std::nullopt)
Slices the first instruction out of binary and returns its opcode and operands via opcode and operand...
spirv::SpecConstantCompositeOp getSpecConstantComposite(uint32_t id)
Gets the composite specialization constant with the given result <id>.
spirv::EXTSpecConstantCompositeReplicateOp getSpecConstantCompositeReplicate(uint32_t id)
Gets the replicated composite specialization constant with the given result <id>.
LogicalResult processOp(ArrayRef< uint32_t > words)
Method to deserialize an operation in the SPIR-V dialect that is a mirror of an instruction in the SP...
Type getUndefType(uint32_t id)
Get the type associated with the result <id> of an OpUndef.
LogicalResult processSpecConstantCompositeReplicateEXT(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpSpecConstantCompositeReplicateEXT instruction with the given operands.
LogicalResult processGraphEntryPointARM(ArrayRef< uint32_t > operands)
LogicalResult processFunction(ArrayRef< uint32_t > operands)
Creates a deserializer for the given SPIR-V binary module.
bool isVoidType(Type type) const
Returns true if the given type is for SPIR-V void type.
LogicalResult processDebugString(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpString instruction with the given operands.
LogicalResult processPhi(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpPhi instruction with the given operands.
void clearDebugLine()
Discontinues any source-level location information that might be active from a previous OpLine instru...
void mergeLongCompositeContinuations(spirv::Opcode opcode, ArrayRef< uint32_t > &operands, SmallVectorImpl< uint32_t > &mergedStorage)
If opcode is a SPV_INTEL_long_composites splittable opcode and the next binary instruction(s) are mat...
LogicalResult processTypeForwardPointer(ArrayRef< uint32_t > operands)
LogicalResult processSwitch(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpSwitch instruction with the given operands.
LogicalResult dispatchToAutogenDeserialization(spirv::Opcode opcode, ArrayRef< uint32_t > words)
Method to dispatch to the specialized deserialization function for an operation in SPIR-V dialect tha...
LogicalResult processOpWithoutGrammarAttr(ArrayRef< uint32_t > words, StringRef opName, bool hasResult, unsigned numOperands)
Processes a SPIR-V instruction from the given operands.
LogicalResult processGraphEndARM(ArrayRef< uint32_t > operands)
LogicalResult processConstantComposite(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpConstantComposite instruction with the given operands.
LogicalResult processBranch(ArrayRef< uint32_t > operands)
std::optional< std::pair< Attribute, Type > > getConstantCompositeReplicate(uint32_t id)
Gets the replicated composite constant's attribute and type associated with the given <id>.
LogicalResult processUndef(ArrayRef< uint32_t > operands)
Processes a OpUndef instruction.
LogicalResult processSpecConstantOperation(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpSpecConstantOp instruction with the given operands.
LogicalResult processConstant(ArrayRef< uint32_t > operands, bool isSpec)
Processes a SPIR-V Op{|Spec}Constant instruction with the given operands.
Location createFileLineColLoc(OpBuilder opBuilder)
Creates a FileLineColLoc with the OpLine location information.
LogicalResult processGraphConstantARM(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpGraphConstantARM instruction with the given operands.
LogicalResult processConstantBool(bool isTrue, ArrayRef< uint32_t > operands, bool isSpec)
Processes a SPIR-V Op{|Spec}Constant{True|False} instruction with the given operands.
spirv::SpecConstantOp getSpecConstant(uint32_t id)
Gets the specialization constant with the given result <id>.
LogicalResult processConstantCompositeReplicateEXT(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpConstantCompositeReplicateEXT instruction with the given operands.
LogicalResult processSelectionMerge(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpSelectionMerge instruction with the given operands.
LogicalResult processOpGraphSetOutputARM(ArrayRef< uint32_t > operands)
LogicalResult processDebugLine(ArrayRef< uint32_t > operands)
Processes a SPIR-V OpLine instruction with the given operands.
constexpr llvm::StringLiteral extDebugInfo
Extension set name for non-semantic graph debug info.
std::optional< spirv::Opcode > getContinuationOpcode(spirv::Opcode parent)
Returns the SPV_INTEL_long_composites continuation opcode that may follow parent, or std::nullopt if ...
constexpr bool isValidGraphDebugInfoExtInst(uint32_t opcode)
constexpr StringRef attributeName()
StringRef decodeStringLiteral(ArrayRef< uint32_t > words, unsigned &wordIndex)
Decodes a string literal in words starting at wordIndex.
GraphDebugInfoExtInst
Instruction opcodes in the NonSemantic.Graph.DebugInfo.1 extended instruction set.
Include the generated interface declarations.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
llvm::DenseMap< KeyT, ValueT, KeyInfoT, BucketT > DenseMap
This represents an operation in an abstracted form, suitable for use with the builder APIs.
void addOperands(ValueRange newOperands)
void addAttributes(ArrayRef< NamedAttribute > newAttributes)
Add an array of named attributes.
void addTypes(ArrayRef< Type > newTypes)