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
116 MlirRewriterBase rewriter, MlirBlock insertBefore, intptr_t nArgTypes,
117 MlirType
const *argTypes, MlirLocation
const *locations);
130 MlirRewriterBase rewriter, MlirOperation op);
155 intptr_t nValues, MlirValue
const *values);
162 MlirOperation op, MlirOperation newOp);
180 MlirOperation op, intptr_t nArgValues,
181 MlirValue
const *argValues);
193 MlirValue
const *argValues);
200 MlirOperation existingOp);
207 MlirOperation existingOp);
212 MlirBlock existingBlock);
247 MlirRewriterBase rewriter, intptr_t nValues, MlirValue
const *from,
248 MlirValue
const *to);
255 MlirOperation from, intptr_t nTo,
256 MlirValue
const *to);
262 MlirRewriterBase rewriter, MlirOperation from, MlirOperation to);
269 MlirRewriterBase rewriter, MlirOperation op, intptr_t nNewValues,
270 MlirValue
const *newValues, MlirBlock block);
277 MlirValue to, MlirOperation exceptedUser);
306 MlirOperation op, MlirFrozenRewritePatternSet
patterns,
307 MlirGreedyRewriteDriverConfig);
310 MlirModule op, MlirFrozenRewritePatternSet
patterns,
311 MlirGreedyRewriteDriverConfig);
317 #if MLIR_ENABLE_PDL_IN_PATTERNMATCH
357 MlirOperation value);
362 MlirAttribute value);
369 MlirPatternRewriter rewriter, MlirPDLResultList results,
size_t nValues,
370 MlirPDLValue *values,
void *userData);
380 #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 MlirValue mlirPDLValueAsValue(MlirPDLValue value)
Cast the MlirPDLValue to an MlirValue.
MLIR_CAPI_EXPORTED void mlirPDLPatternModuleRegisterRewriteFunction(MlirPDLPatternModule pdlModule, MlirStringRef name, MlirPDLRewriteFunction rewriteFn, void *userData)
Register a rewrite function into the given PDL pattern module.
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 MlirType mlirPDLValueAsType(MlirPDLValue value)
Cast the MlirPDLValue to an MlirType.
MLIR_CAPI_EXPORTED MlirOperation mlirPDLValueAsOperation(MlirPDLValue value)
Cast the MlirPDLValue to an MlirOperation.
MlirLogicalResult(* MlirPDLRewriteFunction)(MlirPatternRewriter rewriter, MlirPDLResultList results, size_t nValues, MlirPDLValue *values, void *userData)
This function type is used as callbacks for PDL native rewrite functions.
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 mlirPDLResultListPushBackAttribute(MlirPDLResultList results, MlirAttribute value)
Push the MlirAttribute into the given MlirPDLResultList.
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 MlirLogicalResult mlirApplyPatternsAndFoldGreedilyWithOp(MlirOperation op, MlirFrozenRewritePatternSet patterns, MlirGreedyRewriteDriverConfig)
MLIR_CAPI_EXPORTED void mlirPDLResultListPushBackOperation(MlirPDLResultList results, MlirOperation value)
Push the MlirOperation into the given MlirPDLResultList.
MLIR_CAPI_EXPORTED MlirRewritePatternSet mlirRewritePatternSetFromPDLPatternModule(MlirPDLPatternModule op)
MLIR_CAPI_EXPORTED void mlirPDLResultListPushBackType(MlirPDLResultList results, MlirType value)
Push the MlirType into the given MlirPDLResultList.
MLIR_CAPI_EXPORTED void mlirRewriterBaseInlineRegionBefore(MlirRewriterBase rewriter, MlirRegion region, MlirBlock before)
RewriterBase API.
MLIR_CAPI_EXPORTED MlirAttribute mlirPDLValueAsAttribute(MlirPDLValue value)
Cast the MlirPDLValue to an MlirAttribute.
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 mlirPDLResultListPushBackValue(MlirPDLResultList results, MlirValue value)
Push the MlirValue into the given MlirPDLResultList.
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.
struct MlirLogicalResult MlirLogicalResult
#define MLIR_CAPI_EXPORTED
const FrozenRewritePatternSet & patterns
A logical result value, essentially a boolean with named states.
A pointer to a sized fragment of a string, not necessarily null-terminated.