diff options
| author | Trevor Gross <tmgross@umich.edu> | 2024-08-19 15:46:05 -0500 |
|---|---|---|
| committer | Trevor Gross <tmgross@umich.edu> | 2024-09-24 18:32:58 +0200 |
| commit | 764a177497f9cb27d788e5734b775053187607ac (patch) | |
| tree | 51653e287b13176e134f7ac553f560a6b606078d | |
| parent | 4f8afbabdc26f140e2800056440ed14876976b80 (diff) | |
| download | rust-764a177497f9cb27d788e5734b775053187607ac.tar.gz rust-764a177497f9cb27d788e5734b775053187607ac.zip | |
Add `f128` division
Use the new generic division algorithm to expose `__divtf3` and `__divkf3`.
| -rw-r--r-- | library/compiler-builtins/README.md | 2 | ||||
| -rw-r--r-- | library/compiler-builtins/build.rs | 1 | ||||
| -rw-r--r-- | library/compiler-builtins/examples/intrinsics.rs | 5 | ||||
| -rw-r--r-- | library/compiler-builtins/src/float/div.rs | 17 | ||||
| -rw-r--r-- | library/compiler-builtins/testcrate/tests/div_rem.rs | 16 |
5 files changed, 39 insertions, 2 deletions
diff --git a/library/compiler-builtins/README.md b/library/compiler-builtins/README.md index 46983a281eb..06137f3c754 100644 --- a/library/compiler-builtins/README.md +++ b/library/compiler-builtins/README.md @@ -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 diff --git a/library/compiler-builtins/build.rs b/library/compiler-builtins/build.rs index 5ccff76e7c5..3b2805f8328 100644 --- a/library/compiler-builtins/build.rs +++ b/library/compiler-builtins/build.rs @@ -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"), diff --git a/library/compiler-builtins/examples/intrinsics.rs b/library/compiler-builtins/examples/intrinsics.rs index 8bb70767376..6dcd3820f0d 100644 --- a/library/compiler-builtins/examples/intrinsics.rs +++ b/library/compiler-builtins/examples/intrinsics.rs @@ -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.))); diff --git a/library/compiler-builtins/src/float/div.rs b/library/compiler-builtins/src/float/div.rs index 4aec3418f4b..f085455fa3e 100644 --- a/library/compiler-builtins/src/float/div.rs +++ b/library/compiler-builtins/src/float/div.rs @@ -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 + } } diff --git a/library/compiler-builtins/testcrate/tests/div_rem.rs b/library/compiler-builtins/testcrate/tests/div_rem.rs index 2de61c707d8..ac87eb6302b 100644 --- a/library/compiler-builtins/testcrate/tests/div_rem.rs +++ b/library/compiler-builtins/testcrate/tests/div_rem.rs @@ -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"); + } } |
