@@ -329,17 +329,28 @@ mlirPatternRewriterAsBase(MlirPatternRewriter rewriter);
329329/// RewritePattern API
330330//===----------------------------------------------------------------------===//
331331
332+ /// PatternBenefit represents the benefit of a pattern match.
332333typedef unsigned short MlirPatternBenefit ;
333334
335+ /// Callbacks to construct a rewrite pattern.
334336typedef struct {
337+ /// Optional constructor for the user data.
338+ /// Set to nullptr to disable it.
335339 void (* construct )(void * userData );
340+ /// Optional destructor for the user data.
341+ /// Set to nullptr to disable it.
336342 void (* destruct )(void * userData );
343+ /// The callback function to match against code rooted at the specified
344+ /// operation, and perform the rewrite if the match is successful,
345+ /// corresponding to RewritePattern::matchAndRewrite.
337346 MlirLogicalResult (* matchAndRewrite )(MlirRewritePattern pattern ,
338347 MlirOperation op ,
339348 MlirPatternRewriter rewriter ,
340349 void * userData );
341350} MlirRewritePatternCallbacks ;
342351
352+ /// Create a rewrite pattern that matches the operation
353+ /// with the given rootName, corresponding to mlir::OpRewritePattern.
343354MLIR_CAPI_EXPORTED MlirRewritePattern mlirOpRewritePattenCreate (
344355 MlirStringRef rootName , MlirPatternBenefit benefit , MlirContext context ,
345356 MlirRewritePatternCallbacks callbacks , void * userData ,
@@ -349,11 +360,14 @@ MLIR_CAPI_EXPORTED MlirRewritePattern mlirOpRewritePattenCreate(
349360/// RewritePatternSet API
350361//===----------------------------------------------------------------------===//
351362
363+ /// Create an empty MlirRewritePatternSet.
352364MLIR_CAPI_EXPORTED MlirRewritePatternSet
353365mlirRewritePatternSetCreate (MlirContext context );
354366
367+ /// Destruct the given MlirRewritePatternSet.
355368MLIR_CAPI_EXPORTED void mlirRewritePatternSetDestroy (MlirRewritePatternSet set );
356369
370+ /// Add the given MlirRewritePattern into a MlirRewritePatternSet.
357371MLIR_CAPI_EXPORTED void mlirRewritePatternSetAdd (MlirRewritePatternSet set ,
358372 MlirRewritePattern pattern );
359373
0 commit comments