This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 220
/
packed.rs
81 lines (69 loc) · 1.97 KB
/
packed.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use std::convert::TryInto;
use std::simd::ToBitMask;
use crate::types::simd::*;
use crate::types::{days_ms, f16, months_days_ns};
use super::*;
macro_rules! simd8 {
($type:ty, $md:ty) => {
impl Simd8 for $type {
type Simd = $md;
}
impl Simd8Lanes<$type> for $md {
#[inline]
fn from_chunk(v: &[$type]) -> Self {
<$md>::from_slice(v)
}
#[inline]
fn from_incomplete_chunk(v: &[$type], remaining: $type) -> Self {
let mut a = [remaining; 8];
a.iter_mut().zip(v.iter()).for_each(|(a, b)| *a = *b);
Self::from_array(a)
}
}
impl Simd8PartialEq for $md {
#[inline]
fn eq(self, other: Self) -> u8 {
self.lanes_eq(other).to_bitmask()
}
#[inline]
fn neq(self, other: Self) -> u8 {
self.lanes_ne(other).to_bitmask()
}
}
impl Simd8PartialOrd for $md {
#[inline]
fn lt_eq(self, other: Self) -> u8 {
self.lanes_le(other).to_bitmask()
}
#[inline]
fn lt(self, other: Self) -> u8 {
self.lanes_lt(other).to_bitmask()
}
#[inline]
fn gt_eq(self, other: Self) -> u8 {
self.lanes_ge(other).to_bitmask()
}
#[inline]
fn gt(self, other: Self) -> u8 {
self.lanes_gt(other).to_bitmask()
}
}
};
}
simd8!(u8, u8x8);
simd8!(u16, u16x8);
simd8!(u32, u32x8);
simd8!(u64, u64x8);
simd8!(i8, i8x8);
simd8!(i16, i16x8);
simd8!(i32, i32x8);
simd8!(i64, i64x8);
simd8_native_all!(i128);
simd8_native!(f16);
simd8_native_partial_eq!(f16);
simd8!(f32, f32x8);
simd8!(f64, f64x8);
simd8_native!(days_ms);
simd8_native_partial_eq!(days_ms);
simd8_native!(months_days_ns);
simd8_native_partial_eq!(months_days_ns);