use crate::iced_constants::IcedConstants;
use crate::iced_error::IcedError;
use core::convert::TryFrom;
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
}
}
#[rustfmt::skip]
impl CodeSize {
#[inline]
pub fn values() -> impl Iterator<Item = CodeSize> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::CODE_SIZE_ENUM_COUNT).map(|x| unsafe { core::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);
}
}
#[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());
}
#[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
}
}
#[rustfmt::skip]
impl RoundingControl {
#[inline]
pub fn values() -> impl Iterator<Item = RoundingControl> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::ROUNDING_CONTROL_ENUM_COUNT).map(|x| unsafe { core::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);
}
}
#[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());
}
#[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,
#[deprecated(since = "1.11.0", note = "Don't use it!")]
Memory64 = 24,
Memory = 25,
}
#[rustfmt::skip]
static GEN_DEBUG_OP_KIND: [&str; 26] = [
"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",
"Memory64",
"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
}
}
#[rustfmt::skip]
impl OpKind {
#[inline]
pub fn values() -> impl Iterator<Item = OpKind> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::OP_KIND_ENUM_COUNT).map(|x| unsafe { core::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);
}
}
#[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());
}
#[derive(Copy, Clone, Eq, PartialEq)]
#[cfg(any(feature = "decoder", feature = "encoder"))]
#[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(any(feature = "decoder", feature = "encoder"))]
#[allow(dead_code)]
pub(crate) enum MandatoryPrefixByte {
None,
P66,
PF3,
PF2,
}
#[cfg(any(feature = "decoder", feature = "encoder"))]
#[rustfmt::skip]
static GEN_DEBUG_MANDATORY_PREFIX_BYTE: [&str; 4] = [
"None",
"P66",
"PF3",
"PF2",
];
#[cfg(any(feature = "decoder", 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(any(feature = "decoder", 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"))]
pub enum EncodingKind {
Legacy = 0,
VEX = 1,
EVEX = 2,
XOP = 3,
D3NOW = 4,
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info"))]
#[rustfmt::skip]
static GEN_DEBUG_ENCODING_KIND: [&str; 5] = [
"Legacy",
"VEX",
"EVEX",
"XOP",
"D3NOW",
];
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_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"))]
impl Default for EncodingKind {
#[must_use]
#[inline]
fn default() -> Self {
EncodingKind::Legacy
}
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_info"))]
#[rustfmt::skip]
impl EncodingKind {
#[inline]
pub fn values() -> impl Iterator<Item = EncodingKind> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::ENCODING_KIND_ENUM_COUNT).map(|x| unsafe { core::mem::transmute::<u8, EncodingKind>(x as u8) })
}
}
#[test]
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_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);
}
}
#[cfg(any(feature = "decoder", feature = "encoder", feature = "instr_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"))]
#[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());
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
#[cfg(any(feature = "decoder", feature = "encoder"))]
#[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,
}
#[cfg(any(feature = "decoder", feature = "encoder"))]
#[rustfmt::skip]
static GEN_DEBUG_TUPLE_TYPE: [&str; 14] = [
"N1",
"N2",
"N4",
"N8",
"N16",
"N32",
"N64",
"N8b4",
"N16b4",
"N32b4",
"N64b4",
"N16b8",
"N32b8",
"N64b8",
];
#[cfg(any(feature = "decoder", feature = "encoder"))]
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"))]
impl Default for TupleType {
#[must_use]
#[inline]
fn default() -> Self {
TupleType::N1
}
}
#[cfg(any(feature = "decoder", feature = "encoder"))]
#[rustfmt::skip]
impl TupleType {
#[inline]
pub fn values() -> impl Iterator<Item = TupleType> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::TUPLE_TYPE_ENUM_COUNT).map(|x| unsafe { core::mem::transmute::<u8, TupleType>(x as u8) })
}
}
#[test]
#[cfg(any(feature = "decoder", feature = "encoder"))]
#[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);
}
}
#[cfg(any(feature = "decoder", feature = "encoder"))]
#[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"))]
#[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());
}
#[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")]
#[rustfmt::skip]
impl FlowControl {
#[inline]
pub fn values() -> impl Iterator<Item = FlowControl> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::FLOW_CONTROL_ENUM_COUNT).map(|x| unsafe { core::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);
}
}
#[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());
}
#[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"))]
#[rustfmt::skip]
impl OpCodeOperandKind {
#[inline]
pub fn values() -> impl Iterator<Item = OpCodeOperandKind> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::OP_CODE_OPERAND_KIND_ENUM_COUNT).map(|x| unsafe { core::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);
}
}
#[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());
}
#[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,
}
#[cfg(feature = "instr_info")]
#[rustfmt::skip]
static GEN_DEBUG_CPUID_FEATURE: [&str; 158] = [
"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",
];
#[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")]
#[rustfmt::skip]
impl CpuidFeature {
#[inline]
pub fn values() -> impl Iterator<Item = CpuidFeature> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::CPUID_FEATURE_ENUM_COUNT).map(|x| unsafe { core::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);
}
}
#[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());
}
#[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")]
#[rustfmt::skip]
impl OpAccess {
#[inline]
pub fn values() -> impl Iterator<Item = OpAccess> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::OP_ACCESS_ENUM_COUNT).map(|x| unsafe { core::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);
}
}
#[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());
}
#[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")]
#[rustfmt::skip]
impl ConditionCode {
#[inline]
pub fn values() -> impl Iterator<Item = ConditionCode> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::CONDITION_CODE_ENUM_COUNT).map(|x| unsafe { core::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);
}
}
#[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());
}
#[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"))]
#[rustfmt::skip]
impl MandatoryPrefix {
#[inline]
pub fn values() -> impl Iterator<Item = MandatoryPrefix> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::MANDATORY_PREFIX_ENUM_COUNT).map(|x| unsafe { core::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);
}
}
#[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());
}
#[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,
XOP8 = 4,
XOP9 = 5,
XOPA = 6,
}
#[cfg(all(feature = "encoder", feature = "op_code_info"))]
#[rustfmt::skip]
static GEN_DEBUG_OP_CODE_TABLE_KIND: [&str; 7] = [
"Normal",
"T0F",
"T0F38",
"T0F3A",
"XOP8",
"XOP9",
"XOPA",
];
#[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"))]
#[rustfmt::skip]
impl OpCodeTableKind {
#[inline]
pub fn values() -> impl Iterator<Item = OpCodeTableKind> + ExactSizeIterator + FusedIterator {
(0..IcedConstants::OP_CODE_TABLE_KIND_ENUM_COUNT).map(|x| unsafe { core::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);
}
}
#[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());
}