[Mlir-commits] [mlir] [mlir][emitc] Expose emitc dialect types (PR #119645)
Eliud de León
llvmlistbot at llvm.org
Wed Dec 11 17:38:49 PST 2024
https://github.com/TGMM created https://github.com/llvm/llvm-project/pull/119645
Added C API functions for the EmitC dialect types.
>From ce5010ae922f835da7d0961cf5145a5d0377d908 Mon Sep 17 00:00:00 2001
From: TGMM <tgmm.1000 at gmail.com>
Date: Wed, 11 Dec 2024 17:36:30 -0800
Subject: [PATCH] [mlir][emitc] Expose emitc dialect types
---
mlir/include/mlir-c/Dialect/EmitC.h | 62 +++++++++++++++++
mlir/lib/CAPI/Dialect/EmitC.cpp | 100 ++++++++++++++++++++++++++++
2 files changed, 162 insertions(+)
diff --git a/mlir/include/mlir-c/Dialect/EmitC.h b/mlir/include/mlir-c/Dialect/EmitC.h
index 82e698344bf1e7..384e695e429ef0 100644
--- a/mlir/include/mlir-c/Dialect/EmitC.h
+++ b/mlir/include/mlir-c/Dialect/EmitC.h
@@ -19,6 +19,68 @@ extern "C" {
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(EmitC, emitc);
+//===---------------------------------------------------------------------===//
+// ArrayType
+//===---------------------------------------------------------------------===//
+
+MLIR_CAPI_EXPORTED bool mlirTypeIsAEmitCArrayType(MlirType type);
+
+MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCArrayTypeGetTypeID(void);
+
+MLIR_CAPI_EXPORTED MlirType mlirEmitCArrayTypeGet(intptr_t nDims,
+ int64_t *shape,
+ MlirType elementType);
+//===---------------------------------------------------------------------===//
+// OpaqueType
+//===---------------------------------------------------------------------===//
+
+MLIR_CAPI_EXPORTED bool mlirTypeIsAEmitCOpaqueType(MlirType type);
+
+MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCOpaqueTypeGetTypeID(void);
+
+MLIR_CAPI_EXPORTED MlirType mlirEmitCOpaqueTypeGet(MlirContext ctx,
+ MlirStringRef value);
+
+//===---------------------------------------------------------------------===//
+// PointerType
+//===---------------------------------------------------------------------===//
+
+MLIR_CAPI_EXPORTED bool mlirTypeIsAEmitCPointerType(MlirType type);
+
+MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCPointerTypeGetTypeID(void);
+
+MLIR_CAPI_EXPORTED MlirType mlirEmitCPointerTypeGet(MlirType pointee);
+
+//===---------------------------------------------------------------------===//
+// PtrDiffTType
+//===---------------------------------------------------------------------===//
+
+MLIR_CAPI_EXPORTED bool mlirTypeIsAEmitCPtrDiffTType(MlirType type);
+
+MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCPtrDiffTTypeGetTypeID(void);
+
+MLIR_CAPI_EXPORTED MlirType mlirEmitCPtrDiffTTypeGet(MlirContext ctx);
+
+//===---------------------------------------------------------------------===//
+// SignedSizeTType
+//===---------------------------------------------------------------------===//
+
+MLIR_CAPI_EXPORTED bool mlirTypeIsAEmitCSignedSizeTType(MlirType type);
+
+MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCSignedSizeTTypeGetTypeID(void);
+
+MLIR_CAPI_EXPORTED MlirType mlirEmitCSignedSizeTTypeGet(MlirContext ctx);
+
+//===---------------------------------------------------------------------===//
+// SizeTType
+//===---------------------------------------------------------------------===//
+
+MLIR_CAPI_EXPORTED bool mlirTypeIsAEmitCSizeTType(MlirType type);
+
+MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCSizeTTypeGetTypeID(void);
+
+MLIR_CAPI_EXPORTED MlirType mlirEmitCSizeTTypeGet(MlirContext ctx);
+
#ifdef __cplusplus
}
#endif
diff --git a/mlir/lib/CAPI/Dialect/EmitC.cpp b/mlir/lib/CAPI/Dialect/EmitC.cpp
index 3dcb7038a57981..57619ff776843d 100644
--- a/mlir/lib/CAPI/Dialect/EmitC.cpp
+++ b/mlir/lib/CAPI/Dialect/EmitC.cpp
@@ -10,4 +10,104 @@
#include "mlir/CAPI/Registration.h"
#include "mlir/Dialect/EmitC/IR/EmitC.h"
+using namespace mlir;
+
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(EmitC, emitc, mlir::emitc::EmitCDialect)
+
+//===---------------------------------------------------------------------===//
+// ArrayType
+//===---------------------------------------------------------------------===//
+
+bool mlirTypeIsAEmitCArrayType(MlirType type) {
+ return isa<emitc::ArrayType>(unwrap(type));
+}
+
+MlirTypeID mlirEmitCArrayTypeGetTypeID(void) {
+ return wrap(emitc::ArrayType::getTypeID());
+}
+
+MlirType mlirEmitCArrayTypeGet(intptr_t nDims, int64_t *shape,
+ MlirType elementType) {
+ return wrap(
+ emitc::ArrayType::get(llvm::ArrayRef(shape, nDims), unwrap(elementType)));
+}
+
+//===---------------------------------------------------------------------===//
+// OpaqueType
+//===---------------------------------------------------------------------===//
+
+bool mlirTypeIsAEmitCOpaqueType(MlirType type) {
+ return isa<emitc::OpaqueType>(unwrap(type));
+}
+
+MlirTypeID mlirEmitCOpaqueTypeGetTypeID(void) {
+ return wrap(emitc::OpaqueType::getTypeID());
+}
+
+MlirType mlirEmitCOpaqueTypeGet(MlirContext ctx, MlirStringRef value) {
+ return wrap(emitc::OpaqueType::get(unwrap(ctx), unwrap(value)));
+}
+
+//===---------------------------------------------------------------------===//
+// PointerType
+//===---------------------------------------------------------------------===//
+
+bool mlirTypeIsAEmitCPointerType(MlirType type) {
+ return isa<emitc::PointerType>(unwrap(type));
+}
+
+MlirTypeID mlirEmitCPointerTypeGetTypeID(void) {
+ return wrap(emitc::PointerType::getTypeID());
+}
+
+MlirType mlirEmitCPointerTypeGet(MlirType pointee) {
+ return wrap(emitc::PointerType::get(unwrap(pointee)));
+}
+
+//===---------------------------------------------------------------------===//
+// PtrDiffTType
+//===---------------------------------------------------------------------===//
+
+bool mlirTypeIsAEmitCPtrDiffTType(MlirType type) {
+ return isa<emitc::PtrDiffTType>(unwrap(type));
+}
+
+MlirTypeID mlirEmitCPtrDiffTTypeGetTypeID(void) {
+ return wrap(emitc::PtrDiffTType::getTypeID());
+}
+
+MlirType mlirEmitCPtrDiffTTypeGet(MlirContext ctx) {
+ return wrap(emitc::PtrDiffTType::get(unwrap(ctx)));
+}
+
+//===---------------------------------------------------------------------===//
+// SignedSizeTType
+//===---------------------------------------------------------------------===//
+
+bool mlirTypeIsAEmitCSignedSizeTType(MlirType type) {
+ return isa<emitc::SignedSizeTType>(unwrap(type));
+}
+
+MlirTypeID mlirEmitCSignedSizeTTypeGetTypeID(void) {
+ return wrap(emitc::SignedSizeTType::getTypeID());
+}
+
+MlirType mlirEmitCSignedSizeTTypeGet(MlirContext ctx) {
+ return wrap(emitc::SignedSizeTType::get(unwrap(ctx)));
+}
+
+//===---------------------------------------------------------------------===//
+// SizeTType
+//===---------------------------------------------------------------------===//
+
+bool mlirTypeIsAEmitCSizeTType(MlirType type) {
+ return isa<emitc::SizeTType>(unwrap(type));
+}
+
+MlirTypeID mlirEmitCSizeTTypeGetTypeID(void) {
+ return wrap(emitc::SizeTType::getTypeID());
+}
+
+MlirType mlirEmitCSizeTTypeGet(MlirContext ctx) {
+ return wrap(emitc::SizeTType::get(unwrap(ctx)));
+}
More information about the Mlir-commits
mailing list