| 61 | } |
| 62 | |
| 63 | llvm::Function* FunctionIRBuilder::BuildFunction(const std::string& function_name, |
| 64 | llvm::Type* return_type, |
| 65 | std::vector<NamedArg> in_args) { |
| 66 | std::vector<llvm::Type*> arg_types; |
| 67 | for (auto& arg : in_args) { |
| 68 | arg_types.push_back(arg.type); |
| 69 | } |
| 70 | auto prototype = llvm::FunctionType::get(return_type, arg_types, false /*isVarArg*/); |
| 71 | auto function = llvm::Function::Create(prototype, llvm::GlobalValue::ExternalLinkage, |
| 72 | function_name, module()); |
| 73 | |
| 74 | uint32_t i = 0; |
| 75 | for (auto& fn_arg : function->args()) { |
| 76 | DCHECK_LT(i, in_args.size()); |
| 77 | fn_arg.setName(in_args[i].name); |
| 78 | ++i; |
| 79 | } |
| 80 | return function; |
| 81 | } |
| 82 | |
| 83 | } // namespace gandiva |