Skip to content

Commit 1cd1f00

Browse files
committed
Add f128 division
Use the new generic division algorithm to expose `__divtf3` and `__divkf3`.
1 parent a5ce398 commit 1cd1f00

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ of being added to Rust.
256256

257257
- [x] addtf3.c
258258
- [x] comparetf2.c
259-
- [ ] divtf3.c
259+
- [x] divtf3.c
260260
- [x] extenddftf2.c
261261
- [x] extendhfsf2.c
262262
- [x] extendhftf2.c

build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ mod c {
526526
("__floatsitf", "floatsitf.c"),
527527
("__floatunditf", "floatunditf.c"),
528528
("__floatunsitf", "floatunsitf.c"),
529-
("__divtf3", "divtf3.c"),
530529
("__powitf2", "powitf2.c"),
531530
("__fe_getround", "fp_mode.c"),
532531
("__fe_raise_inexact", "fp_mode.c"),

src/float/div.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,13 @@ intrinsics! {
612612
div(a, b)
613613
}
614614

615+
#[avr_skip]
616+
#[ppc_alias = __divkf3]
617+
#[cfg(not(feature = "no-f16-f128"))]
618+
pub extern "C" fn __divtf3(a: f128, b: f128) -> f128 {
619+
div(a, b)
620+
}
621+
615622
#[cfg(target_arch = "arm")]
616623
pub extern "C" fn __divsf3vfp(a: f32, b: f32) -> f32 {
617624
a / b

testcrate/tests/div_rem.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(f128)]
12
#![allow(unused_macros)]
23

34
use compiler_builtins::int::sdiv::{__divmoddi4, __divmodsi4, __divmodti4};
@@ -152,4 +153,19 @@ mod float_div {
152153
f32, __divsf3vfp, Single, all();
153154
f64, __divdf3vfp, Double, all();
154155
}
156+
157+
#[cfg(not(feature = "no-f16-f128"))]
158+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
159+
float! {
160+
f128, __divtf3, Quad,
161+
// FIXME(llvm): there is a bug in LLVM rt.
162+
// See <https://github.com/llvm/llvm-project/issues/91840>.
163+
not(any(feature = "no-sys-f128", all(target_arch = "aarch64", target_os = "linux")));
164+
}
165+
166+
#[cfg(not(feature = "no-f16-f128"))]
167+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
168+
float! {
169+
f128, __divkf3, Quad, not(feature = "no-sys-f128");
170+
}
155171
}

0 commit comments

Comments
 (0)