MLIR 23.0.0git
Rewrite.cpp File Reference

Go to the source code of this file.

Classes

class  mlir::ExternalRewritePattern

Namespaces

namespace  mlir
 Include the generated interface declarations.

Functions

MlirContext mlirRewriterBaseGetContext (MlirRewriterBase rewriter)
 RewriterBase API inherited from OpBuilder.
void mlirRewriterBaseClearInsertionPoint (MlirRewriterBase rewriter)
 Insertion points methods.
void mlirRewriterBaseSetInsertionPointBefore (MlirRewriterBase rewriter, MlirOperation op)
 Sets the insertion point to the specified operation, which will cause subsequent insertions to go right before it.
void mlirRewriterBaseSetInsertionPointAfter (MlirRewriterBase rewriter, MlirOperation op)
 Sets the insertion point to the node after the specified operation, which will cause subsequent insertions to go right after it.
void mlirRewriterBaseSetInsertionPointAfterValue (MlirRewriterBase rewriter, MlirValue value)
 Sets the insertion point to the node after the specified value.
void mlirRewriterBaseSetInsertionPointToStart (MlirRewriterBase rewriter, MlirBlock block)
 Sets the insertion point to the start of the specified block.
void mlirRewriterBaseSetInsertionPointToEnd (MlirRewriterBase rewriter, MlirBlock block)
 Sets the insertion point to the end of the specified block.
MlirBlock mlirRewriterBaseGetInsertionBlock (MlirRewriterBase rewriter)
 Return the block the current insertion point belongs to.
MlirBlock mlirRewriterBaseGetBlock (MlirRewriterBase rewriter)
 Returns the current block of the rewriter.
MlirOperation mlirRewriterBaseGetOperationAfterInsertion (MlirRewriterBase rewriter)
 Returns the operation right after the current insertion point of the rewriter.
MlirBlock mlirRewriterBaseCreateBlockBefore (MlirRewriterBase rewriter, MlirBlock insertBefore, intptr_t nArgTypes, MlirType const *argTypes, MlirLocation const *locations)
 Block and operation creation/insertion/cloning.
MlirOperation mlirRewriterBaseInsert (MlirRewriterBase rewriter, MlirOperation op)
 Insert the given operation at the current insertion point and return it.
MlirOperation mlirRewriterBaseClone (MlirRewriterBase rewriter, MlirOperation op)
 Creates a deep copy of the specified operation.
MlirOperation mlirRewriterBaseCloneWithoutRegions (MlirRewriterBase rewriter, MlirOperation op)
 Creates a deep copy of this operation but keep the operation regions empty.
void mlirRewriterBaseCloneRegionBefore (MlirRewriterBase rewriter, MlirRegion region, MlirBlock before)
 Clone the blocks that belong to "region" before the given position in another region "parent".
void mlirRewriterBaseInlineRegionBefore (MlirRewriterBase rewriter, MlirRegion region, MlirBlock before)
 RewriterBase API.
void mlirRewriterBaseReplaceOpWithValues (MlirRewriterBase rewriter, MlirOperation op, intptr_t nValues, MlirValue const *values)
 Replace the results of the given (original) operation with the specified list of values (replacements).
void mlirRewriterBaseReplaceOpWithOperation (MlirRewriterBase rewriter, MlirOperation op, MlirOperation newOp)
 Replace the results of the given (original) operation with the specified new op (replacement).
void mlirRewriterBaseEraseOp (MlirRewriterBase rewriter, MlirOperation op)
 Erases an operation that is known to have no uses.
void mlirRewriterBaseEraseBlock (MlirRewriterBase rewriter, MlirBlock block)
 Erases a block along with all operations inside it.
void mlirRewriterBaseInlineBlockBefore (MlirRewriterBase rewriter, MlirBlock source, MlirOperation op, intptr_t nArgValues, MlirValue const *argValues)
 Inline the operations of block 'source' before the operation 'op'.
void mlirRewriterBaseMergeBlocks (MlirRewriterBase rewriter, MlirBlock source, MlirBlock dest, intptr_t nArgValues, MlirValue const *argValues)
 Inline the operations of block 'source' into the end of block 'dest'.
void mlirRewriterBaseMoveOpBefore (MlirRewriterBase rewriter, MlirOperation op, MlirOperation 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.
void mlirRewriterBaseMoveOpAfter (MlirRewriterBase rewriter, MlirOperation op, MlirOperation 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.
void mlirRewriterBaseMoveBlockBefore (MlirRewriterBase rewriter, MlirBlock block, MlirBlock existingBlock)
 Unlink this block and insert it right before existingBlock.
void mlirRewriterBaseStartOpModification (MlirRewriterBase rewriter, MlirOperation op)
 This method is used to notify the rewriter that an in-place operation modification is about to happen.
void mlirRewriterBaseFinalizeOpModification (MlirRewriterBase rewriter, MlirOperation op)
 This method is used to signal the end of an in-place modification of the given operation.
void mlirRewriterBaseCancelOpModification (MlirRewriterBase rewriter, MlirOperation op)
 This method cancels a pending in-place modification.
void mlirRewriterBaseReplaceAllUsesWith (MlirRewriterBase rewriter, MlirValue from, MlirValue to)
 Find uses of from and replace them with to.
void mlirRewriterBaseReplaceAllValueRangeUsesWith (MlirRewriterBase rewriter, intptr_t nValues, MlirValue const *from, MlirValue const *to)
 Find uses of from and replace them with to.
void mlirRewriterBaseReplaceAllOpUsesWithValueRange (MlirRewriterBase rewriter, MlirOperation from, intptr_t nTo, MlirValue const *to)
 Find uses of from and replace them with to.
void mlirRewriterBaseReplaceAllOpUsesWithOperation (MlirRewriterBase rewriter, MlirOperation from, MlirOperation to)
 Find uses of from and replace them with to.
void mlirRewriterBaseReplaceOpUsesWithinBlock (MlirRewriterBase rewriter, MlirOperation op, intptr_t nNewValues, MlirValue const *newValues, MlirBlock block)
 Find uses of from within block and replace them with to.
void mlirRewriterBaseReplaceAllUsesExcept (MlirRewriterBase rewriter, MlirValue from, MlirValue to, MlirOperation exceptedUser)
 Find uses of from and replace them with to except if the user is exceptedUser.
MlirRewriterBase mlirIRRewriterCreate (MlirContext context)
 IRRewriter API.
MlirRewriterBase mlirIRRewriterCreateFromOp (MlirOperation op)
 Create an IRRewriter and transfer ownership to the caller.
void mlirIRRewriterDestroy (MlirRewriterBase rewriter)
 Takes an IRRewriter owned by the caller and destroys it.
MlirFrozenRewritePatternSet mlirFreezeRewritePattern (MlirRewritePatternSet set)
 RewritePatternSet and FrozenRewritePatternSet API.
void mlirFrozenRewritePatternSetDestroy (MlirFrozenRewritePatternSet set)
 Destroy the given MlirFrozenRewritePatternSet.
mlir::GreedyRewriteConfigunwrap (MlirGreedyRewriteDriverConfig config)
 GreedyRewriteDriverConfig API.
MlirGreedyRewriteDriverConfig wrap (mlir::GreedyRewriteConfig *config)
MlirGreedyRewriteDriverConfig mlirGreedyRewriteDriverConfigCreate ()
 GreedyRewriteDriverConfig API.
void mlirGreedyRewriteDriverConfigDestroy (MlirGreedyRewriteDriverConfig config)
 Destroys a greedy rewrite driver configuration.
void mlirGreedyRewriteDriverConfigSetMaxIterations (MlirGreedyRewriteDriverConfig config, int64_t maxIterations)
 Sets the maximum number of iterations for the greedy rewrite driver.
void mlirGreedyRewriteDriverConfigSetMaxNumRewrites (MlirGreedyRewriteDriverConfig config, int64_t maxNumRewrites)
 Sets the maximum number of rewrites within an iteration.
void mlirGreedyRewriteDriverConfigSetUseTopDownTraversal (MlirGreedyRewriteDriverConfig config, bool useTopDownTraversal)
 Sets whether to use top-down traversal for the initial population of the worklist.
void mlirGreedyRewriteDriverConfigEnableFolding (MlirGreedyRewriteDriverConfig config, bool enable)
 Enables or disables folding during greedy rewriting.
void mlirGreedyRewriteDriverConfigSetStrictness (MlirGreedyRewriteDriverConfig config, MlirGreedyRewriteStrictness strictness)
 Sets the strictness level for the greedy rewrite driver.
void mlirGreedyRewriteDriverConfigSetRegionSimplificationLevel (MlirGreedyRewriteDriverConfig config, MlirGreedySimplifyRegionLevel level)
 Sets the region simplification level.
void mlirGreedyRewriteDriverConfigEnableConstantCSE (MlirGreedyRewriteDriverConfig config, bool enable)
 Enables or disables constant CSE.
int64_t mlirGreedyRewriteDriverConfigGetMaxIterations (MlirGreedyRewriteDriverConfig config)
 Gets the maximum number of iterations for the greedy rewrite driver.
int64_t mlirGreedyRewriteDriverConfigGetMaxNumRewrites (MlirGreedyRewriteDriverConfig config)
 Gets the maximum number of rewrites within an iteration.
bool mlirGreedyRewriteDriverConfigGetUseTopDownTraversal (MlirGreedyRewriteDriverConfig config)
 Gets whether top-down traversal is used for initial worklist population.
bool mlirGreedyRewriteDriverConfigIsFoldingEnabled (MlirGreedyRewriteDriverConfig config)
 Gets whether folding is enabled during greedy rewriting.
MlirGreedyRewriteStrictness mlirGreedyRewriteDriverConfigGetStrictness (MlirGreedyRewriteDriverConfig config)
 Gets the strictness level for the greedy rewrite driver.
MlirGreedySimplifyRegionLevel mlirGreedyRewriteDriverConfigGetRegionSimplificationLevel (MlirGreedyRewriteDriverConfig config)
 Gets the region simplification level.
bool mlirGreedyRewriteDriverConfigIsConstantCSEEnabled (MlirGreedyRewriteDriverConfig config)
 Gets whether constant CSE is enabled.
MlirLogicalResult mlirApplyPatternsAndFoldGreedily (MlirModule op, MlirFrozenRewritePatternSet patterns, MlirGreedyRewriteDriverConfig config)
MlirLogicalResult mlirApplyPatternsAndFoldGreedilyWithOp (MlirOperation op, MlirFrozenRewritePatternSet patterns, MlirGreedyRewriteDriverConfig config)
void mlirWalkAndApplyPatterns (MlirOperation op, MlirFrozenRewritePatternSet patterns)
 Applies the given patterns to the given op by a fast walk-based pattern rewrite driver.
MlirRewriterBase mlirPatternRewriterAsBase (MlirPatternRewriter rewriter)
 PatternRewriter API.
MlirRewritePattern mlirOpRewritePatternCreate (MlirStringRef rootName, unsigned benefit, MlirContext context, MlirRewritePatternCallbacks callbacks, void *userData, size_t nGeneratedNames, MlirStringRef *generatedNames)
 Create a rewrite pattern that matches the operation with the given rootName, corresponding to mlir::OpRewritePattern.
MlirRewritePatternSet mlirRewritePatternSetCreate (MlirContext context)
 RewritePatternSet API.
void mlirRewritePatternSetDestroy (MlirRewritePatternSet set)
 Destruct the given MlirRewritePatternSet.
void mlirRewritePatternSetAdd (MlirRewritePatternSet set, MlirRewritePattern pattern)
 Add the given MlirRewritePattern into a MlirRewritePatternSet.

Function Documentation

◆ mlirApplyPatternsAndFoldGreedily()

MlirLogicalResult mlirApplyPatternsAndFoldGreedily ( MlirModule op,
MlirFrozenRewritePatternSet patterns,
MlirGreedyRewriteDriverConfig config )

◆ mlirApplyPatternsAndFoldGreedilyWithOp()

MlirLogicalResult mlirApplyPatternsAndFoldGreedilyWithOp ( MlirOperation op,
MlirFrozenRewritePatternSet patterns,
MlirGreedyRewriteDriverConfig config )

◆ mlirFreezeRewritePattern()

MlirFrozenRewritePatternSet mlirFreezeRewritePattern ( MlirRewritePatternSet set)

◆ mlirFrozenRewritePatternSetDestroy()

void mlirFrozenRewritePatternSetDestroy ( MlirFrozenRewritePatternSet set)

Destroy the given MlirFrozenRewritePatternSet.

Definition at line 281 of file Rewrite.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyFrozenRewritePatternSet::~PyFrozenRewritePatternSet().

◆ mlirGreedyRewriteDriverConfigCreate()

MlirGreedyRewriteDriverConfig mlirGreedyRewriteDriverConfigCreate ( void )

GreedyRewriteDriverConfig API.

Creates a greedy rewrite driver configuration with default settings.

Definition at line 299 of file Rewrite.cpp.

References wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRewriteSubmodule(), and mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGreedyRewriteConfig::PyGreedyRewriteConfig().

◆ mlirGreedyRewriteDriverConfigDestroy()

void mlirGreedyRewriteDriverConfigDestroy ( MlirGreedyRewriteDriverConfig config)

Destroys a greedy rewrite driver configuration.

Definition at line 303 of file Rewrite.cpp.

References mlir::config, and unwrap().

◆ mlirGreedyRewriteDriverConfigEnableConstantCSE()

void mlirGreedyRewriteDriverConfigEnableConstantCSE ( MlirGreedyRewriteDriverConfig config,
bool enable )

◆ mlirGreedyRewriteDriverConfigEnableFolding()

void mlirGreedyRewriteDriverConfigEnableFolding ( MlirGreedyRewriteDriverConfig config,
bool enable )

Enables or disables folding during greedy rewriting.

Definition at line 323 of file Rewrite.cpp.

References mlir::config, mlir::GreedyRewriteConfig::enableFolding(), and unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGreedyRewriteConfig::enableFolding().

◆ mlirGreedyRewriteDriverConfigGetMaxIterations()

int64_t mlirGreedyRewriteDriverConfigGetMaxIterations ( MlirGreedyRewriteDriverConfig config)

Gets the maximum number of iterations for the greedy rewrite driver.

Definition at line 368 of file Rewrite.cpp.

References mlir::config, mlir::GreedyRewriteConfig::getMaxIterations(), and unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGreedyRewriteConfig::getMaxIterations().

◆ mlirGreedyRewriteDriverConfigGetMaxNumRewrites()

int64_t mlirGreedyRewriteDriverConfigGetMaxNumRewrites ( MlirGreedyRewriteDriverConfig config)

Gets the maximum number of rewrites within an iteration.

Definition at line 373 of file Rewrite.cpp.

References mlir::config, mlir::GreedyRewriteConfig::getMaxNumRewrites(), and unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGreedyRewriteConfig::getMaxNumRewrites().

◆ mlirGreedyRewriteDriverConfigGetRegionSimplificationLevel()

◆ mlirGreedyRewriteDriverConfigGetStrictness()

◆ mlirGreedyRewriteDriverConfigGetUseTopDownTraversal()

bool mlirGreedyRewriteDriverConfigGetUseTopDownTraversal ( MlirGreedyRewriteDriverConfig config)

Gets whether top-down traversal is used for initial worklist population.

Definition at line 378 of file Rewrite.cpp.

References mlir::config, mlir::GreedyRewriteConfig::getUseTopDownTraversal(), and unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGreedyRewriteConfig::getUseTopDownTraversal().

◆ mlirGreedyRewriteDriverConfigIsConstantCSEEnabled()

bool mlirGreedyRewriteDriverConfigIsConstantCSEEnabled ( MlirGreedyRewriteDriverConfig config)

◆ mlirGreedyRewriteDriverConfigIsFoldingEnabled()

bool mlirGreedyRewriteDriverConfigIsFoldingEnabled ( MlirGreedyRewriteDriverConfig config)

Gets whether folding is enabled during greedy rewriting.

Definition at line 383 of file Rewrite.cpp.

References mlir::config, mlir::GreedyRewriteConfig::isFoldingEnabled(), and unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGreedyRewriteConfig::isFoldingEnabled().

◆ mlirGreedyRewriteDriverConfigSetMaxIterations()

void mlirGreedyRewriteDriverConfigSetMaxIterations ( MlirGreedyRewriteDriverConfig config,
int64_t maxIterations )

Sets the maximum number of iterations for the greedy rewrite driver.

Use -1 for no limit.

Definition at line 308 of file Rewrite.cpp.

References mlir::config, mlir::GreedyRewriteConfig::setMaxIterations(), and unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGreedyRewriteConfig::setMaxIterations().

◆ mlirGreedyRewriteDriverConfigSetMaxNumRewrites()

void mlirGreedyRewriteDriverConfigSetMaxNumRewrites ( MlirGreedyRewriteDriverConfig config,
int64_t maxNumRewrites )

Sets the maximum number of rewrites within an iteration.

Use -1 for no limit.

Definition at line 313 of file Rewrite.cpp.

References mlir::config, mlir::GreedyRewriteConfig::setMaxNumRewrites(), and unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGreedyRewriteConfig::setMaxNumRewrites().

◆ mlirGreedyRewriteDriverConfigSetRegionSimplificationLevel()

◆ mlirGreedyRewriteDriverConfigSetStrictness()

◆ mlirGreedyRewriteDriverConfigSetUseTopDownTraversal()

void mlirGreedyRewriteDriverConfigSetUseTopDownTraversal ( MlirGreedyRewriteDriverConfig config,
bool useTopDownTraversal )

Sets whether to use top-down traversal for the initial population of the worklist.

Definition at line 318 of file Rewrite.cpp.

References mlir::config, mlir::GreedyRewriteConfig::setUseTopDownTraversal(), and unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGreedyRewriteConfig::setUseTopDownTraversal().

◆ mlirIRRewriterCreate()

MlirRewriterBase mlirIRRewriterCreate ( MlirContext context)

IRRewriter API.

Create an IRRewriter and transfer ownership to the caller.

Definition at line 258 of file Rewrite.cpp.

References unwrap(), and wrap().

◆ mlirIRRewriterCreateFromOp()

MlirRewriterBase mlirIRRewriterCreateFromOp ( MlirOperation op)

Create an IRRewriter and transfer ownership to the caller.

Additionally set the insertion point before the operation.

Definition at line 262 of file Rewrite.cpp.

References unwrap(), and wrap().

◆ mlirIRRewriterDestroy()

void mlirIRRewriterDestroy ( MlirRewriterBase rewriter)

Takes an IRRewriter owned by the caller and destroys it.

It is the responsibility of the user to only pass an IRRewriter class.

Definition at line 266 of file Rewrite.cpp.

References unwrap().

◆ mlirOpRewritePatternCreate()

MlirRewritePattern mlirOpRewritePatternCreate ( MlirStringRef rootName,
unsigned benefit,
MlirContext context,
MlirRewritePatternCallbacks callbacks,
void * userData,
size_t nGeneratedNames,
MlirStringRef * generatedNames )

Create a rewrite pattern that matches the operation with the given rootName, corresponding to mlir::OpRewritePattern.

Definition at line 487 of file Rewrite.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRewritePatternSet::add().

◆ mlirPatternRewriterAsBase()

MlirRewriterBase mlirPatternRewriterAsBase ( MlirPatternRewriter rewriter)

PatternRewriter API.

Cast the PatternRewriter to a RewriterBase

Definition at line 446 of file Rewrite.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyPatternRewriter::PyPatternRewriter().

◆ mlirRewritePatternSetAdd()

void mlirRewritePatternSetAdd ( MlirRewritePatternSet set,
MlirRewritePattern pattern )

Add the given MlirRewritePattern into a MlirRewritePatternSet.

Note that the ownership of the pattern is transferred to the set after this call.

Definition at line 513 of file Rewrite.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRewritePatternSet::add().

◆ mlirRewritePatternSetCreate()

MlirRewritePatternSet mlirRewritePatternSetCreate ( MlirContext context)

RewritePatternSet API.

Create an empty MlirRewritePatternSet.

Definition at line 505 of file Rewrite.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRewritePatternSet::PyRewritePatternSet().

◆ mlirRewritePatternSetDestroy()

void mlirRewritePatternSetDestroy ( MlirRewritePatternSet set)

Destruct the given MlirRewritePatternSet.

Definition at line 509 of file Rewrite.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRewritePatternSet::~PyRewritePatternSet().

◆ mlirRewriterBaseCancelOpModification()

void mlirRewriterBaseCancelOpModification ( MlirRewriterBase rewriter,
MlirOperation op )

This method cancels a pending in-place modification.

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

Definition at line 200 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseClearInsertionPoint()

void mlirRewriterBaseClearInsertionPoint ( MlirRewriterBase rewriter)

Insertion points methods.

Reset the insertion point to no location. Creating an operation without a set insertion point is an error, but this can still be useful when the current insertion point a builder refers to is being removed.

Definition at line 37 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseClone()

MlirOperation mlirRewriterBaseClone ( MlirRewriterBase rewriter,
MlirOperation op )

Creates a deep copy of the specified operation.

Definition at line 109 of file Rewrite.cpp.

References mlir::clone(), unwrap(), and wrap().

◆ mlirRewriterBaseCloneRegionBefore()

void mlirRewriterBaseCloneRegionBefore ( MlirRewriterBase rewriter,
MlirRegion region,
MlirBlock before )

Clone the blocks that belong to "region" before the given position in another region "parent".

Definition at line 119 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseCloneWithoutRegions()

MlirOperation mlirRewriterBaseCloneWithoutRegions ( MlirRewriterBase rewriter,
MlirOperation op )

Creates a deep copy of this operation but keep the operation regions empty.

Definition at line 114 of file Rewrite.cpp.

References mlir::cloneWithoutRegions(), unwrap(), and wrap().

◆ mlirRewriterBaseCreateBlockBefore()

MlirBlock mlirRewriterBaseCreateBlockBefore ( MlirRewriterBase rewriter,
MlirBlock insertBefore,
intptr_t nArgTypes,
MlirType const * argTypes,
MlirLocation const * locations )

Block and operation creation/insertion/cloning.

Add new block with 'argTypes' arguments and set the insertion point to the end of it. The block is placed before 'insertBefore'. locs contains the locations of the inserted arguments, and should match the size of argTypes.

Definition at line 89 of file Rewrite.cpp.

References unwrap(), unwrapList(), and wrap().

◆ mlirRewriterBaseEraseBlock()

void mlirRewriterBaseEraseBlock ( MlirRewriterBase rewriter,
MlirBlock block )

Erases a block along with all operations inside it.

Definition at line 152 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseEraseOp()

void mlirRewriterBaseEraseOp ( MlirRewriterBase rewriter,
MlirOperation op )

Erases an operation that is known to have no uses.

Definition at line 148 of file Rewrite.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyPatternRewriter::eraseOp().

◆ mlirRewriterBaseFinalizeOpModification()

void mlirRewriterBaseFinalizeOpModification ( MlirRewriterBase rewriter,
MlirOperation op )

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.

Definition at line 195 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseGetBlock()

MlirBlock mlirRewriterBaseGetBlock ( MlirRewriterBase rewriter)

Returns the current block of the rewriter.

Definition at line 70 of file Rewrite.cpp.

References unwrap(), and wrap().

◆ mlirRewriterBaseGetContext()

MlirContext mlirRewriterBaseGetContext ( MlirRewriterBase rewriter)

RewriterBase API inherited from OpBuilder.

Get the MLIR context referenced by the rewriter.

Definition at line 29 of file Rewrite.cpp.

References getContext(), unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyPatternRewriter::PyPatternRewriter().

◆ mlirRewriterBaseGetInsertionBlock()

MlirBlock mlirRewriterBaseGetInsertionBlock ( MlirRewriterBase rewriter)

Return the block the current insertion point belongs to.

Note that the insertion point is not necessarily the end of the block.

Definition at line 66 of file Rewrite.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyPatternRewriter::getInsertionPoint().

◆ mlirRewriterBaseGetOperationAfterInsertion()

MlirOperation mlirRewriterBaseGetOperationAfterInsertion ( MlirRewriterBase rewriter)

Returns the operation right after the current insertion point of the rewriter.

A null MlirOperation will be returned

Definition at line 75 of file Rewrite.cpp.

References mlir::Block::end(), mlir::OpBuilder::getInsertionBlock(), mlir::OpBuilder::getInsertionPoint(), unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyPatternRewriter::getInsertionPoint().

◆ mlirRewriterBaseInlineBlockBefore()

void mlirRewriterBaseInlineBlockBefore ( MlirRewriterBase rewriter,
MlirBlock source,
MlirOperation op,
intptr_t nArgValues,
MlirValue const * argValues )

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 156 of file Rewrite.cpp.

References unwrap(), and unwrapList().

◆ mlirRewriterBaseInlineRegionBefore()

void mlirRewriterBaseInlineRegionBefore ( MlirRewriterBase rewriter,
MlirRegion region,
MlirBlock before )

RewriterBase API.

Move 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.

Definition at line 129 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseInsert()

MlirOperation mlirRewriterBaseInsert ( MlirRewriterBase rewriter,
MlirOperation op )

Insert the given operation at the current insertion point and return it.

Definition at line 102 of file Rewrite.cpp.

References unwrap(), and wrap().

◆ mlirRewriterBaseMergeBlocks()

void mlirRewriterBaseMergeBlocks ( MlirRewriterBase rewriter,
MlirBlock source,
MlirBlock dest,
intptr_t nArgValues,
MlirValue const * argValues )

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 167 of file Rewrite.cpp.

References unwrap(), and unwrapList().

◆ mlirRewriterBaseMoveBlockBefore()

void mlirRewriterBaseMoveBlockBefore ( MlirRewriterBase rewriter,
MlirBlock block,
MlirBlock existingBlock )

Unlink this block and insert it right before existingBlock.

Definition at line 185 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseMoveOpAfter()

void mlirRewriterBaseMoveOpAfter ( MlirRewriterBase rewriter,
MlirOperation op,
MlirOperation 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 180 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseMoveOpBefore()

void mlirRewriterBaseMoveOpBefore ( MlirRewriterBase rewriter,
MlirOperation op,
MlirOperation 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 175 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseReplaceAllOpUsesWithOperation()

void mlirRewriterBaseReplaceAllOpUsesWithOperation ( MlirRewriterBase rewriter,
MlirOperation from,
MlirOperation 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.

Definition at line 230 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseReplaceAllOpUsesWithValueRange()

void mlirRewriterBaseReplaceAllOpUsesWithValueRange ( MlirRewriterBase rewriter,
MlirOperation from,
intptr_t nTo,
MlirValue const * 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.

Definition at line 221 of file Rewrite.cpp.

References unwrap(), and unwrapList().

◆ mlirRewriterBaseReplaceAllUsesExcept()

void mlirRewriterBaseReplaceAllUsesExcept ( MlirRewriterBase rewriter,
MlirValue from,
MlirValue to,
MlirOperation exceptedUser )

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 247 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseReplaceAllUsesWith()

void mlirRewriterBaseReplaceAllUsesWith ( MlirRewriterBase rewriter,
MlirValue from,
MlirValue 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).

Definition at line 205 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseReplaceAllValueRangeUsesWith()

void mlirRewriterBaseReplaceAllValueRangeUsesWith ( MlirRewriterBase rewriter,
intptr_t nValues,
MlirValue const * from,
MlirValue const * 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).

Definition at line 210 of file Rewrite.cpp.

References unwrap(), and unwrapList().

◆ mlirRewriterBaseReplaceOpUsesWithinBlock()

void mlirRewriterBaseReplaceOpUsesWithinBlock ( MlirRewriterBase rewriter,
MlirOperation op,
intptr_t nNewValues,
MlirValue const * newValues,
MlirBlock block )

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 236 of file Rewrite.cpp.

References unwrap(), and unwrapList().

◆ mlirRewriterBaseReplaceOpWithOperation()

void mlirRewriterBaseReplaceOpWithOperation ( MlirRewriterBase rewriter,
MlirOperation op,
MlirOperation newOp )

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

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

Definition at line 142 of file Rewrite.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyPatternRewriter::replaceOp().

◆ mlirRewriterBaseReplaceOpWithValues()

void mlirRewriterBaseReplaceOpWithValues ( MlirRewriterBase rewriter,
MlirOperation op,
intptr_t nValues,
MlirValue const * values )

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

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

Definition at line 134 of file Rewrite.cpp.

References unwrap(), and unwrapList().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyPatternRewriter::replaceOp().

◆ mlirRewriterBaseSetInsertionPointAfter()

void mlirRewriterBaseSetInsertionPointAfter ( MlirRewriterBase rewriter,
MlirOperation op )

Sets the insertion point to the node after the specified operation, which will cause subsequent insertions to go right after it.

Definition at line 46 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseSetInsertionPointAfterValue()

void mlirRewriterBaseSetInsertionPointAfterValue ( MlirRewriterBase rewriter,
MlirValue value )

Sets the insertion point to the node after the specified value.

If value has a defining operation, sets the insertion point to the node after such defining operation. This will cause subsequent insertions to go right after it. Otherwise, value is a BlockArgument. Sets the insertion point to the start of its block.

Definition at line 51 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseSetInsertionPointBefore()

void mlirRewriterBaseSetInsertionPointBefore ( MlirRewriterBase rewriter,
MlirOperation op )

Sets the insertion point to the specified operation, which will cause subsequent insertions to go right before it.

Definition at line 41 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseSetInsertionPointToEnd()

void mlirRewriterBaseSetInsertionPointToEnd ( MlirRewriterBase rewriter,
MlirBlock block )

Sets the insertion point to the end of the specified block.

Definition at line 61 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseSetInsertionPointToStart()

void mlirRewriterBaseSetInsertionPointToStart ( MlirRewriterBase rewriter,
MlirBlock block )

Sets the insertion point to the start of the specified block.

Definition at line 56 of file Rewrite.cpp.

References unwrap().

◆ mlirRewriterBaseStartOpModification()

void mlirRewriterBaseStartOpModification ( MlirRewriterBase rewriter,
MlirOperation op )

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.

Definition at line 190 of file Rewrite.cpp.

References unwrap().

◆ mlirWalkAndApplyPatterns()

void mlirWalkAndApplyPatterns ( MlirOperation op,
MlirFrozenRewritePatternSet patterns )

Applies the given patterns to the given op by a fast walk-based pattern rewrite driver.

Definition at line 437 of file Rewrite.cpp.

References mlir::patterns, unwrap(), and mlir::walkAndApplyPatterns().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRewriteSubmodule().

◆ unwrap()

mlir::GreedyRewriteConfig * unwrap ( MlirGreedyRewriteDriverConfig config)
inline

GreedyRewriteDriverConfig API.

Definition at line 290 of file Rewrite.cpp.

References mlir::config.

Referenced by mlirApplyPatternsAndFoldGreedily(), mlirApplyPatternsAndFoldGreedilyWithOp(), mlirFreezeRewritePattern(), mlirFrozenRewritePatternSetDestroy(), mlirGreedyRewriteDriverConfigDestroy(), mlirGreedyRewriteDriverConfigEnableConstantCSE(), mlirGreedyRewriteDriverConfigEnableFolding(), mlirGreedyRewriteDriverConfigGetMaxIterations(), mlirGreedyRewriteDriverConfigGetMaxNumRewrites(), mlirGreedyRewriteDriverConfigGetRegionSimplificationLevel(), mlirGreedyRewriteDriverConfigGetStrictness(), mlirGreedyRewriteDriverConfigGetUseTopDownTraversal(), mlirGreedyRewriteDriverConfigIsConstantCSEEnabled(), mlirGreedyRewriteDriverConfigIsFoldingEnabled(), mlirGreedyRewriteDriverConfigSetMaxIterations(), mlirGreedyRewriteDriverConfigSetMaxNumRewrites(), mlirGreedyRewriteDriverConfigSetRegionSimplificationLevel(), mlirGreedyRewriteDriverConfigSetStrictness(), mlirGreedyRewriteDriverConfigSetUseTopDownTraversal(), mlirIRRewriterCreate(), mlirIRRewriterCreateFromOp(), mlirIRRewriterDestroy(), mlirOpRewritePatternCreate(), mlirPatternRewriterAsBase(), mlirRewritePatternSetAdd(), mlirRewritePatternSetCreate(), mlirRewritePatternSetDestroy(), mlirRewriterBaseCancelOpModification(), mlirRewriterBaseClearInsertionPoint(), mlirRewriterBaseClone(), mlirRewriterBaseCloneRegionBefore(), mlirRewriterBaseCloneWithoutRegions(), mlirRewriterBaseCreateBlockBefore(), mlirRewriterBaseEraseBlock(), mlirRewriterBaseEraseOp(), mlirRewriterBaseFinalizeOpModification(), mlirRewriterBaseGetBlock(), mlirRewriterBaseGetContext(), mlirRewriterBaseGetInsertionBlock(), mlirRewriterBaseGetOperationAfterInsertion(), mlirRewriterBaseInlineBlockBefore(), mlirRewriterBaseInlineRegionBefore(), mlirRewriterBaseInsert(), mlirRewriterBaseMergeBlocks(), mlirRewriterBaseMoveBlockBefore(), mlirRewriterBaseMoveOpAfter(), mlirRewriterBaseMoveOpBefore(), mlirRewriterBaseReplaceAllOpUsesWithOperation(), mlirRewriterBaseReplaceAllOpUsesWithValueRange(), mlirRewriterBaseReplaceAllUsesExcept(), mlirRewriterBaseReplaceAllUsesWith(), mlirRewriterBaseReplaceAllValueRangeUsesWith(), mlirRewriterBaseReplaceOpUsesWithinBlock(), mlirRewriterBaseReplaceOpWithOperation(), mlirRewriterBaseReplaceOpWithValues(), mlirRewriterBaseSetInsertionPointAfter(), mlirRewriterBaseSetInsertionPointAfterValue(), mlirRewriterBaseSetInsertionPointBefore(), mlirRewriterBaseSetInsertionPointToEnd(), mlirRewriterBaseSetInsertionPointToStart(), mlirRewriterBaseStartOpModification(), and mlirWalkAndApplyPatterns().

◆ wrap()