18 #include "mlir/Interfaces/ViewLikeInterface.cpp.inc"
26 if (staticVals.size() != numElements)
27 return op->
emitError(
"expected ") << numElements <<
" " << name
28 <<
" values, got " << staticVals.size();
29 unsigned expectedNumDynamicEntries =
30 llvm::count_if(staticVals, [&](int64_t staticVal) {
31 return ShapedType::isDynamic(staticVal);
33 if (values.size() != expectedNumDynamicEntries)
35 << expectedNumDynamicEntries <<
" dynamic " << name <<
" values";
41 std::array<unsigned, 3> maxRanks = op.getArrayAttrMaxRanks();
46 if (!(op.getMixedOffsets().size() == 1 && maxRanks[0] == 1) &&
47 op.getMixedOffsets().size() != op.getMixedSizes().size())
49 "expected mixed offsets rank to match mixed sizes rank (")
50 << op.getMixedOffsets().size() <<
" vs " << op.getMixedSizes().size()
51 <<
") so the rank of the result type is well-formed.";
54 if (op.getMixedSizes().size() != op.getMixedStrides().size())
56 "expected mixed sizes rank to match mixed strides rank (")
57 << op.getMixedSizes().size() <<
" vs " << op.getMixedStrides().size()
58 <<
") so the rank of the result type is well-formed.";
61 op.static_offsets(), op.offsets())))
64 op.static_sizes(), op.sizes())))
67 op.static_strides(), op.strides())))
83 llvm_unreachable(
"unsupported delimiter");
98 llvm_unreachable(
"unsupported delimiter");
107 bool isTrailingIdxScalable) {
110 printer << leftDelimiter;
111 if (integers.empty()) {
112 printer << rightDelimiter;
116 int64_t trailingScalableInteger;
117 if (isTrailingIdxScalable) {
119 trailingScalableInteger = integers.back();
120 integers = integers.drop_back();
124 llvm::interleaveComma(integers, printer, [&](int64_t integer) {
125 if (ShapedType::isDynamic(integer)) {
126 printer << values[idx];
127 if (!valueTypes.empty())
128 printer <<
" : " << valueTypes[idx];
136 if (isTrailingIdxScalable) {
139 printer << trailingScalableInteger;
143 printer << rightDelimiter;
153 bool foundScalable =
false;
154 auto parseIntegerOrValue = [&]() {
162 <<
"non-trailing tile size cannot be scalable";
167 foundScalable =
true;
169 if (res.has_value() &&
succeeded(res.value())) {
170 values.push_back(operand);
171 integerVals.push_back(ShapedType::kDynamic);
172 if (valueTypes && parser.
parseColonType(valueTypes->emplace_back()))
178 integerVals.push_back(integer);
185 " in dynamic index list"))
187 <<
"expected SSA value or integer";
189 if (isTrailingIdxScalable)
190 *isTrailingIdxScalable = foundScalable;
195 OffsetSizeAndStrideOpInterface a, OffsetSizeAndStrideOpInterface b,
197 if (a.static_offsets().size() != b.static_offsets().size())
199 if (a.static_sizes().size() != b.static_sizes().size())
201 if (a.static_strides().size() != b.static_strides().size())
203 for (
auto it : llvm::zip(a.getMixedOffsets(), b.getMixedOffsets()))
204 if (!cmp(std::get<0>(it), std::get<1>(it)))
206 for (
auto it : llvm::zip(a.getMixedSizes(), b.getMixedSizes()))
207 if (!cmp(std::get<0>(it), std::get<1>(it)))
209 for (
auto it : llvm::zip(a.getMixedStrides(), b.getMixedStrides()))
210 if (!cmp(std::get<0>(it), std::get<1>(it)))
static char getLeftDelimiter(AsmParser::Delimiter delimiter)
static char getRightDelimiter(AsmParser::Delimiter delimiter)
Delimiter
These are the supported delimiters around operand lists and region argument lists,...
@ Paren
Parens surrounding zero or more operands.
@ Braces
{} brackets surrounding zero or more operands.
@ Square
Square brackets surrounding zero or more operands.
@ LessGreater
<> brackets surrounding zero or more operands.
virtual ParseResult parseCommaSeparatedList(Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef())=0
Parse a list of comma-separated items with an optional delimiter.
virtual Builder & getBuilder() const =0
Return a builder which provides useful access to MLIRContext, global objects like types and attribute...
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
ParseResult parseInteger(IntT &result)
Parse an integer value from the stream.
virtual ParseResult parseColonType(Type &result)=0
Parse a colon followed by a type.
virtual SMLoc getNameLoc() const =0
Return the location of the original name token.
virtual ParseResult parseOptionalRSquare()=0
Parse a ] token if present.
virtual ParseResult parseOptionalLSquare()=0
Parse a [ token if present.
DenseI64ArrayAttr getDenseI64ArrayAttr(ArrayRef< int64_t > values)
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
virtual OptionalParseResult parseOptionalOperand(UnresolvedOperand &result, bool allowResultNumber=true)=0
Parse a single operand if present.
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
This class represents a single result from folding an operation.
This class implements the operand iterators for the Operation class.
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
This class represents success/failure for parsing-like operations that find it important to chain tog...
This class provides an abstraction over the various different ranges of value types.
This class provides an abstraction over the different types of ranges over Values.
Base class for DenseArrayAttr that is instantiated and specialized for each supported element type be...
bool sameOffsetsSizesAndStrides(OffsetSizeAndStrideOpInterface a, OffsetSizeAndStrideOpInterface b, llvm::function_ref< bool(OpFoldResult, OpFoldResult)> cmp)
LogicalResult verifyOffsetSizeAndStrideOp(OffsetSizeAndStrideOpInterface op)
This header declares functions that assit transformations in the MemRef dialect.
ParseResult parseDynamicIndexList(OpAsmParser &parser, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &values, DenseI64ArrayAttr &integers, bool *isTrailingIdxScalable=nullptr, SmallVectorImpl< Type > *valueTypes=nullptr, AsmParser::Delimiter delimiter=AsmParser::Delimiter::Square)
Parser hook for custom directive in assemblyFormat.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
bool succeeded(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
void printDynamicIndexList(OpAsmPrinter &printer, Operation *op, OperandRange values, ArrayRef< int64_t > integers, TypeRange valueTypes=TypeRange(), AsmParser::Delimiter delimiter=AsmParser::Delimiter::Square, bool isTrailingIdxScalable=false)
Printer hook for custom directive in assemblyFormat.
LogicalResult verifyListOfOperandsOrIntegers(Operation *op, StringRef name, unsigned expectedNumElements, ArrayRef< int64_t > attr, ValueRange values)
Verify that a the values has as many elements as the number of entries in attr for which isDynamic ev...
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
This class represents an efficient way to signal success or failure.
bool succeeded() const
Returns true if the provided LogicalResult corresponds to a success value.
bool failed() const
Returns true if the provided LogicalResult corresponds to a failure value.
This is the representation of an operand reference.