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

Method AddLarge

cpp/src/gandiva/decimal_ir.cc:246–267  ·  view source on GitHub ↗

This is pretty complex, so use CPP fns.

Source from the content-addressed store, hash-verified

244
245// This is pretty complex, so use CPP fns.
246llvm::Value* DecimalIR::AddLarge(const ValueFull& x, const ValueFull& y,
247 const ValueFull& out) {
248 auto block = ir_builder()->GetInsertBlock();
249 auto out_high_ptr = new llvm::AllocaInst(types()->i64_type(), 0, "out_hi", block);
250 auto out_low_ptr = new llvm::AllocaInst(types()->i64_type(), 0, "out_low", block);
251 auto x_split = ValueSplit::MakeFromInt128(this, x.value());
252 auto y_split = ValueSplit::MakeFromInt128(this, y.value());
253
254 std::vector<llvm::Value*> args = {
255 x_split.high(), x_split.low(), x.precision(), x.scale(),
256 y_split.high(), y_split.low(), y.precision(), y.scale(),
257 out.precision(), out.scale(), out_high_ptr, out_low_ptr,
258 };
259 ir_builder()->CreateCall(module()->getFunction("add_large_decimal128_decimal128"),
260 args);
261
262 auto out_high = ir_builder()->CreateLoad(types()->i64_type(), out_high_ptr);
263 auto out_low = ir_builder()->CreateLoad(types()->i64_type(), out_low_ptr);
264 auto sum = ValueSplit(out_high, out_low).AsInt128(this);
265 ADD_TRACE_128("AddLarge : sum", sum);
266 return sum;
267}
268
269/// The output scale/precision cannot be arbitrary values. The algo here depends on them
270/// to be the same as computed in DecimalTypeSql.

Callers

nothing calls this directly

Calls 10

moduleFunction · 0.85
ValueSplitClass · 0.85
highMethod · 0.80
lowMethod · 0.80
AsInt128Method · 0.80
ir_builderFunction · 0.70
typesFunction · 0.70
valueMethod · 0.45
precisionMethod · 0.45
scaleMethod · 0.45

Tested by

no test coverage detected