#[cfg_attr(miri, allow(unused_imports))]
use core::arch::aarch64::*;
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vaddvq_f64_compat(v: float64x2_t) -> f64 {
#[cfg(not(miri))]
{
vaddvq_f64(v)
}
#[cfg(miri)]
{
let mut a = [0f64; 2];
unsafe { vst1q_f64(a.as_mut_ptr(), v) };
a[0] + a[1]
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vaddvq_u32_compat(v: uint32x4_t) -> u32 {
#[cfg(not(miri))]
{
vaddvq_u32(v)
}
#[cfg(miri)]
{
let mut a = [0u32; 4];
unsafe { vst1q_u32(a.as_mut_ptr(), v) };
a[0]
.wrapping_add(a[1])
.wrapping_add(a[2])
.wrapping_add(a[3])
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vaddvq_u64_compat(v: uint64x2_t) -> u64 {
#[cfg(not(miri))]
{
vaddvq_u64(v)
}
#[cfg(miri)]
{
let mut a = [0u64; 2];
unsafe { vst1q_u64(a.as_mut_ptr(), v) };
a[0].wrapping_add(a[1])
}
}
#[cfg(miri)]
#[inline]
fn fmax_lane(a: f32, b: f32) -> f32 {
if a.is_nan() || b.is_nan() {
f32::NAN
} else if a == b {
if a.is_sign_positive() { a } else { b }
} else if a > b {
a
} else {
b
}
}
#[cfg(miri)]
#[inline]
fn fmin_lane(a: f32, b: f32) -> f32 {
if a.is_nan() || b.is_nan() {
f32::NAN
} else if a == b {
if a.is_sign_negative() { a } else { b }
} else if a < b {
a
} else {
b
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vmaxq_f32_compat(a: float32x4_t, b: float32x4_t) -> float32x4_t {
#[cfg(not(miri))]
{
vmaxq_f32(a, b)
}
#[cfg(miri)]
{
let mut av = [0f32; 4];
let mut bv = [0f32; 4];
unsafe {
vst1q_f32(av.as_mut_ptr(), a);
vst1q_f32(bv.as_mut_ptr(), b);
}
let out = [
fmax_lane(av[0], bv[0]),
fmax_lane(av[1], bv[1]),
fmax_lane(av[2], bv[2]),
fmax_lane(av[3], bv[3]),
];
unsafe { vld1q_f32(out.as_ptr()) }
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vminq_f32_compat(a: float32x4_t, b: float32x4_t) -> float32x4_t {
#[cfg(not(miri))]
{
vminq_f32(a, b)
}
#[cfg(miri)]
{
let mut av = [0f32; 4];
let mut bv = [0f32; 4];
unsafe {
vst1q_f32(av.as_mut_ptr(), a);
vst1q_f32(bv.as_mut_ptr(), b);
}
let out = [
fmin_lane(av[0], bv[0]),
fmin_lane(av[1], bv[1]),
fmin_lane(av[2], bv[2]),
fmin_lane(av[3], bv[3]),
];
unsafe { vld1q_f32(out.as_ptr()) }
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vmaxq_s16_compat(a: int16x8_t, b: int16x8_t) -> int16x8_t {
#[cfg(not(miri))]
{
vmaxq_s16(a, b)
}
#[cfg(miri)]
{
let mut av = [0i16; 8];
let mut bv = [0i16; 8];
unsafe {
vst1q_s16(av.as_mut_ptr(), a);
vst1q_s16(bv.as_mut_ptr(), b);
}
let out = [
av[0].max(bv[0]),
av[1].max(bv[1]),
av[2].max(bv[2]),
av[3].max(bv[3]),
av[4].max(bv[4]),
av[5].max(bv[5]),
av[6].max(bv[6]),
av[7].max(bv[7]),
];
unsafe { vld1q_s16(out.as_ptr()) }
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vminq_s16_compat(a: int16x8_t, b: int16x8_t) -> int16x8_t {
#[cfg(not(miri))]
{
vminq_s16(a, b)
}
#[cfg(miri)]
{
let mut av = [0i16; 8];
let mut bv = [0i16; 8];
unsafe {
vst1q_s16(av.as_mut_ptr(), a);
vst1q_s16(bv.as_mut_ptr(), b);
}
let out = [
av[0].min(bv[0]),
av[1].min(bv[1]),
av[2].min(bv[2]),
av[3].min(bv[3]),
av[4].min(bv[4]),
av[5].min(bv[5]),
av[6].min(bv[6]),
av[7].min(bv[7]),
];
unsafe { vld1q_s16(out.as_ptr()) }
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vcvtnq_u32_f32_compat(v: float32x4_t) -> uint32x4_t {
#[cfg(not(miri))]
{
vcvtnq_u32_f32(v)
}
#[cfg(miri)]
{
let mut a = [0f32; 4];
unsafe { vst1q_f32(a.as_mut_ptr(), v) };
let out = [
a[0].round_ties_even() as u32,
a[1].round_ties_even() as u32,
a[2].round_ties_even() as u32,
a[3].round_ties_even() as u32,
];
unsafe { vld1q_u32(out.as_ptr()) }
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vcvtaq_u32_f32_compat(v: float32x4_t) -> uint32x4_t {
#[cfg(not(miri))]
{
vcvtaq_u32_f32(v)
}
#[cfg(miri)]
{
let mut a = [0f32; 4];
unsafe { vst1q_f32(a.as_mut_ptr(), v) };
let out = [
a[0].round() as u32,
a[1].round() as u32,
a[2].round() as u32,
a[3].round() as u32,
];
unsafe { vld1q_u32(out.as_ptr()) }
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vqmovun_s16_compat(v: int16x8_t) -> uint8x8_t {
#[cfg(not(miri))]
{
vqmovun_s16(v)
}
#[cfg(miri)]
{
let mut a = [0i16; 8];
unsafe { vst1q_s16(a.as_mut_ptr(), v) };
let out = [
a[0].clamp(0, 255) as u8,
a[1].clamp(0, 255) as u8,
a[2].clamp(0, 255) as u8,
a[3].clamp(0, 255) as u8,
a[4].clamp(0, 255) as u8,
a[5].clamp(0, 255) as u8,
a[6].clamp(0, 255) as u8,
a[7].clamp(0, 255) as u8,
];
unsafe { vld1_u8(out.as_ptr()) }
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vqmovn_u16_compat(v: uint16x8_t) -> uint8x8_t {
#[cfg(not(miri))]
{
vqmovn_u16(v)
}
#[cfg(miri)]
{
let mut a = [0u16; 8];
unsafe { vst1q_u16(a.as_mut_ptr(), v) };
let out = [
a[0].min(255) as u8,
a[1].min(255) as u8,
a[2].min(255) as u8,
a[3].min(255) as u8,
a[4].min(255) as u8,
a[5].min(255) as u8,
a[6].min(255) as u8,
a[7].min(255) as u8,
];
unsafe { vld1_u8(out.as_ptr()) }
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vqmovun_s32_compat(v: int32x4_t) -> uint16x4_t {
#[cfg(not(miri))]
{
vqmovun_s32(v)
}
#[cfg(miri)]
{
let mut a = [0i32; 4];
unsafe { vst1q_s32(a.as_mut_ptr(), v) };
let out = [
a[0].clamp(0, 65535) as u16,
a[1].clamp(0, 65535) as u16,
a[2].clamp(0, 65535) as u16,
a[3].clamp(0, 65535) as u16,
];
unsafe { vld1_u16(out.as_ptr()) }
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vqmovn_u32_compat(v: uint32x4_t) -> uint16x4_t {
#[cfg(not(miri))]
{
vqmovn_u32(v)
}
#[cfg(miri)]
{
let mut a = [0u32; 4];
unsafe { vst1q_u32(a.as_mut_ptr(), v) };
let out = [
a[0].min(65535) as u16,
a[1].min(65535) as u16,
a[2].min(65535) as u16,
a[3].min(65535) as u16,
];
unsafe { vld1_u16(out.as_ptr()) }
}
}
#[inline]
#[target_feature(enable = "neon")]
#[allow(dead_code)]
pub(crate) unsafe fn vqmovn_s32_compat(v: int32x4_t) -> int16x4_t {
#[cfg(not(miri))]
{
vqmovn_s32(v)
}
#[cfg(miri)]
{
let mut a = [0i32; 4];
unsafe { vst1q_s32(a.as_mut_ptr(), v) };
let out = [
a[0].clamp(-32768, 32767) as i16,
a[1].clamp(-32768, 32767) as i16,
a[2].clamp(-32768, 32767) as i16,
a[3].clamp(-32768, 32767) as i16,
];
unsafe { vld1_s16(out.as_ptr()) }
}
}