diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h index ed9b23c343150..0992285f997ea 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 c7082445dd9c2..6ed82ba1a0250 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(unwrap(type)).getElementType()); +} + MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes, MlirType const *argumentTypes, bool isVarArg) { SmallVector argumentStorage;