MLIR
20.0.0git
|
#include "mlir-c/Rewrite.h"
#include "mlir-c/Transforms.h"
#include "mlir/CAPI/IR.h"
#include "mlir/CAPI/Rewrite.h"
#include "mlir/CAPI/Support.h"
#include "mlir/CAPI/Wrap.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
Go to the source code of this file.
Functions | |
MlirContext | mlirRewriterBaseGetContext (MlirRewriterBase rewriter) |
RewriterBase API inherited from OpBuilder. More... | |
void | mlirRewriterBaseClearInsertionPoint (MlirRewriterBase rewriter) |
Insertion points methods. More... | |
void | mlirRewriterBaseSetInsertionPointBefore (MlirRewriterBase rewriter, MlirOperation op) |
Sets the insertion point to the specified operation, which will cause subsequent insertions to go right before it. More... | |
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. More... | |
void | mlirRewriterBaseSetInsertionPointAfterValue (MlirRewriterBase rewriter, MlirValue value) |
Sets the insertion point to the node after the specified value. More... | |
void | mlirRewriterBaseSetInsertionPointToStart (MlirRewriterBase rewriter, MlirBlock block) |
Sets the insertion point to the start of the specified block. More... | |
void | mlirRewriterBaseSetInsertionPointToEnd (MlirRewriterBase rewriter, MlirBlock block) |
Sets the insertion point to the end of the specified block. More... | |
MlirBlock | mlirRewriterBaseGetInsertionBlock (MlirRewriterBase rewriter) |
Return the block the current insertion point belongs to. More... | |
MlirBlock | mlirRewriterBaseGetBlock (MlirRewriterBase rewriter) |
Returns the current block of the rewriter. More... | |
MlirBlock | mlirRewriterBaseCreateBlockBefore (MlirRewriterBase rewriter, MlirBlock insertBefore, intptr_t nArgTypes, MlirType const *argTypes, MlirLocation const *locations) |
Block and operation creation/insertion/cloning. More... | |
MlirOperation | mlirRewriterBaseInsert (MlirRewriterBase rewriter, MlirOperation op) |
Insert the given operation at the current insertion point and return it. More... | |
MlirOperation | mlirRewriterBaseClone (MlirRewriterBase rewriter, MlirOperation op) |
Creates a deep copy of the specified operation. More... | |
MlirOperation | mlirRewriterBaseCloneWithoutRegions (MlirRewriterBase rewriter, MlirOperation op) |
Creates a deep copy of this operation but keep the operation regions empty. More... | |
void | mlirRewriterBaseCloneRegionBefore (MlirRewriterBase rewriter, MlirRegion region, MlirBlock before) |
Clone the blocks that belong to "region" before the given position in another region "parent". More... | |
void | mlirRewriterBaseInlineRegionBefore (MlirRewriterBase rewriter, MlirRegion region, MlirBlock before) |
RewriterBase API. More... | |
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). More... | |
void | mlirRewriterBaseReplaceOpWithOperation (MlirRewriterBase rewriter, MlirOperation op, MlirOperation newOp) |
Replace the results of the given (original) operation with the specified new op (replacement). More... | |
void | mlirRewriterBaseEraseOp (MlirRewriterBase rewriter, MlirOperation op) |
Erases an operation that is known to have no uses. More... | |
void | mlirRewriterBaseEraseBlock (MlirRewriterBase rewriter, MlirBlock block) |
Erases a block along with all operations inside it. More... | |
void | mlirRewriterBaseInlineBlockBefore (MlirRewriterBase rewriter, MlirBlock source, MlirOperation op, intptr_t nArgValues, MlirValue const *argValues) |
Inline the operations of block 'source' before the operation 'op'. More... | |
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'. More... | |
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. More... | |
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. More... | |
void | mlirRewriterBaseMoveBlockBefore (MlirRewriterBase rewriter, MlirBlock block, MlirBlock existingBlock) |
Unlink this block and insert it right before existingBlock . More... | |
void | mlirRewriterBaseStartOpModification (MlirRewriterBase rewriter, MlirOperation op) |
This method is used to notify the rewriter that an in-place operation modification is about to happen. More... | |
void | mlirRewriterBaseFinalizeOpModification (MlirRewriterBase rewriter, MlirOperation op) |
This method is used to signal the end of an in-place modification of the given operation. More... | |
void | mlirRewriterBaseCancelOpModification (MlirRewriterBase rewriter, MlirOperation op) |
This method cancels a pending in-place modification. More... | |
void | mlirRewriterBaseReplaceAllUsesWith (MlirRewriterBase rewriter, MlirValue from, MlirValue to) |
Find uses of from and replace them with to . More... | |
void | mlirRewriterBaseReplaceAllValueRangeUsesWith (MlirRewriterBase rewriter, intptr_t nValues, MlirValue const *from, MlirValue const *to) |
Find uses of from and replace them with to . More... | |
void | mlirRewriterBaseReplaceAllOpUsesWithValueRange (MlirRewriterBase rewriter, MlirOperation from, intptr_t nTo, MlirValue const *to) |
Find uses of from and replace them with to . More... | |
void | mlirRewriterBaseReplaceAllOpUsesWithOperation (MlirRewriterBase rewriter, MlirOperation from, MlirOperation to) |
Find uses of from and replace them with to . More... | |
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 . More... | |
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 . More... | |
MlirRewriterBase | mlirIRRewriterCreate (MlirContext context) |
IRRewriter API. More... | |
MlirRewriterBase | mlirIRRewriterCreateFromOp (MlirOperation op) |
Create an IRRewriter and transfer ownership to the caller. More... | |
void | mlirIRRewriterDestroy (MlirRewriterBase rewriter) |
Takes an IRRewriter owned by the caller and destroys it. More... | |
mlir::RewritePatternSet & | unwrap (MlirRewritePatternSet module) |
RewritePatternSet and FrozenRewritePatternSet API. More... | |
MlirRewritePatternSet | wrap (mlir::RewritePatternSet *module) |
mlir::FrozenRewritePatternSet * | unwrap (MlirFrozenRewritePatternSet module) |
MlirFrozenRewritePatternSet | wrap (mlir::FrozenRewritePatternSet *module) |
MlirFrozenRewritePatternSet | mlirFreezeRewritePattern (MlirRewritePatternSet op) |
FrozenRewritePatternSet API. More... | |
void | mlirFrozenRewritePatternSetDestroy (MlirFrozenRewritePatternSet op) |
MlirLogicalResult | mlirApplyPatternsAndFoldGreedily (MlirModule op, MlirFrozenRewritePatternSet patterns, MlirGreedyRewriteDriverConfig) |
MlirLogicalResult mlirApplyPatternsAndFoldGreedily | ( | MlirModule | op, |
MlirFrozenRewritePatternSet | patterns, | ||
MlirGreedyRewriteDriverConfig | |||
) |
Definition at line 289 of file Rewrite.cpp.
References mlir::applyPatternsGreedily(), mlir::patterns, unwrap(), and wrap().
MlirFrozenRewritePatternSet mlirFreezeRewritePattern | ( | MlirRewritePatternSet | op | ) |
FrozenRewritePatternSet API.
Definition at line 277 of file Rewrite.cpp.
void mlirFrozenRewritePatternSetDestroy | ( | MlirFrozenRewritePatternSet | op | ) |
Definition at line 283 of file Rewrite.cpp.
References unwrap().
MlirRewriterBase mlirIRRewriterCreate | ( | MlirContext | context | ) |
IRRewriter API.
Create an IRRewriter and transfer ownership to the caller.
Definition at line 242 of file Rewrite.cpp.
MlirRewriterBase mlirIRRewriterCreateFromOp | ( | MlirOperation | op | ) |
Create an IRRewriter and transfer ownership to the caller.
Additionally set the insertion point before the operation.
Definition at line 246 of file Rewrite.cpp.
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 250 of file Rewrite.cpp.
References unwrap().
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 184 of file Rewrite.cpp.
References unwrap().
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 33 of file Rewrite.cpp.
References unwrap().
MlirOperation mlirRewriterBaseClone | ( | MlirRewriterBase | rewriter, |
MlirOperation | op | ||
) |
Creates a deep copy of the specified operation.
Definition at line 93 of file Rewrite.cpp.
References mlir::clone(), unwrap(), and wrap().
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 103 of file Rewrite.cpp.
References unwrap().
MlirOperation mlirRewriterBaseCloneWithoutRegions | ( | MlirRewriterBase | rewriter, |
MlirOperation | op | ||
) |
Creates a deep copy of this operation but keep the operation regions empty.
Definition at line 98 of file Rewrite.cpp.
References mlir::cloneWithoutRegions(), unwrap(), and wrap().
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 73 of file Rewrite.cpp.
References createBlock(), unwrap(), unwrapList(), and wrap().
void mlirRewriterBaseEraseBlock | ( | MlirRewriterBase | rewriter, |
MlirBlock | block | ||
) |
Erases a block along with all operations inside it.
Definition at line 136 of file Rewrite.cpp.
References unwrap().
void mlirRewriterBaseEraseOp | ( | MlirRewriterBase | rewriter, |
MlirOperation | op | ||
) |
Erases an operation that is known to have no uses.
Definition at line 132 of file Rewrite.cpp.
References unwrap().
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 179 of file Rewrite.cpp.
References unwrap().
MlirBlock mlirRewriterBaseGetBlock | ( | MlirRewriterBase | rewriter | ) |
Returns the current block of the rewriter.
Definition at line 66 of file Rewrite.cpp.
MlirContext mlirRewriterBaseGetContext | ( | MlirRewriterBase | rewriter | ) |
RewriterBase API inherited from OpBuilder.
Get the MLIR context referenced by the rewriter.
Definition at line 26 of file Rewrite.cpp.
References getContext(), unwrap(), and wrap().
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 62 of file Rewrite.cpp.
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 140 of file Rewrite.cpp.
References unwrap(), and unwrapList().
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 113 of file Rewrite.cpp.
References unwrap().
MlirOperation mlirRewriterBaseInsert | ( | MlirRewriterBase | rewriter, |
MlirOperation | op | ||
) |
Insert the given operation at the current insertion point and return it.
Definition at line 86 of file Rewrite.cpp.
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 151 of file Rewrite.cpp.
References unwrap(), and unwrapList().
void mlirRewriterBaseMoveBlockBefore | ( | MlirRewriterBase | rewriter, |
MlirBlock | block, | ||
MlirBlock | existingBlock | ||
) |
Unlink this block and insert it right before existingBlock
.
Definition at line 169 of file Rewrite.cpp.
References unwrap().
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 164 of file Rewrite.cpp.
References unwrap().
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 159 of file Rewrite.cpp.
References unwrap().
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 214 of file Rewrite.cpp.
References unwrap().
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 205 of file Rewrite.cpp.
References unwrap(), and unwrapList().
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 231 of file Rewrite.cpp.
References unwrap().
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 189 of file Rewrite.cpp.
References unwrap().
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 194 of file Rewrite.cpp.
References unwrap(), and unwrapList().
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 220 of file Rewrite.cpp.
References unwrap(), and unwrapList().
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 126 of file Rewrite.cpp.
References unwrap().
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 118 of file Rewrite.cpp.
References unwrap(), and unwrapList().
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 42 of file Rewrite.cpp.
References unwrap().
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 47 of file Rewrite.cpp.
References unwrap().
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 37 of file Rewrite.cpp.
References unwrap().
void mlirRewriterBaseSetInsertionPointToEnd | ( | MlirRewriterBase | rewriter, |
MlirBlock | block | ||
) |
Sets the insertion point to the end of the specified block.
Definition at line 57 of file Rewrite.cpp.
References unwrap().
void mlirRewriterBaseSetInsertionPointToStart | ( | MlirRewriterBase | rewriter, |
MlirBlock | block | ||
) |
Sets the insertion point to the start of the specified block.
Definition at line 52 of file Rewrite.cpp.
References unwrap().
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 174 of file Rewrite.cpp.
References unwrap().
|
inline |
Definition at line 268 of file Rewrite.cpp.
|
inline |
RewritePatternSet and FrozenRewritePatternSet API.
Definition at line 258 of file Rewrite.cpp.
Referenced by mlirApplyPatternsAndFoldGreedily(), mlirFrozenRewritePatternSetDestroy(), mlirIRRewriterCreate(), mlirIRRewriterCreateFromOp(), mlirIRRewriterDestroy(), mlirRewriterBaseCancelOpModification(), mlirRewriterBaseClearInsertionPoint(), mlirRewriterBaseClone(), mlirRewriterBaseCloneRegionBefore(), mlirRewriterBaseCloneWithoutRegions(), mlirRewriterBaseCreateBlockBefore(), mlirRewriterBaseEraseBlock(), mlirRewriterBaseEraseOp(), mlirRewriterBaseFinalizeOpModification(), mlirRewriterBaseGetBlock(), mlirRewriterBaseGetContext(), mlirRewriterBaseGetInsertionBlock(), mlirRewriterBaseInlineBlockBefore(), mlirRewriterBaseInlineRegionBefore(), mlirRewriterBaseInsert(), mlirRewriterBaseMergeBlocks(), mlirRewriterBaseMoveBlockBefore(), mlirRewriterBaseMoveOpAfter(), mlirRewriterBaseMoveOpBefore(), mlirRewriterBaseReplaceAllOpUsesWithOperation(), mlirRewriterBaseReplaceAllOpUsesWithValueRange(), mlirRewriterBaseReplaceAllUsesExcept(), mlirRewriterBaseReplaceAllUsesWith(), mlirRewriterBaseReplaceAllValueRangeUsesWith(), mlirRewriterBaseReplaceOpUsesWithinBlock(), mlirRewriterBaseReplaceOpWithOperation(), mlirRewriterBaseReplaceOpWithValues(), mlirRewriterBaseSetInsertionPointAfter(), mlirRewriterBaseSetInsertionPointAfterValue(), mlirRewriterBaseSetInsertionPointBefore(), mlirRewriterBaseSetInsertionPointToEnd(), mlirRewriterBaseSetInsertionPointToStart(), and mlirRewriterBaseStartOpModification().
|
inline |
Definition at line 273 of file Rewrite.cpp.
|
inline |
Definition at line 263 of file Rewrite.cpp.
Referenced by mlirApplyPatternsAndFoldGreedily(), mlirIRRewriterCreate(), mlirIRRewriterCreateFromOp(), mlirRewriterBaseClone(), mlirRewriterBaseCloneWithoutRegions(), mlirRewriterBaseCreateBlockBefore(), mlirRewriterBaseGetBlock(), mlirRewriterBaseGetContext(), mlirRewriterBaseGetInsertionBlock(), and mlirRewriterBaseInsert().