Skip to content

Commit 5119b1a

Browse files
committed
Correct f128 extend and truncate symbol names on powerpc
PowerPC uses `kf` instead of `tf`: <https://gcc.gnu.org/wiki/Ieee128PowerPC>
1 parent 5bd703d commit 5119b1a

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

src/float/extend.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ intrinsics! {
8383
}
8484
}
8585

86-
#[cfg(not(feature = "no-f16-f128"))]
8786
intrinsics! {
8887
#[avr_skip]
8988
#[aapcs_on_arm]
@@ -100,19 +99,37 @@ intrinsics! {
10099

101100
#[avr_skip]
102101
#[aapcs_on_arm]
102+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
103103
pub extern "C" fn __extendhftf2(a: f16) -> f128 {
104104
extend(a)
105105
}
106106

107+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
108+
pub extern "C" fn __extendhfkf2(a: f16) -> f128 {
109+
extend(a)
110+
}
111+
107112
#[avr_skip]
108113
#[aapcs_on_arm]
114+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
109115
pub extern "C" fn __extendsftf2(a: f32) -> f128 {
110116
extend(a)
111117
}
112118

119+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
120+
pub extern "C" fn __extendsfkf2(a: f32) -> f128 {
121+
extend(a)
122+
}
123+
113124
#[avr_skip]
114125
#[aapcs_on_arm]
126+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
115127
pub extern "C" fn __extenddftf2(a: f64) -> f128 {
116128
extend(a)
117129
}
130+
131+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
132+
pub extern "C" fn __extenddfkf2(a: f64) -> f128 {
133+
extend(a)
134+
}
118135
}

src/float/trunc.rs

+18
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,37 @@ intrinsics! {
155155

156156
#[avr_skip]
157157
#[aapcs_on_arm]
158+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
158159
pub extern "C" fn __trunctfhf2(a: f128) -> f16 {
159160
trunc(a)
160161
}
161162

163+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
164+
pub extern "C" fn __trunckfhf2(a: f128) -> f16 {
165+
trunc(a)
166+
}
167+
162168
#[avr_skip]
163169
#[aapcs_on_arm]
170+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
164171
pub extern "C" fn __trunctfsf2(a: f128) -> f32 {
165172
trunc(a)
166173
}
167174

175+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
176+
pub extern "C" fn __trunckfsf2(a: f128) -> f32 {
177+
trunc(a)
178+
}
179+
168180
#[avr_skip]
169181
#[aapcs_on_arm]
182+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
170183
pub extern "C" fn __trunctfdf2(a: f128) -> f64 {
171184
trunc(a)
172185
}
186+
187+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
188+
pub extern "C" fn __trunckfdf2(a: f128) -> f64 {
189+
trunc(a)
190+
}
173191
}

testcrate/tests/conv.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,15 @@ fn float_extend() {
187187
conv!(f32, f64, __extendsfdf2, Single, Double);
188188
#[cfg(not(feature = "no-f16-f128"))]
189189
{
190+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
190191
use compiler_builtins::float::extend::{
191-
__extenddftf2, __extendhfsf2, __extendhftf2, __extendsftf2, __gnu_h2f_ieee,
192+
__extenddfkf2 as __extenddftf2, __extendhfkf2 as __extendhftf2,
193+
__extendsfkf2 as __extendsftf2,
192194
};
195+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
196+
use compiler_builtins::float::extend::{__extenddftf2, __extendhftf2, __extendsftf2};
197+
use compiler_builtins::float::extend::{__extendhfsf2, __gnu_h2f_ieee};
198+
193199
// FIXME(f16_f128): Also do extend!() for `f16` and `f128` when builtins are in nightly
194200
conv!(f16, f32, __extendhfsf2, Half, Single);
195201
conv!(f16, f32, __gnu_h2f_ieee, Half, Single);
@@ -234,9 +240,15 @@ fn float_trunc() {
234240
conv!(f64, f32, __truncdfsf2, Double, Single);
235241
#[cfg(not(feature = "no-f16-f128"))]
236242
{
243+
use compiler_builtins::float::trunc::{__gnu_f2h_ieee, __truncdfhf2, __truncsfhf2};
244+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
237245
use compiler_builtins::float::trunc::{
238-
__gnu_f2h_ieee, __truncdfhf2, __truncsfhf2, __trunctfdf2, __trunctfhf2, __trunctfsf2,
246+
__trunckfdf2 as __trunctfdf2, __trunckfhf2 as __trunctfhf2,
247+
__trunckfsf2 as __trunctfsf2,
239248
};
249+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
250+
use compiler_builtins::float::trunc::{__trunctfdf2, __trunctfhf2, __trunctfsf2};
251+
240252
// FIXME(f16_f128): Also do trunc!() for `f16` and `f128` when builtins are in nightly
241253
conv!(f32, f16, __truncsfhf2, Single, Half);
242254
conv!(f32, f16, __gnu_f2h_ieee, Single, Half);

0 commit comments

Comments
 (0)