Skip to content

Commit f74817b

Browse files
committed
Add support for f128 integer exponentiation
Adds `__powitf2`.
1 parent 4b74fd3 commit f74817b

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ of being added to Rust.
274274
- [ ] floatunsitf.c
275275
- [ ] floatuntitf.c
276276
- [x] multf3.c
277-
- [ ] powitf2.c
277+
- [x] powitf2.c
278278
- [x] subtf3.c
279279
- [x] truncdfhf2.c
280280
- [x] truncsfhf2.c

build.rs

-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ mod c {
527527
("__floatunditf", "floatunditf.c"),
528528
("__floatunsitf", "floatunsitf.c"),
529529
("__divtf3", "divtf3.c"),
530-
("__powitf2", "powitf2.c"),
531530
("__fe_getround", "fp_mode.c"),
532531
("__fe_raise_inexact", "fp_mode.c"),
533532
]);

src/float/pow.rs

+12
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,16 @@ intrinsics! {
3535
pub extern "C" fn __powidf2(a: f64, b: i32) -> f64 {
3636
pow(a, b)
3737
}
38+
39+
#[avr_skip]
40+
#[cfg(not(any(feature = "no-f16-f128", target_arch = "powerpc", target_arch = "powerpc64")))]
41+
pub extern "C" fn __powitf2(a: f128, b: i32) -> f128 {
42+
pow(a, b)
43+
}
44+
45+
#[avr_skip]
46+
#[cfg(all(not(feature = "no-f16-f128"), any(target_arch = "powerpc", target_arch = "powerpc64")))]
47+
pub extern "C" fn __powikf2(a: f128, b: i32) -> f128 {
48+
pow(a, b)
49+
}
3850
}

testcrate/tests/float_pow.rs

+15
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::*;
@@ -53,3 +54,17 @@ pow! {
5354
f32, 1e-4, __powisf2;
5455
f64, 1e-12, __powidf2;
5556
}
57+
58+
#[cfg(f128_enabled)]
59+
// Windows can't link the required arithmetic functions. See
60+
// <https://github.com/rust-lang/compiler-builtins/pull/614#issuecomment-2118636613>
61+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
62+
pow! {
63+
f128, 1e-36, __powitf2;
64+
}
65+
66+
#[cfg(f128_enabled)]
67+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
68+
pow! {
69+
f128, 1e-36, __powikf2;
70+
}

0 commit comments

Comments
 (0)