Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(
- repr_simd,
- simd_ffi,
- link_llvm_intrinsics,
- platform_intrinsics
- )]
- #[repr(simd)]
- #[derive(Copy, Clone, PartialEq, Debug)]
- #[allow(non_camel_case_types)]
- struct f32x2(f32, f32);
- extern "platform-intrinsic" {
- fn simd_fma<T>(a: T, b: T, c: T) -> T;
- }
- #[allow(improper_ctypes)]
- extern "C" {
- #[link_name = "llvm.cos.v2f32"]
- fn cos_v2f32(x: f32x2) -> f32x2;
- #[link_name = "llvm.sin.v2f32"]
- fn sin_v2f32(x: f32x2) -> f32x2;
- }
- fn main() {
- let a = f32x2(1.0, 1.0);
- let b = f32x2(0.0, 0.0);
- let c = f32x2(2.0, 2.0);
- unsafe {
- assert_eq!(simd_fma(a, c, b), c);
- assert_eq!(sin_v2f32(b), b);
- assert_eq!(cos_v2f32(b), a);
- }
- }
Add Comment
Please, Sign In to add comment