15 #ifndef MLIR_C_REWRITE_H
16 #define MLIR_C_REWRITE_H
20 #include "mlir/Config/mlir-config.h"
30 #define DEFINE_C_API_STRUCT(name, storage) \
34 typedef struct name name
113 MlirRewriterBase rewriter, MlirBlock insertBefore, intptr_t nArgTypes,
114 MlirType
const *argTypes, MlirLocation
const *locations);
127 MlirRewriterBase rewriter, MlirOperation op);
152 intptr_t nValues, MlirValue
const *values);
159 MlirOperation op, MlirOperation newOp);
177 MlirOperation op, intptr_t nArgValues,
178 MlirValue
const *argValues);
190 MlirValue
const *argValues);
197 MlirOperation existingOp);
204 MlirOperation existingOp);
209 MlirBlock existingBlock);
244 MlirRewriterBase rewriter, intptr_t nValues, MlirValue
const *from,
245 MlirValue
const *to);
252 MlirOperation from, intptr_t nTo,
253 MlirValue
const *to);
259 MlirRewriterBase rewriter, MlirOperation from, MlirOperation to);
266 MlirRewriterBase rewriter, MlirOperation op, intptr_t nNewValues,
267 MlirValue
const *newValues, MlirBlock block);
274 MlirValue to, MlirOperation exceptedUser);
303 MlirModule op, MlirFrozenRewritePatternSet patterns,
304 MlirGreedyRewriteDriverConfig);
310 #if MLIR_ENABLE_PDL_IN_PATTERNMATCH
322 #undef DEFINE_C_API_STRUCT
MLIR_CAPI_EXPORTED void mlirRewriterBaseMoveBlockBefore(MlirRewriterBase rewriter, MlirBlock block, MlirBlock existingBlock)
Unlink this block and insert it right before existingBlock.
MLIR_CAPI_EXPORTED void mlirPDLPatternModuleDestroy(MlirPDLPatternModule op)
MLIR_CAPI_EXPORTED void mlirRewriterBaseFinalizeOpModification(MlirRewriterBase rewriter, MlirOperation op)
This method is used to signal the end of an in-place modification of the given operation.
MLIR_CAPI_EXPORTED 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...
MLIR_CAPI_EXPORTED void mlirRewriterBaseEraseBlock(MlirRewriterBase rewriter, MlirBlock block)
Erases a block along with all operations inside it.
MLIR_CAPI_EXPORTED void mlirRewriterBaseSetInsertionPointBefore(MlirRewriterBase rewriter, MlirOperation op)
Sets the insertion point to the specified operation, which will cause subsequent insertions to go rig...
MLIR_CAPI_EXPORTED void mlirRewriterBaseCancelOpModification(MlirRewriterBase rewriter, MlirOperation op)
This method cancels a pending in-place modification.
MLIR_CAPI_EXPORTED void mlirRewriterBaseSetInsertionPointAfter(MlirRewriterBase rewriter, MlirOperation op)
Sets the insertion point to the node after the specified operation, which will cause subsequent inser...
MLIR_CAPI_EXPORTED 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.
MLIR_CAPI_EXPORTED void mlirRewriterBaseReplaceAllOpUsesWithOperation(MlirRewriterBase rewriter, MlirOperation from, MlirOperation to)
Find uses of from and replace them with to.
MLIR_CAPI_EXPORTED MlirPDLPatternModule mlirPDLPatternModuleFromModule(MlirModule op)
MLIR_CAPI_EXPORTED MlirOperation mlirRewriterBaseClone(MlirRewriterBase rewriter, MlirOperation op)
Creates a deep copy of the specified operation.
#define DEFINE_C_API_STRUCT(name, storage)
Opaque type declarations (see mlir-c/IR.h for more details).
MLIR_CAPI_EXPORTED MlirOperation mlirRewriterBaseInsert(MlirRewriterBase rewriter, MlirOperation op)
Insert the given operation at the current insertion point and return it.
MLIR_CAPI_EXPORTED MlirFrozenRewritePatternSet mlirFreezeRewritePattern(MlirRewritePatternSet op)
FrozenRewritePatternSet API.
MLIR_CAPI_EXPORTED void mlirRewriterBaseReplaceAllValueRangeUsesWith(MlirRewriterBase rewriter, intptr_t nValues, MlirValue const *from, MlirValue const *to)
Find uses of from and replace them with to.
MLIR_CAPI_EXPORTED void mlirRewriterBaseEraseOp(MlirRewriterBase rewriter, MlirOperation op)
Erases an operation that is known to have no uses.
MLIR_CAPI_EXPORTED void mlirRewriterBaseInlineBlockBefore(MlirRewriterBase rewriter, MlirBlock source, MlirOperation op, intptr_t nArgValues, MlirValue const *argValues)
Inline the operations of block 'source' before the operation 'op'.
MLIR_CAPI_EXPORTED MlirRewriterBase mlirIRRewriterCreateFromOp(MlirOperation op)
Create an IRRewriter and transfer ownership to the caller.
MLIR_CAPI_EXPORTED void mlirRewriterBaseStartOpModification(MlirRewriterBase rewriter, MlirOperation op)
This method is used to notify the rewriter that an in-place operation modification is about to happen...
MLIR_CAPI_EXPORTED MlirContext mlirRewriterBaseGetContext(MlirRewriterBase rewriter)
RewriterBase API inherited from OpBuilder.
MLIR_CAPI_EXPORTED void mlirRewriterBaseReplaceOpWithOperation(MlirRewriterBase rewriter, MlirOperation op, MlirOperation newOp)
Replace the results of the given (original) operation with the specified new op (replacement).
MLIR_CAPI_EXPORTED MlirRewriterBase mlirIRRewriterCreate(MlirContext context)
IRRewriter API.
MLIR_CAPI_EXPORTED MlirLogicalResult mlirApplyPatternsAndFoldGreedily(MlirModule op, MlirFrozenRewritePatternSet patterns, MlirGreedyRewriteDriverConfig)
MLIR_CAPI_EXPORTED MlirBlock mlirRewriterBaseGetInsertionBlock(MlirRewriterBase rewriter)
Return the block the current insertion point belongs to.
MLIR_CAPI_EXPORTED void mlirFrozenRewritePatternSetDestroy(MlirFrozenRewritePatternSet op)
MLIR_CAPI_EXPORTED void mlirRewriterBaseClearInsertionPoint(MlirRewriterBase rewriter)
Insertion points methods.
MLIR_CAPI_EXPORTED 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...
MLIR_CAPI_EXPORTED void mlirRewriterBaseCloneRegionBefore(MlirRewriterBase rewriter, MlirRegion region, MlirBlock before)
Clone the blocks that belong to "region" before the given position in another region "parent".
MLIR_CAPI_EXPORTED MlirRewritePatternSet mlirRewritePatternSetFromPDLPatternModule(MlirPDLPatternModule op)
MLIR_CAPI_EXPORTED void mlirRewriterBaseInlineRegionBefore(MlirRewriterBase rewriter, MlirRegion region, MlirBlock before)
RewriterBase API.
MLIR_CAPI_EXPORTED MlirBlock mlirRewriterBaseGetBlock(MlirRewriterBase rewriter)
Returns the current block of the rewriter.
MLIR_CAPI_EXPORTED void mlirRewriterBaseSetInsertionPointToEnd(MlirRewriterBase rewriter, MlirBlock block)
Sets the insertion point to the end of the specified block.
MLIR_CAPI_EXPORTED 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.
MLIR_CAPI_EXPORTED void mlirRewriterBaseReplaceAllOpUsesWithValueRange(MlirRewriterBase rewriter, MlirOperation from, intptr_t nTo, MlirValue const *to)
Find uses of from and replace them with to.
MLIR_CAPI_EXPORTED 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 th...
MLIR_CAPI_EXPORTED 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'.
MLIR_CAPI_EXPORTED void mlirRewriterBaseSetInsertionPointAfterValue(MlirRewriterBase rewriter, MlirValue value)
Sets the insertion point to the node after the specified value.
MLIR_CAPI_EXPORTED MlirOperation mlirRewriterBaseCloneWithoutRegions(MlirRewriterBase rewriter, MlirOperation op)
Creates a deep copy of this operation but keep the operation regions empty.
MLIR_CAPI_EXPORTED void mlirIRRewriterDestroy(MlirRewriterBase rewriter)
Takes an IRRewriter owned by the caller and destroys it.
MLIR_CAPI_EXPORTED MlirBlock mlirRewriterBaseCreateBlockBefore(MlirRewriterBase rewriter, MlirBlock insertBefore, intptr_t nArgTypes, MlirType const *argTypes, MlirLocation const *locations)
Block and operation creation/insertion/cloning.
MLIR_CAPI_EXPORTED void mlirRewriterBaseReplaceAllUsesWith(MlirRewriterBase rewriter, MlirValue from, MlirValue to)
Find uses of from and replace them with to.
MLIR_CAPI_EXPORTED void mlirRewriterBaseSetInsertionPointToStart(MlirRewriterBase rewriter, MlirBlock block)
Sets the insertion point to the start of the specified block.
#define MLIR_CAPI_EXPORTED
A logical result value, essentially a boolean with named states.