[Mlir-commits] [mlir] MLIR-C: Add accessor for LLVM array type (PR #119998)

William Moses llvmlistbot at llvm.org
Sun Dec 15 07:45:52 PST 2024


https://github.com/wsmoses updated https://github.com/llvm/llvm-project/pull/119998

>From 068a59574cef5518f7af00893624f0ebd45177cf Mon Sep 17 00:00:00 2001
From: "William S. Moses" <gh at wsmoses.com>
Date: Sun, 15 Dec 2024 02:34:37 -0500
Subject: [PATCH 1/2] MLIR-C: Add accessor for LLVM array type

---
 mlir/include/mlir-c/Dialect/LLVM.h | 3 +++
 mlir/lib/CAPI/Dialect/LLVM.cpp     | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h
index ed9b23c343150c..0992285f997ea8 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -37,6 +37,9 @@ MLIR_CAPI_EXPORTED MlirType mlirLLVMVoidTypeGet(MlirContext ctx);
 MLIR_CAPI_EXPORTED MlirType mlirLLVMArrayTypeGet(MlirType elementType,
                                                  unsigned numElements);
 
+/// Returns the element type of the llvm.array type.
+MLIR_CAPI_EXPORTED MlirType mlirLLVMArrayTypeGetElementType(MlirType type);
+
 /// Creates an llvm.func type.
 MLIR_CAPI_EXPORTED MlirType
 mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index c7082445dd9c27..fd2ed5f8d44ca9 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -43,6 +43,10 @@ MlirType mlirLLVMArrayTypeGet(MlirType elementType, unsigned numElements) {
   return wrap(LLVMArrayType::get(unwrap(elementType), numElements));
 }
 
+MlirType mlirLLVMArrayTypeGetElementType(MlirType type) {
+  return wrap(cast<LLVM::LLVMArrayType>(unwrap(type)).getElementType();
+}
+
 MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
                                  MlirType const *argumentTypes, bool isVarArg) {
   SmallVector<Type, 2> argumentStorage;

>From 339ec34e3de231378cb7d3e4a0adfc1bab011490 Mon Sep 17 00:00:00 2001
From: William Moses <gh at wsmoses.com>
Date: Sun, 15 Dec 2024 09:45:44 -0600
Subject: [PATCH 2/2] Update LLVM.cpp

---
 mlir/lib/CAPI/Dialect/LLVM.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index fd2ed5f8d44ca9..6ed82ba1a0250b 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -44,7 +44,7 @@ MlirType mlirLLVMArrayTypeGet(MlirType elementType, unsigned numElements) {
 }
 
 MlirType mlirLLVMArrayTypeGetElementType(MlirType type) {
-  return wrap(cast<LLVM::LLVMArrayType>(unwrap(type)).getElementType();
+  return wrap(cast<LLVM::LLVMArrayType>(unwrap(type)).getElementType());
 }
 
 MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,



More information about the Mlir-commits mailing list