aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mlir/include/mlir-c/AffineExpr.h22
-rw-r--r--mlir/include/mlir-c/AffineMap.h22
-rw-r--r--mlir/include/mlir-c/IR.h2
3 files changed, 46 insertions, 0 deletions
diff --git a/mlir/include/mlir-c/AffineExpr.h b/mlir/include/mlir-c/AffineExpr.h
index fb00c70..62700ad 100644
--- a/mlir/include/mlir-c/AffineExpr.h
+++ b/mlir/include/mlir-c/AffineExpr.h
@@ -17,8 +17,30 @@
extern "C" {
#endif
+/*============================================================================*/
+/** Opaque type declarations.
+ *
+ * Types are exposed to C bindings as structs containing opaque pointers. They
+ * are not supposed to be inspected from C. This allows the underlying
+ * representation to change without affecting the API users. The use of structs
+ * instead of typedefs enables some type safety as structs are not implicitly
+ * convertible to each other.
+ *
+ * Instances of these types may or may not own the underlying object. The
+ * ownership semantics is defined by how an instance of the type was obtained.
+ */
+/*============================================================================*/
+
+#define DEFINE_C_API_STRUCT(name, storage) \
+ struct name { \
+ storage *ptr; \
+ }; \
+ typedef struct name name
+
DEFINE_C_API_STRUCT(MlirAffineExpr, const void);
+#undef DEFINE_C_API_STRUCT
+
/** Gets the context that owns the affine expression. */
MlirContext mlirAffineExprGetContext(MlirAffineExpr affineExpr);
diff --git a/mlir/include/mlir-c/AffineMap.h b/mlir/include/mlir-c/AffineMap.h
index a5d9918..4793407d 100644
--- a/mlir/include/mlir-c/AffineMap.h
+++ b/mlir/include/mlir-c/AffineMap.h
@@ -16,8 +16,30 @@
extern "C" {
#endif
+/*============================================================================*/
+/** Opaque type declarations.
+ *
+ * Types are exposed to C bindings as structs containing opaque pointers. They
+ * are not supposed to be inspected from C. This allows the underlying
+ * representation to change without affecting the API users. The use of structs
+ * instead of typedefs enables some type safety as structs are not implicitly
+ * convertible to each other.
+ *
+ * Instances of these types may or may not own the underlying object. The
+ * ownership semantics is defined by how an instance of the type was obtained.
+ */
+/*============================================================================*/
+
+#define DEFINE_C_API_STRUCT(name, storage) \
+ struct name { \
+ storage *ptr; \
+ }; \
+ typedef struct name name
+
DEFINE_C_API_STRUCT(MlirAffineMap, const void);
+#undef DEFINE_C_API_STRUCT
+
/** Gets the context that the given affine map was created with*/
MlirContext mlirAffineMapGetContext(MlirAffineMap affineMap);
diff --git a/mlir/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h
index 77c66e0..eea7c51 100644
--- a/mlir/include/mlir-c/IR.h
+++ b/mlir/include/mlir-c/IR.h
@@ -61,6 +61,8 @@ DEFINE_C_API_STRUCT(MlirModule, const void);
DEFINE_C_API_STRUCT(MlirType, const void);
DEFINE_C_API_STRUCT(MlirValue, const void);
+#undef DEFINE_C_API_STRUCT
+
/** Named MLIR attribute.
*
* A named attribute is essentially a (name, attribute) pair where the name is