Add __divmodti4
This commit is contained in:
parent
ffb386369b
commit
92f0680743
3 changed files with 22 additions and 8 deletions
|
|
@ -54,5 +54,12 @@ intrinsics! {
|
|||
i128_div_rem(a, b).1
|
||||
}
|
||||
|
||||
// LLVM does not currently have a `__divmodti4` function
|
||||
// LLVM does not currently have a `__divmodti4` function, but GCC does
|
||||
#[maybe_use_optimized_c_shim]
|
||||
/// Returns `n / d` and sets `*rem = n % d`
|
||||
pub extern "C" fn __divmodti4(a: i128, b: i128, rem: &mut i128) -> i128 {
|
||||
let quo_rem = i128_div_rem(a, b);
|
||||
*rem = quo_rem.1;
|
||||
quo_rem.0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -805,6 +805,19 @@ fn main() {
|
|||
(builtins::int::sdiv::__divmodsi4(a, b, &mut r), r)
|
||||
}",
|
||||
);
|
||||
gen(
|
||||
|(a, b): (MyI128, MyI128)| {
|
||||
if b.0 == 0 {
|
||||
None
|
||||
} else {
|
||||
Some((a.0 / b.0, a.0 % b.0))
|
||||
}
|
||||
},
|
||||
"{
|
||||
let mut r = 0;
|
||||
(builtins::int::sdiv::__divmodti4(a, b, &mut r), r)
|
||||
}",
|
||||
);
|
||||
gen(
|
||||
|(a, b): (MyI32, MyI32)| {
|
||||
if b.0 == 0 {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,9 @@
|
|||
use rand_xoshiro::rand_core::{RngCore, SeedableRng};
|
||||
use rand_xoshiro::Xoshiro128StarStar;
|
||||
|
||||
use compiler_builtins::int::sdiv::{__divmoddi4, __divmodsi4, __divti3, __modti3};
|
||||
use compiler_builtins::int::sdiv::{__divmoddi4, __divmodsi4, __divmodti4};
|
||||
use compiler_builtins::int::udiv::{__udivmoddi4, __udivmodsi4, __udivmodti4};
|
||||
|
||||
// because `__divmodti4` does not exist, we synthesize it
|
||||
fn __divmodti4(a: i128, b: i128, rem: &mut i128) -> i128 {
|
||||
*rem = __modti3(a, b);
|
||||
__divti3(a, b)
|
||||
}
|
||||
|
||||
/// Creates intensive test functions for division functions of a certain size
|
||||
macro_rules! test {
|
||||
(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue