Skip to content

Commit

Permalink
Add support for f128 integer exponentiation
Browse files Browse the repository at this point in the history
Adds `__powitf2`.
  • Loading branch information
tgross35 committed Aug 19, 2024
1 parent 4b74fd3 commit f74817b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ of being added to Rust.
- [ ] floatunsitf.c
- [ ] floatuntitf.c
- [x] multf3.c
- [ ] powitf2.c
- [x] powitf2.c
- [x] subtf3.c
- [x] truncdfhf2.c
- [x] truncsfhf2.c
Expand Down
1 change: 0 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ mod c {
("__floatunditf", "floatunditf.c"),
("__floatunsitf", "floatunsitf.c"),
("__divtf3", "divtf3.c"),
("__powitf2", "powitf2.c"),
("__fe_getround", "fp_mode.c"),
("__fe_raise_inexact", "fp_mode.c"),
]);
Expand Down
12 changes: 12 additions & 0 deletions src/float/pow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,16 @@ intrinsics! {
pub extern "C" fn __powidf2(a: f64, b: i32) -> f64 {
pow(a, b)
}

#[avr_skip]
#[cfg(not(any(feature = "no-f16-f128", target_arch = "powerpc", target_arch = "powerpc64")))]
pub extern "C" fn __powitf2(a: f128, b: i32) -> f128 {
pow(a, b)
}

#[avr_skip]
#[cfg(all(not(feature = "no-f16-f128"), any(target_arch = "powerpc", target_arch = "powerpc64")))]
pub extern "C" fn __powikf2(a: f128, b: i32) -> f128 {
pow(a, b)
}
}
15 changes: 15 additions & 0 deletions testcrate/tests/float_pow.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(unused_macros)]
#![cfg_attr(f128_enabled, feature(f128))]
#![cfg(not(all(target_arch = "x86", not(target_feature = "sse"))))]

use testcrate::*;
Expand Down Expand Up @@ -53,3 +54,17 @@ pow! {
f32, 1e-4, __powisf2;
f64, 1e-12, __powidf2;
}

#[cfg(f128_enabled)]
// Windows can't link the required arithmetic functions. See
// <https://github.com/rust-lang/compiler-builtins/pull/614#issuecomment-2118636613>
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
pow! {
f128, 1e-36, __powitf2;
}

#[cfg(f128_enabled)]
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
pow! {
f128, 1e-36, __powikf2;
}

0 comments on commit f74817b

Please sign in to comment.