Thread through the divCeil implementation from Zig:

+ OPEN QUESTION: Evidently the Zig implementation can throw an overflow error. Do we want to do something in Roc to fix this?
This commit is contained in:
Chelsea Troy 2021-10-17 10:46:16 -05:00
parent 4b65430bef
commit 0cc6e44d35
No known key found for this signature in database
GPG key ID: A631885A970636C2
7 changed files with 79 additions and 3 deletions

View file

@ -5327,7 +5327,7 @@ fn run_low_level<'a, 'ctx, 'env>(
}
NumAdd | NumSub | NumMul | NumLt | NumLte | NumGt | NumGte | NumRemUnchecked
| NumIsMultipleOf | NumAddWrap | NumAddChecked | NumDivUnchecked | NumPow | NumPowInt
| NumIsMultipleOf | NumAddWrap | NumAddChecked | NumDivUnchecked | NumDivCeilUnchecked | NumPow | NumPowInt
| NumSubWrap | NumSubChecked | NumMulWrap | NumMulChecked => {
debug_assert_eq!(args.len(), 2);
@ -6073,6 +6073,7 @@ fn build_int_binop<'a, 'ctx, 'env>(
}
NumDivUnchecked => bd.build_int_signed_div(lhs, rhs, "div_int").into(),
NumPowInt => call_bitcode_fn(env, &[lhs.into(), rhs.into()], bitcode::NUM_POW_INT),
NumDivCeilUnchecked => call_bitcode_fn(env, &[lhs.into(), rhs.into()], bitcode::NUM_DIV_CEIL),
NumBitwiseAnd => bd.build_and(lhs, rhs, "int_bitwise_and").into(),
NumBitwiseXor => bd.build_xor(lhs, rhs, "int_bitwise_xor").into(),
NumBitwiseOr => bd.build_or(lhs, rhs, "int_bitwise_or").into(),