This is pretty complex, so use CPP fns.
| 244 | |
| 245 | // This is pretty complex, so use CPP fns. |
| 246 | llvm::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. |
nothing calls this directly
no test coverage detected