daily pastebin goal
84%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![feature(
  2.     repr_simd,
  3.     simd_ffi,
  4.     link_llvm_intrinsics,
  5.     platform_intrinsics
  6. )]
  7.  
  8. #[repr(simd)]
  9. #[derive(Copy, Clone, PartialEq, Debug)]
  10. #[allow(non_camel_case_types)]
  11. struct f32x2(f32, f32);
  12.  
  13. extern "platform-intrinsic" {
  14.     fn simd_fma<T>(a: T, b: T, c: T) -> T;
  15. }
  16.  
  17. #[allow(improper_ctypes)]
  18. extern "C" {
  19.     #[link_name = "llvm.cos.v2f32"]
  20.     fn cos_v2f32(x: f32x2) -> f32x2;
  21.     #[link_name = "llvm.sin.v2f32"]
  22.     fn sin_v2f32(x: f32x2) -> f32x2;
  23. }
  24.  
  25. fn main() {
  26.     let a = f32x2(1.0, 1.0);
  27.     let b = f32x2(0.0, 0.0);
  28.     let c = f32x2(2.0, 2.0);
  29.  
  30.     unsafe {
  31.         assert_eq!(simd_fma(a, c, b), c);
  32.         assert_eq!(sin_v2f32(b), b);
  33.         assert_eq!(cos_v2f32(b), a);
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top