[Mlir-commits] [mlir] 5656cbc - [MLIR][CAPI] export LLVMFunctionType param getter and setters (#121888)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Jan 6 23:39:48 PST 2025
Author: William Moses
Date: 2025-01-07T02:39:44-05:00
New Revision: 5656cbca52545e608f6fb8b7c9a778c7c9b4b468
URL: https://github.com/llvm/llvm-project/commit/5656cbca52545e608f6fb8b7c9a778c7c9b4b468
DIFF: https://github.com/llvm/llvm-project/commit/5656cbca52545e608f6fb8b7c9a778c7c9b4b468.diff
LOG: [MLIR][CAPI] export LLVMFunctionType param getter and setters (#121888)
Added:
Modified:
mlir/include/mlir-c/Dialect/LLVM.h
mlir/lib/CAPI/Dialect/LLVM.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h
index 0992285f997ea8..26c4140757c3c9 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -45,6 +45,13 @@ MLIR_CAPI_EXPORTED MlirType
mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
MlirType const *argumentTypes, bool isVarArg);
+/// Returns the number of input types.
+MLIR_CAPI_EXPORTED intptr_t mlirLLVMFunctionTypeGetNumInputs(MlirType type);
+
+/// Returns the pos-th input type.
+MLIR_CAPI_EXPORTED MlirType mlirLLVMFunctionTypeGetInput(MlirType type,
+ intptr_t pos);
+
/// Returns `true` if the type is an LLVM dialect struct type.
MLIR_CAPI_EXPORTED bool mlirTypeIsALLVMStructType(MlirType type);
diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index 6ed82ba1a0250b..da450dd3fd8a3b 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -55,6 +55,16 @@ MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
unwrapList(nArgumentTypes, argumentTypes, argumentStorage), isVarArg));
}
+intptr_t mlirLLVMFunctionTypeGetNumInputs(MlirType type) {
+ return llvm::cast<LLVM::LLVMFunctionType>(unwrap(type)).getNumParams();
+}
+
+MlirType mlirLLVMFunctionTypeGetInput(MlirType type, intptr_t pos) {
+ assert(pos >= 0 && "pos in array must be positive");
+ return wrap(llvm::cast<LLVM::LLVMFunctionType>(unwrap(type))
+ .getParamType(static_cast<unsigned>(pos)));
+}
+
bool mlirTypeIsALLVMStructType(MlirType type) {
return isa<LLVM::LLVMStructType>(unwrap(type));
}
More information about the Mlir-commits
mailing list