MCPcopy Create free account
hub / github.com/apache/arrow / BuildCompare

Method BuildCompare

cpp/src/gandiva/decimal_ir.cc:383–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381}
382
383Status DecimalIR::BuildCompare(const std::string& function_name,
384 llvm::ICmpInst::Predicate cmp_instruction) {
385 // Create fn prototype :
386 // bool
387 // function_name(int128_t x_value, int32_t x_precision, int32_t x_scale,
388 // int128_t y_value, int32_t y_precision, int32_t y_scale)
389
390 auto i32 = types()->i32_type();
391 auto i128 = types()->i128_type();
392 auto function = BuildFunction(function_name, types()->i1_type(),
393 {
394 {"x_value", i128},
395 {"x_precision", i32},
396 {"x_scale", i32},
397 {"y_value", i128},
398 {"y_precision", i32},
399 {"y_scale", i32},
400 });
401
402 auto arg_iter = function->arg_begin();
403 ValueFull x(&arg_iter[0], &arg_iter[1], &arg_iter[2]);
404 ValueFull y(&arg_iter[3], &arg_iter[4], &arg_iter[5]);
405
406 auto entry = llvm::BasicBlock::Create(*context(), "entry", function);
407 ir_builder()->SetInsertPoint(entry);
408
409 // Make call to pre-compiled IR function.
410 auto x_split = ValueSplit::MakeFromInt128(this, x.value());
411 auto y_split = ValueSplit::MakeFromInt128(this, y.value());
412
413 std::vector<llvm::Value*> args = {
414 x_split.high(), x_split.low(), x.precision(), x.scale(),
415 y_split.high(), y_split.low(), y.precision(), y.scale(),
416 };
417 auto cmp_value = ir_builder()->CreateCall(
418 module()->getFunction("compare_decimal128_decimal128_internal"), args);
419 auto result =
420 ir_builder()->CreateICmp(cmp_instruction, cmp_value, types()->i32_constant(0));
421 ir_builder()->CreateRet(result);
422 return Status::OK();
423}
424
425llvm::Value* DecimalIR::CallDecimalFunction(const std::string& function_name,
426 llvm::Type* return_type,

Callers 1

AddFunctionsMethod · 0.80

Calls 10

moduleFunction · 0.85
highMethod · 0.80
lowMethod · 0.80
typesFunction · 0.70
contextFunction · 0.70
ir_builderFunction · 0.70
OKFunction · 0.50
valueMethod · 0.45
precisionMethod · 0.45
scaleMethod · 0.45

Tested by

no test coverage detected