[Mlir-commits] [mlir] fd85a64 - [mlir][llvm] Add isVarArg flag to lookupOrCreateFn.

Ingo Müller llvmlistbot at llvm.org
Tue Feb 21 00:34:06 PST 2023


Author: Ingo Müller
Date: 2023-02-21T08:34:00Z
New Revision: fd85a64ffbc06a9ec438d79deac1e06c91231362

URL: https://github.com/llvm/llvm-project/commit/fd85a64ffbc06a9ec438d79deac1e06c91231362
DIFF: https://github.com/llvm/llvm-project/commit/fd85a64ffbc06a9ec438d79deac1e06c91231362.diff

LOG: [mlir][llvm] Add isVarArg flag to lookupOrCreateFn.

The function is a helper for looking up a function by name or creating
it if it doesn't exist. The arguments allow to specify the signature of
the function, if it needs to be created, but do not expose the varArg
parameter of LLVMFunctionType. This patch exposes adds an optional
parameter with a default value of false such that existing usage
continue to work as before.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D144256

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h
    mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h b/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h
index 76838ddf7a634..39b35fedcac68 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h
@@ -60,7 +60,7 @@ LLVM::LLVMFuncOp lookupOrCreateMemRefCopyFn(ModuleOp moduleOp, Type indexType,
 /// Create a FuncOp with signature `resultType`(`paramTypes`)` and name `name`.
 LLVM::LLVMFuncOp lookupOrCreateFn(ModuleOp moduleOp, StringRef name,
                                   ArrayRef<Type> paramTypes = {},
-                                  Type resultType = {});
+                                  Type resultType = {}, bool isVarArg = false);
 
 } // namespace LLVM
 } // namespace mlir

diff  --git a/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp b/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp
index b38f849c186a6..237e576a1d9ef 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp
@@ -45,14 +45,14 @@ static constexpr llvm::StringRef kMemRefCopy = "memrefCopy";
 /// Generic print function lookupOrCreate helper.
 LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFn(ModuleOp moduleOp, StringRef name,
                                               ArrayRef<Type> paramTypes,
-                                              Type resultType) {
+                                              Type resultType, bool isVarArg) {
   auto func = moduleOp.lookupSymbol<LLVM::LLVMFuncOp>(name);
   if (func)
     return func;
   OpBuilder b(moduleOp.getBodyRegion());
   return b.create<LLVM::LLVMFuncOp>(
       moduleOp->getLoc(), name,
-      LLVM::LLVMFunctionType::get(resultType, paramTypes));
+      LLVM::LLVMFunctionType::get(resultType, paramTypes, isVarArg));
 }
 
 LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintI64Fn(ModuleOp moduleOp) {


        


More information about the Mlir-commits mailing list