Skip to main content

diskann_wide/arch/aarch64/
i8x16_.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, i8x8, internal,
14    macros::{self, AArchLoadStore, AArchSplat},
15    masks::mask8x16,
16};
17
18// AArch64 intrinsics
19use std::arch::aarch64::*;
20
21//////////////////
22// 8-bit signed //
23//////////////////
24
25macros::aarch64_define_register!(i8x16, int8x16_t, mask8x16, i8, 16, Neon);
26macros::aarch64_define_splat!(i8x16, vmovq_n_s8);
27macros::aarch64_define_loadstore!(i8x16, vld1q_s8, internal::load_first::i8x16, vst1q_s8, 16);
28macros::aarch64_splitjoin!(i8x16, i8x8, vget_low_s8, vget_high_s8, vcombine_s8);
29
30helpers::unsafe_map_binary_op!(i8x16, std::ops::Add, add, vaddq_s8, "neon");
31helpers::unsafe_map_binary_op!(i8x16, std::ops::Sub, sub, vsubq_s8, "neon");
32helpers::unsafe_map_binary_op!(i8x16, std::ops::Mul, mul, vmulq_s8, "neon");
33helpers::unsafe_map_unary_op!(i8x16, SIMDAbs, abs_simd, vabsq_s8, "neon");
34macros::aarch64_define_fma!(i8x16, vmlaq_s8);
35
36macros::aarch64_define_cmp!(
37    i8x16,
38    vceqq_s8,
39    (vmvnq_u8),
40    vcltq_s8,
41    vcleq_s8,
42    vcgtq_s8,
43    vcgeq_s8
44);
45macros::aarch64_define_bitops!(
46    i8x16,
47    vmvnq_s8,
48    vandq_s8,
49    vorrq_s8,
50    veorq_s8,
51    (
52        vshlq_s8,
53        8,
54        vnegq_s8,
55        vminq_u8,
56        vreinterpretq_s8_u8,
57        vreinterpretq_u8_s8
58    ),
59    (u8, i8, vmovq_n_s8),
60);
61
62///////////
63// Tests //
64///////////
65
66#[cfg(test)]
67mod tests {
68    use super::*;
69    use crate::{arch::aarch64::test_neon, reference::ReferenceScalarOps, test_utils};
70
71    #[test]
72    fn miri_test_load() {
73        if let Some(arch) = test_neon() {
74            test_utils::test_load_simd::<i8, 16, i8x16>(arch);
75        }
76    }
77
78    #[test]
79    fn miri_test_store() {
80        if let Some(arch) = test_neon() {
81            test_utils::test_store_simd::<i8, 16, i8x16>(arch);
82        }
83    }
84
85    // constructors
86    #[test]
87    fn test_constructors() {
88        if let Some(arch) = test_neon() {
89            test_utils::ops::test_splat::<i8, 16, i8x16>(arch);
90        }
91    }
92
93    // Ops
94    test_utils::ops::test_add!(i8x16, 0x3017fd73c99cc633, test_neon());
95    test_utils::ops::test_sub!(i8x16, 0xfc627f10b5f8db8a, test_neon());
96    test_utils::ops::test_mul!(i8x16, 0x0f4caa80eceaa523, test_neon());
97    test_utils::ops::test_fma!(i8x16, 0xb8f702ba85375041, test_neon());
98    test_utils::ops::test_abs!(i8x16, 0xb8f702ba85375041, test_neon());
99    test_utils::ops::test_splitjoin!(i8x16 => i8x8, 0xa4d00a4d04293967, test_neon());
100
101    test_utils::ops::test_cmp!(i8x16, 0x941757bd5cc641a1, test_neon());
102
103    // Bit ops
104    test_utils::ops::test_bitops!(i8x16, 0xd62d8de09f82ed4e, test_neon());
105}