MLIR  19.0.0git
Public Member Functions | Public Attributes | List of all members
mlir::detail::ConversionPatternRewriterImpl::SingleEraseRewriter Struct Reference

A rewriter that keeps track of erased ops and blocks. More...

+ Inheritance diagram for mlir::detail::ConversionPatternRewriterImpl::SingleEraseRewriter:

Public Member Functions

 SingleEraseRewriter (MLIRContext *context)
 
void eraseOp (Operation *op) override
 Erase the given op (unless it was already erased). More...
 
void eraseBlock (Block *block) override
 Erase the given block (unless it was already erased). More...
 
void notifyOperationErased (Operation *op) override
 Notify the listener that the specified operation is about to be erased. More...
 
void notifyBlockErased (Block *block) override
 Notify the listener that the specified block is about to be erased. More...
 
- Public Member Functions inherited from mlir::RewriterBase
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 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, LogicalResultnotifyMatchFailure (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, LogicalResultnotifyMatchFailure (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 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)
 
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...
 
- Public Member Functions inherited from mlir::RewriterBase::Listener
 Listener ()
 
virtual void notifyOperationModified (Operation *op)
 Notify the listener that the specified operation was modified in-place. More...
 
virtual void notifyOperationReplaced (Operation *op, Operation *replacement)
 Notify the listener that all uses of the specified operation's results are about to be replaced with the results of another operation. More...
 
virtual void notifyOperationReplaced (Operation *op, ValueRange replacement)
 Notify the listener that all uses of the specified operation's results are about to be replaced with the a range of values, potentially produced by other operations. More...
 
virtual void notifyPatternBegin (const Pattern &pattern, Operation *op)
 Notify the listener that the specified pattern is about to be applied at the specified root operation. More...
 
virtual void notifyPatternEnd (const Pattern &pattern, LogicalResult status)
 Notify the listener that a pattern application finished with the specified status. More...
 
virtual void notifyMatchFailure (Location loc, function_ref< void(Diagnostic &)> reasonCallback)
 Notify the listener that the pattern failed to match, and provide a callback to populate a diagnostic with the reason why the failure occurred. More...
 
- Public Member Functions inherited from mlir::OpBuilder::Listener
 Listener ()
 
virtual ~Listener ()=default
 
virtual void notifyOperationInserted (Operation *op, InsertPoint previous)
 Notify the listener that the specified operation was inserted. More...
 
virtual void notifyBlockInserted (Block *block, Region *previous, Region::iterator previousIt)
 Notify the listener that the specified block was inserted. More...
 
- Public Member Functions inherited from mlir::OpBuilder::ListenerBase
Kind getKind () const
 

Public Attributes

DenseSet< void * > erased
 Pointers to all erased operations and blocks. More...
 

Additional Inherited Members

- Public Types inherited from mlir::OpBuilder::ListenerBase
enum class  Kind { OpBuilderListener = 0 , RewriterBaseListener = 1 }
 The kind of listener. More...
 
- 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...
 
- Static Public Member Functions inherited from mlir::RewriterBase::Listener
static bool classof (const OpBuilder::Listener *base)
 
- Protected Member Functions inherited from mlir::RewriterBase
 RewriterBase (MLIRContext *ctx, OpBuilder::Listener *listener=nullptr)
 Initialize the builder. More...
 
 RewriterBase (const OpBuilder &otherBuilder)
 
 RewriterBase (Operation *op, OpBuilder::Listener *listener=nullptr)
 
virtual ~RewriterBase ()
 
- Protected Member Functions inherited from mlir::OpBuilder::Listener
 Listener (Kind kind)
 
- Protected Member Functions inherited from mlir::OpBuilder::ListenerBase
 ListenerBase (Kind kind)
 
- 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

A rewriter that keeps track of erased ops and blocks.

It ensures that no operation or block is erased multiple times. This rewriter assumes that no new IR is created between calls to eraseOp/eraseBlock.

Definition at line 936 of file DialectConversion.cpp.

Constructor & Destructor Documentation

◆ SingleEraseRewriter()

mlir::detail::ConversionPatternRewriterImpl::SingleEraseRewriter::SingleEraseRewriter ( MLIRContext context)
inline

Definition at line 938 of file DialectConversion.cpp.

Member Function Documentation

◆ eraseBlock()

void mlir::detail::ConversionPatternRewriterImpl::SingleEraseRewriter::eraseBlock ( Block block)
inlineoverridevirtual

Erase the given block (unless it was already erased).

Reimplemented from mlir::RewriterBase.

Definition at line 950 of file DialectConversion.cpp.

References mlir::Block::dropAllDefinedValueUses(), mlir::Block::empty(), and mlir::RewriterBase::eraseBlock().

◆ eraseOp()

void mlir::detail::ConversionPatternRewriterImpl::SingleEraseRewriter::eraseOp ( Operation op)
inlineoverridevirtual

Erase the given op (unless it was already erased).

Reimplemented from mlir::RewriterBase.

Definition at line 942 of file DialectConversion.cpp.

◆ notifyBlockErased()

void mlir::detail::ConversionPatternRewriterImpl::SingleEraseRewriter::notifyBlockErased ( Block block)
inlineoverridevirtual

Notify the listener that the specified block is about to be erased.

At this point, the block has zero uses.

Reimplemented from mlir::RewriterBase::Listener.

Definition at line 960 of file DialectConversion.cpp.

◆ notifyOperationErased()

void mlir::detail::ConversionPatternRewriterImpl::SingleEraseRewriter::notifyOperationErased ( Operation op)
inlineoverridevirtual

Notify the listener that the specified operation is about to be erased.

At this point, the operation has zero uses.

Note: This notification is not triggered when unlinking an operation.

Reimplemented from mlir::RewriterBase::Listener.

Definition at line 958 of file DialectConversion.cpp.

Member Data Documentation

◆ erased

DenseSet<void *> mlir::detail::ConversionPatternRewriterImpl::SingleEraseRewriter::erased

Pointers to all erased operations and blocks.

Definition at line 963 of file DialectConversion.cpp.


The documentation for this struct was generated from the following file: