summaryrefslogtreecommitdiffstats
path: root/library/stdarch/crates/core_arch/src/x86/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/stdarch/crates/core_arch/src/x86/macros.rs')
-rw-r--r--library/stdarch/crates/core_arch/src/x86/macros.rs75
1 files changed, 15 insertions, 60 deletions
diff --git a/library/stdarch/crates/core_arch/src/x86/macros.rs b/library/stdarch/crates/core_arch/src/x86/macros.rs
index e686e65b3..17d64f5bb 100644
--- a/library/stdarch/crates/core_arch/src/x86/macros.rs
+++ b/library/stdarch/crates/core_arch/src/x86/macros.rs
@@ -1,89 +1,44 @@
//! Utility macros.
-//!
-// Helper struct used to trigger const eval errors when the const generic immediate value `imm` is
-// not a round number.
-pub(crate) struct ValidateConstRound<const IMM: i32>;
-impl<const IMM: i32> ValidateConstRound<IMM> {
- pub(crate) const VALID: () = {
- assert!(
- IMM == 4 || IMM == 8 || IMM == 9 || IMM == 10 || IMM == 11,
- "Invalid IMM value"
- );
- };
-}
+// Helper macro used to trigger const eval errors when the const generic immediate value `imm` is
+// not a round number.
#[allow(unused)]
macro_rules! static_assert_rounding {
($imm:ident) => {
- let _ = $crate::core_arch::x86::macros::ValidateConstRound::<$imm>::VALID;
+ static_assert!(
+ $imm == 4 || $imm == 8 || $imm == 9 || $imm == 10 || $imm == 11,
+ "Invalid IMM value"
+ )
};
}
-// Helper struct used to trigger const eval errors when the const generic immediate value `imm` is
+// Helper macro used to trigger const eval errors when the const generic immediate value `imm` is
// not a sae number.
-pub(crate) struct ValidateConstSae<const IMM: i32>;
-impl<const IMM: i32> ValidateConstSae<IMM> {
- pub(crate) const VALID: () = {
- assert!(IMM == 4 || IMM == 8, "Invalid IMM value");
- };
-}
-
#[allow(unused)]
macro_rules! static_assert_sae {
($imm:ident) => {
- let _ = $crate::core_arch::x86::macros::ValidateConstSae::<$imm>::VALID;
+ static_assert!($imm == 4 || $imm == 8, "Invalid IMM value")
};
}
-// Helper struct used to trigger const eval errors when the const generic immediate value `imm` is
+// Helper macro used to trigger const eval errors when the const generic immediate value `imm` is
// not a mantissas sae number.
-pub(crate) struct ValidateConstMantissasSae<const IMM: i32>;
-impl<const IMM: i32> ValidateConstMantissasSae<IMM> {
- pub(crate) const VALID: () = {
- assert!(IMM == 4 || IMM == 8 || IMM == 12, "Invalid IMM value");
- };
-}
-
#[allow(unused)]
macro_rules! static_assert_mantissas_sae {
($imm:ident) => {
- let _ = $crate::core_arch::x86::macros::ValidateConstMantissasSae::<$imm>::VALID;
+ static_assert!($imm == 4 || $imm == 8 || $imm == 12, "Invalid IMM value")
};
}
-// Helper struct used to trigger const eval errors when the unsigned const generic immediate value
-// `IMM` is out of `[MIN-MAX]` range.
-pub(crate) struct ValidateConstImmU32<const IMM: u32, const MIN: u32, const MAX: u32>;
-impl<const IMM: u32, const MIN: u32, const MAX: u32> ValidateConstImmU32<IMM, MIN, MAX> {
- pub(crate) const VALID: () = {
- assert!(IMM >= MIN && IMM <= MAX, "IMM value not in expected range");
- };
-}
-
-#[allow(unused_macros)]
-macro_rules! static_assert_imm_u8 {
- ($imm:ident) => {
- let _ =
- $crate::core_arch::x86::macros::ValidateConstImmU32::<$imm, 0, { (1 << 8) - 1 }>::VALID;
- };
-}
-
-// Helper struct used to trigger const eval errors when the const generic immediate value `SCALE` is
+// Helper macro used to trigger const eval errors when the const generic immediate value `SCALE` is
// not valid for gather instructions: the only valid scale values are 1, 2, 4 and 8.
-pub(crate) struct ValidateConstGatherScale<const SCALE: i32>;
-impl<const SCALE: i32> ValidateConstGatherScale<SCALE> {
- pub(crate) const VALID: () = {
- assert!(
- SCALE == 1 || SCALE == 2 || SCALE == 4 || SCALE == 8,
- "Invalid SCALE value"
- );
- };
-}
-
#[allow(unused)]
macro_rules! static_assert_imm8_scale {
($imm:ident) => {
- let _ = $crate::core_arch::x86::macros::ValidateConstGatherScale::<$imm>::VALID;
+ static_assert!(
+ $imm == 1 || $imm == 2 || $imm == 4 || $imm == 8,
+ "Invalid SCALE value"
+ )
};
}