MLIR
18.0.0git
|
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to track mutations and create new operations. More...
#include "mlir/IR/PatternMatch.h"
Classes | |
struct | ForwardingListener |
A listener that forwards all notifications to another listener. More... | |
struct | Listener |
Public Member Functions | |
virtual void | inlineRegionBefore (Region ®ion, Region &parent, Region::iterator before) |
Move the blocks that belong to "region" before the given position in another region "parent". More... | |
void | inlineRegionBefore (Region ®ion, Block *before) |
virtual void | cloneRegionBefore (Region ®ion, Region &parent, Region::iterator before, IRMapping &mapping) |
Clone the blocks that belong to "region" before the given position in another region "parent". More... | |
void | cloneRegionBefore (Region ®ion, Region &parent, Region::iterator before) |
void | cloneRegionBefore (Region ®ion, Block *before) |
virtual void | replaceOpWithIf (Operation *op, ValueRange newValues, bool *allUsesReplaced, llvm::unique_function< bool(OpOperand &) const > functor) |
This method replaces the uses of the results of op with the values in newValues when the provided functor returns true for a specific use. More... | |
void | replaceOpWithIf (Operation *op, ValueRange newValues, llvm::unique_function< bool(OpOperand &) const > functor) |
void | replaceOpWithinBlock (Operation *op, ValueRange newValues, Block *block, bool *allUsesReplaced=nullptr) |
This method replaces the uses of the results of op with the values in newValues when a use is nested within the given block . More... | |
virtual void | replaceOp (Operation *op, ValueRange newValues) |
This method replaces the results of the operation with the specified list of values. More... | |
virtual void | replaceOp (Operation *op, Operation *newOp) |
This method replaces the results of the operation with the specified new op (replacement). More... | |
template<typename OpTy , typename... Args> | |
OpTy | replaceOpWithNewOp (Operation *op, Args &&...args) |
Replaces the result op with a new op that is created without verification. More... | |
virtual void | eraseOp (Operation *op) |
This method erases an operation that is known to have no uses. More... | |
virtual void | eraseBlock (Block *block) |
This method erases all operations in a block. More... | |
virtual void | inlineBlockBefore (Block *source, Block *dest, Block::iterator before, ValueRange argValues=std::nullopt) |
Inline the operations of block 'source' into block 'dest' before the given position. More... | |
void | inlineBlockBefore (Block *source, Operation *op, ValueRange argValues=std::nullopt) |
Inline the operations of block 'source' before the operation 'op'. More... | |
void | mergeBlocks (Block *source, Block *dest, ValueRange argValues=std::nullopt) |
Inline the operations of block 'source' into the end of block 'dest'. More... | |
virtual Block * | splitBlock (Block *block, Block::iterator before) |
Split the operations starting at "before" (inclusive) out of the given block into a new block, and return it. More... | |
virtual void | startRootUpdate (Operation *op) |
This method is used to notify the rewriter that an in-place operation modification is about to happen. More... | |
virtual void | finalizeRootUpdate (Operation *op) |
This method is used to signal the end of a root update on the given operation. More... | |
virtual void | cancelRootUpdate (Operation *op) |
This method cancels a pending root update. More... | |
template<typename CallableT > | |
void | updateRootInPlace (Operation *root, CallableT &&callable) |
This method is a utility wrapper around a root update of an operation. More... | |
void | replaceAllUsesWith (Value from, Value to) |
Find uses of from and replace them with to . More... | |
template<typename OperandType , typename ValueT > | |
void | replaceAllUsesWith (IRObjectWithUseList< OperandType > *from, ValueT &&to) |
void | replaceAllUsesWith (ValueRange from, ValueRange to) |
void | replaceUsesWithIf (Value from, Value to, function_ref< bool(OpOperand &)> functor) |
Find uses of from and replace them with to if the functor returns true. More... | |
void | replaceUsesWithIf (ValueRange from, ValueRange to, function_ref< bool(OpOperand &)> functor) |
void | replaceAllUsesExcept (Value from, Value to, Operation *exceptedUser) |
Find uses of from and replace them with to except if the user is exceptedUser . More... | |
template<typename CallbackT > | |
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > | notifyMatchFailure (Location loc, CallbackT &&reasonCallback) |
Used to notify the rewriter that the IR failed to be rewritten because of a match failure, and provide a callback to populate a diagnostic with the reason why the failure occurred. More... | |
template<typename CallbackT > | |
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > | notifyMatchFailure (Operation *op, CallbackT &&reasonCallback) |
template<typename ArgT > | |
LogicalResult | notifyMatchFailure (ArgT &&arg, const Twine &msg) |
template<typename ArgT > | |
LogicalResult | notifyMatchFailure (ArgT &&arg, const char *msg) |
![]() | |
OpBuilder (MLIRContext *ctx, Listener *listener=nullptr) | |
Create a builder with the given context. More... | |
OpBuilder (Region *region, Listener *listener=nullptr) | |
Create a builder and set the insertion point to the start of the region. More... | |
OpBuilder (Region ®ion, Listener *listener=nullptr) | |
OpBuilder (Operation *op, Listener *listener=nullptr) | |
Create a builder and set insertion point to the given operation, which will cause subsequent insertions to go right before it. More... | |
OpBuilder (Block *block, Block::iterator insertPoint, Listener *listener=nullptr) | |
void | setListener (Listener *newListener) |
Sets the listener of this builder to the one provided. More... | |
Listener * | getListener () const |
Returns the current listener of this builder, or nullptr if this builder doesn't have a listener. More... | |
void | clearInsertionPoint () |
Reset the insertion point to no location. More... | |
InsertPoint | saveInsertionPoint () const |
Return a saved insertion point. More... | |
void | restoreInsertionPoint (InsertPoint ip) |
Restore the insert point to a previously saved point. More... | |
void | setInsertionPoint (Block *block, Block::iterator insertPoint) |
Set the insertion point to the specified location. More... | |
void | setInsertionPoint (Operation *op) |
Sets the insertion point to the specified operation, which will cause subsequent insertions to go right before it. More... | |
void | setInsertionPointAfter (Operation *op) |
Sets the insertion point to the node after the specified operation, which will cause subsequent insertions to go right after it. More... | |
void | setInsertionPointAfterValue (Value val) |
Sets the insertion point to the node after the specified value. More... | |
void | setInsertionPointToStart (Block *block) |
Sets the insertion point to the start of the specified block. More... | |
void | setInsertionPointToEnd (Block *block) |
Sets the insertion point to the end of the specified block. More... | |
Block * | getInsertionBlock () const |
Return the block the current insertion point belongs to. More... | |
Block::iterator | getInsertionPoint () const |
Returns the current insertion point of the builder. More... | |
Block * | getBlock () const |
Returns the current block of the builder. More... | |
Block * | createBlock (Region *parent, Region::iterator insertPt={}, TypeRange argTypes=std::nullopt, ArrayRef< Location > locs=std::nullopt) |
Add new block with 'argTypes' arguments and set the insertion point to the end of it. More... | |
Block * | createBlock (Block *insertBefore, TypeRange argTypes=std::nullopt, ArrayRef< Location > locs=std::nullopt) |
Add new block with 'argTypes' arguments and set the insertion point to the end of it. More... | |
Operation * | insert (Operation *op) |
Insert the given operation at the current insertion point and return it. More... | |
Operation * | create (const OperationState &state) |
Creates an operation given the fields represented as an OperationState. More... | |
Operation * | create (Location loc, StringAttr opName, ValueRange operands, TypeRange types={}, ArrayRef< NamedAttribute > attributes={}, BlockRange successors={}, MutableArrayRef< std::unique_ptr< Region >> regions={}) |
Creates an operation with the given fields. More... | |
template<typename OpTy , typename... Args> | |
OpTy | create (Location location, Args &&...args) |
Create an operation of specific op type at the current insertion point. More... | |
template<typename OpTy , typename... Args> | |
void | createOrFold (SmallVectorImpl< Value > &results, Location location, Args &&...args) |
Create an operation of specific op type at the current insertion point, and immediately try to fold it. More... | |
template<typename OpTy , typename... Args> | |
std::enable_if_t< OpTy::template hasTrait< OpTrait::OneResult >), Value > | createOrFold (Location location, Args &&...args) |
Overload to create or fold a single result operation. More... | |
template<typename OpTy , typename... Args> | |
std::enable_if_t< OpTy::template hasTrait< OpTrait::ZeroResults >), OpTy > | createOrFold (Location location, Args &&...args) |
Overload to create or fold a zero result operation. More... | |
LogicalResult | tryFold (Operation *op, SmallVectorImpl< Value > &results) |
Attempts to fold the given operation and places new results within 'results'. More... | |
Operation * | clone (Operation &op, IRMapping &mapper) |
Creates a deep copy of the specified operation, remapping any operands that use values outside of the operation using the map that is provided ( leaving them alone if no entry is present). More... | |
Operation * | clone (Operation &op) |
Operation * | cloneWithoutRegions (Operation &op, IRMapping &mapper) |
Creates a deep copy of this operation but keep the operation regions empty. More... | |
Operation * | cloneWithoutRegions (Operation &op) |
template<typename OpT > | |
OpT | cloneWithoutRegions (OpT op) |
![]() | |
Builder (MLIRContext *context) | |
Builder (Operation *op) | |
MLIRContext * | getContext () const |
Location | getUnknownLoc () |
Location | getFusedLoc (ArrayRef< Location > locs, Attribute metadata=Attribute()) |
FloatType | getFloat8E5M2Type () |
FloatType | getFloat8E4M3FNType () |
FloatType | getFloat8E5M2FNUZType () |
FloatType | getFloat8E4M3FNUZType () |
FloatType | getFloat8E4M3B11FNUZType () |
FloatType | getBF16Type () |
FloatType | getF16Type () |
FloatType | getTF32Type () |
FloatType | getF32Type () |
FloatType | getF64Type () |
FloatType | getF80Type () |
FloatType | getF128Type () |
IndexType | getIndexType () |
IntegerType | getI1Type () |
IntegerType | getI2Type () |
IntegerType | getI4Type () |
IntegerType | getI8Type () |
IntegerType | getI16Type () |
IntegerType | getI32Type () |
IntegerType | getI64Type () |
IntegerType | getIntegerType (unsigned width) |
IntegerType | getIntegerType (unsigned width, bool isSigned) |
FunctionType | getFunctionType (TypeRange inputs, TypeRange results) |
TupleType | getTupleType (TypeRange elementTypes) |
NoneType | getNoneType () |
template<typename Ty , typename... Args> | |
Ty | getType (Args &&...args) |
Get or construct an instance of the type Ty with provided arguments. More... | |
template<typename Attr , typename... Args> | |
Attr | getAttr (Args &&...args) |
Get or construct an instance of the attribute Attr with provided arguments. More... | |
NamedAttribute | getNamedAttr (StringRef name, Attribute val) |
UnitAttr | getUnitAttr () |
BoolAttr | getBoolAttr (bool value) |
DictionaryAttr | getDictionaryAttr (ArrayRef< NamedAttribute > value) |
IntegerAttr | getIntegerAttr (Type type, int64_t value) |
IntegerAttr | getIntegerAttr (Type type, const APInt &value) |
FloatAttr | getFloatAttr (Type type, double value) |
FloatAttr | getFloatAttr (Type type, const APFloat &value) |
StringAttr | getStringAttr (const Twine &bytes) |
ArrayAttr | getArrayAttr (ArrayRef< Attribute > value) |
TypedAttr | getZeroAttr (Type type) |
FloatAttr | getF16FloatAttr (float value) |
FloatAttr | getF32FloatAttr (float value) |
FloatAttr | getF64FloatAttr (double value) |
IntegerAttr | getI8IntegerAttr (int8_t value) |
IntegerAttr | getI16IntegerAttr (int16_t value) |
IntegerAttr | getI32IntegerAttr (int32_t value) |
IntegerAttr | getI64IntegerAttr (int64_t value) |
IntegerAttr | getIndexAttr (int64_t value) |
IntegerAttr | getSI32IntegerAttr (int32_t value) |
Signed and unsigned integer attribute getters. More... | |
IntegerAttr | getUI32IntegerAttr (uint32_t value) |
DenseIntElementsAttr | getBoolVectorAttr (ArrayRef< bool > values) |
Vector-typed DenseIntElementsAttr getters. values must not be empty. More... | |
DenseIntElementsAttr | getI32VectorAttr (ArrayRef< int32_t > values) |
DenseIntElementsAttr | getI64VectorAttr (ArrayRef< int64_t > values) |
DenseIntElementsAttr | getIndexVectorAttr (ArrayRef< int64_t > values) |
DenseFPElementsAttr | getF32VectorAttr (ArrayRef< float > values) |
DenseFPElementsAttr | getF64VectorAttr (ArrayRef< double > values) |
DenseIntElementsAttr | getI32TensorAttr (ArrayRef< int32_t > values) |
Tensor-typed DenseIntElementsAttr getters. More... | |
DenseIntElementsAttr | getI64TensorAttr (ArrayRef< int64_t > values) |
DenseIntElementsAttr | getIndexTensorAttr (ArrayRef< int64_t > values) |
DenseBoolArrayAttr | getDenseBoolArrayAttr (ArrayRef< bool > values) |
Tensor-typed DenseArrayAttr getters. More... | |
DenseI8ArrayAttr | getDenseI8ArrayAttr (ArrayRef< int8_t > values) |
DenseI16ArrayAttr | getDenseI16ArrayAttr (ArrayRef< int16_t > values) |
DenseI32ArrayAttr | getDenseI32ArrayAttr (ArrayRef< int32_t > values) |
DenseI64ArrayAttr | getDenseI64ArrayAttr (ArrayRef< int64_t > values) |
DenseF32ArrayAttr | getDenseF32ArrayAttr (ArrayRef< float > values) |
DenseF64ArrayAttr | getDenseF64ArrayAttr (ArrayRef< double > values) |
ArrayAttr | getAffineMapArrayAttr (ArrayRef< AffineMap > values) |
ArrayAttr | getBoolArrayAttr (ArrayRef< bool > values) |
ArrayAttr | getI32ArrayAttr (ArrayRef< int32_t > values) |
ArrayAttr | getI64ArrayAttr (ArrayRef< int64_t > values) |
ArrayAttr | getIndexArrayAttr (ArrayRef< int64_t > values) |
ArrayAttr | getF32ArrayAttr (ArrayRef< float > values) |
ArrayAttr | getF64ArrayAttr (ArrayRef< double > values) |
ArrayAttr | getStrArrayAttr (ArrayRef< StringRef > values) |
ArrayAttr | getTypeArrayAttr (TypeRange values) |
AffineExpr | getAffineDimExpr (unsigned position) |
AffineExpr | getAffineSymbolExpr (unsigned position) |
AffineExpr | getAffineConstantExpr (int64_t constant) |
AffineMap | getEmptyAffineMap () |
Returns a zero result affine map with no dimensions or symbols: () -> (). More... | |
AffineMap | getConstantAffineMap (int64_t val) |
Returns a single constant result affine map with 0 dimensions and 0 symbols. More... | |
AffineMap | getDimIdentityMap () |
AffineMap | getMultiDimIdentityMap (unsigned rank) |
AffineMap | getSymbolIdentityMap () |
AffineMap | getSingleDimShiftAffineMap (int64_t shift) |
Returns a map that shifts its (single) input dimension by 'shift'. More... | |
AffineMap | getShiftedAffineMap (AffineMap map, int64_t shift) |
Returns an affine map that is a translation (shift) of all result expressions in 'map' by 'shift'. More... | |
Protected Member Functions | |
RewriterBase (MLIRContext *ctx, OpBuilder::Listener *listener=nullptr) | |
Initialize the builder. More... | |
RewriterBase (const OpBuilder &otherBuilder) | |
virtual | ~RewriterBase () |
Additional Inherited Members | |
![]() | |
static OpBuilder | atBlockBegin (Block *block, Listener *listener=nullptr) |
Create a builder and set the insertion point to before the first operation in the block but still inside the block. More... | |
static OpBuilder | atBlockEnd (Block *block, Listener *listener=nullptr) |
Create a builder and set the insertion point to after the last operation in the block but still inside the block. More... | |
static OpBuilder | atBlockTerminator (Block *block, Listener *listener=nullptr) |
Create a builder and set the insertion point to before the block terminator. More... | |
![]() | |
Listener * | listener |
The optional listener for events of this builder. More... | |
![]() | |
MLIRContext * | context |
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to track mutations and create new operations.
This class serves as a common API for IR mutation between pattern rewrites and non-pattern rewrites, and facilitates the development of shared IR transformation utilities.
Definition at line 399 of file PatternMatch.h.
|
inlineexplicitprotected |
Initialize the builder.
Definition at line 690 of file PatternMatch.h.
|
inlineexplicitprotected |
Definition at line 693 of file PatternMatch.h.
|
protectedvirtual |
Definition at line 226 of file PatternMatch.cpp.
|
inlinevirtual |
This method cancels a pending root update.
This can only be called on operations that were provided to a call to startRootUpdate
.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 600 of file PatternMatch.h.
Definition at line 476 of file PatternMatch.cpp.
References cloneRegionBefore(), and mlir::Block::getParent().
void RewriterBase::cloneRegionBefore | ( | Region & | region, |
Region & | parent, | ||
Region::iterator | before | ||
) |
Definition at line 471 of file PatternMatch.cpp.
References cloneRegionBefore().
|
virtual |
Clone the blocks that belong to "region" before the given position in another region "parent".
The two regions must be different. The caller is responsible for creating or updating the operation transferring flow of control to the region and passing it the correct block arguments.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 466 of file PatternMatch.cpp.
References mlir::Region::cloneInto().
Referenced by cloneRegionBefore(), mlir::ConversionPatternRewriter::cloneRegionBefore(), fuseWithReshapeByExpansion(), inlineIfCase(), and inlineWhileCase().
|
virtual |
This method erases all operations in a block.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 375 of file PatternMatch.cpp.
Referenced by inlineIfCase(), inlineWhileCase(), ConvertTypesInSCFForOp::matchAndRewrite(), moveRegionToNewWarpOpAndReplaceReturns(), and replaceForAllWithNewSignature().
|
virtual |
This method erases an operation that is known to have no uses.
The uses of the given operation must be known to be dead.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 306 of file PatternMatch.cpp.
Referenced by mlir::memref::allocToAlloca(), applyTilingToAll(), mlir::NVVM::PtxBuilder::buildAndReplaceOp(), deleteDeadness(), destructureSlot(), mlir::linalg::fuseElementwiseOps(), inlineIfCase(), inlineWhileCase(), mlir::sparse_tensor::insertYieldOp(), mlir::LLVM::SplitStores::matchAndRewrite(), mlir::linalg::LinalgCopyVTRForwardingPattern::matchAndRewrite(), mlir::linalg::LinalgCopyVTWForwardingPattern::matchAndRewrite(), mlir::memref::multiBuffer(), mlir::outlineSingleBlockRegion(), mlir::scf::pipelineForLoop(), mlir::scf::promote(), replaceForOpWithNewSignature(), rewriteOneForallCommonImpl(), mlir::vector::splitFullAndPartialTransfer(), tileAndFuseFirstExtractUseThroughContainingOpBlockArgument(), and mlir::scf::tileAndFuseProducerOfSlice().
|
virtual |
This method is used to signal the end of a root update on the given operation.
This can only be called on operations that were provided to a call to startRootUpdate
.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 383 of file PatternMatch.cpp.
Referenced by mlir::linalg::interchangeGenericOp(), padThroughLoopIterArg(), and updateRootInPlace().
|
virtual |
Inline the operations of block 'source' into block 'dest' before the given position.
The source block will be deleted and must have no uses. 'argValues' is used to replace the block arguments of 'source'.
If the source block is inserted at the end of the dest block, the dest block must have no successors. Similarly, if the source block is inserted somewhere in the middle (or beginning) of the dest block, the source block must have no successors. Otherwise, the resulting IR would have unreachable operations.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 400 of file PatternMatch.cpp.
References mlir::Block::end(), mlir::Block::erase(), mlir::Block::getArguments(), mlir::Block::getNumArguments(), mlir::Block::getOperations(), mlir::Block::hasNoPredecessors(), mlir::Block::hasNoSuccessors(), and replaceAllUsesWith().
Referenced by mlir::sparse_tensor::insertYieldOp(), mergeBlocks(), and mlir::scf::promote().
void RewriterBase::inlineBlockBefore | ( | Block * | source, |
Operation * | op, | ||
ValueRange | argValues = std::nullopt |
||
) |
Inline the operations of block 'source' before the operation 'op'.
The source block will be deleted and must have no uses. 'argValues' is used to replace the block arguments of 'source'
The source block must have no successors. Otherwise, the resulting IR would have unreachable operations.
Definition at line 434 of file PatternMatch.cpp.
Definition at line 458 of file PatternMatch.cpp.
References mlir::Block::getParent(), and inlineRegionBefore().
|
virtual |
Move the blocks that belong to "region" before the given position in another region "parent".
Move the blocks that belong to "region" before the given position in another region.
The two regions must be different. The caller is responsible for creating or updating the operation transferring flow of control to the region and passing it the correct block arguments.
The two regions must be different. The caller is in charge to update create the operation transferring the control flow to the region and pass it the correct block arguments.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 454 of file PatternMatch.cpp.
References mlir::Region::getBlocks().
Referenced by createDecl(), mlir::linalg::dropUnitDims(), mlir::linalg::generalizeNamedOp(), inlineRegionBefore(), mlir::ConversionPatternRewriter::inlineRegionBefore(), ConvertTypesInSCFForOp::matchAndRewrite(), and moveRegionToNewWarpOpAndReplaceReturns().
void RewriterBase::mergeBlocks | ( | Block * | source, |
Block * | dest, | ||
ValueRange | argValues = std::nullopt |
||
) |
Inline the operations of block 'source' into the end of block 'dest'.
The source block will be deleted and must have no uses. 'argValues' is used to replace the block arguments of 'source'
The dest block must have no successors. Otherwise, the resulting IR would have unreachable operation.
Definition at line 439 of file PatternMatch.cpp.
References mlir::Block::end(), and inlineBlockBefore().
Referenced by addInitOperandsToLoopNest(), mlir::makeRegionIsolatedFromAbove(), movePaddingToFillOrGenericOp(), mlir::outlineSingleBlockRegion(), and mlir::linalg::rewriteInDestinationPassingStyle().
|
inline |
Definition at line 684 of file PatternMatch.h.
References notifyMatchFailure().
|
inline |
Definition at line 679 of file PatternMatch.h.
References diag(), and notifyMatchFailure().
|
inline |
Used to notify the rewriter that the IR failed to be rewritten because of a match failure, and provide a callback to populate a diagnostic with the reason why the failure occurred.
This method allows for derived rewriters to optionally hook into the reason why a rewrite failed, and display it to users.
Definition at line 660 of file PatternMatch.h.
References mlir::failure(), and mlir::OpBuilder::listener.
Referenced by mlir::linalg::dropUnitDims(), elementwiseMatchAndRewriteHelper(), emitElementwiseComputation(), mlir::linalg::fuseElementwiseOps(), fuseWithReshapeByExpansion(), mlir::linalg::generalizeNamedOp(), mlir::linalg::interchangeGenericOp(), isGenericOpExpandable(), mlir::linalg::lowerPack(), mlir::linalg::lowerUnPack(), ConvertTypesInSCFForOp::matchAndRewrite(), InsertSliceOfInsertSliceFolder< OpTy >::matchAndRewrite(), mlir::linalg::GeneralizeOuterUnitDimsPackOpPattern::matchAndRewrite(), mlir::linalg::GeneralizeOuterUnitDimsUnPackOpPattern::matchAndRewrite(), ConcatSliceOptimization::matchAndRewrite(), ConsolidateTransposeOptimization::matchAndRewrite(), mlir::linalg::LinalgCopyVTRForwardingPattern::matchAndRewrite(), mlir::linalg::LinalgCopyVTWForwardingPattern::matchAndRewrite(), notifyMatchFailure(), mlir::linalg::pack(), mlir::linalg::packMatmulGreedily(), mlir::linalg::packTranspose(), mlir::linalg::padAndHoistLinalgOp(), padOperandToSmallestStaticBoundingBox(), preconditionsFoldExtractOrInsertWithTransferOp(), preconditionsFoldSubViewOpImpl(), processParallelLoop(), mlir::linalg::rewriteAsPaddedOp(), mlir::linalg::rewriteInDestinationPassingStyle(), mlir::linalg::rewriteInIm2Col(), mlir::scf::tileConsumerAndFuseProducerGreedilyUsingSCFForOp(), and mlir::detail::pdl_function_builder::verifyAsArgs().
|
inline |
Definition at line 672 of file PatternMatch.h.
|
inline |
Find uses of from
and replace them with to
except if the user is exceptedUser
.
It also marks every modified uses and notifies the rewriter that an in-place operation modification is about to happen.
Definition at line 646 of file PatternMatch.h.
References mlir::detail::IROperandBase::getOwner(), and replaceUsesWithIf().
Referenced by VectorizationState::maskOperation().
|
inline |
Definition at line 619 of file PatternMatch.h.
References mlir::IRObjectWithUseList< OperandType >::getUses().
Find uses of from
and replace them with to
.
It also marks every modified uses and notifies the rewriter that an in-place operation modification is about to happen.
Definition at line 615 of file PatternMatch.h.
References mlir::Value::getImpl().
Referenced by applyTilingToAll(), hoistSubsetAtIterArg(), inlineBlockBefore(), padThroughLoopIterArg(), peelForLoop(), mlir::scf::promote(), replaceAllUsesWith(), replaceAndPropagateMemRefType(), replaceForOpWithNewSignature(), replaceUnitMappingIdsHelper(), rewriteOneForallCommonImpl(), and mlir::scf::tileAndFuseProducerOfSlice().
|
inline |
Definition at line 625 of file PatternMatch.h.
References replaceAllUsesWith().
This method replaces the results of the operation with the specified new op (replacement).
The number of results of the two operations must match. The replaced op is erased.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 287 of file PatternMatch.cpp.
|
virtual |
This method replaces the results of the operation with the specified list of values.
The number of provided values must match the number of results of the operation. The replaced op is erased.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 268 of file PatternMatch.cpp.
Referenced by addInitOperandsToLoopNest(), mlir::linalg::bufferizeToAllocation(), mlir::NVVM::PtxBuilder::buildAndReplaceOp(), mlir::bufferization::dropEquivalentBufferResults(), mlir::linalg::dropUnitDims(), emitElementwiseComputation(), mlir::bufferization::foldToMemrefToTensorPair(), mlir::linalg::generalizeNamedOp(), generateCollapsedIndexingRegion(), mlir::linalg::lowerPack(), mlir::linalg::lowerUnPack(), CanonicalizeContractAdd< AddOpType >::matchAndRewrite(), mlir::linalg::ExtractSliceOfPadTensorSwapPattern::matchAndRewrite(), mlir::linalg::GeneralizeOuterUnitDimsPackOpPattern::matchAndRewrite(), mlir::linalg::GeneralizeOuterUnitDimsUnPackOpPattern::matchAndRewrite(), ConcatSliceOptimization::matchAndRewrite(), mlir::linalg::LinalgCopyVTRForwardingPattern::matchAndRewrite(), moveRegionToNewWarpOpAndAppendReturns(), mlir::linalg::pack(), mlir::linalg::packTranspose(), mlir::linalg::padAndHoistLinalgOp(), mlir::scf::pipelineForLoop(), mlir::linalg::DownscaleConv2DOp::returningMatchAndRewrite(), mlir::linalg::DownscaleDepthwiseConv2DNhwcHwcOp::returningMatchAndRewrite(), mlir::linalg::rewriteInDestinationPassingStyle(), mlir::linalg::rewriteInIm2Col(), PadOpVectorizationWithTransferWritePattern::rewriteUser(), tileAndFuseFirstExtractUse(), tileAndFuseFirstExtractUseThroughContainingOpBlockArgument(), transposeOneLinalgOperandAndReplace(), updateExpandedGenericOpRegion(), and mlir::linalg::vectorizeCopy().
|
virtual |
This method replaces the uses of the results of op
with the values in newValues
when the provided functor
returns true for a specific use.
The number of values in newValues
is required to match the number of results of op
. allUsesReplaced
, if non-null, is set to true if all of the uses of op
were replaced. Note that in some rewriters, the given 'functor' may be stored beyond the lifetime of the rewrite being applied. As such, the function should not capture by reference and instead use value capture as necessary.
The number of values in newValues
is required to match the number of results of op
.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 234 of file PatternMatch.cpp.
Referenced by mlir::makeRegionIsolatedFromAbove(), and mlir::linalg::offsetIndices().
|
inline |
Definition at line 513 of file PatternMatch.h.
void RewriterBase::replaceOpWithinBlock | ( | Operation * | op, |
ValueRange | newValues, | ||
Block * | block, | ||
bool * | allUsesReplaced = nullptr |
||
) |
This method replaces the uses of the results of op
with the values in newValues
when a use is nested within the given block
.
The number of values in newValues
is required to match the number of results of op
. If all uses of this operation are replaced, the operation is erased.
Definition at line 258 of file PatternMatch.cpp.
|
inline |
Replaces the result op with a new op that is created without verification.
The result values of the two ops must be the same types.
Definition at line 539 of file PatternMatch.h.
Referenced by addInitOperandsToLoopNest(), mlir::memref::allocToAlloca(), mlir::vector::castAwayContractionLeadingOneDim(), createDecl(), mlir::bufferization::foldToMemrefToTensorPair(), mlir::linalg::interchangeGenericOp(), mlir::ComposeCollapseOfExpandOp< CollapseOpTy, ExpandOpTy, CastOpTy >::matchAndRewrite(), mlir::ComposeExpandOfCollapseOp< ExpandOpTy, CollapseOpTy >::matchAndRewrite(), mlir::LLVM::CanonicalizeAlignedGep::matchAndRewrite(), mlir::LLVM::SplitGEP::matchAndRewrite(), InsertSliceOfInsertSliceFolder< OpTy >::matchAndRewrite(), mlir::ComposeReassociativeReshapeOps< ReshapeOpTy >::matchAndRewrite(), ConvertAccessChain::matchAndRewrite(), ConvertAddressOf::matchAndRewrite(), ConvertStore::matchAndRewrite(), UModSimplification::matchAndRewrite(), DeduplicateAffineMinMaxExpressions< T >::matchAndRewrite(), MergeAffineMinMaxOp< T >::matchAndRewrite(), CanonicalizeAffineMinMaxOpExprAndTermOrder< T >::matchAndRewrite(), CanonicalizeSingleResultAffineMinMaxOp< T >::matchAndRewrite(), SwapExtractSliceOfFill::matchAndRewrite(), mlir::linalg::GeneralizePadOpPattern::matchAndRewrite(), ConsolidateTransposeOptimization::matchAndRewrite(), movePaddingToFillOrGenericOp(), replaceUnitDimIndexOps(), mlir::linalg::rewriteInDestinationPassingStyle(), PadOpVectorizationWithInsertSlicePattern::rewriteUser(), PadOpVectorizationWithTransferWritePattern::rewriteUser(), mlir::linalg::specializeGenericOp(), and GenericPadOpVectorizationPattern::tryVectorizeCopy().
void RewriterBase::replaceUsesWithIf | ( | Value | from, |
Value | to, | ||
function_ref< bool(OpOperand &)> | functor | ||
) |
Find uses of from
and replace them with to
if the functor
returns true.
It also marks every modified uses and notifies the rewriter that an in-place operation modification is about to happen.
Definition at line 392 of file PatternMatch.cpp.
References mlir::Value::getUses(), and updateRootInPlace().
Referenced by mlir::makeRegionIsolatedFromAbove(), replaceAllUsesExcept(), replaceForAllWithNewSignature(), and replaceUsesWithIf().
|
inline |
Definition at line 636 of file PatternMatch.h.
References replaceUsesWithIf().
|
virtual |
Split the operations starting at "before" (inclusive) out of the given block into a new block, and return it.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 446 of file PatternMatch.cpp.
References mlir::Block::splitBlock().
Referenced by mlir::ConversionPatternRewriter::splitBlock().
|
inlinevirtual |
This method is used to notify the rewriter that an in-place operation modification is about to happen.
A call to this function must be followed by a call to either finalizeRootUpdate
or cancelRootUpdate
. This is a minor efficiency win (it avoids creating a new operation and removing the old one) but also often allows simpler code in the client.
Reimplemented in mlir::ConversionPatternRewriter.
Definition at line 591 of file PatternMatch.h.
Referenced by mlir::linalg::interchangeGenericOp(), padThroughLoopIterArg(), and updateRootInPlace().
|
inline |
This method is a utility wrapper around a root update of an operation.
It wraps calls to startRootUpdate
and finalizeRootUpdate
around the given callable.
Definition at line 606 of file PatternMatch.h.
References finalizeRootUpdate(), and startRootUpdate().
Referenced by cloneAndFuseFirstUse(), convertFuncOpTypes(), mlir::LLVM::BitcastStores::matchAndRewrite(), moveRegionToNewWarpOpAndReplaceReturns(), peelForLoop(), replaceAndPropagateMemRefType(), replaceUsesWithIf(), PadOpVectorizationWithTransferReadPattern::rewriteUser(), mlir::vector::splitFullAndPartialTransfer(), tileAndFuseFirstExtractUseThroughContainingOpBlockArgument(), updateDeallocIfChanged(), and mlir::scf::yieldReplacementForFusedProducer().