1 | //===-- mlir-c/Dialect/Transform/Interpreter.h --------------------*- C -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM |
4 | // Exceptions. |
5 | // See https://llvm.org/LICENSE.txt for license information. |
6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | // |
10 | // C interface to the transform dialect interpreter. |
11 | // |
12 | //===----------------------------------------------------------------------===// |
13 | |
14 | #include "mlir-c/IR.h" |
15 | #include "mlir-c/Support.h" |
16 | |
17 | #ifdef __cplusplus |
18 | extern "C" { |
19 | #endif |
20 | |
21 | #define DEFINE_C_API_STRUCT(name, storage) \ |
22 | struct name { \ |
23 | storage *ptr; \ |
24 | }; \ |
25 | typedef struct name name |
26 | |
27 | DEFINE_C_API_STRUCT(MlirTransformOptions, void); |
28 | |
29 | #undef DEFINE_C_API_STRUCT |
30 | |
31 | //----------------------------------------------------------------------------// |
32 | // MlirTransformOptions |
33 | //----------------------------------------------------------------------------// |
34 | |
35 | /// Creates a default-initialized transform options object. |
36 | MLIR_CAPI_EXPORTED MlirTransformOptions mlirTransformOptionsCreate(void); |
37 | |
38 | /// Enables or disables expensive checks in transform options. |
39 | MLIR_CAPI_EXPORTED void |
40 | mlirTransformOptionsEnableExpensiveChecks(MlirTransformOptions transformOptions, |
41 | bool enable); |
42 | |
43 | /// Returns true if expensive checks are enabled in transform options. |
44 | MLIR_CAPI_EXPORTED bool mlirTransformOptionsGetExpensiveChecksEnabled( |
45 | MlirTransformOptions transformOptions); |
46 | |
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); |
51 | |
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); |
56 | |
57 | /// Destroys a transform options object previously created by |
58 | /// mlirTransformOptionsCreate. |
59 | MLIR_CAPI_EXPORTED void |
60 | mlirTransformOptionsDestroy(MlirTransformOptions transformOptions); |
61 | |
62 | //----------------------------------------------------------------------------// |
63 | // Transform interpreter and utilities. |
64 | //----------------------------------------------------------------------------// |
65 | |
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); |
74 | |
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. |
79 | /// |
80 | /// Note that this clones the `other` operation unlike the C++ counterpart that |
81 | /// takes ownership. |
82 | MLIR_CAPI_EXPORTED MlirLogicalResult |
83 | mlirMergeSymbolsIntoFromClone(MlirOperation target, MlirOperation other); |
84 | |
85 | #ifdef __cplusplus |
86 | } |
87 | #endif |
88 | |