Skip to main content

diskann_wide/arch/aarch64/
i8x8_.rs

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