Skip to content

Commit 395627f

Browse files
committed
add docs for C API
1 parent 61b87af commit 395627f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mlir/include/mlir-c/Rewrite.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,17 +329,28 @@ mlirPatternRewriterAsBase(MlirPatternRewriter rewriter);
329329
/// RewritePattern API
330330
//===----------------------------------------------------------------------===//
331331

332+
/// PatternBenefit represents the benefit of a pattern match.
332333
typedef unsigned short MlirPatternBenefit;
333334

335+
/// Callbacks to construct a rewrite pattern.
334336
typedef 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.
343354
MLIR_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.
352364
MLIR_CAPI_EXPORTED MlirRewritePatternSet
353365
mlirRewritePatternSetCreate(MlirContext context);
354366

367+
/// Destruct the given MlirRewritePatternSet.
355368
MLIR_CAPI_EXPORTED void mlirRewritePatternSetDestroy(MlirRewritePatternSet set);
356369

370+
/// Add the given MlirRewritePattern into a MlirRewritePatternSet.
357371
MLIR_CAPI_EXPORTED void mlirRewritePatternSetAdd(MlirRewritePatternSet set,
358372
MlirRewritePattern pattern);
359373

0 commit comments

Comments
 (0)