MLIR  20.0.0git
Classes | Public Member Functions | Protected Member Functions | List of all members
mlir::RewriterBase Class Reference

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"

+ Inheritance diagram for mlir::RewriterBase:

Classes

struct  ForwardingListener
 A listener that forwards all notifications to another listener. More...
 
struct  Listener
 

Public Member Functions

void inlineRegionBefore (Region &region, Region &parent, Region::iterator before)
 Move the blocks that belong to "region" before the given position in another region "parent". More...
 
void inlineRegionBefore (Region &region, Block *before)
 
virtual void replaceOp (Operation *op, ValueRange newValues)
 Replace the results of the given (original) operation with the specified list of values (replacements). More...
 
virtual void replaceOp (Operation *op, Operation *newOp)
 Replace the results of the given (original) operation with the specified new op (replacement). More...
 
template<typename OpTy , typename... Args>
OpTy replaceOpWithNewOp (Operation *op, Args &&...args)
 Replace the results of the given (original) op with a new op that is created without verification (replacement). 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...
 
BlocksplitBlock (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...
 
void moveOpBefore (Operation *op, Operation *existingOp)
 Unlink this operation from its current block and insert it right before existingOp which may be in the same or another block in the same function. More...
 
void moveOpBefore (Operation *op, Block *block, Block::iterator iterator)
 Unlink this operation from its current block and insert it right before iterator in the specified block. More...
 
void moveOpAfter (Operation *op, Operation *existingOp)
 Unlink this operation from its current block and insert it right after existingOp which may be in the same or another block in the same function. More...
 
void moveOpAfter (Operation *op, Block *block, Block::iterator iterator)
 Unlink this operation from its current block and insert it right after iterator in the specified block. More...
 
void moveBlockBefore (Block *block, Block *anotherBlock)
 Unlink this block and insert it right before existingBlock. More...
 
void moveBlockBefore (Block *block, Region *region, Region::iterator iterator)
 Unlink this block and insert it right before the location that the given iterator points to in the given region. More...
 
virtual void startOpModification (Operation *op)
 This method is used to notify the rewriter that an in-place operation modification is about to happen. More...
 
virtual void finalizeOpModification (Operation *op)
 This method is used to signal the end of an in-place modification of the given operation. More...
 
virtual void cancelOpModification (Operation *op)
 This method cancels a pending in-place modification. More...
 
template<typename CallableT >
void modifyOpInPlace (Operation *root, CallableT &&callable)
 This method is a utility wrapper around an in-place modification of an operation. More...
 
void replaceAllUsesWith (Value from, Value to)
 Find uses of from and replace them with to. More...
 
void replaceAllUsesWith (Block *from, Block *to)
 
void replaceAllUsesWith (ValueRange from, ValueRange to)
 
void replaceAllOpUsesWith (Operation *from, ValueRange to)
 Find uses of from and replace them with to. More...
 
void replaceAllOpUsesWith (Operation *from, Operation *to)
 
void replaceUsesWithIf (Value from, Value to, function_ref< bool(OpOperand &)> functor, bool *allUsesReplaced=nullptr)
 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, bool *allUsesReplaced=nullptr)
 
void replaceOpUsesWithIf (Operation *from, ValueRange to, function_ref< bool(OpOperand &)> functor, bool *allUsesReplaced=nullptr)
 
void replaceOpUsesWithinBlock (Operation *op, ValueRange newValues, Block *block, bool *allUsesReplaced=nullptr)
 Find uses of from within block and replace them with to. More...
 
void replaceAllUsesExcept (Value from, Value to, Operation *exceptedUser)
 Find uses of from and replace them with to except if the user is exceptedUser. More...
 
void replaceAllUsesExcept (Value from, Value to, const SmallPtrSetImpl< Operation * > &preservedUsers)
 
template<typename CallbackT >
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure (Location loc, CallbackT &&reasonCallback)
 Used to notify the listener 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)
 
- Public Member Functions inherited from mlir::OpBuilder
 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 &region, 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...
 
ListenergetListener () 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...
 
BlockgetInsertionBlock () const
 Return the block the current insertion point belongs to. More...
 
Block::iterator getInsertionPoint () const
 Returns the current insertion point of the builder. More...
 
BlockgetBlock () const
 Returns the current block of the builder. More...
 
BlockcreateBlock (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...
 
BlockcreateBlock (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...
 
Operationinsert (Operation *op)
 Insert the given operation at the current insertion point and return it. More...
 
Operationcreate (const OperationState &state)
 Creates an operation given the fields represented as an OperationState. More...
 
Operationcreate (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 >), ValuecreateOrFold (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...
 
Operationclone (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...
 
Operationclone (Operation &op)
 
OperationcloneWithoutRegions (Operation &op, IRMapping &mapper)
 Creates a deep copy of this operation but keep the operation regions empty. More...
 
OperationcloneWithoutRegions (Operation &op)
 
template<typename OpT >
OpT cloneWithoutRegions (OpT op)
 
void cloneRegionBefore (Region &region, 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 &region, Region &parent, Region::iterator before)
 
void cloneRegionBefore (Region &region, Block *before)
 
- Public Member Functions inherited from mlir::Builder
 Builder (MLIRContext *context)
 
 Builder (Operation *op)
 
MLIRContextgetContext () const
 
Location getUnknownLoc ()
 
Location getFusedLoc (ArrayRef< Location > locs, Attribute metadata=Attribute())
 
FloatType getFloat4E2M1FNType ()
 
FloatType getFloat6E2M3FNType ()
 
FloatType getFloat6E3M2FNType ()
 
FloatType getFloat8E5M2Type ()
 
FloatType getFloat8E4M3Type ()
 
FloatType getFloat8E4M3FNType ()
 
FloatType getFloat8E5M2FNUZType ()
 
FloatType getFloat8E4M3FNUZType ()
 
FloatType getFloat8E4M3B11FNUZType ()
 
FloatType getFloat8E3M4Type ()
 
FloatType getFloat8E8M0FNUType ()
 
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)
 
TypedAttr getOneAttr (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)
 
 RewriterBase (Operation *op, OpBuilder::Listener *listener=nullptr)
 
virtual ~RewriterBase ()
 

Additional Inherited Members

- Static Public Member Functions inherited from mlir::OpBuilder
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...
 
- Protected Attributes inherited from mlir::OpBuilder
Listenerlistener
 The optional listener for events of this builder. More...
 
- Protected Attributes inherited from mlir::Builder
MLIRContextcontext
 

Detailed Description

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 400 of file PatternMatch.h.

Constructor & Destructor Documentation

◆ RewriterBase() [1/3]

mlir::RewriterBase::RewriterBase ( MLIRContext ctx,
OpBuilder::Listener listener = nullptr 
)
inlineexplicitprotected

Initialize the builder.

Definition at line 750 of file PatternMatch.h.

◆ RewriterBase() [2/3]

mlir::RewriterBase::RewriterBase ( const OpBuilder otherBuilder)
inlineexplicitprotected

Definition at line 753 of file PatternMatch.h.

◆ RewriterBase() [3/3]

mlir::RewriterBase::RewriterBase ( Operation op,
OpBuilder::Listener listener = nullptr 
)
inlineexplicitprotected

Definition at line 755 of file PatternMatch.h.

◆ ~RewriterBase()

RewriterBase::~RewriterBase ( )
protectedvirtual

Definition at line 110 of file PatternMatch.cpp.

Member Function Documentation

◆ cancelOpModification()

virtual void mlir::RewriterBase::cancelOpModification ( Operation op)
inlinevirtual

This method cancels a pending in-place modification.

This can only be called on operations that were provided to a call to startOpModification.

Reimplemented in mlir::ConversionPatternRewriter.

Definition at line 630 of file PatternMatch.h.

◆ eraseBlock()

void RewriterBase::eraseBlock ( Block block)
virtual

◆ eraseOp()

void RewriterBase::eraseOp ( Operation op)
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::detail::ConversionPatternRewriterImpl::SingleEraseRewriter, and mlir::ConversionPatternRewriter.

Definition at line 161 of file PatternMatch.cpp.

References mlir::Operation::erase(), mlir::OpBuilder::listener, and mlir::Operation::use_empty().

Referenced by mlir::memref::allocToAlloca(), applyTilingToAll(), mlir::linalg::bufferizeToAllocation(), mlir::NVVM::PtxBuilder::buildAndReplaceOp(), mlir::coalesceLoops(), convertTransferWriteOp(), convertTransferWriteToStores(), convertYieldOp(), mlir::nvgpu::createAsyncGroups(), deleteDeadness(), eraseBlock(), mlir::memref::eraseDeadAllocAndStores(), mlir::detail::ConversionPatternRewriterImpl::SingleEraseRewriter::eraseOp(), mlir::arm_sme::eraseTriviallyDeadTileOps(), mlir::linalg::fuseElementwiseOps(), genCoIterateBranchNest(), genForeachOnSparseConstant(), genLoopWithIterator(), inlineIfCase(), inlineWhileCase(), mlir::sparse_tensor::insertYieldOp(), AllocaScopeInliner::matchAndRewrite(), MultiBlockExecuteInliner::matchAndRewrite(), VectorizeConvolution::matchAndRewrite(), mlir::linalg::LinalgCopyVTRForwardingPattern::matchAndRewrite(), mlir::linalg::LinalgCopyVTWForwardingPattern::matchAndRewrite(), mlir::memref::multiBuffer(), mlir::outlineSingleBlockRegion(), mlir::scf::pipelineForLoop(), mlir::scf::promote(), mlir::scf::replaceAndCastForOpIterArg(), replaceForOpWithNewSignature(), replaceOp(), replaceOpWithRegion(), replaceUsesAndPropagateType(), CopyBuilder::rewrite(), rewriteOneForallCommonImpl(), simplifyBrToBlockWithSinglePred(), mlir::vector::splitFullAndPartialTransfer(), mlir::scf::tileAndFuseConsumerOfSlice(), tileAndFuseFirstExtractUseThroughContainingOpBlockArgument(), mlir::scf::tileAndFuseProducerOfSlice(), mlir::linalg::tileReductionUsingForall(), mlir::scf::tileReductionUsingScf(), and mlir::scf::tileUsingSCF().

◆ finalizeOpModification()

void RewriterBase::finalizeOpModification ( Operation op)
virtual

This method is used to signal the end of an in-place modification of the given operation.

This can only be called on operations that were provided to a call to startOpModification.

Reimplemented in mlir::ConversionPatternRewriter.

Definition at line 248 of file PatternMatch.cpp.

References mlir::OpBuilder::listener.

Referenced by mlir::ConversionPatternRewriter::finalizeOpModification(), mlir::linalg::interchangeGenericOp(), RemoveUnusedLvlCrds::matchAndRewrite(), modifyOpInPlace(), padThroughLoopIterArg(), mlir::affine::reorderOperandsByHoistability(), and replaceUsesAndPropagateType().

◆ inlineBlockBefore() [1/2]

void RewriterBase::inlineBlockBefore ( Block source,
Block dest,
Block::iterator  before,
ValueRange  argValues = std::nullopt 
)
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 291 of file PatternMatch.cpp.

References mlir::Block::empty(), mlir::Block::end(), eraseBlock(), mlir::Block::front(), mlir::Block::getArguments(), mlir::Block::getNumArguments(), mlir::Block::getOperations(), mlir::Block::hasNoPredecessors(), mlir::Block::hasNoSuccessors(), mlir::OpBuilder::listener, moveOpBefore(), and replaceAllUsesWith().

Referenced by mlir::coalesceLoops(), fuseIfLegal(), genForeachOnSparseConstant(), inlineBlockBefore(), mlir::sparse_tensor::insertYieldOp(), AllocaScopeInliner::matchAndRewrite(), mergeBlocks(), mlir::scf::promote(), and replaceOpWithRegion().

◆ inlineBlockBefore() [2/2]

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 334 of file PatternMatch.cpp.

References mlir::Operation::getBlock(), and inlineBlockBefore().

◆ inlineRegionBefore() [1/2]

void RewriterBase::inlineRegionBefore ( Region region,
Block before 
)

Definition at line 384 of file PatternMatch.cpp.

References mlir::Block::getParent(), and inlineRegionBefore().

◆ inlineRegionBefore() [2/2]

void RewriterBase::inlineRegionBefore ( Region region,
Region parent,
Region::iterator  before 
)

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.

Definition at line 372 of file PatternMatch.cpp.

References mlir::Region::empty(), mlir::Region::front(), mlir::Region::getBlocks(), mlir::OpBuilder::listener, and moveBlockBefore().

Referenced by mlir::convertFuncOpToLLVMFuncOp(), createDecl(), mlir::linalg::dropUnitDims(), mlir::linalg::generalizeNamedOp(), inlineRegionBefore(), lowerAsEntryFunction(), MultiBlockExecuteInliner::matchAndRewrite(), ConvertTypesInSCFForOp::matchAndRewrite(), mlir::GPUFuncOpLowering::matchAndRewrite(), ConvertTypesInSCFIfOp::matchAndRewrite(), ConvertTypesInSCFWhileOp::matchAndRewrite(), moveRegionToNewWarpOpAndReplaceReturns(), mlir::normalizeForallOp(), mlir::linalg::splitReduction(), mlir::linalg::splitReductionByScaling(), and wrapInExecuteRegion().

◆ mergeBlocks()

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 339 of file PatternMatch.cpp.

References mlir::Block::end(), and inlineBlockBefore().

Referenced by addInitOperandsToLoopNest(), cloneToCollapsedOp< GenericOp >(), mlir::makeRegionIsolatedFromAbove(), movePaddingToFillOrGenericOp(), normalizeForallLoopOp(), mlir::outlineSingleBlockRegion(), mlir::scf::replaceAndCastForOpIterArg(), replaceWithDifferentYield(), mlir::linalg::rewriteInDestinationPassingStyle(), and simplifyBrToBlockWithSinglePred().

◆ modifyOpInPlace()

template<typename CallableT >
void mlir::RewriterBase::modifyOpInPlace ( Operation root,
CallableT &&  callable 
)
inline

◆ moveBlockBefore() [1/2]

void RewriterBase::moveBlockBefore ( Block block,
Block anotherBlock 
)

Unlink this block and insert it right before existingBlock.

Definition at line 388 of file PatternMatch.cpp.

References mlir::Block::getParent().

Referenced by inlineRegionBefore().

◆ moveBlockBefore() [2/2]

void RewriterBase::moveBlockBefore ( Block block,
Region region,
Region::iterator  iterator 
)

Unlink this block and insert it right before the location that the given iterator points to in the given region.

Definition at line 393 of file PatternMatch.cpp.

References mlir::Block::getParent(), mlir::OpBuilder::listener, mlir::Block::moveBefore(), and mlir::OpBuilder::Listener::notifyBlockInserted().

◆ moveOpAfter() [1/2]

void RewriterBase::moveOpAfter ( Operation op,
Block block,
Block::iterator  iterator 
)

Unlink this operation from its current block and insert it right after iterator in the specified block.

Definition at line 421 of file PatternMatch.cpp.

References mlir::Block::end(), and moveOpBefore().

◆ moveOpAfter() [2/2]

void RewriterBase::moveOpAfter ( Operation op,
Operation existingOp 
)

Unlink this operation from its current block and insert it right after existingOp which may be in the same or another block in the same function.

Definition at line 417 of file PatternMatch.cpp.

References mlir::Operation::getBlock().

Referenced by mlir::linalg::hoistRedundantVectorBroadcasts(), and hoistSubsetAtIterArg().

◆ moveOpBefore() [1/2]

void RewriterBase::moveOpBefore ( Operation op,
Block block,
Block::iterator  iterator 
)

Unlink this operation from its current block and insert it right before iterator in the specified block.

Definition at line 407 of file PatternMatch.cpp.

References mlir::Operation::getBlock(), mlir::OpBuilder::listener, mlir::Operation::moveBefore(), and mlir::OpBuilder::Listener::notifyOperationInserted().

◆ moveOpBefore() [2/2]

void RewriterBase::moveOpBefore ( Operation op,
Operation existingOp 
)

Unlink this operation from its current block and insert it right before existingOp which may be in the same or another block in the same function.

Definition at line 403 of file PatternMatch.cpp.

References mlir::Operation::getBlock().

Referenced by mlir::detail::ConversionPatternRewriterImpl::applySignatureConversion(), getConsumerFromLoopUses(), hoistSubsetAtIterArg(), inlineBlockBefore(), moveOpAfter(), splitBlock(), and mlir::scf::tileAndFuseConsumerOfSlice().

◆ notifyMatchFailure() [1/4]

template<typename ArgT >
LogicalResult mlir::RewriterBase::notifyMatchFailure ( ArgT &&  arg,
const char *  msg 
)
inline

Definition at line 744 of file PatternMatch.h.

References notifyMatchFailure().

◆ notifyMatchFailure() [2/4]

template<typename ArgT >
LogicalResult mlir::RewriterBase::notifyMatchFailure ( ArgT &&  arg,
const Twine &  msg 
)
inline

Definition at line 739 of file PatternMatch.h.

References diag(), and notifyMatchFailure().

◆ notifyMatchFailure() [3/4]

template<typename CallbackT >
std::enable_if_t<!std::is_convertible<CallbackT, Twine>::value, LogicalResult> mlir::RewriterBase::notifyMatchFailure ( Location  loc,
CallbackT &&  reasonCallback 
)
inline

Used to notify the listener 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 724 of file PatternMatch.h.

References mlir::OpBuilder::listener.

Referenced by alignedConversionPrecondition(), areAllLLVMTypes(), mlir::linalg::blockPackMatmul(), canonicalizeAssociativeCommutativeBinaryOp(), mlir::tosa::checkHasDynamicBatchDims(), checkSourceOpTypes(), mlir::linalg::collapseOpIterationDims(), commonConversionPrecondition(), convertCastingOp(), convertConstantOpMmaSync(), convertContractOp(), convertContractOpToMmaSync(), convertElementwiseOp(), convertExtractStridedSlice(), mlir::convertFuncOpToLLVMFuncOp(), mlir::convertOpResultTypes(), convertRoundEvenOp(), convertRoundOp(), convertTransferReadOp(), convertTransferReadToLoads(), convertTransferWriteOp(), convertTransferWriteToStores(), createLinalgBodyCalculationForElementwiseOp(), createNonLdMatrixLoads(), creatLdMatrixCompatibleLoads(), mlir::linalg::dropUnitDims(), elementwiseMatchAndRewriteHelper(), emitElementwiseComputation(), mlir::linalg::fuseElementwiseOps(), mlir::linalg::generalizeNamedOp(), generateLoopNest(), generateLoopNestUsingForallOp(), generateLoopNestUsingForOp(), getLibraryCallSymbolRef(), getTypeConversionFailure(), insertCasts(), mlir::linalg::interchangeGenericOp(), isAsyncWithOneDependency(), isLinalgOpExpandable(), legalizeBlockArguments(), mlir::linalg::lowerPack(), mlir::scf::lowerToLoopsUsingSCFForOp(), YieldOpLowering::matchAndRewrite(), AssertOpLowering::matchAndRewrite(), ConvertTypesInSCFForOp::matchAndRewrite(), mlir::GPUFuncOpLowering::matchAndRewrite(), mlir::GPUReturnOpLowering::matchAndRewrite(), GPUSubgroupReduceConversion::matchAndRewrite(), FoldAddIntoDest::matchAndRewrite(), mlir::math::ErfPolynomialApproximation::matchAndRewrite(), mlir::spirv::ElementwiseOpPattern< Op, SPIRVOp >::matchAndRewrite(), InsertSliceOfInsertSliceFolder< OpTy >::matchAndRewrite(), mlir::OpToFuncCallLowering< SourceOp >::matchAndRewrite(), ConvertAccessChain::matchAndRewrite(), ConvertLoad::matchAndRewrite(), ConvertStore::matchAndRewrite(), mlir::linalg::DecomposeOuterUnitDimsPackOpPattern::matchAndRewrite(), mlir::linalg::DecomposeOuterUnitDimsUnPackOpPattern::matchAndRewrite(), MaterializePadValue::matchAndRewrite(), ConcatSliceOptimization::matchAndRewrite(), TransposeIsReshape::matchAndRewrite(), ConsolidateTransposeOptimization::matchAndRewrite(), mlir::linalg::LinalgCopyVTRForwardingPattern::matchAndRewrite(), mlir::linalg::LinalgCopyVTWForwardingPattern::matchAndRewrite(), TransposeOpLowering::matchAndRewrite(), notifyMatchFailure(), mlir::linalg::pack(), mlir::linalg::packMatmulGreedily(), mlir::linalg::packTranspose(), mlir::linalg::padAndHoistLinalgOp(), padOperandToSmallestStaticBoundingBox(), preconditionsFoldExtractOrInsertWithTransferOp(), preconditionsFoldSubViewOpImpl(), processParallelLoop(), reduceMatchAndRewriteHelper(), replaceWithLoadOrStore(), mlir::linalg::rewriteAsPaddedOp(), mlir::linalg::rewriteInDestinationPassingStyle(), mlir::linalg::rewriteInIm2Col(), mlir::impl::scalarizeVectorOp(), mlir::linalg::splitReduction(), mlir::linalg::splitReductionByScaling(), mlir::scf::tileAndFuseConsumerOfSlice(), mlir::scf::tileConsumerAndFuseProducersUsingSCF(), mlir::linalg::tileReductionUsingForall(), mlir::scf::tileReductionUsingScf(), mlir::scf::tileUsingSCF(), mlir::linalg::transposeBatchMatmul(), mlir::linalg::transposeMatmul(), validateDynamicDimExpansion(), verifyTileSizeOptions(), and yieldTiledValuesAndReplaceLoop().

◆ notifyMatchFailure() [4/4]

template<typename CallbackT >
std::enable_if_t<!std::is_convertible<CallbackT, Twine>::value, LogicalResult> mlir::RewriterBase::notifyMatchFailure ( Operation op,
CallbackT &&  reasonCallback 
)
inline

Definition at line 732 of file PatternMatch.h.

References mlir::Operation::getLoc(), and mlir::OpBuilder::listener.

◆ replaceAllOpUsesWith() [1/2]

void RewriterBase::replaceAllOpUsesWith ( Operation from,
Operation to 
)

◆ replaceAllOpUsesWith() [2/2]

void RewriterBase::replaceAllOpUsesWith ( Operation from,
ValueRange  to 
)

Find uses of from and replace them with to.

Also notify the listener about every in-place op modification (for every use that was replaced) and that the from operation is about to be replaced.

Note: This function cannot be called replaceAllUsesWith because the overload resolution, when called with an op that can be implicitly converted to a Value, would be ambiguous.

Definition at line 114 of file PatternMatch.cpp.

References mlir::Operation::getResults(), mlir::OpBuilder::listener, and replaceAllUsesWith().

Referenced by FoldAddIntoDest::matchAndRewrite(), mlir::normalizeForallOp(), and replaceOp().

◆ replaceAllUsesExcept() [1/2]

void RewriterBase::replaceAllUsesExcept ( Value  from,
Value  to,
const SmallPtrSetImpl< Operation * > &  preservedUsers 
)

◆ replaceAllUsesExcept() [2/2]

void mlir::RewriterBase::replaceAllUsesExcept ( Value  from,
Value  to,
Operation exceptedUser 
)
inline

Find uses of from and replace them with to except if the user is exceptedUser.

Also notify the listener about every in-place op modification (for every use that was replaced).

Definition at line 708 of file PatternMatch.h.

References mlir::detail::IROperandBase::getOwner(), and replaceUsesWithIf().

Referenced by mlir::coalesceLoops(), mlir::denormalizeInductionVariable(), denormalizeInductionVariableForIndexType(), and VectorizationState::maskOperation().

◆ replaceAllUsesWith() [1/3]

void mlir::RewriterBase::replaceAllUsesWith ( Block from,
Block to 
)
inline

◆ replaceAllUsesWith() [2/3]

void mlir::RewriterBase::replaceAllUsesWith ( Value  from,
Value  to 
)
inline

◆ replaceAllUsesWith() [3/3]

void mlir::RewriterBase::replaceAllUsesWith ( ValueRange  from,
ValueRange  to 
)
inline

Definition at line 656 of file PatternMatch.h.

References replaceAllUsesWith().

◆ replaceOp() [1/2]

void RewriterBase::replaceOp ( Operation op,
Operation newOp 
)
virtual

Replace the results of the given (original) operation with the specified new op (replacement).

This method replaces the results of the operation with the specified new op (replacement).

The result types of the two ops must match. The original op is erased.

The number of results of the two operations must match. The replaced op is erased.

Reimplemented in mlir::ConversionPatternRewriter.

Definition at line 147 of file PatternMatch.cpp.

References eraseOp(), mlir::Operation::getNumResults(), mlir::Operation::getResults(), and replaceAllOpUsesWith().

◆ replaceOp() [2/2]

void RewriterBase::replaceOp ( Operation op,
ValueRange  newValues 
)
virtual

Replace the results of the given (original) operation with the specified list of values (replacements).

This method replaces the results of the operation with the specified list of values.

The result types of the given op and the replacements must match. The original op is erased.

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 133 of file PatternMatch.cpp.

References eraseOp(), mlir::Operation::getNumResults(), and replaceAllOpUsesWith().

Referenced by addInitOperandsToLoopNest(), mlir::applyPartialOneToNConversion(), mlir::linalg::bufferizeToAllocation(), mlir::NVVM::PtxBuilder::buildAndReplaceOp(), mlir::coalesceLoops(), convertAcoshOp(), convertAffineApply(), convertAsinhOp(), convertAtanhOp(), convertCeilOp(), convertCoshOp(), convertCtlzOp(), convertExp2fOp(), convertFloorOp(), convertFmaFOp(), convertFPowIOp(), convertPowfOp(), convertRoundEvenOp(), convertRoundOp(), convertSinhOp(), convertTanOp(), mlir::bufferization::dropEquivalentBufferResults(), mlir::bufferization::foldToMemrefToTensorPair(), mlir::fuseIndependentSiblingForallLoops(), mlir::fuseIndependentSiblingForLoops(), mlir::linalg::generalizeNamedOp(), generateCollapsedIndexingRegion(), genForeachOnSparseConstant(), mlir::OperationFolder::insertKnownConstant(), legalizeUnresolvedMaterialization(), mlir::linalg::lowerPack(), mlir::linalg::lowerUnPack(), CanonicalizeContractAdd< AddOpType >::matchAndRewrite(), AllocaScopeInliner::matchAndRewrite(), FoldTensorCastProducerOp::matchAndRewrite(), MultiBlockExecuteInliner::matchAndRewrite(), Convert1DExtractStridedSliceIntoExtractInsertChain::matchAndRewrite(), DecomposeNDExtractStridedSlice::matchAndRewrite(), IndexSwitchOpLowering::matchAndRewrite(), ConvertSameRankInsertStridedSliceIntoShuffle::matchAndRewrite(), VectorizeConvolution::matchAndRewrite(), mlir::math::ErfPolynomialApproximation::matchAndRewrite(), FoldTensorCastPackOp::matchAndRewrite(), mlir::linalg::ExtractSliceOfPadTensorSwapPattern::matchAndRewrite(), mlir::linalg::DecomposeOuterUnitDimsPackOpPattern::matchAndRewrite(), mlir::linalg::DecomposeOuterUnitDimsUnPackOpPattern::matchAndRewrite(), ClampIsNoOp::matchAndRewrite(), ConcatOptimization::matchAndRewrite(), MaxPool2dIsNoOp::matchAndRewrite(), ConcatSliceOptimization::matchAndRewrite(), mlir::linalg::LinalgCopyVTRForwardingPattern::matchAndRewrite(), moveRegionToNewWarpOpAndAppendReturns(), normalizeForallLoopOp(), SliceCanonicalizer::operator()(), mlir::linalg::pack(), mlir::linalg::packTranspose(), mlir::linalg::padAndHoistLinalgOp(), mlir::scf::pipelineForLoop(), mlir::bufferization::replaceOpWithBufferizedValues(), replaceOpWithNewOp(), replaceOpWithPredicatedOp(), replaceOpWithRegion(), replaceWithDifferentYield(), mlir::linalg::DownscaleSizeOneWindowed2DConvolution< Conv2DOp, Conv1DOp >::returningMatchAndRewrite(), mlir::linalg::DownscaleConv2DOp::returningMatchAndRewrite(), mlir::linalg::DownscaleDepthwiseConv2DNhwcHwcOp::returningMatchAndRewrite(), mlir::linalg::rewriteInDestinationPassingStyle(), mlir::linalg::rewriteInIm2Col(), PadOpVectorizationWithTransferWritePattern::rewriteUser(), mlir::tensor::simplifyCollapseShapeWithRankReducingExtractSlice(), mlir::linalg::splitOp(), mlir::linalg::splitReduction(), mlir::linalg::splitReductionByScaling(), tileAndFuseFirstExtractUse(), tileAndFuseFirstExtractUseThroughContainingOpBlockArgument(), mlir::linalg::tileReductionUsingForall(), mlir::linalg::transposeBatchMatmul(), mlir::linalg::transposeMatmul(), transposeOneLinalgOperandAndReplace(), mlir::OperationFolder::tryToFold(), updateExpandedGenericOpRegion(), mlir::linalg::vectorizeCopy(), and wrapInExecuteRegion().

◆ replaceOpUsesWithIf()

void mlir::RewriterBase::replaceOpUsesWithIf ( Operation from,
ValueRange  to,
function_ref< bool(OpOperand &)>  functor,
bool *  allUsesReplaced = nullptr 
)
inline

◆ replaceOpUsesWithinBlock()

void mlir::RewriterBase::replaceOpUsesWithinBlock ( Operation op,
ValueRange  newValues,
Block block,
bool *  allUsesReplaced = nullptr 
)
inline

Find uses of from within block and replace them with to.

Also notify the listener about every in-place op modification (for every use that was replaced). The optional allUsesReplaced flag is set to "true" if all uses were replaced.

Definition at line 695 of file PatternMatch.h.

References mlir::detail::IROperandBase::getOwner(), mlir::Block::getParentOp(), and replaceOpUsesWithIf().

◆ replaceOpWithNewOp()

template<typename OpTy , typename... Args>
OpTy mlir::RewriterBase::replaceOpWithNewOp ( Operation op,
Args &&...  args 
)
inline

Replace the results of the given (original) op with a new op that is created without verification (replacement).

The result values of the two ops must match. The original op is erased.

Definition at line 542 of file PatternMatch.h.

References mlir::Operation::getLoc(), and replaceOp().

Referenced by addInitOperandsToLoopNest(), mlir::memref::allocToAlloca(), canonicalizeAssociativeCommutativeBinaryOp(), canonicalizeMinMaxOp(), convertCastingOp(), convertRsqrtOp(), convertTanhOp(), createDecl(), mlir::createElementwiseOp(), dropSwitchCasesThatMatchDefault(), foldSwitch(), mlir::bufferization::foldToMemrefToTensorPair(), genResult(), insertCasts(), matchAndReplaceDepthwiseConv(), MergeArithBitcast::matchAndRewrite(), SelectToExtUI::matchAndRewrite(), MergeComplexBitcast::matchAndRewrite(), CmpFIntToFPConst::matchAndRewrite(), mlir::ComposeCollapseOfExpandOp< CollapseOpTy, ExpandOpTy, CastOpTy, DimOpTy, TensorTy >::matchAndRewrite(), CollapseShapeOpMemRefCastFolder::matchAndRewrite(), mlir::ComposeExpandOfCollapseOp< ExpandOpTy, CollapseOpTy >::matchAndRewrite(), Convert1DExtractStridedSliceIntoShuffle::matchAndRewrite(), mlir::GPUReturnOpLowering::matchAndRewrite(), DecomposeDifferentRankInsertStridedSlice::matchAndRewrite(), ConvertSameRankInsertStridedSliceIntoShuffle::matchAndRewrite(), FoldTransposeWithTranspose::matchAndRewrite(), SwapTransposeWithBroadcast::matchAndRewrite(), mlir::linalg::LinalgOpToLibraryCallRewrite::matchAndRewrite(), MulExtendedFold< MulOp, IsSigned >::matchAndRewrite(), InsertSliceOfInsertSliceFolder< OpTy >::matchAndRewrite(), mlir::ComposeReassociativeReshapeOps< ReshapeOpTy, opKind >::matchAndRewrite(), ConvertAccessChain::matchAndRewrite(), ConvertAddressOf::matchAndRewrite(), IAddCarryFold::matchAndRewrite(), ConvertStore::matchAndRewrite(), UModSimplification::matchAndRewrite(), UMulExtendedOpXOne::matchAndRewrite(), DeduplicateAffineMinMaxExpressions< T >::matchAndRewrite(), MergeAffineMinMaxOp< T >::matchAndRewrite(), CanonicalizeAffineMinMaxOpExprAndTermOrder< T >::matchAndRewrite(), CanonicalizeSingleResultAffineMinMaxOp< T >::matchAndRewrite(), SwapExtractSliceOfFill::matchAndRewrite(), InsertSliceVectorizePattern::matchAndRewrite(), mlir::linalg::DecomposePadOpPattern::matchAndRewrite(), ClampClampOptimization::matchAndRewrite(), ConcatOptimization::matchAndRewrite(), MaterializePadValue::matchAndRewrite(), TransposeIsReshape::matchAndRewrite(), ConsolidateTransposeOptimization::matchAndRewrite(), matchAndRewriteSortOp(), movePaddingToFillOrGenericOp(), SubViewCanonicalizer::operator()(), reduceMatchAndRewriteHelper(), replaceUnitDimIndexOps(), replaceWithLoadOrStore(), rewriteFromElementsAsSplat(), mlir::linalg::rewriteInDestinationPassingStyle(), PadOpVectorizationWithInsertSlicePattern::rewriteUser(), PadOpVectorizationWithTransferWritePattern::rewriteUser(), mlir::tensor::simplifyCollapseShapeWithRankReducingExtractSlice(), simplifyPassThroughBr(), simplifyPassThroughSwitch(), simplifySwitchFromDefaultSwitchOnSameCondition(), simplifySwitchFromSwitchOnSameCondition(), simplifySwitchWithOnlyDefault(), and mlir::linalg::specializeGenericOp().

◆ replaceUsesWithIf() [1/2]

void RewriterBase::replaceUsesWithIf ( Value  from,
Value  to,
function_ref< bool(OpOperand &)>  functor,
bool *  allUsesReplaced = nullptr 
)

Find uses of from and replace them with to if the functor returns true.

Also notify the listener about every in-place op modification (for every use that was replaced). The optional allUsesReplaced flag is set to "true" if all uses were replaced.

Definition at line 262 of file PatternMatch.cpp.

References mlir::Value::getUses(), and modifyOpInPlace().

Referenced by mlir::makeRegionIsolatedFromAbove(), mlir::linalg::offsetIndices(), replaceAllUsesExcept(), replaceForAllWithNewSignature(), and replaceOpUsesWithIf().

◆ replaceUsesWithIf() [2/2]

void RewriterBase::replaceUsesWithIf ( ValueRange  from,
ValueRange  to,
function_ref< bool(OpOperand &)>  functor,
bool *  allUsesReplaced = nullptr 
)

Definition at line 276 of file PatternMatch.cpp.

◆ splitBlock()

Block * RewriterBase::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.

Definition at line 346 of file PatternMatch.cpp.

References mlir::Block::back(), mlir::Block::begin(), mlir::OpBuilder::createBlock(), mlir::Block::end(), mlir::Block::getParent(), mlir::OpBuilder::listener, moveOpBefore(), and mlir::Block::splitBlock().

Referenced by AssertOpLowering::matchAndRewrite(), and MultiBlockExecuteInliner::matchAndRewrite().

◆ startOpModification()

virtual void mlir::RewriterBase::startOpModification ( Operation op)
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 finalizeOpModification or cancelOpModification. 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 620 of file PatternMatch.h.

Referenced by mlir::linalg::interchangeGenericOp(), RemoveUnusedLvlCrds::matchAndRewrite(), modifyOpInPlace(), padThroughLoopIterArg(), mlir::affine::reorderOperandsByHoistability(), and replaceUsesAndPropagateType().


The documentation for this class was generated from the following files: