diff --git a/examples/intrinsics.rs b/examples/intrinsics.rs index 368da6af..ef7a3d43 100644 --- a/examples/intrinsics.rs +++ b/examples/intrinsics.rs @@ -28,21 +28,28 @@ extern "C" {} mod intrinsics { /* f16 operations */ + #[cfg(f16_enabled)] pub fn extendhfsf(x: f16) -> f32 { x as f32 } + #[cfg(f16_enabled)] pub fn extendhfdf(x: f16) -> f64 { x as f64 } - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f16_enabled, + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] pub fn extendhftf(x: f16) -> f128 { x as f128 } /* f32 operations */ + #[cfg(f16_enabled)] pub fn truncsfhf(x: f32) -> f16 { x as f16 } @@ -52,6 +59,7 @@ mod intrinsics { x as f64 } + #[cfg(f128_enabled)] pub fn extendsftf(x: f32) -> f128 { x as f128 } @@ -191,73 +199,104 @@ mod intrinsics { /* f128 operations */ - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f16_enabled, + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] pub fn trunctfhf(x: f128) -> f16 { x as f16 } + #[cfg(f128_enabled)] pub fn trunctfsf(x: f128) -> f32 { x as f32 } + #[cfg(f128_enabled)] pub fn trunctfdf(x: f128) -> f64 { x as f64 } - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] pub fn fixtfsi(x: f128) -> i32 { x as i32 } - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] pub fn fixtfdi(x: f128) -> i64 { x as i64 } - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] pub fn fixtfti(x: f128) -> i128 { x as i128 } - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] pub fn fixunstfsi(x: f128) -> u32 { x as u32 } - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] pub fn fixunstfdi(x: f128) -> u64 { x as u64 } - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] pub fn fixunstfti(x: f128) -> u128 { x as u128 } + #[cfg(f128_enabled)] pub fn addtf(a: f128, b: f128) -> f128 { a + b } + #[cfg(f128_enabled)] pub fn eqtf(a: f128, b: f128) -> bool { a == b } + #[cfg(f128_enabled)] pub fn gttf(a: f128, b: f128) -> bool { a > b } + #[cfg(f128_enabled)] pub fn lttf(a: f128, b: f128) -> bool { a < b } + #[cfg(f128_enabled)] pub fn multf(a: f128, b: f128) -> f128 { a * b } + #[cfg(f128_enabled)] pub fn divtf(a: f128, b: f128) -> f128 { a / b } + #[cfg(f128_enabled)] pub fn subtf(a: f128, b: f128) -> f128 { a - b } @@ -274,6 +313,7 @@ mod intrinsics { x as f64 } + #[cfg(f128_enabled)] pub fn floatsitf(x: i32) -> f128 { x as f128 } @@ -298,6 +338,7 @@ mod intrinsics { x as f64 } + #[cfg(f128_enabled)] pub fn floatditf(x: i64) -> f128 { x as f128 } @@ -330,6 +371,7 @@ mod intrinsics { x as f64 } + #[cfg(f128_enabled)] pub fn floattitf(x: i128) -> f128 { x as f128 } @@ -358,6 +400,7 @@ mod intrinsics { x as f64 } + #[cfg(f128_enabled)] pub fn floatunsitf(x: u32) -> f128 { x as f128 } @@ -382,6 +425,7 @@ mod intrinsics { x as f64 } + #[cfg(f128_enabled)] pub fn floatunditf(x: u64) -> f128 { x as f128 } @@ -405,6 +449,7 @@ mod intrinsics { x as f64 } + #[cfg(f128_enabled)] pub fn floatuntitf(x: u128) -> f128 { x as f128 } @@ -440,6 +485,7 @@ fn run() { // FIXME(f16_f128): some PPC f128 <-> int conversion functions have the wrong names + #[cfg(f128_enabled)] bb(addtf(bb(2.), bb(2.))); bb(aeabi_d2f(bb(2.))); bb(aeabi_d2i(bb(2.))); @@ -482,54 +528,98 @@ fn run() { bb(aeabi_uldivmod(bb(2), bb(3))); bb(ashlti3(bb(2), bb(2))); bb(ashrti3(bb(2), bb(2))); + #[cfg(f128_enabled)] bb(divtf(bb(2.), bb(2.))); bb(divti3(bb(2), bb(2))); + #[cfg(f128_enabled)] bb(eqtf(bb(2.), bb(2.))); + #[cfg(f16_enabled)] bb(extendhfdf(bb(2.))); + #[cfg(f16_enabled)] bb(extendhfsf(bb(2.))); - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f16_enabled, + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] bb(extendhftf(bb(2.))); + #[cfg(f128_enabled)] bb(extendsftf(bb(2.))); bb(fixdfti(bb(2.))); bb(fixsfti(bb(2.))); - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] bb(fixtfdi(bb(2.))); - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] bb(fixtfsi(bb(2.))); - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] bb(fixtfti(bb(2.))); bb(fixunsdfti(bb(2.))); bb(fixunssfti(bb(2.))); - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] bb(fixunstfdi(bb(2.))); - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] bb(fixunstfsi(bb(2.))); - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] bb(fixunstfti(bb(2.))); + #[cfg(f128_enabled)] bb(floatditf(bb(2))); + #[cfg(f128_enabled)] bb(floatsitf(bb(2))); bb(floattidf(bb(2))); bb(floattisf(bb(2))); + #[cfg(f128_enabled)] bb(floattitf(bb(2))); + #[cfg(f128_enabled)] bb(floatunditf(bb(2))); + #[cfg(f128_enabled)] bb(floatunsitf(bb(2))); bb(floatuntidf(bb(2))); bb(floatuntisf(bb(2))); + #[cfg(f128_enabled)] bb(floatuntitf(bb(2))); + #[cfg(f128_enabled)] bb(gttf(bb(2.), bb(2.))); bb(lshrti3(bb(2), bb(2))); + #[cfg(f128_enabled)] bb(lttf(bb(2.), bb(2.))); bb(moddi3(bb(2), bb(3))); bb(modti3(bb(2), bb(2))); bb(mulodi4(bb(2), bb(3))); bb(muloti4(bb(2), bb(2))); + #[cfg(f128_enabled)] bb(multf(bb(2.), bb(2.))); bb(multi3(bb(2), bb(2))); + #[cfg(f128_enabled)] bb(subtf(bb(2.), bb(2.))); + #[cfg(f16_enabled)] bb(truncsfhf(bb(2.))); + #[cfg(f128_enabled)] bb(trunctfdf(bb(2.))); - #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + #[cfg(all( + f16_enabled, + f128_enabled, + not(any(target_arch = "powerpc", target_arch = "powerpc64")) + ))] bb(trunctfhf(bb(2.))); + #[cfg(f128_enabled)] bb(trunctfsf(bb(2.))); bb(udivti3(bb(2), bb(2))); bb(umoddi3(bb(2), bb(3)));