MLIR 23.0.0git
IR.h
Go to the documentation of this file.
1//===-- mlir-c/IR.h - C API to Core MLIR IR classes ---------------*- 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 C interface to MLIR core IR classes.
11//
12// Many exotic languages can interoperate with C code but have a harder time
13// with C++ due to name mangling. So in addition to C, this interface enables
14// tools written in such languages.
15//
16//===----------------------------------------------------------------------===//
17
18#ifndef MLIR_C_IR_H
19#define MLIR_C_IR_H
20
21#include <stdbool.h>
22#include <stdint.h>
23
24#include "mlir-c/Support.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30//===----------------------------------------------------------------------===//
31/// Opaque type declarations.
32///
33/// Types are exposed to C bindings as structs containing opaque pointers. They
34/// are not supposed to be inspected from C. This allows the underlying
35/// representation to change without affecting the API users. The use of structs
36/// instead of typedefs enables some type safety as structs are not implicitly
37/// convertible to each other.
38///
39/// Instances of these types may or may not own the underlying object (most
40/// often only point to an IR fragment without owning it). The ownership
41/// semantics is defined by how an instance of the type was obtained.
42
43//===----------------------------------------------------------------------===//
44
45#define DEFINE_C_API_STRUCT(name, storage) \
46 struct name { \
47 storage *ptr; \
48 }; \
49 typedef struct name name
50
51DEFINE_C_API_STRUCT(MlirAsmState, void);
52DEFINE_C_API_STRUCT(MlirBytecodeWriterConfig, void);
53DEFINE_C_API_STRUCT(MlirContext, void);
54DEFINE_C_API_STRUCT(MlirDialect, void);
55DEFINE_C_API_STRUCT(MlirDialectRegistry, void);
56DEFINE_C_API_STRUCT(MlirOperation, void);
57DEFINE_C_API_STRUCT(MlirOpOperand, void);
58DEFINE_C_API_STRUCT(MlirOpPrintingFlags, void);
59DEFINE_C_API_STRUCT(MlirBlock, void);
60DEFINE_C_API_STRUCT(MlirRegion, void);
61DEFINE_C_API_STRUCT(MlirSymbolTable, void);
62DEFINE_C_API_STRUCT(MlirIRMapping, void);
63
64DEFINE_C_API_STRUCT(MlirAttribute, const void);
65DEFINE_C_API_STRUCT(MlirIdentifier, const void);
66DEFINE_C_API_STRUCT(MlirLocation, const void);
67DEFINE_C_API_STRUCT(MlirModule, const void);
68DEFINE_C_API_STRUCT(MlirType, const void);
69DEFINE_C_API_STRUCT(MlirValue, const void);
70
71#undef DEFINE_C_API_STRUCT
72
73/// Named MLIR attribute.
74///
75/// A named attribute is essentially a (name, attribute) pair where the name is
76/// a string.
78 MlirIdentifier name;
79 MlirAttribute attribute;
80};
82
83//===----------------------------------------------------------------------===//
84// Context API.
85//===----------------------------------------------------------------------===//
86
87/// Creates an MLIR context and transfers its ownership to the caller.
88/// This sets the default multithreading option (enabled).
90
91/// Creates an MLIR context with an explicit setting of the multithreading
92/// setting and transfers its ownership to the caller.
93MLIR_CAPI_EXPORTED MlirContext
94mlirContextCreateWithThreading(bool threadingEnabled);
95
96/// Creates an MLIR context, setting the multithreading setting explicitly and
97/// pre-loading the dialects from the provided DialectRegistry.
99 MlirDialectRegistry registry, bool threadingEnabled);
100
101/// Checks if two contexts are equal.
102MLIR_CAPI_EXPORTED bool mlirContextEqual(MlirContext ctx1, MlirContext ctx2);
103
104/// Checks whether a context is null.
105static inline bool mlirContextIsNull(MlirContext context) {
106 return !context.ptr;
107}
108
109/// Takes an MLIR context owned by the caller and destroys it.
110MLIR_CAPI_EXPORTED void mlirContextDestroy(MlirContext context);
111
112/// Sets whether unregistered dialects are allowed in this context.
114mlirContextSetAllowUnregisteredDialects(MlirContext context, bool allow);
115
116/// Returns whether the context allows unregistered dialects.
118mlirContextGetAllowUnregisteredDialects(MlirContext context);
119
120/// Returns the number of dialects registered with the given context. A
121/// registered dialect will be loaded if needed by the parser.
123mlirContextGetNumRegisteredDialects(MlirContext context);
124
125/// Append the contents of the given dialect registry to the registry associated
126/// with the context.
128mlirContextAppendDialectRegistry(MlirContext ctx, MlirDialectRegistry registry);
129
130/// Returns the number of dialects loaded by the context.
131
133mlirContextGetNumLoadedDialects(MlirContext context);
134
135/// Gets the dialect instance owned by the given context using the dialect
136/// namespace to identify it, loads (i.e., constructs the instance of) the
137/// dialect if necessary. If the dialect is not registered with the context,
138/// returns null. Use mlirContextLoad<Name>Dialect to load an unregistered
139/// dialect.
140MLIR_CAPI_EXPORTED MlirDialect mlirContextGetOrLoadDialect(MlirContext context,
142
143/// Set threading mode (must be set to false to mlir-print-ir-after-all).
145 bool enable);
146
147/// Eagerly loads all available dialects registered with a context, making
148/// them available for use for IR construction.
150mlirContextLoadAllAvailableDialects(MlirContext context);
151
152/// Returns whether the given fully-qualified operation (i.e.
153/// 'dialect.operation') is registered with the context. This will return true
154/// if the dialect is loaded and the operation is registered within the
155/// dialect.
158
159/// Sets the thread pool of the context explicitly, enabling multithreading in
160/// the process. This API should be used to avoid re-creating thread pools in
161/// long-running applications that perform multiple compilations, see
162/// the C++ documentation for MLIRContext for details.
163MLIR_CAPI_EXPORTED void mlirContextSetThreadPool(MlirContext context,
164 MlirLlvmThreadPool threadPool);
165
166/// Gets the number of threads of the thread pool of the context when
167/// multithreading is enabled. Returns 1 if no multithreading.
168MLIR_CAPI_EXPORTED unsigned mlirContextGetNumThreads(MlirContext context);
169
170/// Gets the thread pool of the context when enabled multithreading, otherwise
171/// an assertion is raised.
172MLIR_CAPI_EXPORTED MlirLlvmThreadPool
173mlirContextGetThreadPool(MlirContext context);
174
175//===----------------------------------------------------------------------===//
176// Dialect API.
177//===----------------------------------------------------------------------===//
178
179/// Returns the context that owns the dialect.
180MLIR_CAPI_EXPORTED MlirContext mlirDialectGetContext(MlirDialect dialect);
181
182/// Checks if the dialect is null.
183static inline bool mlirDialectIsNull(MlirDialect dialect) {
184 return !dialect.ptr;
185}
186
187/// Checks if two dialects that belong to the same context are equal. Dialects
188/// from different contexts will not compare equal.
189MLIR_CAPI_EXPORTED bool mlirDialectEqual(MlirDialect dialect1,
190 MlirDialect dialect2);
191
192/// Returns the namespace of the given dialect.
194
195//===----------------------------------------------------------------------===//
196// DialectHandle API.
197// Registration entry-points for each dialect are declared using the common
198// MLIR_DECLARE_DIALECT_REGISTRATION_CAPI macro, which takes the dialect
199// API name (i.e. "Func", "Tensor", "Linalg") and namespace (i.e. "func",
200// "tensor", "linalg"). The following declarations are produced:
201//
202// /// Gets the above hook methods in struct form for a dialect by namespace.
203// /// This is intended to facilitate dynamic lookup and registration of
204// /// dialects via a plugin facility based on shared library symbol lookup.
205// const MlirDialectHandle *mlirGetDialectHandle__{NAMESPACE}__();
206//
207// This is done via a common macro to facilitate future expansion to
208// registration schemes.
209//===----------------------------------------------------------------------===//
210
212 const void *ptr;
213};
215
216#define MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Name, Namespace) \
217 MLIR_CAPI_EXPORTED MlirDialectHandle mlirGetDialectHandle__##Namespace##__( \
218 void)
219
220/// Returns the namespace associated with the provided dialect handle.
223
224/// Inserts the dialect associated with the provided dialect handle into the
225/// provided dialect registry
227 MlirDialectRegistry);
228
229/// Registers the dialect associated with the provided dialect handle.
231 MlirContext);
232
233/// Loads the dialect associated with the provided dialect handle.
235 MlirContext);
236
237//===----------------------------------------------------------------------===//
238// DialectRegistry API.
239//===----------------------------------------------------------------------===//
240
241/// Creates a dialect registry and transfers its ownership to the caller.
242MLIR_CAPI_EXPORTED MlirDialectRegistry mlirDialectRegistryCreate(void);
243
244/// Checks if the dialect registry is null.
245static inline bool mlirDialectRegistryIsNull(MlirDialectRegistry registry) {
246 return !registry.ptr;
247}
248
249/// Takes a dialect registry owned by the caller and destroys it.
251mlirDialectRegistryDestroy(MlirDialectRegistry registry);
252
253//===----------------------------------------------------------------------===//
254// Location API.
255//===----------------------------------------------------------------------===//
256
257/// Returns the underlying location attribute of this location.
258MLIR_CAPI_EXPORTED MlirAttribute
259mlirLocationGetAttribute(MlirLocation location);
260
261/// Creates a location from a location attribute.
262MLIR_CAPI_EXPORTED MlirLocation
263mlirLocationFromAttribute(MlirAttribute attribute);
264
265/// Creates an File/Line/Column location owned by the given context.
267 MlirContext context, MlirStringRef filename, unsigned line, unsigned col);
268
269/// Creates an File/Line/Column range location owned by the given context.
271 MlirContext context, MlirStringRef filename, unsigned start_line,
272 unsigned start_col, unsigned end_line, unsigned end_col);
273
274/// Getter for filename of FileLineColRange.
275MLIR_CAPI_EXPORTED MlirIdentifier
276mlirLocationFileLineColRangeGetFilename(MlirLocation location);
277
278/// Getter for start_line of FileLineColRange.
280mlirLocationFileLineColRangeGetStartLine(MlirLocation location);
281
282/// Getter for start_column of FileLineColRange.
284mlirLocationFileLineColRangeGetStartColumn(MlirLocation location);
285
286/// Getter for end_line of FileLineColRange.
288mlirLocationFileLineColRangeGetEndLine(MlirLocation location);
289
290/// Getter for end_column of FileLineColRange.
292mlirLocationFileLineColRangeGetEndColumn(MlirLocation location);
293
294/// TypeID Getter for FileLineColRange.
296
297/// Checks whether the given location is an FileLineColRange.
298MLIR_CAPI_EXPORTED bool mlirLocationIsAFileLineColRange(MlirLocation location);
299
300/// Creates a call site location with a callee and a caller.
301MLIR_CAPI_EXPORTED MlirLocation mlirLocationCallSiteGet(MlirLocation callee,
302 MlirLocation caller);
303
304/// Getter for callee of CallSite.
305MLIR_CAPI_EXPORTED MlirLocation
306mlirLocationCallSiteGetCallee(MlirLocation location);
307
308/// Getter for caller of CallSite.
309MLIR_CAPI_EXPORTED MlirLocation
310mlirLocationCallSiteGetCaller(MlirLocation location);
311
312/// TypeID Getter for CallSite.
314
315/// Checks whether the given location is an CallSite.
316MLIR_CAPI_EXPORTED bool mlirLocationIsACallSite(MlirLocation location);
317
318/// Creates a fused location with an array of locations and metadata.
319MLIR_CAPI_EXPORTED MlirLocation
320mlirLocationFusedGet(MlirContext ctx, intptr_t nLocations,
321 MlirLocation const *locations, MlirAttribute metadata);
322
323/// Getter for number of locations fused together.
324MLIR_CAPI_EXPORTED unsigned
325mlirLocationFusedGetNumLocations(MlirLocation location);
326
327/// Getter for locations of Fused. Requires pre-allocated memory of
328/// #fusedLocations X sizeof(MlirLocation).
330mlirLocationFusedGetLocations(MlirLocation location,
331 MlirLocation *locationsCPtr);
332
333/// Getter for metadata of Fused.
334MLIR_CAPI_EXPORTED MlirAttribute
335mlirLocationFusedGetMetadata(MlirLocation location);
336
337/// TypeID Getter for Fused.
339
340/// Checks whether the given location is an Fused.
341MLIR_CAPI_EXPORTED bool mlirLocationIsAFused(MlirLocation location);
342
343/// Creates a name location owned by the given context. Providing null location
344/// for childLoc is allowed and if childLoc is null location, then the behavior
345/// is the same as having unknown child location.
346MLIR_CAPI_EXPORTED MlirLocation mlirLocationNameGet(MlirContext context,
347 MlirStringRef name,
348 MlirLocation childLoc);
349
350/// Getter for name of Name.
351MLIR_CAPI_EXPORTED MlirIdentifier
352mlirLocationNameGetName(MlirLocation location);
353
354/// Getter for childLoc of Name.
355MLIR_CAPI_EXPORTED MlirLocation
356mlirLocationNameGetChildLoc(MlirLocation location);
357
358/// TypeID Getter for Name.
360
361/// Checks whether the given location is an Name.
362MLIR_CAPI_EXPORTED bool mlirLocationIsAName(MlirLocation location);
363
364/// Creates a location with unknown position owned by the given context.
365MLIR_CAPI_EXPORTED MlirLocation mlirLocationUnknownGet(MlirContext context);
366
367/// TypeID Getter for Unknown.
369
370/// Checks whether the given location is an Unknown.
371MLIR_CAPI_EXPORTED bool mlirLocationIsAUnknown(MlirLocation location);
372
373/// Gets the context that a location was created with.
374MLIR_CAPI_EXPORTED MlirContext mlirLocationGetContext(MlirLocation location);
375
376/// Checks if the location is null.
377static inline bool mlirLocationIsNull(MlirLocation location) {
378 return !location.ptr;
379}
380
381/// Checks if two locations are equal.
382MLIR_CAPI_EXPORTED bool mlirLocationEqual(MlirLocation l1, MlirLocation l2);
383
384/// Prints a location by sending chunks of the string representation and
385/// forwarding `userData to `callback`. Note that the callback may be called
386/// several times with consecutive chunks of the string.
387MLIR_CAPI_EXPORTED void mlirLocationPrint(MlirLocation location,
388 MlirStringCallback callback,
389 void *userData);
390
391//===----------------------------------------------------------------------===//
392// Module API.
393//===----------------------------------------------------------------------===//
394
395/// Creates a new, empty module and transfers ownership to the caller.
396MLIR_CAPI_EXPORTED MlirModule mlirModuleCreateEmpty(MlirLocation location);
397
398/// Parses a module from the string and transfers ownership to the caller.
399MLIR_CAPI_EXPORTED MlirModule mlirModuleCreateParse(MlirContext context,
400 MlirStringRef module);
401
402/// Parses a module from file and transfers ownership to the caller.
403MLIR_CAPI_EXPORTED MlirModule
404mlirModuleCreateParseFromFile(MlirContext context, MlirStringRef fileName);
405
406/// Gets the context that a module was created with.
407MLIR_CAPI_EXPORTED MlirContext mlirModuleGetContext(MlirModule module);
408
409/// Gets the body of the module, i.e. the only block it contains.
410MLIR_CAPI_EXPORTED MlirBlock mlirModuleGetBody(MlirModule module);
411
412/// Checks whether a module is null.
413static inline bool mlirModuleIsNull(MlirModule module) { return !module.ptr; }
414
415/// Takes a module owned by the caller and deletes it.
416MLIR_CAPI_EXPORTED void mlirModuleDestroy(MlirModule module);
417
418/// Views the module as a generic operation.
419MLIR_CAPI_EXPORTED MlirOperation mlirModuleGetOperation(MlirModule module);
420
421/// Views the generic operation as a module.
422/// The returned module is null when the input operation was not a ModuleOp.
423MLIR_CAPI_EXPORTED MlirModule mlirModuleFromOperation(MlirOperation op);
424
425/// Checks if two modules are equal.
426MLIR_CAPI_EXPORTED bool mlirModuleEqual(MlirModule lhs, MlirModule rhs);
427
428/// Compute a hash for the given module.
429MLIR_CAPI_EXPORTED size_t mlirModuleHashValue(MlirModule mod);
430
431//===----------------------------------------------------------------------===//
432// Operation state.
433//===----------------------------------------------------------------------===//
434
435/// An auxiliary class for constructing operations.
436///
437/// This class contains all the information necessary to construct the
438/// operation. It owns the MlirRegions it has pointers to and does not own
439/// anything else. By default, the state can be constructed from a name and
440/// location, the latter being also used to access the context, and has no other
441/// components. These components can be added progressively until the operation
442/// is constructed. Users are not expected to rely on the internals of this
443/// class and should use mlirOperationState* functions instead.
444
445struct MlirOperationState {
446 MlirStringRef name;
447 MlirLocation location;
448 intptr_t nResults;
449 MlirType *results;
450 intptr_t nOperands;
451 MlirValue *operands;
452 intptr_t nRegions;
453 MlirRegion *regions;
454 intptr_t nSuccessors;
455 MlirBlock *successors;
456 intptr_t nAttributes;
457 MlirNamedAttribute *attributes;
458 bool enableResultTypeInference;
459};
460typedef struct MlirOperationState MlirOperationState;
461
462/// Constructs an operation state from a name and a location.
464 MlirLocation loc);
465
466/// Adds a list of components to the operation state.
467MLIR_CAPI_EXPORTED void mlirOperationStateAddResults(MlirOperationState *state,
468 intptr_t n,
469 MlirType const *results);
471mlirOperationStateAddOperands(MlirOperationState *state, intptr_t n,
472 MlirValue const *operands);
474mlirOperationStateAddOwnedRegions(MlirOperationState *state, intptr_t n,
475 MlirRegion const *regions);
477mlirOperationStateAddSuccessors(MlirOperationState *state, intptr_t n,
478 MlirBlock const *successors);
480mlirOperationStateAddAttributes(MlirOperationState *state, intptr_t n,
481 MlirNamedAttribute const *attributes);
482
483/// Enables result type inference for the operation under construction. If
484/// enabled, then the caller must not have called
485/// mlirOperationStateAddResults(). Note that if enabled, the
486/// mlirOperationCreate() call is failable: it will return a null operation
487/// on inference failure and will emit diagnostics.
489mlirOperationStateEnableResultTypeInference(MlirOperationState *state);
490
491//===----------------------------------------------------------------------===//
492// AsmState API.
493// While many of these are simple settings that could be represented in a
494// struct, they are wrapped in a heap allocated object and accessed via
495// functions to maximize the possibility of compatibility over time.
496//===----------------------------------------------------------------------===//
497
498/// Creates new AsmState, as with AsmState the IR should not be mutated
499/// in-between using this state.
500/// Must be freed with a call to mlirAsmStateDestroy().
501// TODO: This should be expanded to handle location & resouce map.
502MLIR_CAPI_EXPORTED MlirAsmState
503mlirAsmStateCreateForOperation(MlirOperation op, MlirOpPrintingFlags flags);
504
505/// Creates new AsmState from value.
506/// Must be freed with a call to mlirAsmStateDestroy().
507// TODO: This should be expanded to handle location & resouce map.
508MLIR_CAPI_EXPORTED MlirAsmState
509mlirAsmStateCreateForValue(MlirValue value, MlirOpPrintingFlags flags);
510
511/// Destroys printing flags created with mlirAsmStateCreate.
512MLIR_CAPI_EXPORTED void mlirAsmStateDestroy(MlirAsmState state);
513
514//===----------------------------------------------------------------------===//
515// Op Printing flags API.
516// While many of these are simple settings that could be represented in a
517// struct, they are wrapped in a heap allocated object and accessed via
518// functions to maximize the possibility of compatibility over time.
519//===----------------------------------------------------------------------===//
520
521/// Creates new printing flags with defaults, intended for customization.
522/// Must be freed with a call to mlirOpPrintingFlagsDestroy().
523MLIR_CAPI_EXPORTED MlirOpPrintingFlags mlirOpPrintingFlagsCreate(void);
524
525/// Destroys printing flags created with mlirOpPrintingFlagsCreate.
526MLIR_CAPI_EXPORTED void mlirOpPrintingFlagsDestroy(MlirOpPrintingFlags flags);
527
528/// Enables the elision of large elements attributes by printing a lexically
529/// valid but otherwise meaningless form instead of the element data. The
530/// `largeElementLimit` is used to configure what is considered to be a "large"
531/// ElementsAttr by providing an upper limit to the number of elements.
533mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags,
534 intptr_t largeElementLimit);
535
536/// Enables the elision of large resources strings by omitting them from the
537/// `dialect_resources` section. The `largeResourceLimit` is used to configure
538/// what is considered to be a "large" resource by providing an upper limit to
539/// the string size.
541mlirOpPrintingFlagsElideLargeResourceString(MlirOpPrintingFlags flags,
542 intptr_t largeResourceLimit);
543
544/// Enable or disable printing of debug information (based on `enable`). If
545/// 'prettyForm' is set to true, debug information is printed in a more readable
546/// 'pretty' form. Note: The IR generated with 'prettyForm' is not parsable.
548mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, bool enable,
549 bool prettyForm);
550
551/// Always print operations in the generic form.
553mlirOpPrintingFlagsPrintGenericOpForm(MlirOpPrintingFlags flags);
554
555/// Print the name and location, if NamedLoc, as a prefix to the SSA ID.
557mlirOpPrintingFlagsPrintNameLocAsPrefix(MlirOpPrintingFlags flags);
558
559/// Use local scope when printing the operation. This allows for using the
560/// printer in a more localized and thread-safe setting, but may not
561/// necessarily be identical to what the IR will look like when dumping
562/// the full module.
564mlirOpPrintingFlagsUseLocalScope(MlirOpPrintingFlags flags);
565
566/// Do not verify the operation when using custom operation printers.
568mlirOpPrintingFlagsAssumeVerified(MlirOpPrintingFlags flags);
569
570/// Skip printing regions.
572mlirOpPrintingFlagsSkipRegions(MlirOpPrintingFlags flags);
573
574//===----------------------------------------------------------------------===//
575// Bytecode printing flags API.
576//===----------------------------------------------------------------------===//
577
578/// Creates new printing flags with defaults, intended for customization.
579/// Must be freed with a call to mlirBytecodeWriterConfigDestroy().
580MLIR_CAPI_EXPORTED MlirBytecodeWriterConfig
582
583/// Destroys printing flags created with mlirBytecodeWriterConfigCreate.
585mlirBytecodeWriterConfigDestroy(MlirBytecodeWriterConfig config);
586
587/// Sets the version to emit in the writer config.
589mlirBytecodeWriterConfigDesiredEmitVersion(MlirBytecodeWriterConfig flags,
590 int64_t version);
591
592//===----------------------------------------------------------------------===//
593// Operation API.
594//===----------------------------------------------------------------------===//
595
596/// Creates an operation and transfers ownership to the caller.
597/// Note that caller owned child objects are transferred in this call and must
598/// not be further used. Particularly, this applies to any regions added to
599/// the state (the implementation may invalidate any such pointers).
600///
601/// This call can fail under the following conditions, in which case, it will
602/// return a null operation and emit diagnostics:
603/// - Result type inference is enabled and cannot be performed.
604MLIR_CAPI_EXPORTED MlirOperation mlirOperationCreate(MlirOperationState *state);
605
606/// Parses an operation, giving ownership to the caller. If parsing fails a null
607/// operation will be returned, and an error diagnostic emitted.
608///
609/// `sourceStr` may be either the text assembly format, or binary bytecode
610/// format. `sourceName` is used as the file name of the source; any IR without
611/// locations will get a `FileLineColLoc` location with `sourceName` as the file
612/// name.
614 MlirContext context, MlirStringRef sourceStr, MlirStringRef sourceName);
615
616/// Creates a deep copy of an operation. The operation is not inserted and
617/// ownership is transferred to the caller.
618MLIR_CAPI_EXPORTED MlirOperation mlirOperationClone(MlirOperation op);
619
620/// Takes an operation owned by the caller and destroys it.
621MLIR_CAPI_EXPORTED void mlirOperationDestroy(MlirOperation op);
622
623/// Removes the given operation from its parent block. The operation is not
624/// destroyed. The ownership of the operation is transferred to the caller.
626
627/// Checks whether the underlying operation is null.
628static inline bool mlirOperationIsNull(MlirOperation op) { return !op.ptr; }
629
630/// Checks whether two operation handles point to the same operation. This does
631/// not perform deep comparison.
632MLIR_CAPI_EXPORTED bool mlirOperationEqual(MlirOperation op,
633 MlirOperation other);
634
635/// Compute a hash for the given operation.
636MLIR_CAPI_EXPORTED size_t mlirOperationHashValue(MlirOperation op);
637
638/// Gets the context this operation is associated with
639MLIR_CAPI_EXPORTED MlirContext mlirOperationGetContext(MlirOperation op);
640
641/// Checks if the operation name has a trait identified by the given type id.
643 MlirTypeID traitTypeID,
644 MlirContext context);
645
646/// Gets the location of the operation.
647MLIR_CAPI_EXPORTED MlirLocation mlirOperationGetLocation(MlirOperation op);
648
649/// Sets the location of the operation.
650MLIR_CAPI_EXPORTED void mlirOperationSetLocation(MlirOperation op,
651 MlirLocation loc);
652
653/// Gets the type id of the operation.
654/// Returns null if the operation does not have a registered operation
655/// description.
656MLIR_CAPI_EXPORTED MlirTypeID mlirOperationGetTypeID(MlirOperation op);
657
658/// Gets the name of the operation as an identifier.
659MLIR_CAPI_EXPORTED MlirIdentifier mlirOperationGetName(MlirOperation op);
660
661/// Gets the block that owns this operation, returning null if the operation is
662/// not owned.
663MLIR_CAPI_EXPORTED MlirBlock mlirOperationGetBlock(MlirOperation op);
664
665/// Gets the operation that owns this operation, returning null if the operation
666/// is not owned.
667MLIR_CAPI_EXPORTED MlirOperation
668mlirOperationGetParentOperation(MlirOperation op);
669
670/// Returns the number of regions attached to the given operation.
672
673/// Returns `pos`-th region attached to the operation.
674MLIR_CAPI_EXPORTED MlirRegion mlirOperationGetRegion(MlirOperation op,
675 intptr_t pos);
676
677/// Returns an operation immediately following the given operation it its
678/// enclosing block.
679MLIR_CAPI_EXPORTED MlirOperation mlirOperationGetNextInBlock(MlirOperation op);
680
681/// Returns the number of operands of the operation.
683
684/// Returns `pos`-th operand of the operation.
685MLIR_CAPI_EXPORTED MlirValue mlirOperationGetOperand(MlirOperation op,
686 intptr_t pos);
687
688/// Returns `pos`-th OpOperand of the operation.
689MLIR_CAPI_EXPORTED MlirOpOperand mlirOperationGetOpOperand(MlirOperation op,
690 intptr_t pos);
691
692/// Sets the `pos`-th operand of the operation.
693MLIR_CAPI_EXPORTED void mlirOperationSetOperand(MlirOperation op, intptr_t pos,
694 MlirValue newValue);
695
696/// Replaces the operands of the operation.
697MLIR_CAPI_EXPORTED void mlirOperationSetOperands(MlirOperation op,
698 intptr_t nOperands,
699 MlirValue const *operands);
700
701/// Returns the number of results of the operation.
703
704/// Returns `pos`-th result of the operation.
705MLIR_CAPI_EXPORTED MlirValue mlirOperationGetResult(MlirOperation op,
706 intptr_t pos);
707
708/// Returns the number of successor blocks of the operation.
710
711/// Returns `pos`-th successor of the operation.
712MLIR_CAPI_EXPORTED MlirBlock mlirOperationGetSuccessor(MlirOperation op,
713 intptr_t pos);
714
715/// Set `pos`-th successor of the operation.
717mlirOperationSetSuccessor(MlirOperation op, intptr_t pos, MlirBlock block);
718
719/// Returns true if this operation defines an inherent attribute with this name.
720/// Note: the attribute can be optional, so
721/// `mlirOperationGetInherentAttributeByName` can still return a null attribute.
724
725/// Returns an inherent attribute attached to the operation given its name.
726MLIR_CAPI_EXPORTED MlirAttribute
728
729/// Sets an inherent attribute by name, replacing the existing if it exists.
730/// This has no effect if "name" does not match an inherent attribute.
733 MlirAttribute attr);
734
735/// Returns the number of discardable attributes attached to the operation.
738
739/// Return `pos`-th discardable attribute of the operation.
742
743/// Returns a discardable attribute attached to the operation given its name.
745 MlirOperation op, MlirStringRef name);
746
747/// Sets a discardable attribute by name, replacing the existing if it exists or
748/// adding a new one otherwise. The new `attr` Attribute is not allowed to be
749/// null, use `mlirOperationRemoveDiscardableAttributeByName` to remove an
750/// Attribute instead.
753 MlirAttribute attr);
754
755/// Removes a discardable attribute by name. Returns false if the attribute was
756/// not found and true if removed.
759 MlirStringRef name);
760
761/// Returns the number of attributes attached to the operation.
762/// Deprecated, please use `mlirOperationGetNumInherentAttributes` or
763/// `mlirOperationGetNumDiscardableAttributes`.
765
766/// Return `pos`-th attribute of the operation.
767/// Deprecated, please use `mlirOperationGetInherentAttribute` or
768/// `mlirOperationGetDiscardableAttribute`.
770mlirOperationGetAttribute(MlirOperation op, intptr_t pos);
771
772/// Returns an attribute attached to the operation given its name.
773/// Deprecated, please use `mlirOperationGetInherentAttributeByName` or
774/// `mlirOperationGetDiscardableAttributeByName`.
775MLIR_CAPI_EXPORTED MlirAttribute
776mlirOperationGetAttributeByName(MlirOperation op, MlirStringRef name);
777
778/// Sets an attribute by name, replacing the existing if it exists or
779/// adding a new one otherwise.
780/// Deprecated, please use `mlirOperationSetInherentAttributeByName` or
781/// `mlirOperationSetDiscardableAttributeByName`.
783 MlirStringRef name,
784 MlirAttribute attr);
785
786/// Removes an attribute by name. Returns false if the attribute was not found
787/// and true if removed.
788/// Deprecated, please use `mlirOperationRemoveInherentAttributeByName` or
789/// `mlirOperationRemoveDiscardableAttributeByName`.
791 MlirStringRef name);
792
793/// Prints an operation by sending chunks of the string representation and
794/// forwarding `userData to `callback`. Note that the callback may be called
795/// several times with consecutive chunks of the string.
796MLIR_CAPI_EXPORTED void mlirOperationPrint(MlirOperation op,
797 MlirStringCallback callback,
798 void *userData);
799
800/// Same as mlirOperationPrint but accepts flags controlling the printing
801/// behavior.
803 MlirOpPrintingFlags flags,
804 MlirStringCallback callback,
805 void *userData);
806
807/// Same as mlirOperationPrint but accepts AsmState controlling the printing
808/// behavior as well as caching computed names.
810 MlirAsmState state,
811 MlirStringCallback callback,
812 void *userData);
813
814/// Same as mlirOperationPrint but writing the bytecode format.
816 MlirStringCallback callback,
817 void *userData);
818
819/// Same as mlirOperationWriteBytecode but with writer config and returns
820/// failure only if desired bytecode could not be honored.
822 MlirOperation op, MlirBytecodeWriterConfig config,
823 MlirStringCallback callback, void *userData);
824
825/// Prints an operation to stderr.
826MLIR_CAPI_EXPORTED void mlirOperationDump(MlirOperation op);
827
828/// Verify the operation and return true if it passes, false if it fails.
829MLIR_CAPI_EXPORTED bool mlirOperationVerify(MlirOperation op);
830
831/// Moves the given operation immediately after the other operation in its
832/// parent block. The given operation may be owned by the caller or by its
833/// current block. The other operation must belong to a block. In any case, the
834/// ownership is transferred to the block of the other operation.
835MLIR_CAPI_EXPORTED void mlirOperationMoveAfter(MlirOperation op,
836 MlirOperation other);
837
838/// Moves the given operation immediately before the other operation in its
839/// parent block. The given operation may be owner by the caller or by its
840/// current block. The other operation must belong to a block. In any case, the
841/// ownership is transferred to the block of the other operation.
842MLIR_CAPI_EXPORTED void mlirOperationMoveBefore(MlirOperation op,
843 MlirOperation other);
844
845/// Given an operation 'other' that is within the same parent block, return
846/// whether the current operation is before 'other' in the operation list
847/// of the parent block.
848/// Note: This function has an average complexity of O(1), but worst case may
849/// take O(N) where N is the number of operations within the parent block.
851 MlirOperation other);
852/// Operation walk result.
858
859/// Traversal order for operation walk.
864
865/// Operation walker type. The handler is passed an (opaque) reference to an
866/// operation and a pointer to a `userData`.
868 void *userData);
869
870/// Walks operation `op` in `walkOrder` and calls `callback` on that operation.
871/// `*userData` is passed to the callback as well and can be used to tunnel some
872/// context or other data into the callback.
874void mlirOperationWalk(MlirOperation op, MlirOperationWalkCallback callback,
875 void *userData, MlirWalkOrder walkOrder);
876
877/// Replace uses of 'of' value with the 'with' value inside the 'op' operation.
879mlirOperationReplaceUsesOfWith(MlirOperation op, MlirValue of, MlirValue with);
880
881//===----------------------------------------------------------------------===//
882// Region API.
883//===----------------------------------------------------------------------===//
884
885/// Creates a new empty region and transfers ownership to the caller.
886MLIR_CAPI_EXPORTED MlirRegion mlirRegionCreate(void);
887
888/// Takes a region owned by the caller and destroys it.
889MLIR_CAPI_EXPORTED void mlirRegionDestroy(MlirRegion region);
890
891/// Checks whether a region is null.
892static inline bool mlirRegionIsNull(MlirRegion region) { return !region.ptr; }
893
894/// Checks whether two region handles point to the same region. This does not
895/// perform deep comparison.
896MLIR_CAPI_EXPORTED bool mlirRegionEqual(MlirRegion region, MlirRegion other);
897
898/// Gets the first block in the region.
899MLIR_CAPI_EXPORTED MlirBlock mlirRegionGetFirstBlock(MlirRegion region);
900
901/// Takes a block owned by the caller and appends it to the given region.
903 MlirBlock block);
904
905/// Takes a block owned by the caller and inserts it at `pos` to the given
906/// region. This is an expensive operation that linearly scans the region,
907/// prefer insertAfter/Before instead.
909mlirRegionInsertOwnedBlock(MlirRegion region, intptr_t pos, MlirBlock block);
910
911/// Takes a block owned by the caller and inserts it after the (non-owned)
912/// reference block in the given region. The reference block must belong to the
913/// region. If the reference block is null, prepends the block to the region.
915 MlirBlock reference,
916 MlirBlock block);
917
918/// Takes a block owned by the caller and inserts it before the (non-owned)
919/// reference block in the given region. The reference block must belong to the
920/// region. If the reference block is null, appends the block to the region.
922 MlirBlock reference,
923 MlirBlock block);
924
925/// Returns first region attached to the operation.
926MLIR_CAPI_EXPORTED MlirRegion mlirOperationGetFirstRegion(MlirOperation op);
927
928/// Returns the region immediately following the given region in its parent
929/// operation.
930MLIR_CAPI_EXPORTED MlirRegion mlirRegionGetNextInOperation(MlirRegion region);
931
932/// Moves the entire content of the source region to the target region.
934 MlirRegion source);
935
936//===----------------------------------------------------------------------===//
937// Block API.
938//===----------------------------------------------------------------------===//
939
940/// Creates a new empty block with the given argument types and transfers
941/// ownership to the caller.
943 MlirType const *args,
944 MlirLocation const *locs);
945
946/// Takes a block owned by the caller and destroys it.
947MLIR_CAPI_EXPORTED void mlirBlockDestroy(MlirBlock block);
948
949/// Detach a block from the owning region and assume ownership.
950MLIR_CAPI_EXPORTED void mlirBlockDetach(MlirBlock block);
951
952/// Checks whether a block is null.
953static inline bool mlirBlockIsNull(MlirBlock block) { return !block.ptr; }
954
955/// Checks whether two blocks handles point to the same block. This does not
956/// perform deep comparison.
957MLIR_CAPI_EXPORTED bool mlirBlockEqual(MlirBlock block, MlirBlock other);
958
959/// Returns the closest surrounding operation that contains this block.
960MLIR_CAPI_EXPORTED MlirOperation mlirBlockGetParentOperation(MlirBlock);
961
962/// Returns the region that contains this block.
963MLIR_CAPI_EXPORTED MlirRegion mlirBlockGetParentRegion(MlirBlock block);
964
965/// Returns the block immediately following the given block in its parent
966/// region.
967MLIR_CAPI_EXPORTED MlirBlock mlirBlockGetNextInRegion(MlirBlock block);
968
969/// Returns the first operation in the block.
970MLIR_CAPI_EXPORTED MlirOperation mlirBlockGetFirstOperation(MlirBlock block);
971
972/// Returns the terminator operation in the block or null if no terminator.
973MLIR_CAPI_EXPORTED MlirOperation mlirBlockGetTerminator(MlirBlock block);
974
975/// Takes an operation owned by the caller and appends it to the block.
977 MlirOperation operation);
978
979/// Takes an operation owned by the caller and inserts it as `pos` to the block.
980/// This is an expensive operation that scans the block linearly, prefer
981/// insertBefore/After instead.
983 intptr_t pos,
984 MlirOperation operation);
985
986/// Takes an operation owned by the caller and inserts it after the (non-owned)
987/// reference operation in the given block. If the reference is null, prepends
988/// the operation. Otherwise, the reference must belong to the block.
990mlirBlockInsertOwnedOperationAfter(MlirBlock block, MlirOperation reference,
991 MlirOperation operation);
992
993/// Takes an operation owned by the caller and inserts it before the (non-owned)
994/// reference operation in the given block. If the reference is null, appends
995/// the operation. Otherwise, the reference must belong to the block.
997mlirBlockInsertOwnedOperationBefore(MlirBlock block, MlirOperation reference,
998 MlirOperation operation);
999
1000/// Returns the number of arguments of the block.
1002
1003/// Appends an argument of the specified type to the block. Returns the newly
1004/// added argument.
1005MLIR_CAPI_EXPORTED MlirValue mlirBlockAddArgument(MlirBlock block,
1006 MlirType type,
1007 MlirLocation loc);
1008
1009/// Erase the argument at 'index' and remove it from the argument list.
1010MLIR_CAPI_EXPORTED void mlirBlockEraseArgument(MlirBlock block, unsigned index);
1011
1012/// Inserts an argument of the specified type at a specified index to the block.
1013/// Returns the newly added argument.
1014MLIR_CAPI_EXPORTED MlirValue mlirBlockInsertArgument(MlirBlock block,
1015 intptr_t pos,
1016 MlirType type,
1017 MlirLocation loc);
1018
1019/// Returns `pos`-th argument of the block.
1020MLIR_CAPI_EXPORTED MlirValue mlirBlockGetArgument(MlirBlock block,
1021 intptr_t pos);
1022
1023/// Prints a block by sending chunks of the string representation and
1024/// forwarding `userData to `callback`. Note that the callback may be called
1025/// several times with consecutive chunks of the string.
1027mlirBlockPrint(MlirBlock block, MlirStringCallback callback, void *userData);
1028
1029/// Returns the number of successor blocks of the block.
1031
1032/// Returns `pos`-th successor of the block.
1033MLIR_CAPI_EXPORTED MlirBlock mlirBlockGetSuccessor(MlirBlock block,
1034 intptr_t pos);
1035
1036/// Returns the number of predecessor blocks of the block.
1038
1039/// Returns `pos`-th predecessor of the block.
1040///
1041/// WARNING: This getter is more expensive than the others here because
1042/// the impl actually iterates the use-def chain (of block operands) anew for
1043/// each indexed access.
1044MLIR_CAPI_EXPORTED MlirBlock mlirBlockGetPredecessor(MlirBlock block,
1045 intptr_t pos);
1046
1047//===----------------------------------------------------------------------===//
1048// Value API.
1049//===----------------------------------------------------------------------===//
1050
1051/// Returns whether the value is null.
1052static inline bool mlirValueIsNull(MlirValue value) { return !value.ptr; }
1053
1054/// Returns 1 if two values are equal, 0 otherwise.
1055MLIR_CAPI_EXPORTED bool mlirValueEqual(MlirValue value1, MlirValue value2);
1056
1057/// Returns 1 if the value is a block argument, 0 otherwise.
1058MLIR_CAPI_EXPORTED bool mlirValueIsABlockArgument(MlirValue value);
1059
1060/// Returns 1 if the value is an operation result, 0 otherwise.
1061MLIR_CAPI_EXPORTED bool mlirValueIsAOpResult(MlirValue value);
1062
1063/// Returns the block in which this value is defined as an argument. Asserts if
1064/// the value is not a block argument.
1065MLIR_CAPI_EXPORTED MlirBlock mlirBlockArgumentGetOwner(MlirValue value);
1066
1067/// Returns the position of the value in the argument list of its block.
1069
1070/// Sets the type of the block argument to the given type.
1071MLIR_CAPI_EXPORTED void mlirBlockArgumentSetType(MlirValue value,
1072 MlirType type);
1073
1074/// Sets the location of the block argument to the given location.
1076 MlirLocation loc);
1077
1078/// Returns an operation that produced this value as its result. Asserts if the
1079/// value is not an op result.
1080MLIR_CAPI_EXPORTED MlirOperation mlirOpResultGetOwner(MlirValue value);
1081
1082/// Returns the position of the value in the list of results of the operation
1083/// that produced it.
1085
1086/// Returns the type of the value.
1087MLIR_CAPI_EXPORTED MlirType mlirValueGetType(MlirValue value);
1088
1089/// Set the type of the value.
1090MLIR_CAPI_EXPORTED void mlirValueSetType(MlirValue value, MlirType type);
1091
1092/// Prints the value to the standard error stream.
1093MLIR_CAPI_EXPORTED void mlirValueDump(MlirValue value);
1094
1095/// Prints a value by sending chunks of the string representation and
1096/// forwarding `userData to `callback`. Note that the callback may be called
1097/// several times with consecutive chunks of the string.
1099mlirValuePrint(MlirValue value, MlirStringCallback callback, void *userData);
1100
1101/// Prints a value as an operand (i.e., the ValueID).
1102MLIR_CAPI_EXPORTED void mlirValuePrintAsOperand(MlirValue value,
1103 MlirAsmState state,
1104 MlirStringCallback callback,
1105 void *userData);
1106
1107/// Returns an op operand representing the first use of the value, or a null op
1108/// operand if there are no uses.
1109MLIR_CAPI_EXPORTED MlirOpOperand mlirValueGetFirstUse(MlirValue value);
1110
1111/// Replace all uses of 'of' value with the 'with' value, updating anything in
1112/// the IR that uses 'of' to use the other value instead. When this returns
1113/// there are zero uses of 'of'.
1115 MlirValue with);
1116
1117/// Replace all uses of 'of' value with 'with' value, updating anything in the
1118/// IR that uses 'of' to use 'with' instead, except if the user is listed in
1119/// 'exceptions'. The 'exceptions' parameter is an array of MlirOperation
1120/// pointers with a length of 'numExceptions'.
1122mlirValueReplaceAllUsesExcept(MlirValue of, MlirValue with,
1123 intptr_t numExceptions,
1124 MlirOperation *exceptions);
1125
1126/// Gets the location of the value.
1127MLIR_CAPI_EXPORTED MlirLocation mlirValueGetLocation(MlirValue v);
1128
1129/// Gets the context that a value was created with.
1130MLIR_CAPI_EXPORTED MlirContext mlirValueGetContext(MlirValue v);
1131
1132//===----------------------------------------------------------------------===//
1133// OpOperand API.
1134//===----------------------------------------------------------------------===//
1135
1136/// Returns whether the op operand is null.
1137MLIR_CAPI_EXPORTED bool mlirOpOperandIsNull(MlirOpOperand opOperand);
1138
1139/// Returns the value of an op operand.
1140MLIR_CAPI_EXPORTED MlirValue mlirOpOperandGetValue(MlirOpOperand opOperand);
1141
1142/// Returns the owner operation of an op operand.
1143MLIR_CAPI_EXPORTED MlirOperation mlirOpOperandGetOwner(MlirOpOperand opOperand);
1144
1145/// Returns the operand number of an op operand.
1146MLIR_CAPI_EXPORTED unsigned
1147mlirOpOperandGetOperandNumber(MlirOpOperand opOperand);
1148
1149/// Returns an op operand representing the next use of the value, or a null op
1150/// operand if there is no next use.
1151MLIR_CAPI_EXPORTED MlirOpOperand
1152mlirOpOperandGetNextUse(MlirOpOperand opOperand);
1153
1154//===----------------------------------------------------------------------===//
1155// Type API.
1156//===----------------------------------------------------------------------===//
1157
1158/// Parses a type. The type is owned by the context.
1159MLIR_CAPI_EXPORTED MlirType mlirTypeParseGet(MlirContext context,
1160 MlirStringRef type);
1161
1162/// Gets the context that a type was created with.
1163MLIR_CAPI_EXPORTED MlirContext mlirTypeGetContext(MlirType type);
1164
1165/// Gets the type ID of the type.
1166MLIR_CAPI_EXPORTED MlirTypeID mlirTypeGetTypeID(MlirType type);
1167
1168/// Gets the dialect a type belongs to.
1169MLIR_CAPI_EXPORTED MlirDialect mlirTypeGetDialect(MlirType type);
1170
1171/// Checks whether a type is null.
1172static inline bool mlirTypeIsNull(MlirType type) { return !type.ptr; }
1173
1174/// Checks if two types are equal.
1175MLIR_CAPI_EXPORTED bool mlirTypeEqual(MlirType t1, MlirType t2);
1176
1177/// Prints a location by sending chunks of the string representation and
1178/// forwarding `userData to `callback`. Note that the callback may be called
1179/// several times with consecutive chunks of the string.
1181mlirTypePrint(MlirType type, MlirStringCallback callback, void *userData);
1182
1183/// Prints the type to the standard error stream.
1184MLIR_CAPI_EXPORTED void mlirTypeDump(MlirType type);
1185
1186//===----------------------------------------------------------------------===//
1187// Attribute API.
1188//===----------------------------------------------------------------------===//
1189
1190/// Parses an attribute. The attribute is owned by the context.
1191MLIR_CAPI_EXPORTED MlirAttribute mlirAttributeParseGet(MlirContext context,
1192 MlirStringRef attr);
1193
1194/// Gets the context that an attribute was created with.
1195MLIR_CAPI_EXPORTED MlirContext mlirAttributeGetContext(MlirAttribute attribute);
1196
1197/// Gets the type of this attribute.
1198MLIR_CAPI_EXPORTED MlirType mlirAttributeGetType(MlirAttribute attribute);
1199
1200/// Gets the type id of the attribute.
1201MLIR_CAPI_EXPORTED MlirTypeID mlirAttributeGetTypeID(MlirAttribute attribute);
1202
1203/// Gets the dialect of the attribute.
1204MLIR_CAPI_EXPORTED MlirDialect mlirAttributeGetDialect(MlirAttribute attribute);
1205
1206/// Checks whether an attribute is null.
1207static inline bool mlirAttributeIsNull(MlirAttribute attr) { return !attr.ptr; }
1208
1209/// Checks if two attributes are equal.
1210MLIR_CAPI_EXPORTED bool mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2);
1211
1212/// Prints an attribute by sending chunks of the string representation and
1213/// forwarding `userData to `callback`. Note that the callback may be called
1214/// several times with consecutive chunks of the string.
1215MLIR_CAPI_EXPORTED void mlirAttributePrint(MlirAttribute attr,
1216 MlirStringCallback callback,
1217 void *userData);
1218
1219/// Prints the attribute to the standard error stream.
1220MLIR_CAPI_EXPORTED void mlirAttributeDump(MlirAttribute attr);
1221
1222/// Associates an attribute with the name. Takes ownership of neither.
1224 MlirAttribute attr);
1225
1226//===----------------------------------------------------------------------===//
1227// Identifier API.
1228//===----------------------------------------------------------------------===//
1229
1230/// Gets an identifier with the given string value.
1231MLIR_CAPI_EXPORTED MlirIdentifier mlirIdentifierGet(MlirContext context,
1232 MlirStringRef str);
1233
1234/// Returns the context associated with this identifier
1235MLIR_CAPI_EXPORTED MlirContext mlirIdentifierGetContext(MlirIdentifier);
1236
1237/// Checks whether two identifiers are the same.
1238MLIR_CAPI_EXPORTED bool mlirIdentifierEqual(MlirIdentifier ident,
1239 MlirIdentifier other);
1240
1241/// Gets the string value of the identifier.
1243
1244//===----------------------------------------------------------------------===//
1245// Symbol and SymbolTable API.
1246//===----------------------------------------------------------------------===//
1247
1248/// Returns the name of the attribute used to store symbol names compatible with
1249/// symbol tables.
1251
1252/// Returns the name of the attribute used to store symbol visibility.
1255
1256/// Creates a symbol table for the given operation. If the operation does not
1257/// have the SymbolTable trait, returns a null symbol table.
1258MLIR_CAPI_EXPORTED MlirSymbolTable
1259mlirSymbolTableCreate(MlirOperation operation);
1260
1261/// Returns true if the symbol table is null.
1262static inline bool mlirSymbolTableIsNull(MlirSymbolTable symbolTable) {
1263 return !symbolTable.ptr;
1264}
1265
1266/// Destroys the symbol table created with mlirSymbolTableCreate. This does not
1267/// affect the operations in the table.
1268MLIR_CAPI_EXPORTED void mlirSymbolTableDestroy(MlirSymbolTable symbolTable);
1269
1270/// Looks up a symbol with the given name in the given symbol table and returns
1271/// the operation that corresponds to the symbol. If the symbol cannot be found,
1272/// returns a null operation.
1273MLIR_CAPI_EXPORTED MlirOperation
1274mlirSymbolTableLookup(MlirSymbolTable symbolTable, MlirStringRef name);
1275
1276/// Inserts the given operation into the given symbol table. The operation must
1277/// have the symbol trait. If the symbol table already has a symbol with the
1278/// same name, renames the symbol being inserted to ensure name uniqueness. Note
1279/// that this does not move the operation itself into the block of the symbol
1280/// table operation, this should be done separately. Returns the name of the
1281/// symbol after insertion.
1282MLIR_CAPI_EXPORTED MlirAttribute
1283mlirSymbolTableInsert(MlirSymbolTable symbolTable, MlirOperation operation);
1284
1285/// Removes the given operation from the symbol table and erases it.
1286MLIR_CAPI_EXPORTED void mlirSymbolTableErase(MlirSymbolTable symbolTable,
1287 MlirOperation operation);
1288
1289/// Attempt to replace all uses that are nested within the given operation
1290/// of the given symbol 'oldSymbol' with the provided 'newSymbol'. This does
1291/// not traverse into nested symbol tables. Will fail atomically if there are
1292/// any unknown operations that may be potential symbol tables.
1294 MlirStringRef oldSymbol, MlirStringRef newSymbol, MlirOperation from);
1295
1296/// Walks all symbol table operations nested within, and including, `op`. For
1297/// each symbol table operation, the provided callback is invoked with the op
1298/// and a boolean signifying if the symbols within that symbol table can be
1299/// treated as if all uses within the IR are visible to the caller.
1300/// `allSymUsesVisible` identifies whether all of the symbol uses of symbols
1301/// within `op` are visible.
1303 MlirOperation from, bool allSymUsesVisible,
1304 void (*callback)(MlirOperation, bool, void *userData), void *userData);
1305
1306//===----------------------------------------------------------------------===//
1307// IRMapping API
1308//===----------------------------------------------------------------------===//
1309
1310/// Creates a new empty IRMapping.
1311MLIR_CAPI_EXPORTED MlirIRMapping mlirIRMappingCreate(void);
1312
1313/// Destroys the given IRMapping.
1314MLIR_CAPI_EXPORTED void mlirIRMappingDestroy(MlirIRMapping mapping);
1315
1316/// Checks whether an IRMapping is null.
1317static inline bool mlirIRMappingIsNull(MlirIRMapping mapping) {
1318 return !mapping.ptr;
1319}
1320
1321/// Maps a Value in the mapping.
1322MLIR_CAPI_EXPORTED void mlirIRMappingMapValue(MlirIRMapping mapping,
1323 MlirValue from, MlirValue to);
1324
1325/// Maps a Block in the mapping.
1326MLIR_CAPI_EXPORTED void mlirIRMappingMapBlock(MlirIRMapping mapping,
1327 MlirBlock from, MlirBlock to);
1328
1329/// Maps an Operation in the mapping.
1330MLIR_CAPI_EXPORTED void mlirIRMappingMapOperation(MlirIRMapping mapping,
1331 MlirOperation from,
1332 MlirOperation to);
1333
1334/// Clears all mappings.
1335MLIR_CAPI_EXPORTED void mlirIRMappingClear(MlirIRMapping mapping);
1336
1337/// Looks up a mapped Value. Returns the mapped value, or the input value if
1338/// no mapping exists.
1339MLIR_CAPI_EXPORTED MlirValue
1340mlirIRMappingLookupOrDefaultValue(MlirIRMapping mapping, MlirValue from);
1341
1342/// Looks up a mapped Value. Returns a null MlirValue if no mapping exists.
1343MLIR_CAPI_EXPORTED MlirValue
1344mlirIRMappingLookupOrNullValue(MlirIRMapping mapping, MlirValue from);
1345
1346/// Looks up a mapped Block. Returns the mapped block, or the input block if
1347/// no mapping exists.
1348MLIR_CAPI_EXPORTED MlirBlock
1349mlirIRMappingLookupOrDefaultBlock(MlirIRMapping mapping, MlirBlock from);
1350
1351/// Looks up a mapped Block. Returns a null MlirBlock if no mapping exists.
1352MLIR_CAPI_EXPORTED MlirBlock
1353mlirIRMappingLookupOrNullBlock(MlirIRMapping mapping, MlirBlock from);
1354
1355/// Looks up a mapped Operation. Returns the mapped operation, or the input
1356/// operation if no mapping exists.
1358 MlirIRMapping mapping, MlirOperation from);
1359
1360/// Looks up a mapped Operation. Returns a null MlirOperation if no mapping
1361/// exists.
1362MLIR_CAPI_EXPORTED MlirOperation
1363mlirIRMappingLookupOrNullOperation(MlirIRMapping mapping, MlirOperation from);
1364
1365/// Returns true if the mapping contains a mapping for the given value.
1366MLIR_CAPI_EXPORTED bool mlirIRMappingContainsValue(MlirIRMapping mapping,
1367 MlirValue value);
1368
1369/// Returns true if the mapping contains a mapping for the given block.
1370MLIR_CAPI_EXPORTED bool mlirIRMappingContainsBlock(MlirIRMapping mapping,
1371 MlirBlock block);
1372
1373/// Returns true if the mapping contains a mapping for the given operation.
1374MLIR_CAPI_EXPORTED bool mlirIRMappingContainsOperation(MlirIRMapping mapping,
1375 MlirOperation op);
1376
1377/// Erases a value mapping.
1378MLIR_CAPI_EXPORTED void mlirIRMappingEraseValue(MlirIRMapping mapping,
1379 MlirValue value);
1380
1381/// Erases a block mapping.
1382MLIR_CAPI_EXPORTED void mlirIRMappingEraseBlock(MlirIRMapping mapping,
1383 MlirBlock block);
1384
1385/// Erases an operation mapping.
1386MLIR_CAPI_EXPORTED void mlirIRMappingEraseOperation(MlirIRMapping mapping,
1387 MlirOperation op);
1388
1389/// Clones the operation with the given mapping. The mapping is updated with
1390/// the cloned operation's results and regions.
1391MLIR_CAPI_EXPORTED MlirOperation
1392mlirOperationCloneWithMapping(MlirOperation op, MlirIRMapping mapping);
1393
1394#ifdef __cplusplus
1395}
1396#endif
1397
1398#endif // MLIR_C_IR_H
lhs
MlirAttribute mlirOperationGetDiscardableAttributeByName(MlirOperation op, MlirStringRef name)
Definition IR.cpp:795
MlirContext mlirModuleGetContext(MlirModule module)
Definition IR.cpp:454
size_t mlirModuleHashValue(MlirModule mod)
Definition IR.cpp:480
intptr_t mlirBlockGetNumPredecessors(MlirBlock block)
Definition IR.cpp:1114
MlirIdentifier mlirOperationGetName(MlirOperation op)
Definition IR.cpp:683
bool mlirValueIsABlockArgument(MlirValue value)
Definition IR.cpp:1134
intptr_t mlirOperationGetNumRegions(MlirOperation op)
Definition IR.cpp:695
MlirBlock mlirOperationGetBlock(MlirOperation op)
Definition IR.cpp:687
void mlirBlockArgumentSetType(MlirValue value, MlirType type)
Definition IR.cpp:1151
void mlirOperationStateAddAttributes(MlirOperationState *state, intptr_t n, MlirNamedAttribute const *attributes)
Definition IR.cpp:529
MlirValue mlirOperationGetResult(MlirOperation op, intptr_t pos)
Definition IR.cpp:750
MlirModule mlirModuleCreateParseFromFile(MlirContext context, MlirStringRef fileName)
Definition IR.cpp:445
bool mlirOperationNameHasTrait(MlirStringRef opName, MlirTypeID traitTypeID, MlirContext context)
Definition IR.cpp:663
MlirAsmState mlirAsmStateCreateForValue(MlirValue value, MlirOpPrintingFlags flags)
Definition IR.cpp:178
intptr_t mlirOperationGetNumResults(MlirOperation op)
Definition IR.cpp:746
void mlirOperationDestroy(MlirOperation op)
Definition IR.cpp:647
MlirAttribute mlirOperationGetInherentAttributeByName(MlirOperation op, MlirStringRef name)
Definition IR.cpp:768
MlirContext mlirAttributeGetContext(MlirAttribute attribute)
Definition IR.cpp:1299
MlirType mlirValueGetType(MlirValue value)
Definition IR.cpp:1170
void mlirBlockPrint(MlirBlock block, MlirStringCallback callback, void *userData)
Definition IR.cpp:1100
void mlirOperationSetDiscardableAttributeByName(MlirOperation op, MlirStringRef name, MlirAttribute attr)
Definition IR.cpp:800
MlirOpPrintingFlags mlirOpPrintingFlagsCreate()
Definition IR.cpp:202
bool mlirModuleEqual(MlirModule lhs, MlirModule rhs)
Definition IR.cpp:476
void mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags, intptr_t largeElementLimit)
Definition IR.cpp:210
void mlirOperationSetSuccessor(MlirOperation op, intptr_t pos, MlirBlock block)
Definition IR.cpp:811
MlirOperation mlirOperationGetNextInBlock(MlirOperation op)
Definition IR.cpp:719
void mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, bool enable, bool prettyForm)
Definition IR.cpp:220
MlirOperation mlirModuleGetOperation(MlirModule module)
Definition IR.cpp:468
void mlirOpPrintingFlagsElideLargeResourceString(MlirOpPrintingFlags flags, intptr_t largeResourceLimit)
Definition IR.cpp:215
void mlirOpPrintingFlagsUseLocalScope(MlirOpPrintingFlags flags)
Definition IR.cpp:233
MlirTypeID mlirOperationGetTypeID(MlirOperation op)
Definition IR.cpp:677
intptr_t mlirBlockArgumentGetArgNumber(MlirValue value)
Definition IR.cpp:1146
MlirBlock mlirOperationGetSuccessor(MlirOperation op, intptr_t pos)
Definition IR.cpp:758
bool mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2)
Definition IR.cpp:1318
MlirAsmState mlirAsmStateCreateForOperation(MlirOperation op, MlirOpPrintingFlags flags)
Definition IR.cpp:157
bool mlirOperationEqual(MlirOperation op, MlirOperation other)
Definition IR.cpp:651
void mlirOperationSetInherentAttributeByName(MlirOperation op, MlirStringRef name, MlirAttribute attr)
Definition IR.cpp:776
void mlirOpPrintingFlagsAssumeVerified(MlirOpPrintingFlags flags)
Definition IR.cpp:237
bool mlirValueEqual(MlirValue value1, MlirValue value2)
Definition IR.cpp:1130
void mlirBytecodeWriterConfigDestroy(MlirBytecodeWriterConfig config)
Definition IR.cpp:252
MlirBlock mlirBlockGetSuccessor(MlirBlock block, intptr_t pos)
Definition IR.cpp:1110
void mlirModuleDestroy(MlirModule module)
Definition IR.cpp:462
MlirModule mlirModuleCreateEmpty(MlirLocation location)
Definition IR.cpp:433
void mlirOpPrintingFlagsPrintGenericOpForm(MlirOpPrintingFlags flags)
Definition IR.cpp:225
MlirOperation mlirOperationGetParentOperation(MlirOperation op)
Definition IR.cpp:691
void mlirValueSetType(MlirValue value, MlirType type)
Definition IR.cpp:1174
intptr_t mlirOperationGetNumSuccessors(MlirOperation op)
Definition IR.cpp:754
MlirDialect mlirAttributeGetDialect(MlirAttribute attr)
Definition IR.cpp:1314
void mlirLocationPrint(MlirLocation location, MlirStringCallback callback, void *userData)
Definition IR.cpp:423
void mlirOperationSetAttributeByName(MlirOperation op, MlirStringRef name, MlirAttribute attr)
Definition IR.cpp:830
void mlirOperationSetOperand(MlirOperation op, intptr_t pos, MlirValue newValue)
Definition IR.cpp:735
MlirOperation mlirOpResultGetOwner(MlirValue value)
Definition IR.cpp:1161
MlirModule mlirModuleCreateParse(MlirContext context, MlirStringRef module)
Definition IR.cpp:437
size_t mlirOperationHashValue(MlirOperation op)
Definition IR.cpp:655
void mlirOperationStateAddResults(MlirOperationState *state, intptr_t n, MlirType const *results)
Definition IR.cpp:512
MlirOperation mlirOperationClone(MlirOperation op)
Definition IR.cpp:643
MlirBlock mlirBlockArgumentGetOwner(MlirValue value)
Definition IR.cpp:1142
void mlirBlockArgumentSetLocation(MlirValue value, MlirLocation loc)
Definition IR.cpp:1156
MlirValue mlirOperationGetOperand(MlirOperation op, intptr_t pos)
Definition IR.cpp:727
MlirModule mlirModuleFromOperation(MlirOperation op)
Definition IR.cpp:472
MlirOpOperand mlirOperationGetOpOperand(MlirOperation op, intptr_t pos)
Definition IR.cpp:731
MlirLocation mlirOperationGetLocation(MlirOperation op)
Definition IR.cpp:669
MlirAttribute mlirOperationGetAttributeByName(MlirOperation op, MlirStringRef name)
Definition IR.cpp:825
MlirTypeID mlirAttributeGetTypeID(MlirAttribute attr)
Definition IR.cpp:1310
intptr_t mlirOperationGetNumDiscardableAttributes(MlirOperation op)
Definition IR.cpp:783
void mlirOperationStateAddOwnedRegions(MlirOperationState *state, intptr_t n, MlirRegion const *regions)
Definition IR.cpp:521
void mlirOperationSetLocation(MlirOperation op, MlirLocation loc)
Definition IR.cpp:673
MlirType mlirAttributeGetType(MlirAttribute attribute)
Definition IR.cpp:1303
bool mlirOperationRemoveDiscardableAttributeByName(MlirOperation op, MlirStringRef name)
Definition IR.cpp:806
bool mlirOperationRemoveAttributeByName(MlirOperation op, MlirStringRef name)
Definition IR.cpp:835
bool mlirValueIsAOpResult(MlirValue value)
Definition IR.cpp:1138
MLIR_CAPI_EXPORTED bool mlirOperationHasInherentAttributeByName(MlirOperation op, MlirStringRef name)
Definition IR.cpp:763
MlirBlock mlirBlockGetPredecessor(MlirBlock block, intptr_t pos)
Definition IR.cpp:1119
MlirRegion mlirOperationGetRegion(MlirOperation op, intptr_t pos)
Definition IR.cpp:699
MlirOperation mlirOperationCreate(MlirOperationState *state)
Definition IR.cpp:597
void mlirBytecodeWriterConfigDesiredEmitVersion(MlirBytecodeWriterConfig flags, int64_t version)
Definition IR.cpp:256
MlirAttribute mlirAttributeParseGet(MlirContext context, MlirStringRef attr)
Definition IR.cpp:1295
void mlirOperationRemoveFromParent(MlirOperation op)
Definition IR.cpp:649
intptr_t mlirBlockGetNumSuccessors(MlirBlock block)
Definition IR.cpp:1106
MlirNamedAttribute mlirOperationGetAttribute(MlirOperation op, intptr_t pos)
Definition IR.cpp:820
void mlirOpPrintingFlagsDestroy(MlirOpPrintingFlags flags)
Definition IR.cpp:206
void mlirValueDump(MlirValue value)
Definition IR.cpp:1178
void mlirOperationSetOperands(MlirOperation op, intptr_t nOperands, MlirValue const *operands)
Definition IR.cpp:740
void mlirTypePrint(MlirType type, MlirStringCallback callback, void *userData)
Definition IR.cpp:1284
MlirBlock mlirModuleGetBody(MlirModule module)
Definition IR.cpp:458
MlirOperation mlirOperationCreateParse(MlirContext context, MlirStringRef sourceStr, MlirStringRef sourceName)
Definition IR.cpp:634
void mlirAsmStateDestroy(MlirAsmState state)
Destroys printing flags created with mlirAsmStateCreate.
Definition IR.cpp:196
MlirContext mlirOperationGetContext(MlirOperation op)
Definition IR.cpp:659
intptr_t mlirOpResultGetResultNumber(MlirValue value)
Definition IR.cpp:1165
MlirNamedAttribute mlirOperationGetDiscardableAttribute(MlirOperation op, intptr_t pos)
Definition IR.cpp:788
void mlirOperationStateEnableResultTypeInference(MlirOperationState *state)
Definition IR.cpp:534
void mlirOperationStateAddSuccessors(MlirOperationState *state, intptr_t n, MlirBlock const *successors)
Definition IR.cpp:525
MlirBytecodeWriterConfig mlirBytecodeWriterConfigCreate()
Definition IR.cpp:248
void mlirOpPrintingFlagsPrintNameLocAsPrefix(MlirOpPrintingFlags flags)
Definition IR.cpp:229
void mlirOpPrintingFlagsSkipRegions(MlirOpPrintingFlags flags)
Definition IR.cpp:241
void mlirOperationStateAddOperands(MlirOperationState *state, intptr_t n, MlirValue const *operands)
Definition IR.cpp:517
MlirOperationState mlirOperationStateGet(MlirStringRef name, MlirLocation loc)
Definition IR.cpp:488
intptr_t mlirOperationGetNumOperands(MlirOperation op)
Definition IR.cpp:723
void mlirTypeDump(MlirType type)
Definition IR.cpp:1289
intptr_t mlirOperationGetNumAttributes(MlirOperation op)
Definition IR.cpp:816
MLIR_CAPI_EXPORTED MlirValue mlirIRMappingLookupOrDefaultValue(MlirIRMapping mapping, MlirValue from)
Looks up a mapped Value.
Definition IR.cpp:1439
MLIR_CAPI_EXPORTED MlirOperation mlirIRMappingLookupOrDefaultOperation(MlirIRMapping mapping, MlirOperation from)
Looks up a mapped Operation.
Definition IR.cpp:1459
MLIR_CAPI_EXPORTED MlirAttribute mlirLocationGetAttribute(MlirLocation location)
Returns the underlying location attribute of this location.
Definition IR.cpp:265
MlirWalkResult(* MlirOperationWalkCallback)(MlirOperation, void *userData)
Operation walker type.
Definition IR.h:867
MLIR_CAPI_EXPORTED MlirLocation mlirValueGetLocation(MlirValue v)
Gets the location of the value.
Definition IR.cpp:1221
MLIR_CAPI_EXPORTED MlirBlock mlirIRMappingLookupOrNullBlock(MlirIRMapping mapping, MlirBlock from)
Looks up a mapped Block. Returns a null MlirBlock if no mapping exists.
Definition IR.cpp:1454
MLIR_CAPI_EXPORTED unsigned mlirContextGetNumThreads(MlirContext context)
Gets the number of threads of the thread pool of the context when multithreading is enabled.
Definition IR.cpp:117
MLIR_CAPI_EXPORTED void mlirOperationWriteBytecode(MlirOperation op, MlirStringCallback callback, void *userData)
Same as mlirOperationPrint but writing the bytecode format.
Definition IR.cpp:860
MLIR_CAPI_EXPORTED MlirLocation mlirLocationFileLineColGet(MlirContext context, MlirStringRef filename, unsigned line, unsigned col)
Creates an File/Line/Column location owned by the given context.
Definition IR.cpp:273
MLIR_CAPI_EXPORTED void mlirSymbolTableWalkSymbolTables(MlirOperation from, bool allSymUsesVisible, void(*callback)(MlirOperation, bool, void *userData), void *userData)
Walks all symbol table operations nested within, and including, op.
Definition IR.cpp:1403
MLIR_CAPI_EXPORTED MlirStringRef mlirDialectGetNamespace(MlirDialect dialect)
Returns the namespace of the given dialect.
Definition IR.cpp:137
MLIR_CAPI_EXPORTED int mlirLocationFileLineColRangeGetEndColumn(MlirLocation location)
Getter for end_column of FileLineColRange.
Definition IR.cpp:311
MLIR_CAPI_EXPORTED MlirAttribute mlirSymbolTableInsert(MlirSymbolTable symbolTable, MlirOperation operation)
Inserts the given operation into the given symbol table.
Definition IR.cpp:1382
MLIR_CAPI_EXPORTED MlirDialect mlirDialectHandleLoadDialect(MlirDialectHandle, MlirContext)
Loads the dialect associated with the provided dialect handle.
MlirWalkOrder
Traversal order for operation walk.
Definition IR.h:860
@ MlirWalkPreOrder
Definition IR.h:861
@ MlirWalkPostOrder
Definition IR.h:862
MLIR_CAPI_EXPORTED bool mlirLocationIsAUnknown(MlirLocation location)
Checks whether the given location is an Unknown.
Definition IR.cpp:411
MLIR_CAPI_EXPORTED MlirOperation mlirIRMappingLookupOrNullOperation(MlirIRMapping mapping, MlirOperation from)
Looks up a mapped Operation.
Definition IR.cpp:1464
MLIR_CAPI_EXPORTED MlirTypeID mlirLocationUnknownGetTypeID(void)
TypeID Getter for Unknown.
Definition IR.cpp:407
MLIR_CAPI_EXPORTED MlirNamedAttribute mlirNamedAttributeGet(MlirIdentifier name, MlirAttribute attr)
Associates an attribute with the name. Takes ownership of neither.
Definition IR.cpp:1330
MLIR_CAPI_EXPORTED MlirOperation mlirOperationCloneWithMapping(MlirOperation op, MlirIRMapping mapping)
Clones the operation with the given mapping.
Definition IR.cpp:1493
MLIR_CAPI_EXPORTED MlirLocation mlirLocationNameGetChildLoc(MlirLocation location)
Getter for childLoc of Name.
Definition IR.cpp:392
MLIR_CAPI_EXPORTED void mlirSymbolTableErase(MlirSymbolTable symbolTable, MlirOperation operation)
Removes the given operation from the symbol table and erases it.
Definition IR.cpp:1387
MLIR_CAPI_EXPORTED void mlirContextAppendDialectRegistry(MlirContext ctx, MlirDialectRegistry registry)
Append the contents of the given dialect registry to the registry associated with the context.
Definition IR.cpp:84
MLIR_CAPI_EXPORTED MlirStringRef mlirIdentifierStr(MlirIdentifier ident)
Gets the string value of the identifier.
Definition IR.cpp:1351
MLIR_CAPI_EXPORTED MlirType mlirTypeParseGet(MlirContext context, MlirStringRef type)
Parses a type. The type is owned by the context.
Definition IR.cpp:1264
MLIR_CAPI_EXPORTED void mlirDialectRegistryDestroy(MlirDialectRegistry registry)
Takes a dialect registry owned by the caller and destroys it.
Definition IR.cpp:149
MLIR_CAPI_EXPORTED intptr_t mlirContextGetNumLoadedDialects(MlirContext context)
Returns the number of dialects loaded by the context.
Definition IR.cpp:91
MLIR_CAPI_EXPORTED MlirOpOperand mlirOpOperandGetNextUse(MlirOpOperand opOperand)
Returns an op operand representing the next use of the value, or a null op operand if there is no nex...
Definition IR.cpp:1247
MLIR_CAPI_EXPORTED void mlirContextSetAllowUnregisteredDialects(MlirContext context, bool allow)
Sets whether unregistered dialects are allowed in this context.
Definition IR.cpp:73
MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlockBefore(MlirRegion region, MlirBlock reference, MlirBlock block)
Takes a block owned by the caller and inserts it before the (non-owned) reference block in the given ...
Definition IR.cpp:970
MLIR_CAPI_EXPORTED bool mlirLocationIsAFileLineColRange(MlirLocation location)
Checks whether the given location is an FileLineColRange.
Definition IR.cpp:321
MLIR_CAPI_EXPORTED unsigned mlirLocationFusedGetNumLocations(MlirLocation location)
Getter for number of locations fused together.
Definition IR.cpp:355
MLIR_CAPI_EXPORTED void mlirValueReplaceAllUsesOfWith(MlirValue of, MlirValue with)
Replace all uses of 'of' value with the 'with' value, updating anything in the IR that uses 'of' to u...
Definition IR.cpp:1203
MLIR_CAPI_EXPORTED void mlirValuePrintAsOperand(MlirValue value, MlirAsmState state, MlirStringCallback callback, void *userData)
Prints a value as an operand (i.e., the ValueID).
Definition IR.cpp:1186
MLIR_CAPI_EXPORTED MlirLocation mlirLocationUnknownGet(MlirContext context)
Creates a location with unknown position owned by the given context.
Definition IR.cpp:403
MLIR_CAPI_EXPORTED MlirOperation mlirOpOperandGetOwner(MlirOpOperand opOperand)
Returns the owner operation of an op operand.
Definition IR.cpp:1235
MLIR_CAPI_EXPORTED bool mlirIdentifierEqual(MlirIdentifier ident, MlirIdentifier other)
Checks whether two identifiers are the same.
Definition IR.cpp:1347
MLIR_CAPI_EXPORTED void mlirIRMappingDestroy(MlirIRMapping mapping)
Destroys the given IRMapping.
Definition IR.cpp:1420
MLIR_CAPI_EXPORTED MlirIdentifier mlirLocationFileLineColRangeGetFilename(MlirLocation location)
Getter for filename of FileLineColRange.
Definition IR.cpp:289
MLIR_CAPI_EXPORTED void mlirLocationFusedGetLocations(MlirLocation location, MlirLocation *locationsCPtr)
Getter for locations of Fused.
Definition IR.cpp:361
MLIR_CAPI_EXPORTED void mlirIRMappingMapBlock(MlirIRMapping mapping, MlirBlock from, MlirBlock to)
Maps a Block in the mapping.
Definition IR.cpp:1427
MLIR_CAPI_EXPORTED intptr_t mlirContextGetNumRegisteredDialects(MlirContext context)
Returns the number of dialects registered with the given context.
Definition IR.cpp:80
MLIR_CAPI_EXPORTED void mlirAttributePrint(MlirAttribute attr, MlirStringCallback callback, void *userData)
Prints a location by sending chunks of the string representation and forwarding userData to callback`...
Definition IR.cpp:1322
MLIR_CAPI_EXPORTED void mlirIRMappingClear(MlirIRMapping mapping)
Clears all mappings.
Definition IR.cpp:1437
MLIR_CAPI_EXPORTED MlirRegion mlirBlockGetParentRegion(MlirBlock block)
Returns the region that contains this block.
Definition IR.cpp:1009
MLIR_CAPI_EXPORTED void mlirOperationMoveBefore(MlirOperation op, MlirOperation other)
Moves the given operation immediately before the other operation in its parent block.
Definition IR.cpp:884
MLIR_CAPI_EXPORTED bool mlirIRMappingContainsValue(MlirIRMapping mapping, MlirValue value)
Returns true if the mapping contains a mapping for the given value.
Definition IR.cpp:1469
MLIR_CAPI_EXPORTED void mlirValueReplaceAllUsesExcept(MlirValue of, MlirValue with, intptr_t numExceptions, MlirOperation *exceptions)
Replace all uses of 'of' value with 'with' value, updating anything in the IR that uses 'of' to use '...
Definition IR.cpp:1207
MLIR_CAPI_EXPORTED void mlirIRMappingEraseValue(MlirIRMapping mapping, MlirValue value)
Erases a value mapping.
Definition IR.cpp:1481
MLIR_CAPI_EXPORTED void mlirOperationPrintWithState(MlirOperation op, MlirAsmState state, MlirStringCallback callback, void *userData)
Same as mlirOperationPrint but accepts AsmState controlling the printing behavior as well as caching ...
Definition IR.cpp:851
MLIR_CAPI_EXPORTED void mlirBlockDestroy(MlirBlock block)
Takes a block owned by the caller and destroys it.
Definition IR.cpp:1071
MlirWalkResult
Operation walk result.
Definition IR.h:853
@ MlirWalkResultInterrupt
Definition IR.h:855
@ MlirWalkResultSkip
Definition IR.h:856
@ MlirWalkResultAdvance
Definition IR.h:854
MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlock(MlirRegion region, intptr_t pos, MlirBlock block)
Takes a block owned by the caller and inserts it at pos to the given region.
Definition IR.cpp:950
static bool mlirTypeIsNull(MlirType type)
Checks whether a type is null.
Definition IR.h:1172
MLIR_CAPI_EXPORTED bool mlirRegionEqual(MlirRegion region, MlirRegion other)
Checks whether two region handles point to the same region.
Definition IR.cpp:935
MLIR_CAPI_EXPORTED bool mlirContextIsRegisteredOperation(MlirContext context, MlirStringRef name)
Returns whether the given fully-qualified operation (i.e.
Definition IR.cpp:100
MLIR_CAPI_EXPORTED intptr_t mlirBlockGetNumArguments(MlirBlock block)
Returns the number of arguments of the block.
Definition IR.cpp:1078
MLIR_CAPI_EXPORTED int mlirLocationFileLineColRangeGetStartLine(MlirLocation location)
Getter for start_line of FileLineColRange.
Definition IR.cpp:293
MLIR_CAPI_EXPORTED MlirLocation mlirLocationFusedGet(MlirContext ctx, intptr_t nLocations, MlirLocation const *locations, MlirAttribute metadata)
Creates a fused location with an array of locations and metadata.
Definition IR.cpp:347
MLIR_CAPI_EXPORTED void mlirIRMappingEraseBlock(MlirIRMapping mapping, MlirBlock block)
Erases a block mapping.
Definition IR.cpp:1485
MLIR_CAPI_EXPORTED void mlirBlockInsertOwnedOperationBefore(MlirBlock block, MlirOperation reference, MlirOperation operation)
Takes an operation owned by the caller and inserts it before the (non-owned) reference operation in t...
Definition IR.cpp:1059
static bool mlirContextIsNull(MlirContext context)
Checks whether a context is null.
Definition IR.h:105
MLIR_CAPI_EXPORTED MlirDialect mlirContextGetOrLoadDialect(MlirContext context, MlirStringRef name)
Gets the dialect instance owned by the given context using the dialect namespace to identify it,...
Definition IR.cpp:95
MLIR_CAPI_EXPORTED void mlirDialectHandleRegisterDialect(MlirDialectHandle, MlirContext)
Registers the dialect associated with the provided dialect handle.
MLIR_CAPI_EXPORTED bool mlirLocationIsACallSite(MlirLocation location)
Checks whether the given location is an CallSite.
Definition IR.cpp:343
#define DEFINE_C_API_STRUCT(name, storage)
Opaque type declarations.
Definition IR.h:45
struct MlirNamedAttribute MlirNamedAttribute
Definition IR.h:81
MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlockAfter(MlirRegion region, MlirBlock reference, MlirBlock block)
Takes a block owned by the caller and inserts it after the (non-owned) reference block in the given r...
Definition IR.cpp:956
MLIR_CAPI_EXPORTED MlirBlock mlirBlockCreate(intptr_t nArgs, MlirType const *args, MlirLocation const *locs)
Creates a new empty block with the given argument types and transfers ownership to the caller.
Definition IR.cpp:993
MLIR_CAPI_EXPORTED MlirIRMapping mlirIRMappingCreate(void)
Creates a new empty IRMapping.
Definition IR.cpp:1418
static bool mlirBlockIsNull(MlirBlock block)
Checks whether a block is null.
Definition IR.h:953
MLIR_CAPI_EXPORTED void mlirBlockAppendOwnedOperation(MlirBlock block, MlirOperation operation)
Takes an operation owned by the caller and appends it to the block.
Definition IR.cpp:1034
MLIR_CAPI_EXPORTED MlirValue mlirBlockGetArgument(MlirBlock block, intptr_t pos)
Returns pos-th argument of the block.
Definition IR.cpp:1096
MLIR_CAPI_EXPORTED MlirOperation mlirSymbolTableLookup(MlirSymbolTable symbolTable, MlirStringRef name)
Looks up a symbol with the given name in the given symbol table and returns the operation that corres...
Definition IR.cpp:1377
MLIR_CAPI_EXPORTED MlirContext mlirTypeGetContext(MlirType type)
Gets the context that a type was created with.
Definition IR.cpp:1268
MLIR_CAPI_EXPORTED MlirLocation mlirLocationFileLineColRangeGet(MlirContext context, MlirStringRef filename, unsigned start_line, unsigned start_col, unsigned end_line, unsigned end_col)
Creates an File/Line/Column range location owned by the given context.
Definition IR.cpp:281
MLIR_CAPI_EXPORTED bool mlirOpOperandIsNull(MlirOpOperand opOperand)
Returns whether the op operand is null.
Definition IR.cpp:1233
MLIR_CAPI_EXPORTED MlirSymbolTable mlirSymbolTableCreate(MlirOperation operation)
Creates a symbol table for the given operation.
Definition IR.cpp:1367
MLIR_CAPI_EXPORTED bool mlirLocationEqual(MlirLocation l1, MlirLocation l2)
Checks if two locations are equal.
Definition IR.cpp:415
MLIR_CAPI_EXPORTED int mlirLocationFileLineColRangeGetStartColumn(MlirLocation location)
Getter for start_column of FileLineColRange.
Definition IR.cpp:299
MLIR_CAPI_EXPORTED bool mlirLocationIsAFused(MlirLocation location)
Checks whether the given location is an Fused.
Definition IR.cpp:375
MLIR_CAPI_EXPORTED bool mlirIRMappingContainsOperation(MlirIRMapping mapping, MlirOperation op)
Returns true if the mapping contains a mapping for the given operation.
Definition IR.cpp:1477
static bool mlirLocationIsNull(MlirLocation location)
Checks if the location is null.
Definition IR.h:377
MLIR_CAPI_EXPORTED MlirValue mlirBlockAddArgument(MlirBlock block, MlirType type, MlirLocation loc)
Appends an argument of the specified type to the block.
Definition IR.cpp:1082
MLIR_CAPI_EXPORTED void mlirOperationPrintWithFlags(MlirOperation op, MlirOpPrintingFlags flags, MlirStringCallback callback, void *userData)
Same as mlirOperationPrint but accepts flags controlling the printing behavior.
Definition IR.cpp:845
MLIR_CAPI_EXPORTED MlirOpOperand mlirValueGetFirstUse(MlirValue value)
Returns an op operand representing the first use of the value, or a null op operand if there are no u...
Definition IR.cpp:1193
MLIR_CAPI_EXPORTED void mlirContextSetThreadPool(MlirContext context, MlirLlvmThreadPool threadPool)
Sets the thread pool of the context explicitly, enabling multithreading in the process.
Definition IR.cpp:112
MLIR_CAPI_EXPORTED bool mlirOperationVerify(MlirOperation op)
Verify the operation and return true if it passes, false if it fails.
Definition IR.cpp:876
MLIR_CAPI_EXPORTED bool mlirTypeEqual(MlirType t1, MlirType t2)
Checks if two types are equal.
Definition IR.cpp:1280
MLIR_CAPI_EXPORTED void mlirSymbolTableDestroy(MlirSymbolTable symbolTable)
Destroys the symbol table created with mlirSymbolTableCreate.
Definition IR.cpp:1373
MLIR_CAPI_EXPORTED unsigned mlirOpOperandGetOperandNumber(MlirOpOperand opOperand)
Returns the operand number of an op operand.
Definition IR.cpp:1243
MLIR_CAPI_EXPORTED MlirLocation mlirLocationCallSiteGetCaller(MlirLocation location)
Getter for caller of CallSite.
Definition IR.cpp:334
MLIR_CAPI_EXPORTED MlirContext mlirDialectGetContext(MlirDialect dialect)
Returns the context that owns the dialect.
Definition IR.cpp:129
MLIR_CAPI_EXPORTED bool mlirBlockEqual(MlirBlock block, MlirBlock other)
Checks whether two blocks handles point to the same block.
Definition IR.cpp:1001
MLIR_CAPI_EXPORTED MlirOperation mlirBlockGetTerminator(MlirBlock block)
Returns the terminator operation in the block or null if no terminator.
Definition IR.cpp:1024
MLIR_CAPI_EXPORTED void mlirRegionDestroy(MlirRegion region)
Takes a region owned by the caller and destroys it.
Definition IR.cpp:981
MLIR_CAPI_EXPORTED MlirContext mlirIdentifierGetContext(MlirIdentifier)
Returns the context associated with this identifier.
Definition IR.cpp:1343
MLIR_CAPI_EXPORTED MlirStringRef mlirDialectHandleGetNamespace(MlirDialectHandle)
Returns the namespace associated with the provided dialect handle.
MLIR_CAPI_EXPORTED MlirIdentifier mlirLocationNameGetName(MlirLocation location)
Getter for name of Name.
Definition IR.cpp:388
MLIR_CAPI_EXPORTED bool mlirOperationIsBeforeInBlock(MlirOperation op, MlirOperation other)
Given an operation 'other' that is within the same parent block, return whether the current operation...
Definition IR.cpp:888
MLIR_CAPI_EXPORTED MlirLocation mlirLocationFromAttribute(MlirAttribute attribute)
Creates a location from a location attribute.
Definition IR.cpp:269
MLIR_CAPI_EXPORTED MlirTypeID mlirTypeGetTypeID(MlirType type)
Gets the type ID of the type.
Definition IR.cpp:1272
MLIR_CAPI_EXPORTED bool mlirIRMappingContainsBlock(MlirIRMapping mapping, MlirBlock block)
Returns true if the mapping contains a mapping for the given block.
Definition IR.cpp:1473
MLIR_CAPI_EXPORTED MlirStringRef mlirSymbolTableGetVisibilityAttributeName(void)
Returns the name of the attribute used to store symbol visibility.
Definition IR.cpp:1363
static bool mlirDialectIsNull(MlirDialect dialect)
Checks if the dialect is null.
Definition IR.h:183
MLIR_CAPI_EXPORTED MlirAttribute mlirLocationFusedGetMetadata(MlirLocation location)
Getter for metadata of Fused.
Definition IR.cpp:369
MLIR_CAPI_EXPORTED MlirBlock mlirBlockGetNextInRegion(MlirBlock block)
Returns the block immediately following the given block in its parent region.
Definition IR.cpp:1013
MLIR_CAPI_EXPORTED MlirLocation mlirLocationCallSiteGet(MlirLocation callee, MlirLocation caller)
Creates a call site location with a callee and a caller.
Definition IR.cpp:325
MLIR_CAPI_EXPORTED bool mlirLocationIsAName(MlirLocation location)
Checks whether the given location is an Name.
Definition IR.cpp:399
static bool mlirDialectRegistryIsNull(MlirDialectRegistry registry)
Checks if the dialect registry is null.
Definition IR.h:245
MLIR_CAPI_EXPORTED void mlirOperationWalk(MlirOperation op, MlirOperationWalkCallback callback, void *userData, MlirWalkOrder walkOrder)
Walks operation op in walkOrder and calls callback on that operation.
Definition IR.cpp:906
MLIR_CAPI_EXPORTED MlirContext mlirContextCreateWithThreading(bool threadingEnabled)
Creates an MLIR context with an explicit setting of the multithreading setting and transfers its owne...
Definition IR.cpp:55
MLIR_CAPI_EXPORTED MlirOperation mlirBlockGetParentOperation(MlirBlock)
Returns the closest surrounding operation that contains this block.
Definition IR.cpp:1005
MLIR_CAPI_EXPORTED void mlirRegionTakeBody(MlirRegion target, MlirRegion source)
Moves the entire content of the source region to the target region.
Definition IR.cpp:985
MLIR_CAPI_EXPORTED MlirContext mlirLocationGetContext(MlirLocation location)
Gets the context that a location was created with.
Definition IR.cpp:419
MLIR_CAPI_EXPORTED void mlirBlockEraseArgument(MlirBlock block, unsigned index)
Erase the argument at 'index' and remove it from the argument list.
Definition IR.cpp:1087
MLIR_CAPI_EXPORTED void mlirAttributeDump(MlirAttribute attr)
Prints the attribute to the standard error stream.
Definition IR.cpp:1328
MLIR_CAPI_EXPORTED MlirBlock mlirIRMappingLookupOrDefaultBlock(MlirIRMapping mapping, MlirBlock from)
Looks up a mapped Block.
Definition IR.cpp:1449
MLIR_CAPI_EXPORTED MlirLogicalResult mlirSymbolTableReplaceAllSymbolUses(MlirStringRef oldSymbol, MlirStringRef newSymbol, MlirOperation from)
Attempt to replace all uses that are nested within the given operation of the given symbol 'oldSymbol...
Definition IR.cpp:1392
MLIR_CAPI_EXPORTED MlirTypeID mlirLocationFileLineColRangeGetTypeID(void)
TypeID Getter for FileLineColRange.
Definition IR.cpp:317
MLIR_CAPI_EXPORTED void mlirRegionAppendOwnedBlock(MlirRegion region, MlirBlock block)
Takes a block owned by the caller and appends it to the given region.
Definition IR.cpp:946
MLIR_CAPI_EXPORTED MlirOperation mlirBlockGetFirstOperation(MlirBlock block)
Returns the first operation in the block.
Definition IR.cpp:1017
MLIR_CAPI_EXPORTED void mlirOperationPrint(MlirOperation op, MlirStringCallback callback, void *userData)
Prints a location by sending chunks of the string representation and forwarding userData to callback`...
Definition IR.cpp:839
static bool mlirRegionIsNull(MlirRegion region)
Checks whether a region is null.
Definition IR.h:892
MLIR_CAPI_EXPORTED MlirValue mlirOpOperandGetValue(MlirOpOperand opOperand)
Returns the value of an op operand.
Definition IR.cpp:1239
MLIR_CAPI_EXPORTED MlirRegion mlirRegionGetNextInOperation(MlirRegion region)
Returns the region immediately following the given region in its parent operation.
Definition IR.cpp:710
MLIR_CAPI_EXPORTED MlirValue mlirBlockInsertArgument(MlirBlock block, intptr_t pos, MlirType type, MlirLocation loc)
Inserts an argument of the specified type at a specified index to the block.
Definition IR.cpp:1091
MLIR_CAPI_EXPORTED MlirDialect mlirTypeGetDialect(MlirType type)
Gets the dialect a type belongs to.
Definition IR.cpp:1276
MLIR_CAPI_EXPORTED MlirIdentifier mlirIdentifierGet(MlirContext context, MlirStringRef str)
Gets an identifier with the given string value.
Definition IR.cpp:1339
MLIR_CAPI_EXPORTED void mlirContextLoadAllAvailableDialects(MlirContext context)
Eagerly loads all available dialects registered with a context, making them available for use for IR ...
Definition IR.cpp:108
MLIR_CAPI_EXPORTED MlirTypeID mlirLocationCallSiteGetTypeID(void)
TypeID Getter for CallSite.
Definition IR.cpp:339
MLIR_CAPI_EXPORTED MlirLlvmThreadPool mlirContextGetThreadPool(MlirContext context)
Gets the thread pool of the context when enabled multithreading, otherwise an assertion is raised.
Definition IR.cpp:121
MLIR_CAPI_EXPORTED int mlirLocationFileLineColRangeGetEndLine(MlirLocation location)
Getter for end_line of FileLineColRange.
Definition IR.cpp:305
MLIR_CAPI_EXPORTED MlirDialectRegistry mlirDialectRegistryCreate(void)
Creates a dialect registry and transfers its ownership to the caller.
Definition IR.cpp:145
MLIR_CAPI_EXPORTED MlirLocation mlirLocationNameGet(MlirContext context, MlirStringRef name, MlirLocation childLoc)
Creates a name location owned by the given context.
Definition IR.cpp:379
MLIR_CAPI_EXPORTED MlirContext mlirContextCreateWithRegistry(MlirDialectRegistry registry, bool threadingEnabled)
Creates an MLIR context, setting the multithreading setting explicitly and pre-loading the dialects f...
Definition IR.cpp:60
MLIR_CAPI_EXPORTED void mlirContextEnableMultithreading(MlirContext context, bool enable)
Set threading mode (must be set to false to mlir-print-ir-after-all).
Definition IR.cpp:104
MLIR_CAPI_EXPORTED MlirRegion mlirOperationGetFirstRegion(MlirOperation op)
Returns first region attached to the operation.
Definition IR.cpp:703
MLIR_CAPI_EXPORTED MlirLocation mlirLocationCallSiteGetCallee(MlirLocation location)
Getter for callee of CallSite.
Definition IR.cpp:329
MLIR_CAPI_EXPORTED MlirTypeID mlirLocationNameGetTypeID(void)
TypeID Getter for Name.
Definition IR.cpp:397
MLIR_CAPI_EXPORTED MlirContext mlirValueGetContext(MlirValue v)
Gets the context that a value was created with.
Definition IR.cpp:1225
MLIR_CAPI_EXPORTED MlirValue mlirIRMappingLookupOrNullValue(MlirIRMapping mapping, MlirValue from)
Looks up a mapped Value. Returns a null MlirValue if no mapping exists.
Definition IR.cpp:1444
MLIR_CAPI_EXPORTED void mlirIRMappingMapValue(MlirIRMapping mapping, MlirValue from, MlirValue to)
Maps a Value in the mapping.
Definition IR.cpp:1422
MLIR_CAPI_EXPORTED MlirStringRef mlirSymbolTableGetSymbolAttributeName(void)
Returns the name of the attribute used to store symbol names compatible with symbol tables.
Definition IR.cpp:1359
MLIR_CAPI_EXPORTED MlirRegion mlirRegionCreate(void)
Creates a new empty region and transfers ownership to the caller.
Definition IR.cpp:933
MLIR_CAPI_EXPORTED void mlirIRMappingEraseOperation(MlirIRMapping mapping, MlirOperation op)
Erases an operation mapping.
Definition IR.cpp:1489
MLIR_CAPI_EXPORTED MlirTypeID mlirLocationFusedGetTypeID(void)
TypeID Getter for Fused.
Definition IR.cpp:373
MLIR_CAPI_EXPORTED void mlirBlockDetach(MlirBlock block)
Detach a block from the owning region and assume ownership.
Definition IR.cpp:1073
MLIR_CAPI_EXPORTED void mlirDialectHandleInsertDialect(MlirDialectHandle, MlirDialectRegistry)
Inserts the dialect associated with the provided dialect handle into the provided dialect registry.
MLIR_CAPI_EXPORTED void mlirOperationDump(MlirOperation op)
Prints an operation to stderr.
Definition IR.cpp:874
MLIR_CAPI_EXPORTED bool mlirContextEqual(MlirContext ctx1, MlirContext ctx2)
Checks if two contexts are equal.
Definition IR.cpp:67
MLIR_CAPI_EXPORTED bool mlirDialectEqual(MlirDialect dialect1, MlirDialect dialect2)
Checks if two dialects that belong to the same context are equal.
Definition IR.cpp:133
MLIR_CAPI_EXPORTED void mlirBlockInsertOwnedOperation(MlirBlock block, intptr_t pos, MlirOperation operation)
Takes an operation owned by the caller and inserts it as pos to the block.
Definition IR.cpp:1038
MLIR_CAPI_EXPORTED MlirContext mlirContextCreate(void)
Creates an MLIR context and transfers its ownership to the caller.
Definition IR.cpp:45
MLIR_CAPI_EXPORTED void mlirIRMappingMapOperation(MlirIRMapping mapping, MlirOperation from, MlirOperation to)
Maps an Operation in the mapping.
Definition IR.cpp:1432
static bool mlirSymbolTableIsNull(MlirSymbolTable symbolTable)
Returns true if the symbol table is null.
Definition IR.h:1262
MLIR_CAPI_EXPORTED bool mlirContextGetAllowUnregisteredDialects(MlirContext context)
Returns whether the context allows unregistered dialects.
Definition IR.cpp:77
MLIR_CAPI_EXPORTED void mlirOperationReplaceUsesOfWith(MlirOperation op, MlirValue of, MlirValue with)
Replace uses of 'of' value with the 'with' value inside the 'op' operation.
Definition IR.cpp:924
MLIR_CAPI_EXPORTED void mlirOperationMoveAfter(MlirOperation op, MlirOperation other)
Moves the given operation immediately after the other operation in its parent block.
Definition IR.cpp:880
static bool mlirIRMappingIsNull(MlirIRMapping mapping)
Checks whether an IRMapping is null.
Definition IR.h:1317
MLIR_CAPI_EXPORTED void mlirValuePrint(MlirValue value, MlirStringCallback callback, void *userData)
Prints a block by sending chunks of the string representation and forwarding userData to callback`.
Definition IR.cpp:1180
MLIR_CAPI_EXPORTED void mlirBlockInsertOwnedOperationAfter(MlirBlock block, MlirOperation reference, MlirOperation operation)
Takes an operation owned by the caller and inserts it after the (non-owned) reference operation in th...
Definition IR.cpp:1044
MLIR_CAPI_EXPORTED MlirLogicalResult mlirOperationWriteBytecodeWithConfig(MlirOperation op, MlirBytecodeWriterConfig config, MlirStringCallback callback, void *userData)
Same as mlirOperationWriteBytecode but with writer config and returns failure only if desired bytecod...
Definition IR.cpp:867
MLIR_CAPI_EXPORTED void mlirContextDestroy(MlirContext context)
Takes an MLIR context owned by the caller and destroys it.
Definition IR.cpp:71
MLIR_CAPI_EXPORTED MlirBlock mlirRegionGetFirstBlock(MlirRegion region)
Gets the first block in the region.
Definition IR.cpp:939
#define MLIR_CAPI_EXPORTED
Definition Support.h:46
struct MlirStringRef MlirStringRef
Definition Support.h:82
void(* MlirStringCallback)(MlirStringRef, void *)
A callback for returning string references.
Definition Support.h:110
const void * ptr
Definition IR.h:212
A logical result value, essentially a boolean with named states.
Definition Support.h:121
Named MLIR attribute.
Definition IR.h:77
MlirAttribute attribute
Definition IR.h:79
MlirIdentifier name
Definition IR.h:78
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition Support.h:78