Skip to content

Commit 4b1c851

Browse files
committed
Enable conditional compilation for intrinsics with f16_enabled
1 parent d4a3955 commit 4b1c851

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

examples/intrinsics.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,27 @@ extern "C" {}
2828
mod intrinsics {
2929
/* f16 operations */
3030

31+
#[cfg(f16_enabled)]
3132
pub fn extendhfsf(x: f16) -> f32 {
3233
x as f32
3334
}
3435

36+
#[cfg(f16_enabled)]
3537
pub fn extendhfdf(x: f16) -> f64 {
3638
x as f64
3739
}
3840

39-
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
41+
#[cfg(all(
42+
f16_enabled,
43+
not(any(target_arch = "powerpc", target_arch = "powerpc64"))
44+
))]
4045
pub fn extendhftf(x: f16) -> f128 {
4146
x as f128
4247
}
4348

4449
/* f32 operations */
4550

51+
#[cfg(f16_enabled)]
4652
pub fn truncsfhf(x: f32) -> f16 {
4753
x as f16
4854
}
@@ -191,7 +197,10 @@ mod intrinsics {
191197

192198
/* f128 operations */
193199

194-
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
200+
#[cfg(all(
201+
f16_enabled,
202+
not(any(target_arch = "powerpc", target_arch = "powerpc64"))
203+
))]
195204
pub fn trunctfhf(x: f128) -> f16 {
196205
x as f16
197206
}
@@ -485,9 +494,14 @@ fn run() {
485494
bb(divtf(bb(2.), bb(2.)));
486495
bb(divti3(bb(2), bb(2)));
487496
bb(eqtf(bb(2.), bb(2.)));
497+
#[cfg(f16_enabled)]
488498
bb(extendhfdf(bb(2.)));
499+
#[cfg(f16_enabled)]
489500
bb(extendhfsf(bb(2.)));
490-
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
501+
#[cfg(all(
502+
f16_enabled,
503+
not(any(target_arch = "powerpc", target_arch = "powerpc64"))
504+
))]
491505
bb(extendhftf(bb(2.)));
492506
bb(extendsftf(bb(2.)));
493507
bb(fixdfti(bb(2.)));
@@ -526,9 +540,13 @@ fn run() {
526540
bb(multf(bb(2.), bb(2.)));
527541
bb(multi3(bb(2), bb(2)));
528542
bb(subtf(bb(2.), bb(2.)));
543+
#[cfg(f16_enabled)]
529544
bb(truncsfhf(bb(2.)));
530545
bb(trunctfdf(bb(2.)));
531-
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
546+
#[cfg(all(
547+
f16_enabled,
548+
not(any(target_arch = "powerpc", target_arch = "powerpc64"))
549+
))]
532550
bb(trunctfhf(bb(2.)));
533551
bb(trunctfsf(bb(2.)));
534552
bb(udivti3(bb(2), bb(2)));

0 commit comments

Comments
 (0)