diff --git a/example/std_example.rs b/example/std_example.rs index 8e6ab2d712c..079b4299049 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -1,5 +1,6 @@ #![feature(core_intrinsics, generators, generator_trait, is_sorted)] +#[cfg(target_arch = "x86_64")] use std::arch::x86_64::*; use std::io::Write; use std::ops::Generator; @@ -96,6 +97,7 @@ fn main() { println!("{:?}", std::intrinsics::caller_location()); + #[cfg(target_arch = "x86_64")] unsafe { test_simd(); } @@ -124,6 +126,7 @@ fn panic(_: u128) { panic!(); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_simd() { assert!(is_x86_feature_detected!("sse2")); @@ -153,6 +156,7 @@ unsafe fn test_simd() { assert_eq!(mask1, 1); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_slli_si128() { #[rustfmt::skip] @@ -193,6 +197,7 @@ unsafe fn test_mm_slli_si128() { assert_eq_m128i(r, _mm_set1_epi8(0)); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_movemask_epi8() { #[rustfmt::skip] @@ -206,6 +211,7 @@ unsafe fn test_mm_movemask_epi8() { assert_eq!(r, 0b10100100_00100101); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "avx2")] unsafe fn test_mm256_movemask_epi8() { let a = _mm256_set1_epi8(-1); @@ -214,6 +220,7 @@ unsafe fn test_mm256_movemask_epi8() { assert_eq!(r, e); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_add_epi8() { let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -229,6 +236,7 @@ unsafe fn test_mm_add_epi8() { assert_eq_m128i(r, e); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_add_pd() { let a = _mm_setr_pd(1.0, 2.0); @@ -237,12 +245,14 @@ unsafe fn test_mm_add_pd() { assert_eq_m128d(r, _mm_setr_pd(6.0, 12.0)); } +#[cfg(target_arch = "x86_64")] fn assert_eq_m128i(x: std::arch::x86_64::__m128i, y: std::arch::x86_64::__m128i) { unsafe { assert_eq!(std::mem::transmute::<_, [u8; 16]>(x), std::mem::transmute::<_, [u8; 16]>(y)); } } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] pub unsafe fn assert_eq_m128d(a: __m128d, b: __m128d) { if _mm_movemask_pd(_mm_cmpeq_pd(a, b)) != 0b11 { @@ -250,12 +260,14 @@ pub unsafe fn assert_eq_m128d(a: __m128d, b: __m128d) { } } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_cvtsi128_si64() { let r = _mm_cvtsi128_si64(std::mem::transmute::<[i64; 2], _>([5, 0])); assert_eq!(r, 5); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse4.1")] unsafe fn test_mm_cvtepi8_epi16() { let a = _mm_set1_epi8(10); @@ -268,6 +280,7 @@ unsafe fn test_mm_cvtepi8_epi16() { assert_eq_m128i(r, e); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse4.1")] unsafe fn test_mm_extract_epi8() { #[rustfmt::skip] @@ -281,6 +294,7 @@ unsafe fn test_mm_extract_epi8() { assert_eq!(r2, 3); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_insert_epi16() { let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);