use crate::iced_constants::IcedConstants;
use crate::iced_error::IcedError;
use core::iter::{ExactSizeIterator, FusedIterator, Iterator};
use core::{fmt, mem};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum CodeSize {
Unknown = 0,
Code16 = 1,
Code32 = 2,
Code64 = 3,
}
#[rustfmt::skip]
static GEN_DEBUG_CODE_SIZE: [&str; 4] = [
"Unknown",
"Code16",
"Code32",
"Code64",
];
impl fmt::Debug for CodeSize {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_CODE_SIZE[*self as usize])
}
}
impl Default for CodeSize {
#[must_use]
#[inline]
fn default() -> Self {
CodeSize::Unknown
}
}
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type CodeSizeUnderlyingType = u8;
#[rustfmt::skip]
impl CodeSize {
#[inline]
pub fn values() -> impl Iterator<Item = CodeSize> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::CODE_SIZE_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, CodeSize>(x as u8) })
}
}
#[test]
#[rustfmt::skip]
fn test_codesize_values() {
let mut iter = CodeSize::values();
assert_eq!(iter.size_hint(), (IcedConstants::CODE_SIZE_ENUM_COUNT, Some(IcedConstants::CODE_SIZE_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::CODE_SIZE_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::CODE_SIZE_ENUM_COUNT - 1, Some(IcedConstants::CODE_SIZE_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::CODE_SIZE_ENUM_COUNT - 1);
let values: Vec<CodeSize> = CodeSize::values().collect();
assert_eq!(values.len(), IcedConstants::CODE_SIZE_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<CodeSize> = CodeSize::values().collect();
let mut values2: Vec<CodeSize> = CodeSize::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[rustfmt::skip]
impl TryFrom<usize> for CodeSize {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::CODE_SIZE_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid CodeSize value"))
}
}
}
#[test]
#[rustfmt::skip]
fn test_codesize_try_from_usize() {
for value in CodeSize::values() {
let converted = <CodeSize as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<CodeSize as TryFrom<usize>>::try_from(IcedConstants::CODE_SIZE_ENUM_COUNT).is_err());
assert!(<CodeSize as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = CodeSize;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum CodeSize")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid CodeSize variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum RoundingControl {
None = 0,
RoundToNearest = 1,
RoundDown = 2,
RoundUp = 3,
RoundTowardZero = 4,
}
#[rustfmt::skip]
static GEN_DEBUG_ROUNDING_CONTROL: [&str; 5] = [
"None",
"RoundToNearest",
"RoundDown",
"RoundUp",
"RoundTowardZero",
];
impl fmt::Debug for RoundingControl {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_ROUNDING_CONTROL[*self as usize])
}
}
impl Default for RoundingControl {
#[must_use]
#[inline]
fn default() -> Self {
RoundingControl::None
}
}
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type RoundingControlUnderlyingType = u8;
#[rustfmt::skip]
impl RoundingControl {
#[inline]
pub fn values() -> impl Iterator<Item = RoundingControl> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::ROUNDING_CONTROL_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, RoundingControl>(x as u8) })
}
}
#[test]
#[rustfmt::skip]
fn test_roundingcontrol_values() {
let mut iter = RoundingControl::values();
assert_eq!(iter.size_hint(), (IcedConstants::ROUNDING_CONTROL_ENUM_COUNT, Some(IcedConstants::ROUNDING_CONTROL_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::ROUNDING_CONTROL_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::ROUNDING_CONTROL_ENUM_COUNT - 1, Some(IcedConstants::ROUNDING_CONTROL_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::ROUNDING_CONTROL_ENUM_COUNT - 1);
let values: Vec<RoundingControl> = RoundingControl::values().collect();
assert_eq!(values.len(), IcedConstants::ROUNDING_CONTROL_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<RoundingControl> = RoundingControl::values().collect();
let mut values2: Vec<RoundingControl> = RoundingControl::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[rustfmt::skip]
impl TryFrom<usize> for RoundingControl {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::ROUNDING_CONTROL_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid RoundingControl value"))
}
}
}
#[test]
#[rustfmt::skip]
fn test_roundingcontrol_try_from_usize() {
for value in RoundingControl::values() {
let converted = <RoundingControl as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<RoundingControl as TryFrom<usize>>::try_from(IcedConstants::ROUNDING_CONTROL_ENUM_COUNT).is_err());
assert!(<RoundingControl as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = RoundingControl;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum RoundingControl")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid RoundingControl variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[allow(non_camel_case_types)]
pub enum OpKind {
Register = 0,
NearBranch16 = 1,
NearBranch32 = 2,
NearBranch64 = 3,
FarBranch16 = 4,
FarBranch32 = 5,
Immediate8 = 6,
Immediate8_2nd = 7,
Immediate16 = 8,
Immediate32 = 9,
Immediate64 = 10,
Immediate8to16 = 11,
Immediate8to32 = 12,
Immediate8to64 = 13,
Immediate32to64 = 14,
MemorySegSI = 15,
MemorySegESI = 16,
MemorySegRSI = 17,
MemorySegDI = 18,
MemorySegEDI = 19,
MemorySegRDI = 20,
MemoryESDI = 21,
MemoryESEDI = 22,
MemoryESRDI = 23,
Memory = 24,
}
#[rustfmt::skip]
static GEN_DEBUG_OP_KIND: [&str; 25] = [
"Register",
"NearBranch16",
"NearBranch32",
"NearBranch64",
"FarBranch16",
"FarBranch32",
"Immediate8",
"Immediate8_2nd",
"Immediate16",
"Immediate32",
"Immediate64",
"Immediate8to16",
"Immediate8to32",
"Immediate8to64",
"Immediate32to64",
"MemorySegSI",
"MemorySegESI",
"MemorySegRSI",
"MemorySegDI",
"MemorySegEDI",
"MemorySegRDI",
"MemoryESDI",
"MemoryESEDI",
"MemoryESRDI",
"Memory",
];
impl fmt::Debug for OpKind {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_OP_KIND[*self as usize])
}
}
impl Default for OpKind {
#[must_use]
#[inline]
fn default() -> Self {
OpKind::Register
}
}
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type OpKindUnderlyingType = u8;
#[rustfmt::skip]
impl OpKind {
#[inline]
pub fn values() -> impl Iterator<Item = OpKind> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::OP_KIND_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, OpKind>(x as u8) })
}
}
#[test]
#[rustfmt::skip]
fn test_opkind_values() {
let mut iter = OpKind::values();
assert_eq!(iter.size_hint(), (IcedConstants::OP_KIND_ENUM_COUNT, Some(IcedConstants::OP_KIND_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::OP_KIND_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::OP_KIND_ENUM_COUNT - 1, Some(IcedConstants::OP_KIND_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::OP_KIND_ENUM_COUNT - 1);
let values: Vec<OpKind> = OpKind::values().collect();
assert_eq!(values.len(), IcedConstants::OP_KIND_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<OpKind> = OpKind::values().collect();
let mut values2: Vec<OpKind> = OpKind::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[rustfmt::skip]
impl TryFrom<usize> for OpKind {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::OP_KIND_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid OpKind value"))
}
}
}
#[test]
#[rustfmt::skip]
fn test_opkind_try_from_usize() {
for value in OpKind::values() {
let converted = <OpKind as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<OpKind as TryFrom<usize>>::try_from(IcedConstants::OP_KIND_ENUM_COUNT).is_err());
assert!(<OpKind as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = OpKind;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum OpKind")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid OpKind variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq)]
#[cfg(any(feature = "decoder", feature = "encoder"))]
#[repr(u32)]
#[allow(dead_code)]
pub(crate) enum VectorLength {
L128,
L256,
L512,
Unknown,
}
#[cfg(any(feature = "decoder", feature = "encoder"))]
#[rustfmt::skip]
static GEN_DEBUG_VECTOR_LENGTH: [&str; 4] = [
"L128",
"L256",
"L512",
"Unknown",
];
#[cfg(any(feature = "decoder", feature = "encoder"))]
impl fmt::Debug for VectorLength {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_VECTOR_LENGTH[*self as usize])
}
}
#[cfg(any(feature = "decoder", feature = "encoder"))]
impl Default for VectorLength {
#[must_use]
#[inline]
fn default() -> Self {
VectorLength::L128
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
#[cfg(feature = "encoder")]
#[allow(dead_code)]
pub(crate) enum MandatoryPrefixByte {
None,
P66,
PF3,
PF2,
}
#[cfg(feature = "encoder")]
#[rustfmt::skip]
static GEN_DEBUG_MANDATORY_PREFIX_BYTE: [&str; 4] = [
"None",
"P66",
"PF3",
"PF2",
];
#[cfg(feature = "encoder")]
impl fmt::Debug for MandatoryPrefixByte {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_MANDATORY_PREFIX_BYTE[*self as usize])
}
}
#[cfg(feature = "encoder")]
impl Default for MandatoryPrefixByte {
#[must_use]
#[inline]
fn default() -> Self {
MandatoryPrefixByte::None
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info", feature = "op_code_info"))]
pub enum EncodingKind {
Legacy = 0,
VEX = 1,
EVEX = 2,
XOP = 3,
D3NOW = 4,
MVEX = 5,
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info", feature = "op_code_info"))]
#[rustfmt::skip]
static GEN_DEBUG_ENCODING_KIND: [&str; 6] = [
"Legacy",
"VEX",
"EVEX",
"XOP",
"D3NOW",
"MVEX",
];
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info", feature = "op_code_info"))]
impl fmt::Debug for EncodingKind {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_ENCODING_KIND[*self as usize])
}
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info", feature = "op_code_info"))]
impl Default for EncodingKind {
#[must_use]
#[inline]
fn default() -> Self {
EncodingKind::Legacy
}
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info", feature = "op_code_info"))]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type EncodingKindUnderlyingType = u8;
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info", feature = "op_code_info"))]
#[rustfmt::skip]
impl EncodingKind {
#[inline]
pub fn values() -> impl Iterator<Item = EncodingKind> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::ENCODING_KIND_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, EncodingKind>(x as u8) })
}
}
#[test]
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info", feature = "op_code_info"))]
#[rustfmt::skip]
fn test_encodingkind_values() {
let mut iter = EncodingKind::values();
assert_eq!(iter.size_hint(), (IcedConstants::ENCODING_KIND_ENUM_COUNT, Some(IcedConstants::ENCODING_KIND_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::ENCODING_KIND_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::ENCODING_KIND_ENUM_COUNT - 1, Some(IcedConstants::ENCODING_KIND_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::ENCODING_KIND_ENUM_COUNT - 1);
let values: Vec<EncodingKind> = EncodingKind::values().collect();
assert_eq!(values.len(), IcedConstants::ENCODING_KIND_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<EncodingKind> = EncodingKind::values().collect();
let mut values2: Vec<EncodingKind> = EncodingKind::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info", feature = "op_code_info"))]
#[rustfmt::skip]
impl TryFrom<usize> for EncodingKind {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::ENCODING_KIND_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid EncodingKind value"))
}
}
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info", feature = "op_code_info"))]
#[test]
#[rustfmt::skip]
fn test_encodingkind_try_from_usize() {
for value in EncodingKind::values() {
let converted = <EncodingKind as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<EncodingKind as TryFrom<usize>>::try_from(IcedConstants::ENCODING_KIND_ENUM_COUNT).is_err());
assert!(<EncodingKind as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info", feature = "op_code_info"))]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = EncodingKind;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum EncodingKind")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid EncodingKind variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
#[cfg(any(feature = "decoder", feature = "encoder", feature = "op_code_info"))]
#[allow(non_camel_case_types)]
pub enum TupleType {
N1 = 0,
N2 = 1,
N4 = 2,
N8 = 3,
N16 = 4,
N32 = 5,
N64 = 6,
N8b4 = 7,
N16b4 = 8,
N32b4 = 9,
N64b4 = 10,
N16b8 = 11,
N32b8 = 12,
N64b8 = 13,
N4b2 = 14,
N8b2 = 15,
N16b2 = 16,
N32b2 = 17,
N64b2 = 18,
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
static GEN_DEBUG_TUPLE_TYPE: [&str; 19] = [
"N1",
"N2",
"N4",
"N8",
"N16",
"N32",
"N64",
"N8b4",
"N16b4",
"N32b4",
"N64b4",
"N16b8",
"N32b8",
"N64b8",
"N4b2",
"N8b2",
"N16b2",
"N32b2",
"N64b2",
];
#[cfg(any(feature = "decoder", feature = "encoder", feature = "op_code_info"))]
impl fmt::Debug for TupleType {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_TUPLE_TYPE[*self as usize])
}
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "op_code_info"))]
impl Default for TupleType {
#[must_use]
#[inline]
fn default() -> Self {
TupleType::N1
}
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "op_code_info"))]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type TupleTypeUnderlyingType = u8;
#[cfg(any(feature = "decoder", feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
impl TupleType {
#[inline]
pub fn values() -> impl Iterator<Item = TupleType> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::TUPLE_TYPE_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, TupleType>(x as u8) })
}
}
#[test]
#[cfg(any(feature = "decoder", feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
fn test_tupletype_values() {
let mut iter = TupleType::values();
assert_eq!(iter.size_hint(), (IcedConstants::TUPLE_TYPE_ENUM_COUNT, Some(IcedConstants::TUPLE_TYPE_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::TUPLE_TYPE_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::TUPLE_TYPE_ENUM_COUNT - 1, Some(IcedConstants::TUPLE_TYPE_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::TUPLE_TYPE_ENUM_COUNT - 1);
let values: Vec<TupleType> = TupleType::values().collect();
assert_eq!(values.len(), IcedConstants::TUPLE_TYPE_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<TupleType> = TupleType::values().collect();
let mut values2: Vec<TupleType> = TupleType::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
impl TryFrom<usize> for TupleType {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::TUPLE_TYPE_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid TupleType value"))
}
}
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "op_code_info"))]
#[test]
#[rustfmt::skip]
fn test_tupletype_try_from_usize() {
for value in TupleType::values() {
let converted = <TupleType as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<TupleType as TryFrom<usize>>::try_from(IcedConstants::TUPLE_TYPE_ENUM_COUNT).is_err());
assert!(<TupleType as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(any(feature = "decoder", feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = TupleType;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum TupleType")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid TupleType variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg(feature = "instr_info")]
pub enum FlowControl {
Next = 0,
UnconditionalBranch = 1,
IndirectBranch = 2,
ConditionalBranch = 3,
Return = 4,
Call = 5,
IndirectCall = 6,
Interrupt = 7,
XbeginXabortXend = 8,
Exception = 9,
}
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
static GEN_DEBUG_FLOW_CONTROL: [&str; 10] = [
"Next",
"UnconditionalBranch",
"IndirectBranch",
"ConditionalBranch",
"Return",
"Call",
"IndirectCall",
"Interrupt",
"XbeginXabortXend",
"Exception",
];
#[cfg(feature = "instr_info")]
impl fmt::Debug for FlowControl {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_FLOW_CONTROL[*self as usize])
}
}
#[cfg(feature = "instr_info")]
impl Default for FlowControl {
#[must_use]
#[inline]
fn default() -> Self {
FlowControl::Next
}
}
#[cfg(feature = "instr_info")]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type FlowControlUnderlyingType = u8;
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
impl FlowControl {
#[inline]
pub fn values() -> impl Iterator<Item = FlowControl> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::FLOW_CONTROL_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, FlowControl>(x as u8) })
}
}
#[test]
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
fn test_flowcontrol_values() {
let mut iter = FlowControl::values();
assert_eq!(iter.size_hint(), (IcedConstants::FLOW_CONTROL_ENUM_COUNT, Some(IcedConstants::FLOW_CONTROL_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::FLOW_CONTROL_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::FLOW_CONTROL_ENUM_COUNT - 1, Some(IcedConstants::FLOW_CONTROL_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::FLOW_CONTROL_ENUM_COUNT - 1);
let values: Vec<FlowControl> = FlowControl::values().collect();
assert_eq!(values.len(), IcedConstants::FLOW_CONTROL_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<FlowControl> = FlowControl::values().collect();
let mut values2: Vec<FlowControl> = FlowControl::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
impl TryFrom<usize> for FlowControl {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::FLOW_CONTROL_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid FlowControl value"))
}
}
}
#[cfg(feature = "instr_info")]
#[test]
#[rustfmt::skip]
fn test_flowcontrol_try_from_usize() {
for value in FlowControl::values() {
let converted = <FlowControl as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<FlowControl as TryFrom<usize>>::try_from(IcedConstants::FLOW_CONTROL_ENUM_COUNT).is_err());
assert!(<FlowControl as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = FlowControl;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum FlowControl")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid FlowControl variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[allow(non_camel_case_types)]
pub enum OpCodeOperandKind {
None = 0,
farbr2_2 = 1,
farbr4_2 = 2,
mem_offs = 3,
mem = 4,
mem_mpx = 5,
mem_mib = 6,
mem_vsib32x = 7,
mem_vsib64x = 8,
mem_vsib32y = 9,
mem_vsib64y = 10,
mem_vsib32z = 11,
mem_vsib64z = 12,
r8_or_mem = 13,
r16_or_mem = 14,
r32_or_mem = 15,
r32_or_mem_mpx = 16,
r64_or_mem = 17,
r64_or_mem_mpx = 18,
mm_or_mem = 19,
xmm_or_mem = 20,
ymm_or_mem = 21,
zmm_or_mem = 22,
bnd_or_mem_mpx = 23,
k_or_mem = 24,
r8_reg = 25,
r8_opcode = 26,
r16_reg = 27,
r16_reg_mem = 28,
r16_rm = 29,
r16_opcode = 30,
r32_reg = 31,
r32_reg_mem = 32,
r32_rm = 33,
r32_opcode = 34,
r32_vvvv = 35,
r64_reg = 36,
r64_reg_mem = 37,
r64_rm = 38,
r64_opcode = 39,
r64_vvvv = 40,
seg_reg = 41,
k_reg = 42,
kp1_reg = 43,
k_rm = 44,
k_vvvv = 45,
mm_reg = 46,
mm_rm = 47,
xmm_reg = 48,
xmm_rm = 49,
xmm_vvvv = 50,
xmmp3_vvvv = 51,
xmm_is4 = 52,
xmm_is5 = 53,
ymm_reg = 54,
ymm_rm = 55,
ymm_vvvv = 56,
ymm_is4 = 57,
ymm_is5 = 58,
zmm_reg = 59,
zmm_rm = 60,
zmm_vvvv = 61,
zmmp3_vvvv = 62,
cr_reg = 63,
dr_reg = 64,
tr_reg = 65,
bnd_reg = 66,
es = 67,
cs = 68,
ss = 69,
ds = 70,
fs = 71,
gs = 72,
al = 73,
cl = 74,
ax = 75,
dx = 76,
eax = 77,
rax = 78,
st0 = 79,
sti_opcode = 80,
imm4_m2z = 81,
imm8 = 82,
imm8_const_1 = 83,
imm8sex16 = 84,
imm8sex32 = 85,
imm8sex64 = 86,
imm16 = 87,
imm32 = 88,
imm32sex64 = 89,
imm64 = 90,
seg_rSI = 91,
es_rDI = 92,
seg_rDI = 93,
seg_rBX_al = 94,
br16_1 = 95,
br32_1 = 96,
br64_1 = 97,
br16_2 = 98,
br32_4 = 99,
br64_4 = 100,
xbegin_2 = 101,
xbegin_4 = 102,
brdisp_2 = 103,
brdisp_4 = 104,
sibmem = 105,
tmm_reg = 106,
tmm_rm = 107,
tmm_vvvv = 108,
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
static GEN_DEBUG_OP_CODE_OPERAND_KIND: [&str; 109] = [
"None",
"farbr2_2",
"farbr4_2",
"mem_offs",
"mem",
"mem_mpx",
"mem_mib",
"mem_vsib32x",
"mem_vsib64x",
"mem_vsib32y",
"mem_vsib64y",
"mem_vsib32z",
"mem_vsib64z",
"r8_or_mem",
"r16_or_mem",
"r32_or_mem",
"r32_or_mem_mpx",
"r64_or_mem",
"r64_or_mem_mpx",
"mm_or_mem",
"xmm_or_mem",
"ymm_or_mem",
"zmm_or_mem",
"bnd_or_mem_mpx",
"k_or_mem",
"r8_reg",
"r8_opcode",
"r16_reg",
"r16_reg_mem",
"r16_rm",
"r16_opcode",
"r32_reg",
"r32_reg_mem",
"r32_rm",
"r32_opcode",
"r32_vvvv",
"r64_reg",
"r64_reg_mem",
"r64_rm",
"r64_opcode",
"r64_vvvv",
"seg_reg",
"k_reg",
"kp1_reg",
"k_rm",
"k_vvvv",
"mm_reg",
"mm_rm",
"xmm_reg",
"xmm_rm",
"xmm_vvvv",
"xmmp3_vvvv",
"xmm_is4",
"xmm_is5",
"ymm_reg",
"ymm_rm",
"ymm_vvvv",
"ymm_is4",
"ymm_is5",
"zmm_reg",
"zmm_rm",
"zmm_vvvv",
"zmmp3_vvvv",
"cr_reg",
"dr_reg",
"tr_reg",
"bnd_reg",
"es",
"cs",
"ss",
"ds",
"fs",
"gs",
"al",
"cl",
"ax",
"dx",
"eax",
"rax",
"st0",
"sti_opcode",
"imm4_m2z",
"imm8",
"imm8_const_1",
"imm8sex16",
"imm8sex32",
"imm8sex64",
"imm16",
"imm32",
"imm32sex64",
"imm64",
"seg_rSI",
"es_rDI",
"seg_rDI",
"seg_rBX_al",
"br16_1",
"br32_1",
"br64_1",
"br16_2",
"br32_4",
"br64_4",
"xbegin_2",
"xbegin_4",
"brdisp_2",
"brdisp_4",
"sibmem",
"tmm_reg",
"tmm_rm",
"tmm_vvvv",
];
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
impl fmt::Debug for OpCodeOperandKind {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_OP_CODE_OPERAND_KIND[*self as usize])
}
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
impl Default for OpCodeOperandKind {
#[must_use]
#[inline]
fn default() -> Self {
OpCodeOperandKind::None
}
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type OpCodeOperandKindUnderlyingType = u8;
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
impl OpCodeOperandKind {
#[inline]
pub fn values() -> impl Iterator<Item = OpCodeOperandKind> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::OP_CODE_OPERAND_KIND_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, OpCodeOperandKind>(x as u8) })
}
}
#[test]
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
fn test_opcodeoperandkind_values() {
let mut iter = OpCodeOperandKind::values();
assert_eq!(iter.size_hint(), (IcedConstants::OP_CODE_OPERAND_KIND_ENUM_COUNT, Some(IcedConstants::OP_CODE_OPERAND_KIND_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::OP_CODE_OPERAND_KIND_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::OP_CODE_OPERAND_KIND_ENUM_COUNT - 1, Some(IcedConstants::OP_CODE_OPERAND_KIND_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::OP_CODE_OPERAND_KIND_ENUM_COUNT - 1);
let values: Vec<OpCodeOperandKind> = OpCodeOperandKind::values().collect();
assert_eq!(values.len(), IcedConstants::OP_CODE_OPERAND_KIND_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<OpCodeOperandKind> = OpCodeOperandKind::values().collect();
let mut values2: Vec<OpCodeOperandKind> = OpCodeOperandKind::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
impl TryFrom<usize> for OpCodeOperandKind {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::OP_CODE_OPERAND_KIND_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid OpCodeOperandKind value"))
}
}
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[test]
#[rustfmt::skip]
fn test_opcodeoperandkind_try_from_usize() {
for value in OpCodeOperandKind::values() {
let converted = <OpCodeOperandKind as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<OpCodeOperandKind as TryFrom<usize>>::try_from(IcedConstants::OP_CODE_OPERAND_KIND_ENUM_COUNT).is_err());
assert!(<OpCodeOperandKind as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = OpCodeOperandKind;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum OpCodeOperandKind")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid OpCodeOperandKind variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
#[cfg(feature = "mvex")]
#[allow(non_camel_case_types)]
pub enum MvexEHBit {
None = 0,
EH0 = 1,
EH1 = 2,
}
#[cfg(feature = "mvex")]
#[rustfmt::skip]
static GEN_DEBUG_MVEX_EHBIT: [&str; 3] = [
"None",
"EH0",
"EH1",
];
#[cfg(feature = "mvex")]
impl fmt::Debug for MvexEHBit {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_MVEX_EHBIT[*self as usize])
}
}
#[cfg(feature = "mvex")]
impl Default for MvexEHBit {
#[must_use]
#[inline]
fn default() -> Self {
MvexEHBit::None
}
}
#[cfg(feature = "mvex")]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type MvexEHBitUnderlyingType = u8;
#[cfg(feature = "mvex")]
#[rustfmt::skip]
impl MvexEHBit {
#[inline]
pub fn values() -> impl Iterator<Item = MvexEHBit> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::MVEX_EHBIT_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, MvexEHBit>(x as u8) })
}
}
#[test]
#[cfg(feature = "mvex")]
#[rustfmt::skip]
fn test_mvexehbit_values() {
let mut iter = MvexEHBit::values();
assert_eq!(iter.size_hint(), (IcedConstants::MVEX_EHBIT_ENUM_COUNT, Some(IcedConstants::MVEX_EHBIT_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::MVEX_EHBIT_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::MVEX_EHBIT_ENUM_COUNT - 1, Some(IcedConstants::MVEX_EHBIT_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::MVEX_EHBIT_ENUM_COUNT - 1);
let values: Vec<MvexEHBit> = MvexEHBit::values().collect();
assert_eq!(values.len(), IcedConstants::MVEX_EHBIT_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<MvexEHBit> = MvexEHBit::values().collect();
let mut values2: Vec<MvexEHBit> = MvexEHBit::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(feature = "mvex")]
#[rustfmt::skip]
impl TryFrom<usize> for MvexEHBit {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::MVEX_EHBIT_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid MvexEHBit value"))
}
}
}
#[cfg(feature = "mvex")]
#[test]
#[rustfmt::skip]
fn test_mvexehbit_try_from_usize() {
for value in MvexEHBit::values() {
let converted = <MvexEHBit as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<MvexEHBit as TryFrom<usize>>::try_from(IcedConstants::MVEX_EHBIT_ENUM_COUNT).is_err());
assert!(<MvexEHBit as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(feature = "mvex")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = MvexEHBit;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum MvexEHBit")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid MvexEHBit variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[cfg(feature = "mvex")]
pub(crate) struct MvexInfoFlags1;
#[cfg(feature = "mvex")]
#[allow(dead_code)]
impl MvexInfoFlags1 {
pub(crate) const NONE: u32 = 0x0000_0000;
pub(crate) const NDD: u32 = 0x0000_0001;
pub(crate) const NDS: u32 = 0x0000_0002;
pub(crate) const EVICTION_HINT: u32 = 0x0000_0004;
pub(crate) const IMM_ROUNDING_CONTROL: u32 = 0x0000_0008;
pub(crate) const ROUNDING_CONTROL: u32 = 0x0000_0010;
pub(crate) const SUPPRESS_ALL_EXCEPTIONS: u32 = 0x0000_0020;
pub(crate) const IGNORES_OP_MASK_REGISTER: u32 = 0x0000_0040;
pub(crate) const REQUIRE_OP_MASK_REGISTER: u32 = 0x0000_0080;
}
#[cfg(feature = "mvex")]
pub(crate) struct MvexInfoFlags2;
#[cfg(feature = "mvex")]
#[allow(dead_code)]
impl MvexInfoFlags2 {
pub(crate) const NONE: u32 = 0x0000_0000;
pub(crate) const NO_SAE_ROUNDING_CONTROL: u32 = 0x0000_0001;
pub(crate) const CONV_FN32: u32 = 0x0000_0002;
pub(crate) const IGNORES_EVICTION_HINT: u32 = 0x0000_0004;
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
#[cfg(feature = "instr_info")]
#[allow(non_camel_case_types)]
pub enum CpuidFeature {
INTEL8086 = 0,
INTEL8086_ONLY = 1,
INTEL186 = 2,
INTEL286 = 3,
INTEL286_ONLY = 4,
INTEL386 = 5,
INTEL386_ONLY = 6,
INTEL386_A0_ONLY = 7,
INTEL486 = 8,
INTEL486_A_ONLY = 9,
UMOV = 10,
IA64 = 11,
X64 = 12,
ADX = 13,
AES = 14,
AVX = 15,
AVX2 = 16,
AVX512_4FMAPS = 17,
AVX512_4VNNIW = 18,
AVX512_BF16 = 19,
AVX512_BITALG = 20,
AVX512_IFMA = 21,
AVX512_VBMI = 22,
AVX512_VBMI2 = 23,
AVX512_VNNI = 24,
AVX512_VP2INTERSECT = 25,
AVX512_VPOPCNTDQ = 26,
AVX512BW = 27,
AVX512CD = 28,
AVX512DQ = 29,
AVX512ER = 30,
AVX512F = 31,
AVX512PF = 32,
AVX512VL = 33,
BMI1 = 34,
BMI2 = 35,
CET_IBT = 36,
CET_SS = 37,
CL1INVMB = 38,
CLDEMOTE = 39,
CLFLUSHOPT = 40,
CLFSH = 41,
CLWB = 42,
CLZERO = 43,
CMOV = 44,
CMPXCHG16B = 45,
CPUID = 46,
CX8 = 47,
D3NOW = 48,
D3NOWEXT = 49,
OSS = 50,
ENQCMD = 51,
F16C = 52,
FMA = 53,
FMA4 = 54,
FPU = 55,
FPU287 = 56,
FPU287XL_ONLY = 57,
FPU387 = 58,
FPU387SL_ONLY = 59,
FSGSBASE = 60,
FXSR = 61,
CYRIX_D3NOW = 62,
GFNI = 63,
HLE = 64,
HLE_or_RTM = 65,
INVEPT = 66,
INVPCID = 67,
INVVPID = 68,
LWP = 69,
LZCNT = 70,
MCOMMIT = 71,
MMX = 72,
MONITOR = 73,
MONITORX = 74,
MOVBE = 75,
MOVDIR64B = 76,
MOVDIRI = 77,
MPX = 78,
MSR = 79,
MULTIBYTENOP = 80,
PADLOCK_ACE = 81,
PADLOCK_PHE = 82,
PADLOCK_PMM = 83,
PADLOCK_RNG = 84,
PAUSE = 85,
PCLMULQDQ = 86,
PCOMMIT = 87,
PCONFIG = 88,
PKU = 89,
POPCNT = 90,
PREFETCHW = 91,
PREFETCHWT1 = 92,
PTWRITE = 93,
RDPID = 94,
RDPMC = 95,
RDPRU = 96,
RDRAND = 97,
RDSEED = 98,
RDTSCP = 99,
RTM = 100,
SEP = 101,
SGX1 = 102,
SHA = 103,
SKINIT = 104,
SKINIT_or_SVM = 105,
SMAP = 106,
SMX = 107,
SSE = 108,
SSE2 = 109,
SSE3 = 110,
SSE4_1 = 111,
SSE4_2 = 112,
SSE4A = 113,
SSSE3 = 114,
SVM = 115,
SEV_ES = 116,
SYSCALL = 117,
TBM = 118,
TSC = 119,
VAES = 120,
VMX = 121,
VPCLMULQDQ = 122,
WAITPKG = 123,
WBNOINVD = 124,
XOP = 125,
XSAVE = 126,
XSAVEC = 127,
XSAVEOPT = 128,
XSAVES = 129,
SEV_SNP = 130,
SERIALIZE = 131,
TSXLDTRK = 132,
INVLPGB = 133,
AMX_BF16 = 134,
AMX_TILE = 135,
AMX_INT8 = 136,
CYRIX_FPU = 137,
CYRIX_SMM = 138,
CYRIX_SMINT = 139,
CYRIX_SMINT_0F7E = 140,
CYRIX_SHR = 141,
CYRIX_DDI = 142,
CYRIX_EMMI = 143,
CYRIX_DMI = 144,
CENTAUR_AIS = 145,
MOV_TR = 146,
SMM = 147,
TDX = 148,
KL = 149,
AESKLE = 150,
WIDE_KL = 151,
UINTR = 152,
HRESET = 153,
AVX_VNNI = 154,
PADLOCK_GMI = 155,
FRED = 156,
LKGS = 157,
AVX512_FP16 = 158,
UDBG = 159,
KNC = 160,
PADLOCK_UNDOC = 161,
RMPQUERY = 162,
RAO_INT = 163,
PREFETCHITI = 164,
AMX_FP16 = 165,
CMPCCXADD = 166,
AVX_IFMA = 167,
AVX_NE_CONVERT = 168,
AVX_VNNI_INT8 = 169,
MSRLIST = 170,
WRMSRNS = 171,
AMX_COMPLEX = 172,
SHA512 = 173,
SM3 = 174,
SM4 = 175,
TSE = 176,
AVX_VNNI_INT16 = 177,
}
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
static GEN_DEBUG_CPUID_FEATURE: [&str; 178] = [
"INTEL8086",
"INTEL8086_ONLY",
"INTEL186",
"INTEL286",
"INTEL286_ONLY",
"INTEL386",
"INTEL386_ONLY",
"INTEL386_A0_ONLY",
"INTEL486",
"INTEL486_A_ONLY",
"UMOV",
"IA64",
"X64",
"ADX",
"AES",
"AVX",
"AVX2",
"AVX512_4FMAPS",
"AVX512_4VNNIW",
"AVX512_BF16",
"AVX512_BITALG",
"AVX512_IFMA",
"AVX512_VBMI",
"AVX512_VBMI2",
"AVX512_VNNI",
"AVX512_VP2INTERSECT",
"AVX512_VPOPCNTDQ",
"AVX512BW",
"AVX512CD",
"AVX512DQ",
"AVX512ER",
"AVX512F",
"AVX512PF",
"AVX512VL",
"BMI1",
"BMI2",
"CET_IBT",
"CET_SS",
"CL1INVMB",
"CLDEMOTE",
"CLFLUSHOPT",
"CLFSH",
"CLWB",
"CLZERO",
"CMOV",
"CMPXCHG16B",
"CPUID",
"CX8",
"D3NOW",
"D3NOWEXT",
"OSS",
"ENQCMD",
"F16C",
"FMA",
"FMA4",
"FPU",
"FPU287",
"FPU287XL_ONLY",
"FPU387",
"FPU387SL_ONLY",
"FSGSBASE",
"FXSR",
"CYRIX_D3NOW",
"GFNI",
"HLE",
"HLE_or_RTM",
"INVEPT",
"INVPCID",
"INVVPID",
"LWP",
"LZCNT",
"MCOMMIT",
"MMX",
"MONITOR",
"MONITORX",
"MOVBE",
"MOVDIR64B",
"MOVDIRI",
"MPX",
"MSR",
"MULTIBYTENOP",
"PADLOCK_ACE",
"PADLOCK_PHE",
"PADLOCK_PMM",
"PADLOCK_RNG",
"PAUSE",
"PCLMULQDQ",
"PCOMMIT",
"PCONFIG",
"PKU",
"POPCNT",
"PREFETCHW",
"PREFETCHWT1",
"PTWRITE",
"RDPID",
"RDPMC",
"RDPRU",
"RDRAND",
"RDSEED",
"RDTSCP",
"RTM",
"SEP",
"SGX1",
"SHA",
"SKINIT",
"SKINIT_or_SVM",
"SMAP",
"SMX",
"SSE",
"SSE2",
"SSE3",
"SSE4_1",
"SSE4_2",
"SSE4A",
"SSSE3",
"SVM",
"SEV_ES",
"SYSCALL",
"TBM",
"TSC",
"VAES",
"VMX",
"VPCLMULQDQ",
"WAITPKG",
"WBNOINVD",
"XOP",
"XSAVE",
"XSAVEC",
"XSAVEOPT",
"XSAVES",
"SEV_SNP",
"SERIALIZE",
"TSXLDTRK",
"INVLPGB",
"AMX_BF16",
"AMX_TILE",
"AMX_INT8",
"CYRIX_FPU",
"CYRIX_SMM",
"CYRIX_SMINT",
"CYRIX_SMINT_0F7E",
"CYRIX_SHR",
"CYRIX_DDI",
"CYRIX_EMMI",
"CYRIX_DMI",
"CENTAUR_AIS",
"MOV_TR",
"SMM",
"TDX",
"KL",
"AESKLE",
"WIDE_KL",
"UINTR",
"HRESET",
"AVX_VNNI",
"PADLOCK_GMI",
"FRED",
"LKGS",
"AVX512_FP16",
"UDBG",
"KNC",
"PADLOCK_UNDOC",
"RMPQUERY",
"RAO_INT",
"PREFETCHITI",
"AMX_FP16",
"CMPCCXADD",
"AVX_IFMA",
"AVX_NE_CONVERT",
"AVX_VNNI_INT8",
"MSRLIST",
"WRMSRNS",
"AMX_COMPLEX",
"SHA512",
"SM3",
"SM4",
"TSE",
"AVX_VNNI_INT16",
];
#[cfg(feature = "instr_info")]
impl fmt::Debug for CpuidFeature {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_CPUID_FEATURE[*self as usize])
}
}
#[cfg(feature = "instr_info")]
impl Default for CpuidFeature {
#[must_use]
#[inline]
fn default() -> Self {
CpuidFeature::INTEL8086
}
}
#[cfg(feature = "instr_info")]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type CpuidFeatureUnderlyingType = u8;
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
impl CpuidFeature {
#[inline]
pub fn values() -> impl Iterator<Item = CpuidFeature> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::CPUID_FEATURE_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, CpuidFeature>(x as u8) })
}
}
#[test]
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
fn test_cpuidfeature_values() {
let mut iter = CpuidFeature::values();
assert_eq!(iter.size_hint(), (IcedConstants::CPUID_FEATURE_ENUM_COUNT, Some(IcedConstants::CPUID_FEATURE_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::CPUID_FEATURE_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::CPUID_FEATURE_ENUM_COUNT - 1, Some(IcedConstants::CPUID_FEATURE_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::CPUID_FEATURE_ENUM_COUNT - 1);
let values: Vec<CpuidFeature> = CpuidFeature::values().collect();
assert_eq!(values.len(), IcedConstants::CPUID_FEATURE_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<CpuidFeature> = CpuidFeature::values().collect();
let mut values2: Vec<CpuidFeature> = CpuidFeature::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
impl TryFrom<usize> for CpuidFeature {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::CPUID_FEATURE_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid CpuidFeature value"))
}
}
}
#[cfg(feature = "instr_info")]
#[test]
#[rustfmt::skip]
fn test_cpuidfeature_try_from_usize() {
for value in CpuidFeature::values() {
let converted = <CpuidFeature as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<CpuidFeature as TryFrom<usize>>::try_from(IcedConstants::CPUID_FEATURE_ENUM_COUNT).is_err());
assert!(<CpuidFeature as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = CpuidFeature;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum CpuidFeature")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid CpuidFeature variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[allow(missing_copy_implementations)]
#[allow(missing_debug_implementations)]
#[cfg(feature = "instr_info")]
pub struct RflagsBits;
#[cfg(feature = "instr_info")]
impl RflagsBits {
pub const NONE: u32 = 0x0000_0000;
pub const OF: u32 = 0x0000_0001;
pub const SF: u32 = 0x0000_0002;
pub const ZF: u32 = 0x0000_0004;
pub const AF: u32 = 0x0000_0008;
pub const CF: u32 = 0x0000_0010;
pub const PF: u32 = 0x0000_0020;
pub const DF: u32 = 0x0000_0040;
pub const IF: u32 = 0x0000_0080;
pub const AC: u32 = 0x0000_0100;
pub const UIF: u32 = 0x0000_0200;
pub const C0: u32 = 0x0000_0400;
pub const C1: u32 = 0x0000_0800;
pub const C2: u32 = 0x0000_1000;
pub const C3: u32 = 0x0000_2000;
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg(feature = "instr_info")]
pub enum OpAccess {
None = 0,
Read = 1,
CondRead = 2,
Write = 3,
CondWrite = 4,
ReadWrite = 5,
ReadCondWrite = 6,
NoMemAccess = 7,
}
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
static GEN_DEBUG_OP_ACCESS: [&str; 8] = [
"None",
"Read",
"CondRead",
"Write",
"CondWrite",
"ReadWrite",
"ReadCondWrite",
"NoMemAccess",
];
#[cfg(feature = "instr_info")]
impl fmt::Debug for OpAccess {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_OP_ACCESS[*self as usize])
}
}
#[cfg(feature = "instr_info")]
impl Default for OpAccess {
#[must_use]
#[inline]
fn default() -> Self {
OpAccess::None
}
}
#[cfg(feature = "instr_info")]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type OpAccessUnderlyingType = u8;
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
impl OpAccess {
#[inline]
pub fn values() -> impl Iterator<Item = OpAccess> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::OP_ACCESS_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, OpAccess>(x as u8) })
}
}
#[test]
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
fn test_opaccess_values() {
let mut iter = OpAccess::values();
assert_eq!(iter.size_hint(), (IcedConstants::OP_ACCESS_ENUM_COUNT, Some(IcedConstants::OP_ACCESS_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::OP_ACCESS_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::OP_ACCESS_ENUM_COUNT - 1, Some(IcedConstants::OP_ACCESS_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::OP_ACCESS_ENUM_COUNT - 1);
let values: Vec<OpAccess> = OpAccess::values().collect();
assert_eq!(values.len(), IcedConstants::OP_ACCESS_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<OpAccess> = OpAccess::values().collect();
let mut values2: Vec<OpAccess> = OpAccess::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
impl TryFrom<usize> for OpAccess {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::OP_ACCESS_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid OpAccess value"))
}
}
}
#[cfg(feature = "instr_info")]
#[test]
#[rustfmt::skip]
fn test_opaccess_try_from_usize() {
for value in OpAccess::values() {
let converted = <OpAccess as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<OpAccess as TryFrom<usize>>::try_from(IcedConstants::OP_ACCESS_ENUM_COUNT).is_err());
assert!(<OpAccess as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = OpAccess;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum OpAccess")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid OpAccess variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg(feature = "instr_info")]
#[allow(non_camel_case_types)]
pub enum ConditionCode {
None = 0,
o = 1,
no = 2,
b = 3,
ae = 4,
e = 5,
ne = 6,
be = 7,
a = 8,
s = 9,
ns = 10,
p = 11,
np = 12,
l = 13,
ge = 14,
le = 15,
g = 16,
}
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
static GEN_DEBUG_CONDITION_CODE: [&str; 17] = [
"None",
"o",
"no",
"b",
"ae",
"e",
"ne",
"be",
"a",
"s",
"ns",
"p",
"np",
"l",
"ge",
"le",
"g",
];
#[cfg(feature = "instr_info")]
impl fmt::Debug for ConditionCode {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_CONDITION_CODE[*self as usize])
}
}
#[cfg(feature = "instr_info")]
impl Default for ConditionCode {
#[must_use]
#[inline]
fn default() -> Self {
ConditionCode::None
}
}
#[cfg(feature = "instr_info")]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type ConditionCodeUnderlyingType = u8;
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
impl ConditionCode {
#[inline]
pub fn values() -> impl Iterator<Item = ConditionCode> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::CONDITION_CODE_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, ConditionCode>(x as u8) })
}
}
#[test]
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
fn test_conditioncode_values() {
let mut iter = ConditionCode::values();
assert_eq!(iter.size_hint(), (IcedConstants::CONDITION_CODE_ENUM_COUNT, Some(IcedConstants::CONDITION_CODE_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::CONDITION_CODE_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::CONDITION_CODE_ENUM_COUNT - 1, Some(IcedConstants::CONDITION_CODE_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::CONDITION_CODE_ENUM_COUNT - 1);
let values: Vec<ConditionCode> = ConditionCode::values().collect();
assert_eq!(values.len(), IcedConstants::CONDITION_CODE_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<ConditionCode> = ConditionCode::values().collect();
let mut values2: Vec<ConditionCode> = ConditionCode::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
impl TryFrom<usize> for ConditionCode {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::CONDITION_CODE_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid ConditionCode value"))
}
}
}
#[cfg(feature = "instr_info")]
#[test]
#[rustfmt::skip]
fn test_conditioncode_try_from_usize() {
for value in ConditionCode::values() {
let converted = <ConditionCode as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<ConditionCode as TryFrom<usize>>::try_from(IcedConstants::CONDITION_CODE_ENUM_COUNT).is_err());
assert!(<ConditionCode as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = ConditionCode;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum ConditionCode")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid ConditionCode variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
pub enum MandatoryPrefix {
None = 0,
PNP = 1,
P66 = 2,
PF3 = 3,
PF2 = 4,
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
static GEN_DEBUG_MANDATORY_PREFIX: [&str; 5] = [
"None",
"PNP",
"P66",
"PF3",
"PF2",
];
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
impl fmt::Debug for MandatoryPrefix {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_MANDATORY_PREFIX[*self as usize])
}
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
impl Default for MandatoryPrefix {
#[must_use]
#[inline]
fn default() -> Self {
MandatoryPrefix::None
}
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type MandatoryPrefixUnderlyingType = u8;
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
impl MandatoryPrefix {
#[inline]
pub fn values() -> impl Iterator<Item = MandatoryPrefix> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::MANDATORY_PREFIX_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, MandatoryPrefix>(x as u8) })
}
}
#[test]
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
fn test_mandatoryprefix_values() {
let mut iter = MandatoryPrefix::values();
assert_eq!(iter.size_hint(), (IcedConstants::MANDATORY_PREFIX_ENUM_COUNT, Some(IcedConstants::MANDATORY_PREFIX_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::MANDATORY_PREFIX_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::MANDATORY_PREFIX_ENUM_COUNT - 1, Some(IcedConstants::MANDATORY_PREFIX_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::MANDATORY_PREFIX_ENUM_COUNT - 1);
let values: Vec<MandatoryPrefix> = MandatoryPrefix::values().collect();
assert_eq!(values.len(), IcedConstants::MANDATORY_PREFIX_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<MandatoryPrefix> = MandatoryPrefix::values().collect();
let mut values2: Vec<MandatoryPrefix> = MandatoryPrefix::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
impl TryFrom<usize> for MandatoryPrefix {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::MANDATORY_PREFIX_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid MandatoryPrefix value"))
}
}
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[test]
#[rustfmt::skip]
fn test_mandatoryprefix_try_from_usize() {
for value in MandatoryPrefix::values() {
let converted = <MandatoryPrefix as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<MandatoryPrefix as TryFrom<usize>>::try_from(IcedConstants::MANDATORY_PREFIX_ENUM_COUNT).is_err());
assert!(<MandatoryPrefix as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = MandatoryPrefix;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum MandatoryPrefix")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid MandatoryPrefix variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
pub enum OpCodeTableKind {
Normal = 0,
T0F = 1,
T0F38 = 2,
T0F3A = 3,
MAP5 = 4,
MAP6 = 5,
MAP8 = 6,
MAP9 = 7,
MAP10 = 8,
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
static GEN_DEBUG_OP_CODE_TABLE_KIND: [&str; 9] = [
"Normal",
"T0F",
"T0F38",
"T0F3A",
"MAP5",
"MAP6",
"MAP8",
"MAP9",
"MAP10",
];
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
impl fmt::Debug for OpCodeTableKind {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_OP_CODE_TABLE_KIND[*self as usize])
}
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
impl Default for OpCodeTableKind {
#[must_use]
#[inline]
fn default() -> Self {
OpCodeTableKind::Normal
}
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type OpCodeTableKindUnderlyingType = u8;
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
impl OpCodeTableKind {
#[inline]
pub fn values() -> impl Iterator<Item = OpCodeTableKind> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::OP_CODE_TABLE_KIND_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, OpCodeTableKind>(x as u8) })
}
}
#[test]
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
fn test_opcodetablekind_values() {
let mut iter = OpCodeTableKind::values();
assert_eq!(iter.size_hint(), (IcedConstants::OP_CODE_TABLE_KIND_ENUM_COUNT, Some(IcedConstants::OP_CODE_TABLE_KIND_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::OP_CODE_TABLE_KIND_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::OP_CODE_TABLE_KIND_ENUM_COUNT - 1, Some(IcedConstants::OP_CODE_TABLE_KIND_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::OP_CODE_TABLE_KIND_ENUM_COUNT - 1);
let values: Vec<OpCodeTableKind> = OpCodeTableKind::values().collect();
assert_eq!(values.len(), IcedConstants::OP_CODE_TABLE_KIND_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<OpCodeTableKind> = OpCodeTableKind::values().collect();
let mut values2: Vec<OpCodeTableKind> = OpCodeTableKind::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
impl TryFrom<usize> for OpCodeTableKind {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::OP_CODE_TABLE_KIND_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid OpCodeTableKind value"))
}
}
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[test]
#[rustfmt::skip]
fn test_opcodetablekind_try_from_usize() {
for value in OpCodeTableKind::values() {
let converted = <OpCodeTableKind as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<OpCodeTableKind as TryFrom<usize>>::try_from(IcedConstants::OP_CODE_TABLE_KIND_ENUM_COUNT).is_err());
assert!(<OpCodeTableKind as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = OpCodeTableKind;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum OpCodeTableKind")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid OpCodeTableKind variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) enum InstrScale {
Scale1 = 0,
Scale2 = 1,
Scale4 = 2,
Scale8 = 3,
}
#[rustfmt::skip]
static GEN_DEBUG_INSTR_SCALE: [&str; 4] = [
"Scale1",
"Scale2",
"Scale4",
"Scale8",
];
impl fmt::Debug for InstrScale {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_INSTR_SCALE[*self as usize])
}
}
impl Default for InstrScale {
#[must_use]
#[inline]
fn default() -> Self {
InstrScale::Scale1
}
}
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type InstrScaleUnderlyingType = u8;
#[rustfmt::skip]
impl InstrScale {
#[inline]
#[allow(dead_code)]
pub(crate) fn values() -> impl Iterator<Item = InstrScale> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..4).map(|x| unsafe { mem::transmute::<u8, InstrScale>(x as u8) })
}
}
#[test]
#[rustfmt::skip]
fn test_instrscale_values() {
let mut iter = InstrScale::values();
assert_eq!(iter.size_hint(), (4, Some(4)));
assert_eq!(iter.len(), 4);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (4 - 1, Some(4 - 1)));
assert_eq!(iter.len(), 4 - 1);
let values: Vec<InstrScale> = InstrScale::values().collect();
assert_eq!(values.len(), 4);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<InstrScale> = InstrScale::values().collect();
let mut values2: Vec<InstrScale> = InstrScale::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[rustfmt::skip]
impl TryFrom<usize> for InstrScale {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < 4 {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid InstrScale value"))
}
}
}
#[test]
#[rustfmt::skip]
fn test_instrscale_try_from_usize() {
for value in InstrScale::values() {
let converted = <InstrScale as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<InstrScale as TryFrom<usize>>::try_from(4).is_err());
assert!(<InstrScale as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = InstrScale;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum InstrScale")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid InstrScale variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
#[cfg(feature = "mvex")]
#[allow(non_camel_case_types)]
pub enum MvexConvFn {
None = 0,
Sf32 = 1,
Sf64 = 2,
Si32 = 3,
Si64 = 4,
Uf32 = 5,
Uf64 = 6,
Ui32 = 7,
Ui64 = 8,
Df32 = 9,
Df64 = 10,
Di32 = 11,
Di64 = 12,
}
#[cfg(feature = "mvex")]
#[rustfmt::skip]
static GEN_DEBUG_MVEX_CONV_FN: [&str; 13] = [
"None",
"Sf32",
"Sf64",
"Si32",
"Si64",
"Uf32",
"Uf64",
"Ui32",
"Ui64",
"Df32",
"Df64",
"Di32",
"Di64",
];
#[cfg(feature = "mvex")]
impl fmt::Debug for MvexConvFn {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_MVEX_CONV_FN[*self as usize])
}
}
#[cfg(feature = "mvex")]
impl Default for MvexConvFn {
#[must_use]
#[inline]
fn default() -> Self {
MvexConvFn::None
}
}
#[cfg(feature = "mvex")]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type MvexConvFnUnderlyingType = u8;
#[cfg(feature = "mvex")]
#[rustfmt::skip]
impl MvexConvFn {
#[inline]
pub fn values() -> impl Iterator<Item = MvexConvFn> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::MVEX_CONV_FN_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, MvexConvFn>(x as u8) })
}
}
#[test]
#[cfg(feature = "mvex")]
#[rustfmt::skip]
fn test_mvexconvfn_values() {
let mut iter = MvexConvFn::values();
assert_eq!(iter.size_hint(), (IcedConstants::MVEX_CONV_FN_ENUM_COUNT, Some(IcedConstants::MVEX_CONV_FN_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::MVEX_CONV_FN_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::MVEX_CONV_FN_ENUM_COUNT - 1, Some(IcedConstants::MVEX_CONV_FN_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::MVEX_CONV_FN_ENUM_COUNT - 1);
let values: Vec<MvexConvFn> = MvexConvFn::values().collect();
assert_eq!(values.len(), IcedConstants::MVEX_CONV_FN_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<MvexConvFn> = MvexConvFn::values().collect();
let mut values2: Vec<MvexConvFn> = MvexConvFn::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(feature = "mvex")]
#[rustfmt::skip]
impl TryFrom<usize> for MvexConvFn {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::MVEX_CONV_FN_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid MvexConvFn value"))
}
}
}
#[cfg(feature = "mvex")]
#[test]
#[rustfmt::skip]
fn test_mvexconvfn_try_from_usize() {
for value in MvexConvFn::values() {
let converted = <MvexConvFn as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<MvexConvFn as TryFrom<usize>>::try_from(IcedConstants::MVEX_CONV_FN_ENUM_COUNT).is_err());
assert!(<MvexConvFn as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(feature = "mvex")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = MvexConvFn;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum MvexConvFn")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid MvexConvFn variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
#[cfg(feature = "mvex")]
#[allow(non_camel_case_types)]
pub enum MvexRegMemConv {
None = 0,
RegSwizzleNone = 1,
RegSwizzleCdab = 2,
RegSwizzleBadc = 3,
RegSwizzleDacb = 4,
RegSwizzleAaaa = 5,
RegSwizzleBbbb = 6,
RegSwizzleCccc = 7,
RegSwizzleDddd = 8,
MemConvNone = 9,
MemConvBroadcast1 = 10,
MemConvBroadcast4 = 11,
MemConvFloat16 = 12,
MemConvUint8 = 13,
MemConvSint8 = 14,
MemConvUint16 = 15,
MemConvSint16 = 16,
}
#[cfg(feature = "mvex")]
#[rustfmt::skip]
static GEN_DEBUG_MVEX_REG_MEM_CONV: [&str; 17] = [
"None",
"RegSwizzleNone",
"RegSwizzleCdab",
"RegSwizzleBadc",
"RegSwizzleDacb",
"RegSwizzleAaaa",
"RegSwizzleBbbb",
"RegSwizzleCccc",
"RegSwizzleDddd",
"MemConvNone",
"MemConvBroadcast1",
"MemConvBroadcast4",
"MemConvFloat16",
"MemConvUint8",
"MemConvSint8",
"MemConvUint16",
"MemConvSint16",
];
#[cfg(feature = "mvex")]
impl fmt::Debug for MvexRegMemConv {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_MVEX_REG_MEM_CONV[*self as usize])
}
}
#[cfg(feature = "mvex")]
impl Default for MvexRegMemConv {
#[must_use]
#[inline]
fn default() -> Self {
MvexRegMemConv::None
}
}
#[cfg(feature = "mvex")]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type MvexRegMemConvUnderlyingType = u8;
#[cfg(feature = "mvex")]
#[rustfmt::skip]
impl MvexRegMemConv {
#[inline]
pub fn values() -> impl Iterator<Item = MvexRegMemConv> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::MVEX_REG_MEM_CONV_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, MvexRegMemConv>(x as u8) })
}
}
#[test]
#[cfg(feature = "mvex")]
#[rustfmt::skip]
fn test_mvexregmemconv_values() {
let mut iter = MvexRegMemConv::values();
assert_eq!(iter.size_hint(), (IcedConstants::MVEX_REG_MEM_CONV_ENUM_COUNT, Some(IcedConstants::MVEX_REG_MEM_CONV_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::MVEX_REG_MEM_CONV_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::MVEX_REG_MEM_CONV_ENUM_COUNT - 1, Some(IcedConstants::MVEX_REG_MEM_CONV_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::MVEX_REG_MEM_CONV_ENUM_COUNT - 1);
let values: Vec<MvexRegMemConv> = MvexRegMemConv::values().collect();
assert_eq!(values.len(), IcedConstants::MVEX_REG_MEM_CONV_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<MvexRegMemConv> = MvexRegMemConv::values().collect();
let mut values2: Vec<MvexRegMemConv> = MvexRegMemConv::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(feature = "mvex")]
#[rustfmt::skip]
impl TryFrom<usize> for MvexRegMemConv {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::MVEX_REG_MEM_CONV_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid MvexRegMemConv value"))
}
}
}
#[cfg(feature = "mvex")]
#[test]
#[rustfmt::skip]
fn test_mvexregmemconv_try_from_usize() {
for value in MvexRegMemConv::values() {
let converted = <MvexRegMemConv as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<MvexRegMemConv as TryFrom<usize>>::try_from(IcedConstants::MVEX_REG_MEM_CONV_ENUM_COUNT).is_err());
assert!(<MvexRegMemConv as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(feature = "mvex")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = MvexRegMemConv;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum MvexRegMemConv")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid MvexRegMemConv variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
#[cfg(feature = "mvex")]
#[allow(non_camel_case_types)]
pub enum MvexTupleTypeLutKind {
Int32 = 0,
Int32_Half = 1,
Int32_4to16 = 2,
Int32_1to16_or_elem = 3,
Int64 = 4,
Int64_4to8 = 5,
Int64_1to8_or_elem = 6,
Float32 = 7,
Float32_Half = 8,
Float32_4to16 = 9,
Float32_1to16_or_elem = 10,
Float64 = 11,
Float64_4to8 = 12,
Float64_1to8_or_elem = 13,
}
#[cfg(feature = "mvex")]
#[rustfmt::skip]
static GEN_DEBUG_MVEX_TUPLE_TYPE_LUT_KIND: [&str; 14] = [
"Int32",
"Int32_Half",
"Int32_4to16",
"Int32_1to16_or_elem",
"Int64",
"Int64_4to8",
"Int64_1to8_or_elem",
"Float32",
"Float32_Half",
"Float32_4to16",
"Float32_1to16_or_elem",
"Float64",
"Float64_4to8",
"Float64_1to8_or_elem",
];
#[cfg(feature = "mvex")]
impl fmt::Debug for MvexTupleTypeLutKind {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", GEN_DEBUG_MVEX_TUPLE_TYPE_LUT_KIND[*self as usize])
}
}
#[cfg(feature = "mvex")]
impl Default for MvexTupleTypeLutKind {
#[must_use]
#[inline]
fn default() -> Self {
MvexTupleTypeLutKind::Int32
}
}
#[cfg(feature = "mvex")]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type MvexTupleTypeLutKindUnderlyingType = u8;
#[cfg(feature = "mvex")]
#[rustfmt::skip]
impl MvexTupleTypeLutKind {
#[inline]
pub fn values() -> impl Iterator<Item = MvexTupleTypeLutKind> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
(0..IcedConstants::MVEX_TUPLE_TYPE_LUT_KIND_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, MvexTupleTypeLutKind>(x as u8) })
}
}
#[test]
#[cfg(feature = "mvex")]
#[rustfmt::skip]
fn test_mvextupletypelutkind_values() {
let mut iter = MvexTupleTypeLutKind::values();
assert_eq!(iter.size_hint(), (IcedConstants::MVEX_TUPLE_TYPE_LUT_KIND_ENUM_COUNT, Some(IcedConstants::MVEX_TUPLE_TYPE_LUT_KIND_ENUM_COUNT)));
assert_eq!(iter.len(), IcedConstants::MVEX_TUPLE_TYPE_LUT_KIND_ENUM_COUNT);
assert!(iter.next().is_some());
assert_eq!(iter.size_hint(), (IcedConstants::MVEX_TUPLE_TYPE_LUT_KIND_ENUM_COUNT - 1, Some(IcedConstants::MVEX_TUPLE_TYPE_LUT_KIND_ENUM_COUNT - 1)));
assert_eq!(iter.len(), IcedConstants::MVEX_TUPLE_TYPE_LUT_KIND_ENUM_COUNT - 1);
let values: Vec<MvexTupleTypeLutKind> = MvexTupleTypeLutKind::values().collect();
assert_eq!(values.len(), IcedConstants::MVEX_TUPLE_TYPE_LUT_KIND_ENUM_COUNT);
for (i, value) in values.into_iter().enumerate() {
assert_eq!(i, value as usize);
}
let values1: Vec<MvexTupleTypeLutKind> = MvexTupleTypeLutKind::values().collect();
let mut values2: Vec<MvexTupleTypeLutKind> = MvexTupleTypeLutKind::values().rev().collect();
values2.reverse();
assert_eq!(values1, values2);
}
#[cfg(feature = "mvex")]
#[rustfmt::skip]
impl TryFrom<usize> for MvexTupleTypeLutKind {
type Error = IcedError;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if value < IcedConstants::MVEX_TUPLE_TYPE_LUT_KIND_ENUM_COUNT {
Ok(unsafe { mem::transmute(value as u8) })
} else {
Err(IcedError::new("Invalid MvexTupleTypeLutKind value"))
}
}
}
#[cfg(feature = "mvex")]
#[test]
#[rustfmt::skip]
fn test_mvextupletypelutkind_try_from_usize() {
for value in MvexTupleTypeLutKind::values() {
let converted = <MvexTupleTypeLutKind as TryFrom<usize>>::try_from(value as usize).unwrap();
assert_eq!(converted, value);
}
assert!(<MvexTupleTypeLutKind as TryFrom<usize>>::try_from(IcedConstants::MVEX_TUPLE_TYPE_LUT_KIND_ENUM_COUNT).is_err());
assert!(<MvexTupleTypeLutKind as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[cfg(feature = "mvex")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
use core::marker::PhantomData;
use serde::de;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
type EnumType = MvexTupleTypeLutKind;
impl Serialize for EnumType {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u8(*self as u8)
}
}
impl<'de> Deserialize<'de> for EnumType {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor<'de> {
marker: PhantomData<EnumType>,
lifetime: PhantomData<&'de ()>,
}
impl<'de> de::Visitor<'de> for Visitor<'de> {
type Value = EnumType;
#[inline]
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("enum MvexTupleTypeLutKind")
}
#[inline]
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
return Ok(value);
}
}
Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid MvexTupleTypeLutKind variant value"))
}
}
deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
}
}
};