13#ifndef MLIR_INTERFACES_VIEWLIKEINTERFACE_H_
14#define MLIR_INTERFACES_VIEWLIKEINTERFACE_H_
22#include "llvm/ADT/STLExtras.h"
26class OffsetSizeAndStrideOpInterface;
33 OffsetSizeAndStrideOpInterface a, OffsetSizeAndStrideOpInterface
b,
34 llvm::function_ref<
bool(OpFoldResult, OpFoldResult)> cmp);
45#include "mlir/Interfaces/ViewLikeInterface.h.inc"
65 bool generateErrorMessage =
false);
69 bool generateErrorMessage =
false);
80template <
typename OpType,
typename ResultTypeFn,
typename CastOpFunc>
100 cast<ShapedType>(op.getSource().getType()).getShape(), mixedOffsets,
101 mixedSizes, mixedStrides);
107 ResultTypeFn()(op, mixedOffsets, mixedSizes, mixedStrides);
113 OpType::create(rewriter, op.getLoc(), resultType, op.getSource(),
114 mixedOffsets, mixedSizes, mixedStrides);
115 CastOpFunc()(rewriter, op, newOp);
166 OpAsmPrinter &printer, Operation *op, OperandRange values,
167 ArrayRef<int64_t> integers, ArrayRef<bool> scalableFlags,
175 {}, valueTypes, delimiter);
215 SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
217 SmallVectorImpl<Type> *valueTypes =
nullptr,
226 valueTypes, delimiter)))
228 if (llvm::is_contained(scalableFlags.
asArrayRef(),
true))
230 <<
"scalable indices are not supported";
237 unsigned expectedNumElements,
238 ArrayRef<int64_t> attr,
252template <
typename ConcreteType>
254 :
public TraitBase<ConcreteType, DistinctObjectsTrait> {};
Delimiter
These are the supported delimiters around operand lists and region argument lists,...
@ Square
Square brackets surrounding zero or more operands.
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
virtual SMLoc getNameLoc() const =0
Return the location of the original name token.
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
This trai indicates that pointer-like objects (such as memrefs) returned from this operation will nev...
Helper class for implementing traits.
Pattern to rewrite dynamic offsets/sizes/strides of view/slice-like ops as constant arguments.
LogicalResult matchAndRewrite(OpType op, PatternRewriter &rewriter) const override
This class implements the operand iterators for the Operation class.
Operation is the basic unit of execution within MLIR.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
This class provides an abstraction over the various different ranges of value types.
ArrayRef< T > asArrayRef() const
bool sameOffsetsSizesAndStrides(OffsetSizeAndStrideOpInterface a, OffsetSizeAndStrideOpInterface b, llvm::function_ref< bool(OpFoldResult, OpFoldResult)> cmp)
unsigned getNumDynamicEntriesUpToIdx(ArrayRef< int64_t > staticVals, unsigned idx)
Helper method to compute the number of dynamic entries of staticVals, up to idx.
LogicalResult verifyOffsetSizeAndStrideOp(OffsetSizeAndStrideOpInterface op)
Include the generated interface declarations.
detail::DenseArrayAttrImpl< int64_t > DenseI64ArrayAttr
ParseResult parseDynamicIndexList(OpAsmParser &parser, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &values, DenseI64ArrayAttr &integers, DenseBoolArrayAttr &scalableFlags, SmallVectorImpl< Type > *valueTypes=nullptr, AsmParser::Delimiter delimiter=AsmParser::Delimiter::Square)
Parser hooks for custom directive in assemblyFormat.
SliceBoundsVerificationResult verifyInBoundsSlice(ArrayRef< int64_t > shape, ArrayRef< int64_t > staticOffsets, ArrayRef< int64_t > staticSizes, ArrayRef< int64_t > staticStrides, bool generateErrorMessage=false)
Verify that the offsets/sizes/strides-style access into the given shape is in-bounds.
detail::DenseArrayAttrImpl< bool > DenseBoolArrayAttr
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...
void printDynamicIndexList(OpAsmPrinter &printer, Operation *op, OperandRange values, ArrayRef< int64_t > integers, ArrayRef< bool > scalableFlags, TypeRange valueTypes=TypeRange(), AsmParser::Delimiter delimiter=AsmParser::Delimiter::Square)
Printer hooks for custom directive in assemblyFormat.
LogicalResult foldDynamicIndexList(SmallVectorImpl< OpFoldResult > &ofrs, bool onlyNonNegative=false, bool onlyNonZero=false)
Returns "success" when any of the elements in ofrs is a constant value.
OpRewritePattern(MLIRContext *context, PatternBenefit benefit=1, ArrayRef< StringRef > generatedNames={})
Result for slice bounds verification;.
bool isValid
If set to "true", the slice bounds verification was successful.
std::string errorMessage
An error message that can be printed during op verification.