Skip to content

Commit 5039355

Browse files
committed
Add support for f128 integer exponentiation
Create the symbol `__powitf2`.
1 parent 759b027 commit 5039355

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ of being added to Rust.
240240
- [ ] floatunsitf.c
241241
- [ ] floatuntitf.c
242242
- [x] multf3.c
243-
- [ ] powitf2.c
243+
- [x] powitf2.c
244244
- [x] subtf3.c
245245
- [x] truncdfhf2.c
246246
- [x] truncsfhf2.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-
("__powitf2", "powitf2.c"),
530529
("__fe_getround", "fp_mode.c"),
531530
("__fe_raise_inexact", "fp_mode.c"),
532531
]);

src/float/pow.rs

+9
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,13 @@ intrinsics! {
3535
pub extern "C" fn __powidf2(a: f64, b: i32) -> f64 {
3636
pow(a, b)
3737
}
38+
39+
#[avr_skip]
40+
#[ppc_alias = __powikf2]
41+
#[cfg(f128_enabled)]
42+
// FIXME(f16_f128): MSVC cannot build these until `__divtf3` is available in nightly.
43+
#[cfg(not(target_env = "msvc"))]
44+
pub extern "C" fn __powitf2(a: f128, b: i32) -> f128 {
45+
pow(a, b)
46+
}
3847
}

testcrate/tests/float_pow.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![allow(unused_macros)]
2+
#![cfg_attr(f128_enabled, feature(f128))]
23
#![cfg(not(all(target_arch = "x86", not(target_feature = "sse"))))]
34

45
use testcrate::*;
@@ -7,9 +8,12 @@ use testcrate::*;
78
// https://github.com/rust-lang/rust/issues/73920.
89
// TODO how do we resolve this indeterminacy?
910
macro_rules! pow {
10-
($($f:ty, $tolerance:expr, $fn:ident);*;) => {
11+
($($f:ty, $tolerance:expr, $fn:ident, $sys_available:meta);*;) => {
1112
$(
1213
#[test]
14+
// FIXME(apfloat): We skip tests if system symbols aren't available rather
15+
// than providing a fallback, since `rustc_apfloat` does not provide `pow`.
16+
#[cfg($sys_available)]
1317
fn $fn() {
1418
use compiler_builtins::float::pow::$fn;
1519
use compiler_builtins::float::Float;
@@ -49,6 +53,20 @@ macro_rules! pow {
4953
}
5054

5155
pow! {
52-
f32, 1e-4, __powisf2;
53-
f64, 1e-12, __powidf2;
56+
f32, 1e-4, __powisf2, all();
57+
f64, 1e-12, __powidf2, all();
58+
}
59+
60+
#[cfg(f128_enabled)]
61+
// FIXME(f16_f128): MSVC cannot build these until `__divtf3` is available in nightly.
62+
#[cfg(not(target_env = "msvc"))]
63+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
64+
pow! {
65+
f128, 1e-36, __powitf2, not(feature = "no-sys-f128");
66+
}
67+
68+
#[cfg(f128_enabled)]
69+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
70+
pow! {
71+
f128, 1e-36, __powikf2, not(feature = "no-sys-f128");
5472
}

0 commit comments

Comments
 (0)