File tree Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change 1
1
//! Utility macros.
2
2
3
3
// Helper struct used to trigger const eval errors when a const generic immediate value is
4
- // out of range.
5
- pub ( crate ) struct ValidateConstImm8 < const imm8: i32 > ( ) ;
4
+ // out of 8-bit range.
5
+ pub ( crate ) struct ValidateConstImm8 < const imm8: i32 > ;
6
6
impl < const imm8: i32 > ValidateConstImm8 < imm8 > {
7
7
pub ( crate ) const VALID : ( ) = {
8
8
let _ = 1 / ( ( imm8 >= 0 && imm8 <= 255 ) as usize ) ;
Original file line number Diff line number Diff line change 1
1
//! Utility macros.
2
+ // Helper struct used to trigger const eval errors when a const generic immediate value is
3
+ // out of 2-bit range.
4
+ pub ( crate ) struct ValidateConstImm2 < const imm2: i32 > ;
5
+ impl < const imm2: i32 > ValidateConstImm2 < imm2 > {
6
+ pub ( crate ) const VALID : ( ) = {
7
+ let _ = 1 / ( ( imm2 >= 0 && imm2 <= 3 ) as usize ) ;
8
+ } ;
9
+ }
10
+
11
+ #[ allow( unused) ]
12
+ macro_rules! static_assert_imm2 {
13
+ ( $imm: ident) => {
14
+ let _ = $crate:: core_arch:: x86:: macros:: ValidateConstImm2 :: <$imm>:: VALID ;
15
+ } ;
16
+ }
2
17
18
+ // Helper struct used to trigger const eval errors when a const generic immediate value is
19
+ // out of 3-bit range.
20
+ pub ( crate ) struct ValidateConstImm3 < const imm3: i32 > ;
21
+ impl < const imm3: i32 > ValidateConstImm3 < imm3 > {
22
+ pub ( crate ) const VALID : ( ) = {
23
+ let _ = 1 / ( ( imm3 >= 0 && imm3 <= 7 ) as usize ) ;
24
+ } ;
25
+ }
26
+
27
+ #[ allow( unused) ]
28
+ macro_rules! static_assert_imm3 {
29
+ ( $imm: ident) => {
30
+ let _ = $crate:: core_arch:: x86:: macros:: ValidateConstImm3 :: <$imm>:: VALID ;
31
+ } ;
32
+ }
33
+
34
+ // Helper struct used to trigger const eval errors when a const generic immediate value is
35
+ // out of 4-bit range.
36
+ pub ( crate ) struct ValidateConstImm4 < const imm4: i32 > ;
37
+ impl < const imm4: i32 > ValidateConstImm4 < imm4 > {
38
+ pub ( crate ) const VALID : ( ) = {
39
+ let _ = 1 / ( ( imm4 >= 0 && imm4 <= 15 ) as usize ) ;
40
+ } ;
41
+ }
42
+
43
+ #[ allow( unused) ]
44
+ macro_rules! static_assert_imm4 {
45
+ ( $imm: ident) => {
46
+ let _ = $crate:: core_arch:: x86:: macros:: ValidateConstImm4 :: <$imm>:: VALID ;
47
+ } ;
48
+ }
3
49
macro_rules! constify_imm6 {
4
50
( $imm8: expr, $expand: ident) => {
5
51
#[ allow( overflowing_literals) ]
You can’t perform that action at this time.
0 commit comments