| 2cd40ea1 Andy McCall ↶ |
1 |
|
| 2 |
|
| 3 |
#![cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))] |
| 4 |
|
| 5 |
|
| 6 |
#[cfg(all(feature = "std", target_arch = "aarch64"))] |
| 7 |
use core::arch::aarch64::*; |
| 8 |
|
| 9 |
#[cfg(all(feature = "std", target_arch = "x86"))] |
| 10 |
use core::arch::x86::*; |
| 11 |
|
| 12 |
#[cfg(all(feature = "std", target_arch = "x86_64"))] |
| 13 |
use core::arch::x86_64::*; |
| 14 |
|
| 15 |
|
| 16 |
#[cfg(feature = "std")] |
| 17 |
use crate::traits::ArchOps; |
| 18 |
|
| 19 |
#[cfg(all(feature = "std", target_arch = "aarch64"))] |
| 20 |
#[allow(dead_code)] |
| 21 |
#[target_feature(enable = "aes")] |
| 22 |
pub(crate) unsafe fn print_xmm_hex(prefix: &str, xmm: uint8x16_t) { |
| 23 |
let mut temp = [0u64; 2]; |
| 24 |
vst1q_u64(temp.as_mut_ptr(), vreinterpretq_u64_u8(xmm)); |
| 25 |
println!("{}={:#016x}{:016x}", prefix, temp[1], temp[0]); |
| 26 |
} |
| 27 |
|
| 28 |
#[cfg(all(feature = "std", any(target_arch = "x86", target_arch = "x86_64")))] |
| 29 |
#[allow(dead_code)] |
| 30 |
#[target_feature(enable = "sse4.1")] |
| 31 |
pub(crate) unsafe fn print_xmm_hex(prefix: &str, xmm: __m128i) { |
| 32 |
let mut temp = [0u64; 2]; |
| 33 |
_mm_storeu_si128(temp.as_mut_ptr() as *mut __m128i, xmm); |
| 34 |
println!("{}={:#016x}{:016x}", prefix, temp[1], temp[0]); |
| 35 |
} |
| 36 |
|
| 37 |
#[cfg(feature = "std")] |
| 38 |
#[allow(dead_code)] |
| 39 |
pub(crate) unsafe fn print_vector_hex<T: ArchOps>(prefix: &str, vector: T::Vector, ops: &T) { |
| 40 |
|
| 41 |
let values = ops.extract_u64s(vector); |
| 42 |
|
| 43 |
|
| 44 |
println!("{}={:#016x}_{:016x}", prefix, values[1], values[0]); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
#[cfg(feature = "std")] |
| 49 |
#[allow(dead_code)] |
| 50 |
pub(crate) unsafe fn print_vector_bytes<T: ArchOps>(prefix: &str, vector: T::Vector, ops: &T) { |
| 51 |
|
| 52 |
let values = ops.extract_u64s(vector); |
| 53 |
|
| 54 |
|
| 55 |
let bytes: [u8; 16] = core::mem::transmute([values[0], values[1]]); |
| 56 |
|
| 57 |
println!("{}=[{:02x},{:02x},{:02x},{:02x},{:02x},{:02x},{:02x},{:02x},{:02x},{:02x},{:02x},{:02x},{:02x},{:02x},{:02x},{:02x}]", |
| 58 |
prefix, |
| 59 |
bytes[0], bytes[1], bytes[2], bytes[3], |
| 60 |
bytes[4], bytes[5], bytes[6], bytes[7], |
| 61 |
bytes[8], bytes[9], bytes[10], bytes[11], |
| 62 |
bytes[12], bytes[13], bytes[14], bytes[15] |
| 63 |
); |
| 64 |
} |