| 1253 | } |
| 1254 | |
| 1255 | LValuePtr LLVMGenerator::Visitor::BuildFunctionCall(const NativeFunction* func, |
| 1256 | DataTypePtr arrow_return_type, |
| 1257 | std::vector<llvm::Value*>* params) { |
| 1258 | auto types = generator_->types(); |
| 1259 | auto arrow_return_type_id = arrow_return_type->id(); |
| 1260 | auto llvm_return_type = types->IRType(arrow_return_type_id); |
| 1261 | DecimalIR decimalIR(generator_->engine_.get()); |
| 1262 | |
| 1263 | if (arrow_return_type_id == arrow::Type::DECIMAL) { |
| 1264 | // For decimal fns, the output precision/scale are passed along as parameters. |
| 1265 | // |
| 1266 | // convert from this : |
| 1267 | // out = add_decimal(v1, p1, s1, v2, p2, s2) |
| 1268 | // to: |
| 1269 | // out = add_decimal(v1, p1, s1, v2, p2, s2, out_p, out_s) |
| 1270 | |
| 1271 | // Append the out_precision and out_scale |
| 1272 | auto ret_lvalue = generator_->BuildDecimalLValue(nullptr, arrow_return_type); |
| 1273 | params->push_back(ret_lvalue->precision()); |
| 1274 | params->push_back(ret_lvalue->scale()); |
| 1275 | |
| 1276 | // Make the function call |
| 1277 | auto out = decimalIR.CallDecimalFunction(func->pc_name(), llvm_return_type, *params); |
| 1278 | ret_lvalue->set_data(out); |
| 1279 | return ret_lvalue; |
| 1280 | } else { |
| 1281 | bool isDecimalFunction = false; |
| 1282 | for (auto& arg : *params) { |
| 1283 | if (arg->getType() == types->i128_type()) { |
| 1284 | isDecimalFunction = true; |
| 1285 | } |
| 1286 | } |
| 1287 | // add extra arg for return length for variable len return types (allocated on stack). |
| 1288 | llvm::AllocaInst* result_len_ptr = nullptr; |
| 1289 | if (arrow::is_binary_like(arrow_return_type_id)) { |
| 1290 | result_len_ptr = new llvm::AllocaInst(generator_->types()->i32_type(), 0, |
| 1291 | "result_len", entry_block_); |
| 1292 | params->push_back(result_len_ptr); |
| 1293 | has_arena_allocs_ = true; |
| 1294 | } |
| 1295 | |
| 1296 | // Make the function call |
| 1297 | llvm::IRBuilder<>* builder = ir_builder(); |
| 1298 | auto value = |
| 1299 | isDecimalFunction |
| 1300 | ? decimalIR.CallDecimalFunction(func->pc_name(), llvm_return_type, *params) |
| 1301 | : generator_->AddFunctionCall(func->pc_name(), llvm_return_type, *params); |
| 1302 | auto value_len = |
| 1303 | (result_len_ptr == nullptr) |
| 1304 | ? nullptr |
| 1305 | : builder->CreateLoad(result_len_ptr->getAllocatedType(), result_len_ptr); |
| 1306 | return std::make_shared<LValue>(value, value_len); |
| 1307 | } |
| 1308 | } |
| 1309 | |
| 1310 | std::vector<llvm::Value*> LLVMGenerator::Visitor::BuildParams( |
| 1311 | int holder_idx, const ValueValidityPairVector& args, bool with_validity, |
nothing calls this directly
no test coverage detected