Skip to main content

diskann_wide/arch/aarch64/
u8x8_.rs

1/*
2 * Copyright (c) Microsoft Corporation. All rights reserved.
3 * Licensed under the MIT license.
4 */
5
6use crate::{
7    Emulated,
8    constant::Const,
9    helpers,
10    traits::{SIMDMask, SIMDMulAdd, SIMDPartialEq, SIMDPartialOrd, SIMDVector},
11};
12
13// AArch64 masks
14use super::{
15    Neon, internal,
16    macros::{self, AArchLoadStore, AArchSplat},
17    masks::mask8x8,
18};
19
20// AArch64 intrinsics
21use std::arch::aarch64::*;
22
23////////////////////
24// 8-bit unsigned //
25////////////////////
26
27macros::aarch64_define_register!(u8x8, uint8x8_t, mask8x8, u8, 8, Neon);
28macros::aarch64_define_splat!(u8x8, vmov_n_u8);
29macros::aarch64_define_loadstore!(u8x8, vld1_u8, internal::load_first::u8x8, vst1_u8, 8);
30
31helpers::unsafe_map_binary_op!(u8x8, std::ops::Add, add, vadd_u8, "neon");
32helpers::unsafe_map_binary_op!(u8x8, std::ops::Sub, sub, vsub_u8, "neon");
33helpers::unsafe_map_binary_op!(u8x8, std::ops::Mul, mul, vmul_u8, "neon");
34macros::aarch64_define_fma!(u8x8, vmla_u8);
35
36macros::aarch64_define_cmp!(u8x8, vceq_u8, (vmvn_u8), vclt_u8, vcle_u8, vcgt_u8, vcge_u8);
37macros::aarch64_define_bitops!(
38    u8x8,
39    vmvn_u8,
40    vand_u8,
41    vorr_u8,
42    veor_u8,
43    (
44        vshl_u8,
45        8,
46        vneg_s8,
47        vmin_u8,
48        vreinterpret_s8_u8,
49        std::convert::identity
50    ),
51    (u8, i8, vmov_n_s8),
52);
53
54///////////
55// Tests //
56///////////
57
58#[cfg(test)]
59mod tests {
60    use super::*;
61    use crate::{arch::aarch64::test_neon, reference::ReferenceScalarOps, test_utils};
62
63    #[test]
64    fn miri_test_load() {
65        if let Some(arch) = test_neon() {
66            test_utils::test_load_simd::<u8, 8, u8x8>(arch);
67        }
68    }
69
70    #[test]
71    fn miri_test_store() {
72        if let Some(arch) = test_neon() {
73            test_utils::test_store_simd::<u8, 8, u8x8>(arch);
74        }
75    }
76
77    // constructors
78    #[test]
79    fn test_constructors() {
80        if let Some(arch) = test_neon() {
81            test_utils::ops::test_splat::<u8, 8, u8x8>(arch);
82        }
83    }
84
85    // Ops
86    test_utils::ops::test_add!(u8x8, 0x3017fd73c99cc633, test_neon());
87    test_utils::ops::test_sub!(u8x8, 0xfc627f10b5f8db8a, test_neon());
88    test_utils::ops::test_mul!(u8x8, 0x0f4caa80eceaa523, test_neon());
89    test_utils::ops::test_fma!(u8x8, 0xb8f702ba85375041, test_neon());
90
91    test_utils::ops::test_cmp!(u8x8, 0x941757bd5cc641a1, test_neon());
92
93    // Bit ops
94    test_utils::ops::test_bitops!(u8x8, 0xd62d8de09f82ed4e, test_neon());
95}