Add f128 division

Use the new generic division algorithm to expose `__divtf3` and
`__divkf3`.
This commit is contained in:
Trevor Gross 2024-08-19 15:46:05 -05:00
parent 4f8afbabdc
commit 764a177497
5 changed files with 39 additions and 2 deletions

View file

@ -222,7 +222,7 @@ of being added to Rust.
- [x] addtf3.c
- [x] comparetf2.c
- [ ] divtf3.c
- [x] divtf3.c
- [x] extenddftf2.c
- [x] extendhfsf2.c
- [x] extendhftf2.c

View file

@ -526,7 +526,6 @@ mod c {
("__floatsitf", "floatsitf.c"),
("__floatunditf", "floatunditf.c"),
("__floatunsitf", "floatunsitf.c"),
("__divtf3", "divtf3.c"),
("__powitf2", "powitf2.c"),
("__fe_getround", "fp_mode.c"),
("__fe_raise_inexact", "fp_mode.c"),

View file

@ -256,6 +256,10 @@ mod intrinsics {
a * b
}
pub fn divtf(a: f128, b: f128) -> f128 {
a / b
}
pub fn subtf(a: f128, b: f128) -> f128 {
a - b
}
@ -440,6 +444,7 @@ fn run() {
bb(aeabi_uldivmod(bb(2), bb(3)));
bb(ashlti3(bb(2), bb(2)));
bb(ashrti3(bb(2), bb(2)));
bb(divtf(bb(2.), bb(2.)));
bb(divti3(bb(2), bb(2)));
bb(eqtf(bb(2.), bb(2.)));
bb(extendhfdf(bb(2.)));

View file

@ -617,4 +617,21 @@ intrinsics! {
pub extern "C" fn __divdf3(a: f64, b: f64) -> f64 {
div(a, b)
}
#[avr_skip]
#[ppc_alias = __divkf3]
#[cfg(not(feature = "no-f16-f128"))]
pub extern "C" fn __divtf3(a: f128, b: f128) -> f128 {
div(a, b)
}
#[cfg(target_arch = "arm")]
pub extern "C" fn __divsf3vfp(a: f32, b: f32) -> f32 {
a / b
}
#[cfg(target_arch = "arm")]
pub extern "C" fn __divdf3vfp(a: f64, b: f64) -> f64 {
a / b
}
}

View file

@ -1,3 +1,4 @@
#![feature(f128)]
#![allow(unused_macros)]
use compiler_builtins::int::sdiv::{__divmoddi4, __divmodsi4, __divmodti4};
@ -146,4 +147,19 @@ mod float_div {
f32, __divsf3, Single, all();
f64, __divdf3, Double, all();
}
#[cfg(not(feature = "no-f16-f128"))]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
float! {
f128, __divtf3, Quad,
// FIXME(llvm): there is a bug in LLVM rt.
// See <https://github.com/llvm/llvm-project/issues/91840>.
not(any(feature = "no-sys-f128", all(target_arch = "aarch64", target_os = "linux")));
}
#[cfg(not(feature = "no-f16-f128"))]
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
float! {
f128, __divkf3, Quad, not(feature = "no-sys-f128");
}
}