#[doc(inline)]
pub use crate::intel_imm as imm;
pub trait Imm<T>: Copy {
const VAL: T;
}
#[doc(hidden)]
#[macro_export]
macro_rules! intel_imm {
($expr:expr, $type:ty) => {
{
#[derive(Copy, Clone)]
struct Imm;
impl $crate::intel::Imm<$type> for Imm {
const VAL: $type = $expr;
}
Imm
}
};
{ $(
$vis:vis type $name:ident
$(<$($gname:ident $(: $gtype:path)?),* $(,)?>)?
: $type:ty
= $expr:expr;
)+ } => { $(
#[derive(Copy, Clone)]
$vis struct $name
$(<$($gname $(: $gtype)?),*>)?
($($($crate::__core::marker::PhantomData<$gname>),*)?);
impl
$(<$($gname $(: $gtype)?),*>)?
$name $(<$($gname),*>)? {
pub const fn new() -> Self {
Self($($($crate::__core::marker::PhantomData::<$gname>),*)?)
}
}
impl
$(<$($gname $(: $gtype)?),*>)?
$crate::intel::value::Imm<$type>
for $name $(<$($gname),*>)? {
const VAL: $type = const {
const fn compute
$(<$($gname $(: $gtype)?),*>)?
() -> $type {
$expr
}
compute $(::<$($gname),*>)? ()
};
}
)+ };
}