MLIR  22.0.0git
Rewrite.h
Go to the documentation of this file.
1 //===-- mlir-c/Rewrite.h - Helpers for C API to Rewrites ----------*- 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 // This header declares the registration and creation method for
11 // rewrite patterns.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef MLIR_C_REWRITE_H
16 #define MLIR_C_REWRITE_H
17 
18 #include "mlir-c/IR.h"
19 #include "mlir-c/Support.h"
20 #include "mlir/Config/mlir-config.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 //===----------------------------------------------------------------------===//
27 /// Opaque type declarations (see mlir-c/IR.h for more details).
28 //===----------------------------------------------------------------------===//
29 
30 #define DEFINE_C_API_STRUCT(name, storage) \
31  struct name { \
32  storage *ptr; \
33  }; \
34  typedef struct name name
35 
36 DEFINE_C_API_STRUCT(MlirRewriterBase, void);
37 DEFINE_C_API_STRUCT(MlirFrozenRewritePatternSet, void);
38 DEFINE_C_API_STRUCT(MlirGreedyRewriteDriverConfig, void);
39 DEFINE_C_API_STRUCT(MlirRewritePatternSet, void);
40 DEFINE_C_API_STRUCT(MlirPatternRewriter, void);
41 
42 //===----------------------------------------------------------------------===//
43 /// RewriterBase API inherited from OpBuilder
44 //===----------------------------------------------------------------------===//
45 
46 /// Get the MLIR context referenced by the rewriter.
47 MLIR_CAPI_EXPORTED MlirContext
48 mlirRewriterBaseGetContext(MlirRewriterBase rewriter);
49 
50 //===----------------------------------------------------------------------===//
51 /// Insertion points methods
52 //===----------------------------------------------------------------------===//
53 
54 // These do not include functions using Block::iterator or Region::iterator, as
55 // they are not exposed by the C API yet. Similarly for methods using
56 // `InsertPoint` directly.
57 
58 /// Reset the insertion point to no location. Creating an operation without a
59 /// set insertion point is an error, but this can still be useful when the
60 /// current insertion point a builder refers to is being removed.
62 mlirRewriterBaseClearInsertionPoint(MlirRewriterBase rewriter);
63 
64 /// Sets the insertion point to the specified operation, which will cause
65 /// subsequent insertions to go right before it.
67 mlirRewriterBaseSetInsertionPointBefore(MlirRewriterBase rewriter,
68  MlirOperation op);
69 
70 /// Sets the insertion point to the node after the specified operation, which
71 /// will cause subsequent insertions to go right after it.
73 mlirRewriterBaseSetInsertionPointAfter(MlirRewriterBase rewriter,
74  MlirOperation op);
75 
76 /// Sets the insertion point to the node after the specified value. If value
77 /// has a defining operation, sets the insertion point to the node after such
78 /// defining operation. This will cause subsequent insertions to go right
79 /// after it. Otherwise, value is a BlockArgument. Sets the insertion point to
80 /// the start of its block.
82 mlirRewriterBaseSetInsertionPointAfterValue(MlirRewriterBase rewriter,
83  MlirValue value);
84 
85 /// Sets the insertion point to the start of the specified block.
87 mlirRewriterBaseSetInsertionPointToStart(MlirRewriterBase rewriter,
88  MlirBlock block);
89 
90 /// Sets the insertion point to the end of the specified block.
92 mlirRewriterBaseSetInsertionPointToEnd(MlirRewriterBase rewriter,
93  MlirBlock block);
94 
95 /// Return the block the current insertion point belongs to. Note that the
96 /// insertion point is not necessarily the end of the block.
97 MLIR_CAPI_EXPORTED MlirBlock
98 mlirRewriterBaseGetInsertionBlock(MlirRewriterBase rewriter);
99 
100 /// Returns the current block of the rewriter.
101 MLIR_CAPI_EXPORTED MlirBlock
102 mlirRewriterBaseGetBlock(MlirRewriterBase rewriter);
103 
104 //===----------------------------------------------------------------------===//
105 /// Block and operation creation/insertion/cloning
106 //===----------------------------------------------------------------------===//
107 
108 // These functions do not include the IRMapper, as it is not yet exposed by the
109 // C API.
110 
111 /// Add new block with 'argTypes' arguments and set the insertion point to the
112 /// end of it. The block is placed before 'insertBefore'. `locs` contains the
113 /// locations of the inserted arguments, and should match the size of
114 /// `argTypes`.
116  MlirRewriterBase rewriter, MlirBlock insertBefore, intptr_t nArgTypes,
117  MlirType const *argTypes, MlirLocation const *locations);
118 
119 /// Insert the given operation at the current insertion point and return it.
120 MLIR_CAPI_EXPORTED MlirOperation
121 mlirRewriterBaseInsert(MlirRewriterBase rewriter, MlirOperation op);
122 
123 /// Creates a deep copy of the specified operation.
124 MLIR_CAPI_EXPORTED MlirOperation
125 mlirRewriterBaseClone(MlirRewriterBase rewriter, MlirOperation op);
126 
127 /// Creates a deep copy of this operation but keep the operation regions
128 /// empty.
130  MlirRewriterBase rewriter, MlirOperation op);
131 
132 /// Clone the blocks that belong to "region" before the given position in
133 /// another region "parent".
135 mlirRewriterBaseCloneRegionBefore(MlirRewriterBase rewriter, MlirRegion region,
136  MlirBlock before);
137 
138 //===----------------------------------------------------------------------===//
139 /// RewriterBase API
140 //===----------------------------------------------------------------------===//
141 
142 /// Move the blocks that belong to "region" before the given position in
143 /// another region "parent". The two regions must be different. The caller
144 /// is responsible for creating or updating the operation transferring flow
145 /// of control to the region and passing it the correct block arguments.
147 mlirRewriterBaseInlineRegionBefore(MlirRewriterBase rewriter, MlirRegion region,
148  MlirBlock before);
149 
150 /// Replace the results of the given (original) operation with the specified
151 /// list of values (replacements). The result types of the given op and the
152 /// replacements must match. The original op is erased.
154 mlirRewriterBaseReplaceOpWithValues(MlirRewriterBase rewriter, MlirOperation op,
155  intptr_t nValues, MlirValue const *values);
156 
157 /// Replace the results of the given (original) operation with the specified
158 /// new op (replacement). The result types of the two ops must match. The
159 /// original op is erased.
161 mlirRewriterBaseReplaceOpWithOperation(MlirRewriterBase rewriter,
162  MlirOperation op, MlirOperation newOp);
163 
164 /// Erases an operation that is known to have no uses.
165 MLIR_CAPI_EXPORTED void mlirRewriterBaseEraseOp(MlirRewriterBase rewriter,
166  MlirOperation op);
167 
168 /// Erases a block along with all operations inside it.
169 MLIR_CAPI_EXPORTED void mlirRewriterBaseEraseBlock(MlirRewriterBase rewriter,
170  MlirBlock block);
171 
172 /// Inline the operations of block 'source' before the operation 'op'. The
173 /// source block will be deleted and must have no uses. 'argValues' is used to
174 /// replace the block arguments of 'source'
175 ///
176 /// The source block must have no successors. Otherwise, the resulting IR
177 /// would have unreachable operations.
179 mlirRewriterBaseInlineBlockBefore(MlirRewriterBase rewriter, MlirBlock source,
180  MlirOperation op, intptr_t nArgValues,
181  MlirValue const *argValues);
182 
183 /// Inline the operations of block 'source' into the end of block 'dest'. The
184 /// source block will be deleted and must have no uses. 'argValues' is used to
185 /// replace the block arguments of 'source'
186 ///
187 /// The dest block must have no successors. Otherwise, the resulting IR would
188 /// have unreachable operation.
189 MLIR_CAPI_EXPORTED void mlirRewriterBaseMergeBlocks(MlirRewriterBase rewriter,
190  MlirBlock source,
191  MlirBlock dest,
192  intptr_t nArgValues,
193  MlirValue const *argValues);
194 
195 /// Unlink this operation from its current block and insert it right before
196 /// `existingOp` which may be in the same or another block in the same
197 /// function.
198 MLIR_CAPI_EXPORTED void mlirRewriterBaseMoveOpBefore(MlirRewriterBase rewriter,
199  MlirOperation op,
200  MlirOperation existingOp);
201 
202 /// Unlink this operation from its current block and insert it right after
203 /// `existingOp` which may be in the same or another block in the same
204 /// function.
205 MLIR_CAPI_EXPORTED void mlirRewriterBaseMoveOpAfter(MlirRewriterBase rewriter,
206  MlirOperation op,
207  MlirOperation existingOp);
208 
209 /// Unlink this block and insert it right before `existingBlock`.
211 mlirRewriterBaseMoveBlockBefore(MlirRewriterBase rewriter, MlirBlock block,
212  MlirBlock existingBlock);
213 
214 /// This method is used to notify the rewriter that an in-place operation
215 /// modification is about to happen. A call to this function *must* be
216 /// followed by a call to either `finalizeOpModification` or
217 /// `cancelOpModification`. This is a minor efficiency win (it avoids creating
218 /// a new operation and removing the old one) but also often allows simpler
219 /// code in the client.
221 mlirRewriterBaseStartOpModification(MlirRewriterBase rewriter,
222  MlirOperation op);
223 
224 /// This method is used to signal the end of an in-place modification of the
225 /// given operation. This can only be called on operations that were provided
226 /// to a call to `startOpModification`.
228 mlirRewriterBaseFinalizeOpModification(MlirRewriterBase rewriter,
229  MlirOperation op);
230 
231 /// This method cancels a pending in-place modification. This can only be
232 /// called on operations that were provided to a call to
233 /// `startOpModification`.
235 mlirRewriterBaseCancelOpModification(MlirRewriterBase rewriter,
236  MlirOperation op);
237 
238 /// Find uses of `from` and replace them with `to`. Also notify the listener
239 /// about every in-place op modification (for every use that was replaced).
241 mlirRewriterBaseReplaceAllUsesWith(MlirRewriterBase rewriter, MlirValue from,
242  MlirValue to);
243 
244 /// Find uses of `from` and replace them with `to`. Also notify the listener
245 /// about every in-place op modification (for every use that was replaced).
247  MlirRewriterBase rewriter, intptr_t nValues, MlirValue const *from,
248  MlirValue const *to);
249 
250 /// Find uses of `from` and replace them with `to`. Also notify the listener
251 /// about every in-place op modification (for every use that was replaced)
252 /// and that the `from` operation is about to be replaced.
254 mlirRewriterBaseReplaceAllOpUsesWithValueRange(MlirRewriterBase rewriter,
255  MlirOperation from, intptr_t nTo,
256  MlirValue const *to);
257 
258 /// Find uses of `from` and replace them with `to`. Also notify the listener
259 /// about every in-place op modification (for every use that was replaced)
260 /// and that the `from` operation is about to be replaced.
262  MlirRewriterBase rewriter, MlirOperation from, MlirOperation to);
263 
264 /// Find uses of `from` within `block` and replace them with `to`. Also notify
265 /// the listener about every in-place op modification (for every use that was
266 /// replaced). The optional `allUsesReplaced` flag is set to "true" if all
267 /// uses were replaced.
269  MlirRewriterBase rewriter, MlirOperation op, intptr_t nNewValues,
270  MlirValue const *newValues, MlirBlock block);
271 
272 /// Find uses of `from` and replace them with `to` except if the user is
273 /// `exceptedUser`. Also notify the listener about every in-place op
274 /// modification (for every use that was replaced).
276 mlirRewriterBaseReplaceAllUsesExcept(MlirRewriterBase rewriter, MlirValue from,
277  MlirValue to, MlirOperation exceptedUser);
278 
279 //===----------------------------------------------------------------------===//
280 /// IRRewriter API
281 //===----------------------------------------------------------------------===//
282 
283 /// Create an IRRewriter and transfer ownership to the caller.
284 MLIR_CAPI_EXPORTED MlirRewriterBase mlirIRRewriterCreate(MlirContext context);
285 
286 /// Create an IRRewriter and transfer ownership to the caller. Additionally
287 /// set the insertion point before the operation.
288 MLIR_CAPI_EXPORTED MlirRewriterBase
289 mlirIRRewriterCreateFromOp(MlirOperation op);
290 
291 /// Takes an IRRewriter owned by the caller and destroys it. It is the
292 /// responsibility of the user to only pass an IRRewriter class.
293 MLIR_CAPI_EXPORTED void mlirIRRewriterDestroy(MlirRewriterBase rewriter);
294 
295 //===----------------------------------------------------------------------===//
296 /// FrozenRewritePatternSet API
297 //===----------------------------------------------------------------------===//
298 
299 MLIR_CAPI_EXPORTED MlirFrozenRewritePatternSet
300 mlirFreezeRewritePattern(MlirRewritePatternSet op);
301 
303 mlirFrozenRewritePatternSetDestroy(MlirFrozenRewritePatternSet op);
304 
306  MlirOperation op, MlirFrozenRewritePatternSet patterns,
307  MlirGreedyRewriteDriverConfig);
308 
310  MlirModule op, MlirFrozenRewritePatternSet patterns,
311  MlirGreedyRewriteDriverConfig);
312 
313 //===----------------------------------------------------------------------===//
314 /// PDLPatternModule API
315 //===----------------------------------------------------------------------===//
316 
317 #if MLIR_ENABLE_PDL_IN_PATTERNMATCH
318 DEFINE_C_API_STRUCT(MlirPDLPatternModule, void);
319 DEFINE_C_API_STRUCT(MlirPDLValue, const void);
320 DEFINE_C_API_STRUCT(MlirPDLResultList, void);
321 
322 MLIR_CAPI_EXPORTED MlirPDLPatternModule
324 
325 MLIR_CAPI_EXPORTED void mlirPDLPatternModuleDestroy(MlirPDLPatternModule op);
326 
327 MLIR_CAPI_EXPORTED MlirRewritePatternSet
329 
330 /// Cast the MlirPDLValue to an MlirValue.
331 /// Return a null value if the cast fails, just like llvm::dyn_cast.
332 MLIR_CAPI_EXPORTED MlirValue mlirPDLValueAsValue(MlirPDLValue value);
333 
334 /// Cast the MlirPDLValue to an MlirType.
335 /// Return a null value if the cast fails, just like llvm::dyn_cast.
336 MLIR_CAPI_EXPORTED MlirType mlirPDLValueAsType(MlirPDLValue value);
337 
338 /// Cast the MlirPDLValue to an MlirOperation.
339 /// Return a null value if the cast fails, just like llvm::dyn_cast.
340 MLIR_CAPI_EXPORTED MlirOperation mlirPDLValueAsOperation(MlirPDLValue value);
341 
342 /// Cast the MlirPDLValue to an MlirAttribute.
343 /// Return a null value if the cast fails, just like llvm::dyn_cast.
344 MLIR_CAPI_EXPORTED MlirAttribute mlirPDLValueAsAttribute(MlirPDLValue value);
345 
346 /// Push the MlirValue into the given MlirPDLResultList.
348 mlirPDLResultListPushBackValue(MlirPDLResultList results, MlirValue value);
349 
350 /// Push the MlirType into the given MlirPDLResultList.
351 MLIR_CAPI_EXPORTED void mlirPDLResultListPushBackType(MlirPDLResultList results,
352  MlirType value);
353 
354 /// Push the MlirOperation into the given MlirPDLResultList.
356 mlirPDLResultListPushBackOperation(MlirPDLResultList results,
357  MlirOperation value);
358 
359 /// Push the MlirAttribute into the given MlirPDLResultList.
361 mlirPDLResultListPushBackAttribute(MlirPDLResultList results,
362  MlirAttribute value);
363 
364 /// This function type is used as callbacks for PDL native rewrite functions.
365 /// Input values can be accessed by `values` with its size `nValues`;
366 /// output values can be added into `results` by `mlirPDLResultListPushBack*`
367 /// APIs. And the return value indicates whether the rewrite succeeds.
369  MlirPatternRewriter rewriter, MlirPDLResultList results, size_t nValues,
370  MlirPDLValue *values, void *userData);
371 
372 /// Register a rewrite function into the given PDL pattern module.
373 /// `userData` will be provided as an argument to the rewrite function.
375  MlirPDLPatternModule pdlModule, MlirStringRef name,
376  MlirPDLRewriteFunction rewriteFn, void *userData);
377 
378 #endif // MLIR_ENABLE_PDL_IN_PATTERNMATCH
379 
380 #undef DEFINE_C_API_STRUCT
381 
382 #ifdef __cplusplus
383 }
384 #endif
385 
386 #endif // MLIR_C_REWRITE_H
MLIR_CAPI_EXPORTED void mlirRewriterBaseMoveBlockBefore(MlirRewriterBase rewriter, MlirBlock block, MlirBlock existingBlock)
Unlink this block and insert it right before existingBlock.
Definition: Rewrite.cpp:173
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.
Definition: Rewrite.cpp:183
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...
Definition: Rewrite.cpp:122
MLIR_CAPI_EXPORTED void mlirRewriterBaseEraseBlock(MlirRewriterBase rewriter, MlirBlock block)
Erases a block along with all operations inside it.
Definition: Rewrite.cpp:140
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...
Definition: Rewrite.cpp:40
MLIR_CAPI_EXPORTED void mlirRewriterBaseCancelOpModification(MlirRewriterBase rewriter, MlirOperation op)
This method cancels a pending in-place modification.
Definition: Rewrite.cpp:188
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...
Definition: Rewrite.cpp:45
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.
Definition: Rewrite.cpp:224
MLIR_CAPI_EXPORTED void mlirRewriterBaseReplaceAllOpUsesWithOperation(MlirRewriterBase rewriter, MlirOperation from, MlirOperation to)
Find uses of from and replace them with to.
Definition: Rewrite.cpp:218
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.
Definition: Rewrite.h:368
MLIR_CAPI_EXPORTED MlirOperation mlirRewriterBaseClone(MlirRewriterBase rewriter, MlirOperation op)
Creates a deep copy of the specified operation.
Definition: Rewrite.cpp:97
#define DEFINE_C_API_STRUCT(name, storage)
Opaque type declarations (see mlir-c/IR.h for more details).
Definition: Rewrite.h:30
MLIR_CAPI_EXPORTED MlirOperation mlirRewriterBaseInsert(MlirRewriterBase rewriter, MlirOperation op)
Insert the given operation at the current insertion point and return it.
Definition: Rewrite.cpp:90
MLIR_CAPI_EXPORTED MlirFrozenRewritePatternSet mlirFreezeRewritePattern(MlirRewritePatternSet op)
FrozenRewritePatternSet API.
Definition: Rewrite.cpp:281
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.
Definition: Rewrite.cpp:198
MLIR_CAPI_EXPORTED void mlirRewriterBaseEraseOp(MlirRewriterBase rewriter, MlirOperation op)
Erases an operation that is known to have no uses.
Definition: Rewrite.cpp:136
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'.
Definition: Rewrite.cpp:144
MLIR_CAPI_EXPORTED MlirRewriterBase mlirIRRewriterCreateFromOp(MlirOperation op)
Create an IRRewriter and transfer ownership to the caller.
Definition: Rewrite.cpp:250
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...
Definition: Rewrite.cpp:178
MLIR_CAPI_EXPORTED MlirContext mlirRewriterBaseGetContext(MlirRewriterBase rewriter)
RewriterBase API inherited from OpBuilder.
Definition: Rewrite.cpp:28
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).
Definition: Rewrite.cpp:130
MLIR_CAPI_EXPORTED MlirRewriterBase mlirIRRewriterCreate(MlirContext context)
IRRewriter API.
Definition: Rewrite.cpp:246
MLIR_CAPI_EXPORTED MlirLogicalResult mlirApplyPatternsAndFoldGreedily(MlirModule op, MlirFrozenRewritePatternSet patterns, MlirGreedyRewriteDriverConfig)
Definition: Rewrite.cpp:293
MLIR_CAPI_EXPORTED MlirBlock mlirRewriterBaseGetInsertionBlock(MlirRewriterBase rewriter)
Return the block the current insertion point belongs to.
Definition: Rewrite.cpp:65
MLIR_CAPI_EXPORTED void mlirFrozenRewritePatternSetDestroy(MlirFrozenRewritePatternSet op)
Definition: Rewrite.cpp:287
MLIR_CAPI_EXPORTED void mlirRewriterBaseClearInsertionPoint(MlirRewriterBase rewriter)
Insertion points methods.
Definition: Rewrite.cpp:36
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...
Definition: Rewrite.cpp:168
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".
Definition: Rewrite.cpp:107
MLIR_CAPI_EXPORTED MlirLogicalResult mlirApplyPatternsAndFoldGreedilyWithOp(MlirOperation op, MlirFrozenRewritePatternSet patterns, MlirGreedyRewriteDriverConfig)
Definition: Rewrite.cpp:300
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.
Definition: Rewrite.cpp:117
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.
Definition: Rewrite.cpp:69
MLIR_CAPI_EXPORTED void mlirRewriterBaseSetInsertionPointToEnd(MlirRewriterBase rewriter, MlirBlock block)
Sets the insertion point to the end of the specified block.
Definition: Rewrite.cpp:60
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.
Definition: Rewrite.cpp:235
MLIR_CAPI_EXPORTED void mlirRewriterBaseReplaceAllOpUsesWithValueRange(MlirRewriterBase rewriter, MlirOperation from, intptr_t nTo, MlirValue const *to)
Find uses of from and replace them with to.
Definition: Rewrite.cpp:209
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...
Definition: Rewrite.cpp:163
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'.
Definition: Rewrite.cpp:155
MLIR_CAPI_EXPORTED void mlirRewriterBaseSetInsertionPointAfterValue(MlirRewriterBase rewriter, MlirValue value)
Sets the insertion point to the node after the specified value.
Definition: Rewrite.cpp:50
MLIR_CAPI_EXPORTED MlirOperation mlirRewriterBaseCloneWithoutRegions(MlirRewriterBase rewriter, MlirOperation op)
Creates a deep copy of this operation but keep the operation regions empty.
Definition: Rewrite.cpp:102
MLIR_CAPI_EXPORTED void mlirIRRewriterDestroy(MlirRewriterBase rewriter)
Takes an IRRewriter owned by the caller and destroys it.
Definition: Rewrite.cpp:254
MLIR_CAPI_EXPORTED MlirBlock mlirRewriterBaseCreateBlockBefore(MlirRewriterBase rewriter, MlirBlock insertBefore, intptr_t nArgTypes, MlirType const *argTypes, MlirLocation const *locations)
Block and operation creation/insertion/cloning.
Definition: Rewrite.cpp:77
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.
Definition: Rewrite.cpp:193
MLIR_CAPI_EXPORTED void mlirRewriterBaseSetInsertionPointToStart(MlirRewriterBase rewriter, MlirBlock block)
Sets the insertion point to the start of the specified block.
Definition: Rewrite.cpp:55
struct MlirLogicalResult MlirLogicalResult
Definition: Support.h:119
#define MLIR_CAPI_EXPORTED
Definition: Support.h:46
const FrozenRewritePatternSet & patterns
A logical result value, essentially a boolean with named states.
Definition: Support.h:116
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition: Support.h:73