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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#[macro_use]
mod api;
mod v128;
mod v16;
mod v256;
mod v32;
mod v512;
mod v64;
pub use self::v128::*;
pub use self::v16::*;
pub use self::v256::*;
pub use self::v32::*;
pub use self::v512::*;
pub use self::v64::*;
pub trait FromBits<T>: ::marker::Sized {
fn from_bits(T) -> Self;
}
pub trait IntoBits<T>: ::marker::Sized {
fn into_bits(self) -> T;
}
impl<T, U> IntoBits<U> for T
where
U: FromBits<T>,
{
#[inline]
fn into_bits(self) -> U {
debug_assert!(::mem::size_of::<Self>() == ::mem::size_of::<U>());
U::from_bits(self)
}
}
impl<T> FromBits<T> for T {
#[inline]
fn from_bits(t: Self) -> Self {
t
}
}
#[cfg(target_arch = "aarch64")]
mod codegen {
#[cfg(target_arch = "aarch64")]
pub mod wrapping {
pub trait Wrapping {
fn add(self, other: Self) -> Self;
fn mul(self, other: Self) -> Self;
}
macro_rules! int_impl {
($id:ident) => {
impl Wrapping for $id {
fn add(self, other: Self) -> Self {
self.wrapping_add(other)
}
fn mul(self, other: Self) -> Self {
self.wrapping_mul(other)
}
}
};
}
int_impl!(i8);
int_impl!(i16);
int_impl!(i32);
int_impl!(i64);
int_impl!(u8);
int_impl!(u16);
int_impl!(u32);
int_impl!(u64);
macro_rules! float_impl {
($id:ident) => {
impl Wrapping for $id {
fn add(self, other: Self) -> Self {
self + other
}
fn mul(self, other: Self) -> Self {
self * other
}
}
};
}
float_impl!(f32);
float_impl!(f64);
}
}