1 //===-- mlir-c/Dialect/Transform/Interpreter.h --------------------*- C -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 // C interface to the transform dialect interpreter.
12 //===----------------------------------------------------------------------===//
14 #include "mlir-c/IR.h"
15 #include "mlir-c/Support.h"
21 #define DEFINE_C_API_STRUCT(name, storage) \
25 typedef struct name name
27 DEFINE_C_API_STRUCT(MlirTransformOptions
, void);
29 #undef DEFINE_C_API_STRUCT
31 //----------------------------------------------------------------------------//
32 // MlirTransformOptions
33 //----------------------------------------------------------------------------//
35 /// Creates a default-initialized transform options object.
36 MLIR_CAPI_EXPORTED MlirTransformOptions
mlirTransformOptionsCreate(void);
38 /// Enables or disables expensive checks in transform options.
39 MLIR_CAPI_EXPORTED
void
40 mlirTransformOptionsEnableExpensiveChecks(MlirTransformOptions transformOptions
,
43 /// Returns true if expensive checks are enabled in transform options.
44 MLIR_CAPI_EXPORTED
bool mlirTransformOptionsGetExpensiveChecksEnabled(
45 MlirTransformOptions transformOptions
);
47 /// Enables or disables the enforcement of the top-level transform op being
48 /// single in transform options.
49 MLIR_CAPI_EXPORTED
void mlirTransformOptionsEnforceSingleTopLevelTransformOp(
50 MlirTransformOptions transformOptions
, bool enable
);
52 /// Returns true if the enforcement of the top-level transform op being single
53 /// is enabled in transform options.
54 MLIR_CAPI_EXPORTED
bool mlirTransformOptionsGetEnforceSingleTopLevelTransformOp(
55 MlirTransformOptions transformOptions
);
57 /// Destroys a transform options object previously created by
58 /// mlirTransformOptionsCreate.
59 MLIR_CAPI_EXPORTED
void
60 mlirTransformOptionsDestroy(MlirTransformOptions transformOptions
);
62 //----------------------------------------------------------------------------//
63 // Transform interpreter and utilities.
64 //----------------------------------------------------------------------------//
66 /// Applies the transformation script starting at the given transform root
67 /// operation to the given payload operation. The module containing the
68 /// transform root as well as the transform options should be provided. The
69 /// transform operation must implement TransformOpInterface and the module must
70 /// be a ModuleOp. Returns the status of the application.
71 MLIR_CAPI_EXPORTED MlirLogicalResult
mlirTransformApplyNamedSequence(
72 MlirOperation payload
, MlirOperation transformRoot
,
73 MlirOperation transformModule
, MlirTransformOptions transformOptions
);
75 /// Merge the symbols from `other` into `target`, potentially renaming them to
76 /// avoid conflicts. Private symbols may be renamed during the merge, public
77 /// symbols must have at most one declaration. A name conflict in public symbols
78 /// is reported as an error before returning a failure.
80 /// Note that this clones the `other` operation unlike the C++ counterpart that
82 MLIR_CAPI_EXPORTED MlirLogicalResult
83 mlirMergeSymbolsIntoFromClone(MlirOperation target
, MlirOperation other
);