Skip to content

Commit

Permalink
Correct f128 extend and truncate symbol names on powerpc
Browse files Browse the repository at this point in the history
PowerPC uses `kf` instead of `tf`:
<https://gcc.gnu.org/wiki/Ieee128PowerPC>
  • Loading branch information
tgross35 committed May 12, 2024
1 parent 5bd703d commit 5119b1a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
19 changes: 18 additions & 1 deletion src/float/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ intrinsics! {
}
}

#[cfg(not(feature = "no-f16-f128"))]
intrinsics! {
#[avr_skip]
#[aapcs_on_arm]
Expand All @@ -100,19 +99,37 @@ intrinsics! {

#[avr_skip]
#[aapcs_on_arm]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
pub extern "C" fn __extendhftf2(a: f16) -> f128 {
extend(a)
}

#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
pub extern "C" fn __extendhfkf2(a: f16) -> f128 {
extend(a)
}

#[avr_skip]
#[aapcs_on_arm]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
pub extern "C" fn __extendsftf2(a: f32) -> f128 {
extend(a)
}

#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
pub extern "C" fn __extendsfkf2(a: f32) -> f128 {
extend(a)
}

#[avr_skip]
#[aapcs_on_arm]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
pub extern "C" fn __extenddftf2(a: f64) -> f128 {
extend(a)
}

#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
pub extern "C" fn __extenddfkf2(a: f64) -> f128 {
extend(a)
}
}
18 changes: 18 additions & 0 deletions src/float/trunc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,37 @@ intrinsics! {

#[avr_skip]
#[aapcs_on_arm]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
pub extern "C" fn __trunctfhf2(a: f128) -> f16 {
trunc(a)
}

#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
pub extern "C" fn __trunckfhf2(a: f128) -> f16 {
trunc(a)
}

#[avr_skip]
#[aapcs_on_arm]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
pub extern "C" fn __trunctfsf2(a: f128) -> f32 {
trunc(a)
}

#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
pub extern "C" fn __trunckfsf2(a: f128) -> f32 {
trunc(a)
}

#[avr_skip]
#[aapcs_on_arm]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
pub extern "C" fn __trunctfdf2(a: f128) -> f64 {
trunc(a)
}

#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
pub extern "C" fn __trunckfdf2(a: f128) -> f64 {
trunc(a)
}
}
16 changes: 14 additions & 2 deletions testcrate/tests/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,15 @@ fn float_extend() {
conv!(f32, f64, __extendsfdf2, Single, Double);
#[cfg(not(feature = "no-f16-f128"))]
{
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
use compiler_builtins::float::extend::{
__extenddftf2, __extendhfsf2, __extendhftf2, __extendsftf2, __gnu_h2f_ieee,
__extenddfkf2 as __extenddftf2, __extendhfkf2 as __extendhftf2,
__extendsfkf2 as __extendsftf2,
};
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
use compiler_builtins::float::extend::{__extenddftf2, __extendhftf2, __extendsftf2};
use compiler_builtins::float::extend::{__extendhfsf2, __gnu_h2f_ieee};

// FIXME(f16_f128): Also do extend!() for `f16` and `f128` when builtins are in nightly
conv!(f16, f32, __extendhfsf2, Half, Single);
conv!(f16, f32, __gnu_h2f_ieee, Half, Single);
Expand Down Expand Up @@ -234,9 +240,15 @@ fn float_trunc() {
conv!(f64, f32, __truncdfsf2, Double, Single);
#[cfg(not(feature = "no-f16-f128"))]
{
use compiler_builtins::float::trunc::{__gnu_f2h_ieee, __truncdfhf2, __truncsfhf2};
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
use compiler_builtins::float::trunc::{
__gnu_f2h_ieee, __truncdfhf2, __truncsfhf2, __trunctfdf2, __trunctfhf2, __trunctfsf2,
__trunckfdf2 as __trunctfdf2, __trunckfhf2 as __trunctfhf2,
__trunckfsf2 as __trunctfsf2,
};
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
use compiler_builtins::float::trunc::{__trunctfdf2, __trunctfhf2, __trunctfsf2};

// FIXME(f16_f128): Also do trunc!() for `f16` and `f128` when builtins are in nightly
conv!(f32, f16, __truncsfhf2, Single, Half);
conv!(f32, f16, __gnu_f2h_ieee, Single, Half);
Expand Down

0 comments on commit 5119b1a

Please sign in to comment.