MLIR 23.0.0git
ExtensibleDialect.h
Go to the documentation of this file.
1//===-- mlir-c/ExtensibleDialect.h - Extensible dialect APIs -----*- 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 provides APIs for extensible dialects.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MLIR_C_EXTENSIBLEDIALECT_H
15#define MLIR_C_EXTENSIBLEDIALECT_H
16
17#include "mlir-c/IR.h"
18#include "mlir-c/Support.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24//===----------------------------------------------------------------------===//
25/// Opaque type declarations (see mlir-c/IR.h for more details).
26//===----------------------------------------------------------------------===//
27
28#define DEFINE_C_API_STRUCT(name, storage) \
29 struct name { \
30 storage *ptr; \
31 }; \
32 typedef struct name name
33
34DEFINE_C_API_STRUCT(MlirDynamicOpTrait, void);
35
36#undef DEFINE_C_API_STRUCT
37
38/// Attach a dynamic op trait to the given operation name.
39/// Note that the operation name must be modeled by dynamic dialect and must be
40/// registered.
41/// The ownership of the trait will be transferred to the operation name
42/// after this call.
44mlirDynamicOpTraitAttach(MlirDynamicOpTrait dynamicOpTrait,
45 MlirStringRef opName, MlirContext context);
46
47/// Get the dynamic op trait that indicates the operation is a terminator.
48MLIR_CAPI_EXPORTED MlirDynamicOpTrait
50
51/// Get the dynamic op trait that indicates regions have no terminator.
52MLIR_CAPI_EXPORTED MlirDynamicOpTrait
54
55/// Destroy the dynamic op trait.
57mlirDynamicOpTraitDestroy(MlirDynamicOpTrait dynamicOpTrait);
58
59typedef struct {
60 /// Optional constructor for the user data.
61 /// Set to nullptr to disable it.
62 void (*construct)(void *userData);
63 /// Optional destructor for the user data.
64 /// Set to nullptr to disable it.
65 void (*destruct)(void *userData);
66 /// The callback function to verify the operation.
67 MlirLogicalResult (*verifyTrait)(MlirOperation op, void *userData);
68 /// The callback function to verify the operation with access to regions.
69 MlirLogicalResult (*verifyRegionTrait)(MlirOperation op, void *userData);
71
72/// Create a custom dynamic op trait with the given type ID and callbacks.
74 MlirTypeID typeID, MlirDynamicOpTraitCallbacks callbacks, void *userData);
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif // MLIR_C_EXTENSIBLEDIALECT_H
MLIR_CAPI_EXPORTED void mlirDynamicOpTraitDestroy(MlirDynamicOpTrait dynamicOpTrait)
Destroy the dynamic op trait.
MLIR_CAPI_EXPORTED MlirDynamicOpTrait mlirDynamicOpTraitIsTerminatorCreate(void)
Get the dynamic op trait that indicates the operation is a terminator.
#define DEFINE_C_API_STRUCT(name, storage)
Opaque type declarations (see mlir-c/IR.h for more details).
MLIR_CAPI_EXPORTED MlirDynamicOpTrait mlirDynamicOpTraitCreate(MlirTypeID typeID, MlirDynamicOpTraitCallbacks callbacks, void *userData)
Create a custom dynamic op trait with the given type ID and callbacks.
MLIR_CAPI_EXPORTED bool mlirDynamicOpTraitAttach(MlirDynamicOpTrait dynamicOpTrait, MlirStringRef opName, MlirContext context)
Attach a dynamic op trait to the given operation name.
MLIR_CAPI_EXPORTED MlirDynamicOpTrait mlirDynamicOpTraitNoTerminatorCreate(void)
Get the dynamic op trait that indicates regions have no terminator.
struct MlirLogicalResult MlirLogicalResult
Definition Support.h:124
#define MLIR_CAPI_EXPORTED
Definition Support.h:46
MlirLogicalResult(* verifyTrait)(MlirOperation op, void *userData)
The callback function to verify the operation.
void(* construct)(void *userData)
Optional constructor for the user data.
void(* destruct)(void *userData)
Optional destructor for the user data.
MlirLogicalResult(* verifyRegionTrait)(MlirOperation op, void *userData)
The callback function to verify the operation with access to regions.
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition Support.h:78