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
pub(crate) struct ValidateConstImm<const IMM: i32, const MIN: i32, const MAX: i32>;
impl<const IMM: i32, const MIN: i32, const MAX: i32> ValidateConstImm<IMM, MIN, MAX> {
pub(crate) const VALID: () = {
let _ = 1 / ((IMM >= MIN && IMM <= MAX) as usize);
};
}
#[allow(unused_macros)]
macro_rules! static_assert_imm1 {
($imm:ident) => {
let _ = $crate::core_arch::macros::ValidateConstImm::<$imm, 0, { (1 << 1) - 1 }>::VALID;
};
}
#[allow(unused_macros)]
macro_rules! static_assert_imm2 {
($imm:ident) => {
let _ = $crate::core_arch::macros::ValidateConstImm::<$imm, 0, { (1 << 2) - 1 }>::VALID;
};
}
#[allow(unused_macros)]
macro_rules! static_assert_imm3 {
($imm:ident) => {
let _ = $crate::core_arch::macros::ValidateConstImm::<$imm, 0, { (1 << 3) - 1 }>::VALID;
};
}
#[allow(unused_macros)]
macro_rules! static_assert_imm4 {
($imm:ident) => {
let _ = $crate::core_arch::macros::ValidateConstImm::<$imm, 0, { (1 << 4) - 1 }>::VALID;
};
}
#[allow(unused_macros)]
macro_rules! static_assert_imm5 {
($imm:ident) => {
let _ = $crate::core_arch::macros::ValidateConstImm::<$imm, 0, { (1 << 5) - 1 }>::VALID;
};
}
#[allow(unused_macros)]
macro_rules! static_assert_imm6 {
($imm:ident) => {
let _ = $crate::core_arch::macros::ValidateConstImm::<$imm, 0, { (1 << 6) - 1 }>::VALID;
};
}
#[allow(unused_macros)]
macro_rules! static_assert_imm8 {
($imm:ident) => {
let _ = $crate::core_arch::macros::ValidateConstImm::<$imm, 0, { (1 << 8) - 1 }>::VALID;
};
}
#[allow(unused_macros)]
macro_rules! static_assert_imm16 {
($imm:ident) => {
let _ = $crate::core_arch::macros::ValidateConstImm::<$imm, 0, { (1 << 16) - 1 }>::VALID;
};
}
#[allow(unused)]
macro_rules! static_assert {
($imm:ident : $ty:ty where $e:expr) => {{
struct Validate<const $imm: $ty>();
impl<const $imm: $ty> Validate<$imm> {
const VALID: () = {
let _ = 1 / ($e as usize);
};
}
let _ = Validate::<$imm>::VALID;
}};
}
#[allow(unused)]
macro_rules! types {
($(
$(#[$doc:meta])*
pub struct $name:ident($($fields:tt)*);
)*) => ($(
$(#[$doc])*
#[derive(Copy, Clone, Debug)]
#[allow(non_camel_case_types)]
#[repr(simd)]
#[allow(clippy::missing_inline_in_public_items)]
pub struct $name($($fields)*);
)*)
}