Skip to content

Commit 910e92f

Browse files
committed
Add f128 division
Use the new generic division algorithm to expose `__divtf3` and `__divkf3`.
1 parent 8990af8 commit 910e92f

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ of being added to Rust.
222222

223223
- [x] addtf3.c
224224
- [x] comparetf2.c
225-
- [ ] divtf3.c
225+
- [x] divtf3.c
226226
- [x] extenddftf2.c
227227
- [x] extendhfsf2.c
228228
- [x] extendhftf2.c

build.rs

-1
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"),

examples/intrinsics.rs

+5
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ mod intrinsics {
256256
a * b
257257
}
258258

259+
pub fn divtf(a: f128, b: f128) -> f128 {
260+
a / b
261+
}
262+
259263
pub fn subtf(a: f128, b: f128) -> f128 {
260264
a - b
261265
}
@@ -440,6 +444,7 @@ fn run() {
440444
bb(aeabi_uldivmod(bb(2), bb(3)));
441445
bb(ashlti3(bb(2), bb(2)));
442446
bb(ashrti3(bb(2), bb(2)));
447+
bb(divtf(bb(2.), bb(2.)));
443448
bb(divti3(bb(2), bb(2)));
444449
bb(eqtf(bb(2.), bb(2.)));
445450
bb(extendhfdf(bb(2.)));

src/float/div.rs

+17
Original file line numberDiff line numberDiff line change
@@ -617,4 +617,21 @@ intrinsics! {
617617
pub extern "C" fn __divdf3(a: f64, b: f64) -> f64 {
618618
div(a, b)
619619
}
620+
621+
#[avr_skip]
622+
#[ppc_alias = __divkf3]
623+
#[cfg(not(feature = "no-f16-f128"))]
624+
pub extern "C" fn __divtf3(a: f128, b: f128) -> f128 {
625+
div(a, b)
626+
}
627+
628+
#[cfg(target_arch = "arm")]
629+
pub extern "C" fn __divsf3vfp(a: f32, b: f32) -> f32 {
630+
a / b
631+
}
632+
633+
#[cfg(target_arch = "arm")]
634+
pub extern "C" fn __divdf3vfp(a: f64, b: f64) -> f64 {
635+
a / b
636+
}
620637
}

testcrate/tests/div_rem.rs

+16
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};
@@ -146,4 +147,19 @@ mod float_div {
146147
f32, __divsf3, Single, all();
147148
f64, __divdf3, Double, all();
148149
}
150+
151+
#[cfg(not(feature = "no-f16-f128"))]
152+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
153+
float! {
154+
f128, __divtf3, Quad,
155+
// FIXME(llvm): there is a bug in LLVM rt.
156+
// See <https://github.com/llvm/llvm-project/issues/91840>.
157+
not(any(feature = "no-sys-f128", all(target_arch = "aarch64", target_os = "linux")));
158+
}
159+
160+
#[cfg(not(feature = "no-f16-f128"))]
161+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
162+
float! {
163+
f128, __divkf3, Quad, not(feature = "no-sys-f128");
164+
}
149165
}

0 commit comments

Comments
 (0)