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
macro_rules! rust_fallback_impl {
(impl $trait:tt for $type:tt where $feat:tt {
$($rustfn:ident => $mmfn:tt ( $($mmfnargs:expr),* ), [$($n:expr),+]);*;}) => (
impl $trait for $type {
$(
#[inline(always)]
#[cfg(target_feature = $feat)]
fn $rustfn(&self) -> Self {
unsafe { $mmfn(*self, $($mmfnargs),*) }
}
#[inline(always)]
#[cfg(not(target_feature = $feat))]
fn $rustfn(&self) -> Self {
Self::new($(self.extract($n).$rustfn(),)*)
}
)*
}
);
}
macro_rules! rust_fallback_impl_binary {
(impl $trait:tt for $type:tt where $feat:tt {
$($rustfn:ident => $mmfn:tt ( $($mmfnargs:expr),* ), [$($n:expr),+]);*;}) => (
impl $trait for $type {
$(
#[inline(always)]
#[cfg(target_feature = $feat)]
fn $rustfn(&self, other: Self) -> Self {
use core_or_std::mem::transmute;
unsafe { transmute($mmfn(transmute(*self), transmute(other), $($mmfnargs),*)) }
}
#[inline(always)]
#[cfg(not(target_feature = $feat))]
fn $rustfn(&self, other: Self) -> Self {
Self::new($(self.extract($n).$rustfn(other.extract($n)),)*)
}
)*
}
);
}
macro_rules! hop {
($name:ident, $fn:path, $($a:expr, $b:expr),*) => {
#[inline(always)]
fn $name(&self, other: Self) -> Self {
Self::new($($fn(self.extract($a), self.extract($b)),
$fn(other.extract($a), other.extract($b))),*)
}
}
}