29 if (isa<FunctionOpInterface>(op))
41 if (isa<spirv::GraphARMOp>(op))
56 if (
auto vecType = llvm::dyn_cast<VectorType>(operandType))
57 return VectorType::get(vecType.getNumElements(), resultType);
62 spirv::ImageOperandsAttr &attr) {
67 spirv::ImageOperands imageOperands;
71 attr = spirv::ImageOperandsAttr::get(parser.
getContext(), imageOperands);
77 spirv::ImageOperandsAttr attr) {
79 auto strImageOperands = stringifyImageOperands(attr.getValue());
80 printer <<
"[\"" << strImageOperands <<
"\"]";
111 values.push_back(APInt(bitWidth, value,
true));
125 targets.push_back(
target);
126 targetOperands.emplace_back(operands);
127 targetOperandTypes.emplace_back(operandTypes);
130 if (!values.empty()) {
131 ShapedType literalType =
132 VectorType::get(
static_cast<int64_t>(values.size()), selectorType);
150 for (
auto [
index, literal] : llvm::enumerate(literals.getValues<APInt>())) {
154 p << literal.getLimitedValue();
164#define GET_OP_CLASSES
165#include "mlir/Dialect/SPIRV/IR/SPIRVOps.cpp.inc"
@ None
Zero or more operands with no delimiters.
virtual ParseResult parseColonTypeList(SmallVectorImpl< Type > &result)=0
Parse a colon followed by a type list, which must have at least one type.
MLIRContext * getContext() const
virtual ParseResult parseRParen()=0
Parse a ) token.
virtual ParseResult parseRSquare()=0
Parse a ] token.
ParseResult parseInteger(IntT &result)
Parse an integer value from the stream.
virtual ParseResult parseOptionalComma()=0
Parse a , token if present.
virtual ParseResult parseColon()=0
Parse a : token.
virtual ParseResult parseOptionalLParen()=0
Parse a ( token if present.
ParseResult parseKeyword(StringRef keyword)
Parse a given keyword.
virtual ParseResult parseOptionalLSquare()=0
Parse a [ token if present.
Block represents an ordered list of Operations.
This class is a general helper class for creating context-global objects like types,...
IntegerType getIntegerType(unsigned width)
An attribute that represents a reference to a dense integer vector or tensor object.
static DenseIntElementsAttr get(const ShapedType &type, Arg &&arg)
Get an instance of a DenseIntElementsAttr with the given arguments.
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
virtual ParseResult parseSuccessor(Block *&dest)=0
Parse a single operation successor.
virtual ParseResult parseOperandList(SmallVectorImpl< UnresolvedOperand > &result, Delimiter delimiter=Delimiter::None, bool allowResultNumber=true, int requiredOperandCount=-1)=0
Parse zero or more SSA comma-separated operand references with a specified surrounding delimiter,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
virtual void printNewline()=0
Print a newline and indent the printer to the start of the current operation.
virtual void printSuccessorAndUseList(Block *successor, ValueRange succOperands)=0
Print the successor and its operands.
A trait used to provide symbol table functionalities to a region operation.
This class represents a contiguous range of operand ranges, e.g.
This class implements the operand iterators for the Operation class.
Operation is the basic unit of execution within MLIR.
bool hasTrait()
Returns true if the operation was registered with a particular trait, e.g.
Operation * getParentOp()
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...
This class implements the successor iterators for Block.
This class provides an abstraction for a range of TypeRange.
This class provides an abstraction over the various different ranges of value types.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
MLIRContext * getContext() const
Return the MLIRContext in which this type was uniqued.
unsigned getIntOrFloatBitWidth() const
Return the bit width of an integer or a float type, assert failure on other types.
static bool isNestedInGraphARMOpInterface(Operation *op)
Returns true if the given op is a GraphARM op or nested in a GraphARM op without a module-like op in ...
ParseResult parseEnumStrAttr(EnumClass &value, OpAsmParser &parser, StringRef attrName=spirv::attributeName< EnumClass >())
Parses the next string attribute in parser as an enumerant of the given EnumClass.
static bool isDirectInModuleLikeOp(Operation *op)
Returns true if the given op is an module-like op that maintains a symbol table.
static Type getUnaryOpResultType(Type operandType)
Result of a logical op must be a scalar or vector of boolean type.
static ParseResult parseSwitchOpCases(OpAsmParser &parser, Type &selectorType, Block *&defaultTarget, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &defaultOperands, SmallVectorImpl< Type > &defaultOperandTypes, DenseIntElementsAttr &literals, SmallVectorImpl< Block * > &targets, SmallVectorImpl< SmallVector< OpAsmParser::UnresolvedOperand > > &targetOperands, SmallVectorImpl< SmallVector< Type > > &targetOperandTypes)
Adapted from the cf.switch implementation.
static void printImageOperands(OpAsmPrinter &printer, Operation *imageOp, spirv::ImageOperandsAttr attr)
static bool isNestedInFunctionOpInterface(Operation *op)
Returns true if the given op is a function-like op or nested in a function-like op without a module-l...
static ParseResult parseImageOperands(OpAsmParser &parser, spirv::ImageOperandsAttr &attr)
static void printSwitchOpCases(OpAsmPrinter &p, SwitchOp op, Type selectorType, Block *defaultTarget, OperandRange defaultOperands, TypeRange defaultOperandTypes, DenseIntElementsAttr literals, SuccessorRange targets, OperandRangeRange targetOperands, const TypeRangeRange &targetOperandTypes)