iced_x86/
memory_size.rs

1// SPDX-License-Identifier: MIT
2// Copyright (C) 2018-present iced project and contributors
3
4use crate::iced_constants::IcedConstants;
5use crate::iced_error::IcedError;
6use core::iter::{ExactSizeIterator, FusedIterator, Iterator};
7use core::{fmt, mem};
8
9#[cfg(any(feature = "instr_info", feature = "encoder"))]
10pub use crate::memory_size::info::*;
11
12#[cfg(any(feature = "instr_info", feature = "encoder"))]
13mod info {
14	use crate::iced_constants::IcedConstants;
15	use crate::MemorySize;
16
17	#[rustfmt::skip]
18	pub(super) static MEMORY_SIZE_INFOS: &[MemorySizeInfo; IcedConstants::MEMORY_SIZE_ENUM_COUNT] = &[
19		// GENERATOR-BEGIN: MemorySizeInfoTable
20		// ⚠️This was generated by GENERATOR!🦹‍♂️
21		MemorySizeInfo { size: 0, element_size: 0, memory_size: MemorySize::Unknown, element_type: MemorySize::Unknown, is_signed: false, is_broadcast: false },
22		MemorySizeInfo { size: 1, element_size: 1, memory_size: MemorySize::UInt8, element_type: MemorySize::UInt8, is_signed: false, is_broadcast: false },
23		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::UInt16, element_type: MemorySize::UInt16, is_signed: false, is_broadcast: false },
24		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::UInt32, element_type: MemorySize::UInt32, is_signed: false, is_broadcast: false },
25		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::UInt52, element_type: MemorySize::UInt52, is_signed: false, is_broadcast: false },
26		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::UInt64, element_type: MemorySize::UInt64, is_signed: false, is_broadcast: false },
27		MemorySizeInfo { size: 16, element_size: 16, memory_size: MemorySize::UInt128, element_type: MemorySize::UInt128, is_signed: false, is_broadcast: false },
28		MemorySizeInfo { size: 32, element_size: 32, memory_size: MemorySize::UInt256, element_type: MemorySize::UInt256, is_signed: false, is_broadcast: false },
29		MemorySizeInfo { size: 64, element_size: 64, memory_size: MemorySize::UInt512, element_type: MemorySize::UInt512, is_signed: false, is_broadcast: false },
30		MemorySizeInfo { size: 1, element_size: 1, memory_size: MemorySize::Int8, element_type: MemorySize::Int8, is_signed: true, is_broadcast: false },
31		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Int16, element_type: MemorySize::Int16, is_signed: true, is_broadcast: false },
32		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Int32, element_type: MemorySize::Int32, is_signed: true, is_broadcast: false },
33		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Int64, element_type: MemorySize::Int64, is_signed: true, is_broadcast: false },
34		MemorySizeInfo { size: 16, element_size: 16, memory_size: MemorySize::Int128, element_type: MemorySize::Int128, is_signed: true, is_broadcast: false },
35		MemorySizeInfo { size: 32, element_size: 32, memory_size: MemorySize::Int256, element_type: MemorySize::Int256, is_signed: true, is_broadcast: false },
36		MemorySizeInfo { size: 64, element_size: 64, memory_size: MemorySize::Int512, element_type: MemorySize::Int512, is_signed: true, is_broadcast: false },
37		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::SegPtr16, element_type: MemorySize::SegPtr16, is_signed: false, is_broadcast: false },
38		MemorySizeInfo { size: 6, element_size: 6, memory_size: MemorySize::SegPtr32, element_type: MemorySize::SegPtr32, is_signed: false, is_broadcast: false },
39		MemorySizeInfo { size: 10, element_size: 10, memory_size: MemorySize::SegPtr64, element_type: MemorySize::SegPtr64, is_signed: false, is_broadcast: false },
40		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::WordOffset, element_type: MemorySize::WordOffset, is_signed: false, is_broadcast: false },
41		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::DwordOffset, element_type: MemorySize::DwordOffset, is_signed: false, is_broadcast: false },
42		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::QwordOffset, element_type: MemorySize::QwordOffset, is_signed: false, is_broadcast: false },
43		MemorySizeInfo { size: 4, element_size: 2, memory_size: MemorySize::Bound16_WordWord, element_type: MemorySize::UInt16, is_signed: false, is_broadcast: false },
44		MemorySizeInfo { size: 8, element_size: 4, memory_size: MemorySize::Bound32_DwordDword, element_type: MemorySize::UInt32, is_signed: false, is_broadcast: false },
45		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Bnd32, element_type: MemorySize::Bnd32, is_signed: false, is_broadcast: false },
46		MemorySizeInfo { size: 16, element_size: 16, memory_size: MemorySize::Bnd64, element_type: MemorySize::Bnd64, is_signed: false, is_broadcast: false },
47		MemorySizeInfo { size: 6, element_size: 6, memory_size: MemorySize::Fword6, element_type: MemorySize::Fword6, is_signed: false, is_broadcast: false },
48		MemorySizeInfo { size: 10, element_size: 10, memory_size: MemorySize::Fword10, element_type: MemorySize::Fword10, is_signed: false, is_broadcast: false },
49		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Float16, element_type: MemorySize::Float16, is_signed: true, is_broadcast: false },
50		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Float32, element_type: MemorySize::Float32, is_signed: true, is_broadcast: false },
51		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Float64, element_type: MemorySize::Float64, is_signed: true, is_broadcast: false },
52		MemorySizeInfo { size: 10, element_size: 10, memory_size: MemorySize::Float80, element_type: MemorySize::Float80, is_signed: true, is_broadcast: false },
53		MemorySizeInfo { size: 16, element_size: 16, memory_size: MemorySize::Float128, element_type: MemorySize::Float128, is_signed: true, is_broadcast: false },
54		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::BFloat16, element_type: MemorySize::BFloat16, is_signed: true, is_broadcast: false },
55		MemorySizeInfo { size: 14, element_size: 14, memory_size: MemorySize::FpuEnv14, element_type: MemorySize::FpuEnv14, is_signed: false, is_broadcast: false },
56		MemorySizeInfo { size: 28, element_size: 28, memory_size: MemorySize::FpuEnv28, element_type: MemorySize::FpuEnv28, is_signed: false, is_broadcast: false },
57		MemorySizeInfo { size: 94, element_size: 94, memory_size: MemorySize::FpuState94, element_type: MemorySize::FpuState94, is_signed: false, is_broadcast: false },
58		MemorySizeInfo { size: 108, element_size: 108, memory_size: MemorySize::FpuState108, element_type: MemorySize::FpuState108, is_signed: false, is_broadcast: false },
59		MemorySizeInfo { size: 512, element_size: 512, memory_size: MemorySize::Fxsave_512Byte, element_type: MemorySize::Fxsave_512Byte, is_signed: false, is_broadcast: false },
60		MemorySizeInfo { size: 512, element_size: 512, memory_size: MemorySize::Fxsave64_512Byte, element_type: MemorySize::Fxsave64_512Byte, is_signed: false, is_broadcast: false },
61		MemorySizeInfo { size: 0, element_size: 0, memory_size: MemorySize::Xsave, element_type: MemorySize::Xsave, is_signed: false, is_broadcast: false },
62		MemorySizeInfo { size: 0, element_size: 0, memory_size: MemorySize::Xsave64, element_type: MemorySize::Xsave64, is_signed: false, is_broadcast: false },
63		MemorySizeInfo { size: 10, element_size: 10, memory_size: MemorySize::Bcd, element_type: MemorySize::Bcd, is_signed: true, is_broadcast: false },
64		MemorySizeInfo { size: 64, element_size: 64, memory_size: MemorySize::Tilecfg, element_type: MemorySize::Tilecfg, is_signed: false, is_broadcast: false },
65		MemorySizeInfo { size: 0, element_size: 0, memory_size: MemorySize::Tile, element_type: MemorySize::Tile, is_signed: false, is_broadcast: false },
66		MemorySizeInfo { size: 10, element_size: 10, memory_size: MemorySize::SegmentDescSelector, element_type: MemorySize::SegmentDescSelector, is_signed: false, is_broadcast: false },
67		MemorySizeInfo { size: 48, element_size: 48, memory_size: MemorySize::KLHandleAes128, element_type: MemorySize::KLHandleAes128, is_signed: false, is_broadcast: false },
68		MemorySizeInfo { size: 64, element_size: 64, memory_size: MemorySize::KLHandleAes256, element_type: MemorySize::KLHandleAes256, is_signed: false, is_broadcast: false },
69		MemorySizeInfo { size: 2, element_size: 1, memory_size: MemorySize::Packed16_UInt8, element_type: MemorySize::UInt8, is_signed: false, is_broadcast: false },
70		MemorySizeInfo { size: 2, element_size: 1, memory_size: MemorySize::Packed16_Int8, element_type: MemorySize::Int8, is_signed: true, is_broadcast: false },
71		MemorySizeInfo { size: 4, element_size: 1, memory_size: MemorySize::Packed32_UInt8, element_type: MemorySize::UInt8, is_signed: false, is_broadcast: false },
72		MemorySizeInfo { size: 4, element_size: 1, memory_size: MemorySize::Packed32_Int8, element_type: MemorySize::Int8, is_signed: true, is_broadcast: false },
73		MemorySizeInfo { size: 4, element_size: 2, memory_size: MemorySize::Packed32_UInt16, element_type: MemorySize::UInt16, is_signed: false, is_broadcast: false },
74		MemorySizeInfo { size: 4, element_size: 2, memory_size: MemorySize::Packed32_Int16, element_type: MemorySize::Int16, is_signed: true, is_broadcast: false },
75		MemorySizeInfo { size: 4, element_size: 2, memory_size: MemorySize::Packed32_Float16, element_type: MemorySize::Float16, is_signed: true, is_broadcast: false },
76		MemorySizeInfo { size: 4, element_size: 2, memory_size: MemorySize::Packed32_BFloat16, element_type: MemorySize::BFloat16, is_signed: true, is_broadcast: false },
77		MemorySizeInfo { size: 8, element_size: 1, memory_size: MemorySize::Packed64_UInt8, element_type: MemorySize::UInt8, is_signed: false, is_broadcast: false },
78		MemorySizeInfo { size: 8, element_size: 1, memory_size: MemorySize::Packed64_Int8, element_type: MemorySize::Int8, is_signed: true, is_broadcast: false },
79		MemorySizeInfo { size: 8, element_size: 2, memory_size: MemorySize::Packed64_UInt16, element_type: MemorySize::UInt16, is_signed: false, is_broadcast: false },
80		MemorySizeInfo { size: 8, element_size: 2, memory_size: MemorySize::Packed64_Int16, element_type: MemorySize::Int16, is_signed: true, is_broadcast: false },
81		MemorySizeInfo { size: 8, element_size: 4, memory_size: MemorySize::Packed64_UInt32, element_type: MemorySize::UInt32, is_signed: false, is_broadcast: false },
82		MemorySizeInfo { size: 8, element_size: 4, memory_size: MemorySize::Packed64_Int32, element_type: MemorySize::Int32, is_signed: true, is_broadcast: false },
83		MemorySizeInfo { size: 8, element_size: 2, memory_size: MemorySize::Packed64_Float16, element_type: MemorySize::Float16, is_signed: true, is_broadcast: false },
84		MemorySizeInfo { size: 8, element_size: 4, memory_size: MemorySize::Packed64_Float32, element_type: MemorySize::Float32, is_signed: true, is_broadcast: false },
85		MemorySizeInfo { size: 16, element_size: 1, memory_size: MemorySize::Packed128_UInt8, element_type: MemorySize::UInt8, is_signed: false, is_broadcast: false },
86		MemorySizeInfo { size: 16, element_size: 1, memory_size: MemorySize::Packed128_Int8, element_type: MemorySize::Int8, is_signed: true, is_broadcast: false },
87		MemorySizeInfo { size: 16, element_size: 2, memory_size: MemorySize::Packed128_UInt16, element_type: MemorySize::UInt16, is_signed: false, is_broadcast: false },
88		MemorySizeInfo { size: 16, element_size: 2, memory_size: MemorySize::Packed128_Int16, element_type: MemorySize::Int16, is_signed: true, is_broadcast: false },
89		MemorySizeInfo { size: 16, element_size: 4, memory_size: MemorySize::Packed128_UInt32, element_type: MemorySize::UInt32, is_signed: false, is_broadcast: false },
90		MemorySizeInfo { size: 16, element_size: 4, memory_size: MemorySize::Packed128_Int32, element_type: MemorySize::Int32, is_signed: true, is_broadcast: false },
91		MemorySizeInfo { size: 16, element_size: 8, memory_size: MemorySize::Packed128_UInt52, element_type: MemorySize::UInt52, is_signed: false, is_broadcast: false },
92		MemorySizeInfo { size: 16, element_size: 8, memory_size: MemorySize::Packed128_UInt64, element_type: MemorySize::UInt64, is_signed: false, is_broadcast: false },
93		MemorySizeInfo { size: 16, element_size: 8, memory_size: MemorySize::Packed128_Int64, element_type: MemorySize::Int64, is_signed: true, is_broadcast: false },
94		MemorySizeInfo { size: 16, element_size: 2, memory_size: MemorySize::Packed128_Float16, element_type: MemorySize::Float16, is_signed: true, is_broadcast: false },
95		MemorySizeInfo { size: 16, element_size: 4, memory_size: MemorySize::Packed128_Float32, element_type: MemorySize::Float32, is_signed: true, is_broadcast: false },
96		MemorySizeInfo { size: 16, element_size: 8, memory_size: MemorySize::Packed128_Float64, element_type: MemorySize::Float64, is_signed: true, is_broadcast: false },
97		MemorySizeInfo { size: 16, element_size: 2, memory_size: MemorySize::Packed128_BFloat16, element_type: MemorySize::BFloat16, is_signed: true, is_broadcast: false },
98		MemorySizeInfo { size: 16, element_size: 4, memory_size: MemorySize::Packed128_2xFloat16, element_type: MemorySize::Packed32_Float16, is_signed: true, is_broadcast: false },
99		MemorySizeInfo { size: 16, element_size: 4, memory_size: MemorySize::Packed128_2xBFloat16, element_type: MemorySize::Packed32_BFloat16, is_signed: true, is_broadcast: false },
100		MemorySizeInfo { size: 32, element_size: 1, memory_size: MemorySize::Packed256_UInt8, element_type: MemorySize::UInt8, is_signed: false, is_broadcast: false },
101		MemorySizeInfo { size: 32, element_size: 1, memory_size: MemorySize::Packed256_Int8, element_type: MemorySize::Int8, is_signed: true, is_broadcast: false },
102		MemorySizeInfo { size: 32, element_size: 2, memory_size: MemorySize::Packed256_UInt16, element_type: MemorySize::UInt16, is_signed: false, is_broadcast: false },
103		MemorySizeInfo { size: 32, element_size: 2, memory_size: MemorySize::Packed256_Int16, element_type: MemorySize::Int16, is_signed: true, is_broadcast: false },
104		MemorySizeInfo { size: 32, element_size: 4, memory_size: MemorySize::Packed256_UInt32, element_type: MemorySize::UInt32, is_signed: false, is_broadcast: false },
105		MemorySizeInfo { size: 32, element_size: 4, memory_size: MemorySize::Packed256_Int32, element_type: MemorySize::Int32, is_signed: true, is_broadcast: false },
106		MemorySizeInfo { size: 32, element_size: 8, memory_size: MemorySize::Packed256_UInt52, element_type: MemorySize::UInt52, is_signed: false, is_broadcast: false },
107		MemorySizeInfo { size: 32, element_size: 8, memory_size: MemorySize::Packed256_UInt64, element_type: MemorySize::UInt64, is_signed: false, is_broadcast: false },
108		MemorySizeInfo { size: 32, element_size: 8, memory_size: MemorySize::Packed256_Int64, element_type: MemorySize::Int64, is_signed: true, is_broadcast: false },
109		MemorySizeInfo { size: 32, element_size: 16, memory_size: MemorySize::Packed256_UInt128, element_type: MemorySize::UInt128, is_signed: false, is_broadcast: false },
110		MemorySizeInfo { size: 32, element_size: 16, memory_size: MemorySize::Packed256_Int128, element_type: MemorySize::Int128, is_signed: true, is_broadcast: false },
111		MemorySizeInfo { size: 32, element_size: 2, memory_size: MemorySize::Packed256_Float16, element_type: MemorySize::Float16, is_signed: true, is_broadcast: false },
112		MemorySizeInfo { size: 32, element_size: 4, memory_size: MemorySize::Packed256_Float32, element_type: MemorySize::Float32, is_signed: true, is_broadcast: false },
113		MemorySizeInfo { size: 32, element_size: 8, memory_size: MemorySize::Packed256_Float64, element_type: MemorySize::Float64, is_signed: true, is_broadcast: false },
114		MemorySizeInfo { size: 32, element_size: 16, memory_size: MemorySize::Packed256_Float128, element_type: MemorySize::Float128, is_signed: true, is_broadcast: false },
115		MemorySizeInfo { size: 32, element_size: 2, memory_size: MemorySize::Packed256_BFloat16, element_type: MemorySize::BFloat16, is_signed: true, is_broadcast: false },
116		MemorySizeInfo { size: 32, element_size: 4, memory_size: MemorySize::Packed256_2xFloat16, element_type: MemorySize::Packed32_Float16, is_signed: true, is_broadcast: false },
117		MemorySizeInfo { size: 32, element_size: 4, memory_size: MemorySize::Packed256_2xBFloat16, element_type: MemorySize::Packed32_BFloat16, is_signed: true, is_broadcast: false },
118		MemorySizeInfo { size: 64, element_size: 1, memory_size: MemorySize::Packed512_UInt8, element_type: MemorySize::UInt8, is_signed: false, is_broadcast: false },
119		MemorySizeInfo { size: 64, element_size: 1, memory_size: MemorySize::Packed512_Int8, element_type: MemorySize::Int8, is_signed: true, is_broadcast: false },
120		MemorySizeInfo { size: 64, element_size: 2, memory_size: MemorySize::Packed512_UInt16, element_type: MemorySize::UInt16, is_signed: false, is_broadcast: false },
121		MemorySizeInfo { size: 64, element_size: 2, memory_size: MemorySize::Packed512_Int16, element_type: MemorySize::Int16, is_signed: true, is_broadcast: false },
122		MemorySizeInfo { size: 64, element_size: 4, memory_size: MemorySize::Packed512_UInt32, element_type: MemorySize::UInt32, is_signed: false, is_broadcast: false },
123		MemorySizeInfo { size: 64, element_size: 4, memory_size: MemorySize::Packed512_Int32, element_type: MemorySize::Int32, is_signed: true, is_broadcast: false },
124		MemorySizeInfo { size: 64, element_size: 8, memory_size: MemorySize::Packed512_UInt52, element_type: MemorySize::UInt52, is_signed: false, is_broadcast: false },
125		MemorySizeInfo { size: 64, element_size: 8, memory_size: MemorySize::Packed512_UInt64, element_type: MemorySize::UInt64, is_signed: false, is_broadcast: false },
126		MemorySizeInfo { size: 64, element_size: 8, memory_size: MemorySize::Packed512_Int64, element_type: MemorySize::Int64, is_signed: true, is_broadcast: false },
127		MemorySizeInfo { size: 64, element_size: 16, memory_size: MemorySize::Packed512_UInt128, element_type: MemorySize::UInt128, is_signed: false, is_broadcast: false },
128		MemorySizeInfo { size: 64, element_size: 2, memory_size: MemorySize::Packed512_Float16, element_type: MemorySize::Float16, is_signed: true, is_broadcast: false },
129		MemorySizeInfo { size: 64, element_size: 4, memory_size: MemorySize::Packed512_Float32, element_type: MemorySize::Float32, is_signed: true, is_broadcast: false },
130		MemorySizeInfo { size: 64, element_size: 8, memory_size: MemorySize::Packed512_Float64, element_type: MemorySize::Float64, is_signed: true, is_broadcast: false },
131		MemorySizeInfo { size: 64, element_size: 4, memory_size: MemorySize::Packed512_2xFloat16, element_type: MemorySize::Packed32_Float16, is_signed: true, is_broadcast: false },
132		MemorySizeInfo { size: 64, element_size: 4, memory_size: MemorySize::Packed512_2xBFloat16, element_type: MemorySize::Packed32_BFloat16, is_signed: true, is_broadcast: false },
133		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Broadcast32_Float16, element_type: MemorySize::Float16, is_signed: true, is_broadcast: true },
134		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast64_UInt32, element_type: MemorySize::UInt32, is_signed: false, is_broadcast: true },
135		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast64_Int32, element_type: MemorySize::Int32, is_signed: true, is_broadcast: true },
136		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Broadcast64_Float16, element_type: MemorySize::Float16, is_signed: true, is_broadcast: true },
137		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast64_Float32, element_type: MemorySize::Float32, is_signed: true, is_broadcast: true },
138		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Broadcast128_Int16, element_type: MemorySize::Int16, is_signed: false, is_broadcast: true },
139		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Broadcast128_UInt16, element_type: MemorySize::UInt16, is_signed: false, is_broadcast: true },
140		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast128_UInt32, element_type: MemorySize::UInt32, is_signed: false, is_broadcast: true },
141		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast128_Int32, element_type: MemorySize::Int32, is_signed: true, is_broadcast: true },
142		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast128_UInt52, element_type: MemorySize::UInt52, is_signed: false, is_broadcast: true },
143		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast128_UInt64, element_type: MemorySize::UInt64, is_signed: false, is_broadcast: true },
144		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast128_Int64, element_type: MemorySize::Int64, is_signed: true, is_broadcast: true },
145		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Broadcast128_Float16, element_type: MemorySize::Float16, is_signed: true, is_broadcast: true },
146		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast128_Float32, element_type: MemorySize::Float32, is_signed: true, is_broadcast: true },
147		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast128_Float64, element_type: MemorySize::Float64, is_signed: true, is_broadcast: true },
148		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast128_2xInt16, element_type: MemorySize::Packed32_Int16, is_signed: true, is_broadcast: true },
149		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast128_2xInt32, element_type: MemorySize::Packed64_Int32, is_signed: true, is_broadcast: true },
150		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast128_2xUInt32, element_type: MemorySize::Packed64_UInt32, is_signed: false, is_broadcast: true },
151		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast128_2xFloat16, element_type: MemorySize::Packed32_Float16, is_signed: true, is_broadcast: true },
152		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast128_2xBFloat16, element_type: MemorySize::Packed32_BFloat16, is_signed: true, is_broadcast: true },
153		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Broadcast256_Int16, element_type: MemorySize::Int16, is_signed: false, is_broadcast: true },
154		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Broadcast256_UInt16, element_type: MemorySize::UInt16, is_signed: false, is_broadcast: true },
155		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast256_UInt32, element_type: MemorySize::UInt32, is_signed: false, is_broadcast: true },
156		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast256_Int32, element_type: MemorySize::Int32, is_signed: true, is_broadcast: true },
157		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast256_UInt52, element_type: MemorySize::UInt52, is_signed: false, is_broadcast: true },
158		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast256_UInt64, element_type: MemorySize::UInt64, is_signed: false, is_broadcast: true },
159		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast256_Int64, element_type: MemorySize::Int64, is_signed: true, is_broadcast: true },
160		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Broadcast256_Float16, element_type: MemorySize::Float16, is_signed: true, is_broadcast: true },
161		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast256_Float32, element_type: MemorySize::Float32, is_signed: true, is_broadcast: true },
162		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast256_Float64, element_type: MemorySize::Float64, is_signed: true, is_broadcast: true },
163		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast256_2xInt16, element_type: MemorySize::Packed32_Int16, is_signed: true, is_broadcast: true },
164		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast256_2xInt32, element_type: MemorySize::Packed64_Int32, is_signed: true, is_broadcast: true },
165		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast256_2xUInt32, element_type: MemorySize::Packed64_UInt32, is_signed: false, is_broadcast: true },
166		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast256_2xFloat16, element_type: MemorySize::Packed32_Float16, is_signed: true, is_broadcast: true },
167		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast256_2xBFloat16, element_type: MemorySize::Packed32_BFloat16, is_signed: true, is_broadcast: true },
168		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Broadcast512_Int16, element_type: MemorySize::Int16, is_signed: false, is_broadcast: true },
169		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Broadcast512_UInt16, element_type: MemorySize::UInt16, is_signed: false, is_broadcast: true },
170		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast512_UInt32, element_type: MemorySize::UInt32, is_signed: false, is_broadcast: true },
171		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast512_Int32, element_type: MemorySize::Int32, is_signed: true, is_broadcast: true },
172		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast512_UInt52, element_type: MemorySize::UInt52, is_signed: false, is_broadcast: true },
173		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast512_UInt64, element_type: MemorySize::UInt64, is_signed: false, is_broadcast: true },
174		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast512_Int64, element_type: MemorySize::Int64, is_signed: true, is_broadcast: true },
175		MemorySizeInfo { size: 2, element_size: 2, memory_size: MemorySize::Broadcast512_Float16, element_type: MemorySize::Float16, is_signed: true, is_broadcast: true },
176		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast512_Float32, element_type: MemorySize::Float32, is_signed: true, is_broadcast: true },
177		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast512_Float64, element_type: MemorySize::Float64, is_signed: true, is_broadcast: true },
178		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast512_2xFloat16, element_type: MemorySize::Packed32_Float16, is_signed: true, is_broadcast: true },
179		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast512_2xInt16, element_type: MemorySize::Packed32_Int16, is_signed: true, is_broadcast: true },
180		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast512_2xUInt32, element_type: MemorySize::Packed64_UInt32, is_signed: false, is_broadcast: true },
181		MemorySizeInfo { size: 8, element_size: 8, memory_size: MemorySize::Broadcast512_2xInt32, element_type: MemorySize::Packed64_Int32, is_signed: true, is_broadcast: true },
182		MemorySizeInfo { size: 4, element_size: 4, memory_size: MemorySize::Broadcast512_2xBFloat16, element_type: MemorySize::Packed32_BFloat16, is_signed: true, is_broadcast: true },
183		// GENERATOR-END: MemorySizeInfoTable
184	];
185
186	/// [`MemorySize`] information
187	///
188	/// [`MemorySize`]: enum.MemorySize.html
189	#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
190	pub struct MemorySizeInfo {
191		size: u16,
192		element_size: u16,
193		memory_size: MemorySize,
194		element_type: MemorySize,
195		// Use flags if more booleans are needed
196		is_signed: bool,
197		is_broadcast: bool,
198	}
199
200	impl MemorySizeInfo {
201		/// Gets the [`MemorySize`] value
202		///
203		/// [`MemorySize`]: enum.MemorySize.html
204		///
205		/// # Examples
206		///
207		/// ```
208		/// use iced_x86::*;
209		/// let info = MemorySize::Packed256_UInt16.info();
210		/// assert_eq!(info.memory_size(), MemorySize::Packed256_UInt16);
211		/// ```
212		#[must_use]
213		#[inline]
214		pub const fn memory_size(&self) -> MemorySize {
215			self.memory_size
216		}
217
218		/// Gets the size in bytes of the memory location or 0 if it's not accessed or unknown
219		///
220		/// # Examples
221		///
222		/// ```
223		/// use iced_x86::*;
224		/// let info = MemorySize::UInt32.info();
225		/// assert_eq!(info.size(), 4);
226		/// let info = MemorySize::Packed256_UInt16.info();
227		/// assert_eq!(info.size(), 32);
228		/// let info = MemorySize::Broadcast512_UInt64.info();
229		/// assert_eq!(info.size(), 8);
230		/// ```
231		#[must_use]
232		#[inline]
233		pub const fn size(&self) -> usize {
234			self.size as usize
235		}
236
237		/// Gets the size in bytes of the packed element. If it's not a packed data type, it's equal to [`size()`].
238		///
239		/// [`size()`]: #method.size
240		///
241		/// # Examples
242		///
243		/// ```
244		/// use iced_x86::*;
245		/// let info = MemorySize::UInt32.info();
246		/// assert_eq!(info.element_size(), 4);
247		/// let info = MemorySize::Packed256_UInt16.info();
248		/// assert_eq!(info.element_size(), 2);
249		/// let info = MemorySize::Broadcast512_UInt64.info();
250		/// assert_eq!(info.element_size(), 8);
251		/// ```
252		#[must_use]
253		#[inline]
254		pub const fn element_size(&self) -> usize {
255			self.element_size as usize
256		}
257
258		/// Gets the element type if it's packed data or the type itself if it's not packed data
259		///
260		/// # Examples
261		///
262		/// ```
263		/// use iced_x86::*;
264		/// let info = MemorySize::UInt32.info();
265		/// assert_eq!(info.element_type(), MemorySize::UInt32);
266		/// let info = MemorySize::Packed256_UInt16.info();
267		/// assert_eq!(info.element_type(), MemorySize::UInt16);
268		/// let info = MemorySize::Broadcast512_UInt64.info();
269		/// assert_eq!(info.element_type(), MemorySize::UInt64);
270		/// ```
271		#[must_use]
272		#[inline]
273		pub const fn element_type(&self) -> MemorySize {
274			self.element_type
275		}
276
277		/// Gets the element type if it's packed data or the type itself if it's not packed data
278		///
279		/// # Examples
280		///
281		/// ```
282		/// use iced_x86::*;
283		/// let info = MemorySize::UInt32.info().element_type_info();
284		/// assert_eq!(info.memory_size(), MemorySize::UInt32);
285		/// let info = MemorySize::Packed256_UInt16.info().element_type_info();
286		/// assert_eq!(info.memory_size(), MemorySize::UInt16);
287		/// let info = MemorySize::Broadcast512_UInt64.info().element_type_info();
288		/// assert_eq!(info.memory_size(), MemorySize::UInt64);
289		/// ```
290		#[must_use]
291		#[inline]
292		pub fn element_type_info(&self) -> &'static Self {
293			self.element_type().info()
294		}
295
296		/// `true` if it's signed data (signed integer or a floating point value)
297		///
298		/// # Examples
299		///
300		/// ```
301		/// use iced_x86::*;
302		/// let info = MemorySize::UInt32.info();
303		/// assert!(!info.is_signed());
304		/// let info = MemorySize::Int32.info();
305		/// assert!(info.is_signed());
306		/// let info = MemorySize::Float64.info();
307		/// assert!(info.is_signed());
308		/// ```
309		#[must_use]
310		#[inline]
311		pub const fn is_signed(&self) -> bool {
312			self.is_signed
313		}
314
315		/// `true` if it's a broadcast memory type
316		///
317		/// # Examples
318		///
319		/// ```
320		/// use iced_x86::*;
321		/// let info = MemorySize::UInt32.info();
322		/// assert!(!info.is_broadcast());
323		/// let info = MemorySize::Packed256_UInt16.info();
324		/// assert!(!info.is_broadcast());
325		/// let info = MemorySize::Broadcast512_UInt64.info();
326		/// assert!(info.is_broadcast());
327		/// ```
328		#[must_use]
329		#[inline]
330		pub const fn is_broadcast(&self) -> bool {
331			self.is_broadcast
332		}
333
334		/// `true` if this is a packed data type, eg. [`MemorySize::Packed128_Float32`]. See also [`element_count()`]
335		///
336		/// [`MemorySize::Packed128_Float32`]: #variant.Packed128_Float32
337		/// [`element_count()`]: #method.element_count
338		///
339		/// # Examples
340		///
341		/// ```
342		/// use iced_x86::*;
343		/// let info = MemorySize::UInt32.info();
344		/// assert!(!info.is_packed());
345		/// let info = MemorySize::Packed256_UInt16.info();
346		/// assert!(info.is_packed());
347		/// let info = MemorySize::Broadcast512_UInt64.info();
348		/// assert!(!info.is_packed());
349		/// ```
350		#[must_use]
351		#[inline]
352		pub const fn is_packed(&self) -> bool {
353			self.element_size < self.size
354		}
355
356		/// Gets the number of elements in the packed data type or `1` if it's not packed data ([`is_packed()`])
357		///
358		/// [`is_packed()`]: #method.is_packed
359		///
360		/// # Examples
361		///
362		/// ```
363		/// use iced_x86::*;
364		/// let info = MemorySize::UInt32.info();
365		/// assert_eq!(info.element_count(), 1);
366		/// let info = MemorySize::Packed256_UInt16.info();
367		/// assert_eq!(info.element_count(), 16);
368		/// let info = MemorySize::Broadcast512_UInt64.info();
369		/// assert_eq!(info.element_count(), 1);
370		/// ```
371		#[must_use]
372		#[inline]
373		pub const fn element_count(&self) -> usize {
374			// element_size can be 0 so we don't divide by it if es == s
375			if self.element_size == self.size {
376				1
377			} else {
378				self.size as usize / self.element_size as usize
379			}
380		}
381	}
382}
383
384// GENERATOR-BEGIN: MemorySize
385// ⚠️This was generated by GENERATOR!🦹‍♂️
386/// Size of a memory reference
387#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
388#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
389#[allow(non_camel_case_types)]
390pub enum MemorySize {
391	/// Unknown size or the instruction doesn't reference any memory (eg. `LEA`)
392	Unknown = 0,
393	/// Memory location contains a `u8`
394	UInt8 = 1,
395	/// Memory location contains a `u16`
396	UInt16 = 2,
397	/// Memory location contains a `u32`
398	UInt32 = 3,
399	/// Memory location contains a `u52`
400	UInt52 = 4,
401	/// Memory location contains a `u64`
402	UInt64 = 5,
403	/// Memory location contains a `u128`
404	UInt128 = 6,
405	/// Memory location contains a `u256`
406	UInt256 = 7,
407	/// Memory location contains a `u512`
408	UInt512 = 8,
409	/// Memory location contains a `i8`
410	Int8 = 9,
411	/// Memory location contains a `i16`
412	Int16 = 10,
413	/// Memory location contains a `i32`
414	Int32 = 11,
415	/// Memory location contains a `i64`
416	Int64 = 12,
417	/// Memory location contains a `i128`
418	Int128 = 13,
419	/// Memory location contains a `i256`
420	Int256 = 14,
421	/// Memory location contains a `i512`
422	Int512 = 15,
423	/// Memory location contains a seg:ptr pair, `u16` (offset) + `u16` (segment/selector)
424	SegPtr16 = 16,
425	/// Memory location contains a seg:ptr pair, `u32` (offset) + `u16` (segment/selector)
426	SegPtr32 = 17,
427	/// Memory location contains a seg:ptr pair, `u64` (offset) + `u16` (segment/selector)
428	SegPtr64 = 18,
429	/// Memory location contains a 16-bit offset (`JMP/CALL WORD PTR [mem]`)
430	WordOffset = 19,
431	/// Memory location contains a 32-bit offset (`JMP/CALL DWORD PTR [mem]`)
432	DwordOffset = 20,
433	/// Memory location contains a 64-bit offset (`JMP/CALL QWORD PTR [mem]`)
434	QwordOffset = 21,
435	/// Memory location contains two `u16`s (16-bit `BOUND`)
436	Bound16_WordWord = 22,
437	/// Memory location contains two `u32`s (32-bit `BOUND`)
438	Bound32_DwordDword = 23,
439	/// 32-bit `BNDMOV`, 2 x `u32`
440	Bnd32 = 24,
441	/// 64-bit `BNDMOV`, 2 x `u64`
442	Bnd64 = 25,
443	/// Memory location contains a 16-bit limit and a 32-bit address (eg. `LGDTW`, `LGDTD`)
444	Fword6 = 26,
445	/// Memory location contains a 16-bit limit and a 64-bit address (eg. `LGDTQ`)
446	Fword10 = 27,
447	/// Memory location contains a `f16`
448	Float16 = 28,
449	/// Memory location contains a `f32`
450	Float32 = 29,
451	/// Memory location contains a `f64`
452	Float64 = 30,
453	/// Memory location contains a `f80`
454	Float80 = 31,
455	/// Memory location contains a `f128`
456	Float128 = 32,
457	/// Memory location contains a `bfloat16`
458	BFloat16 = 33,
459	/// Memory location contains a 14-byte FPU environment (16-bit `FLDENV`/`FSTENV`)
460	FpuEnv14 = 34,
461	/// Memory location contains a 28-byte FPU environment (32/64-bit `FLDENV`/`FSTENV`)
462	FpuEnv28 = 35,
463	/// Memory location contains a 94-byte FPU environment (16-bit `FSAVE`/`FRSTOR`)
464	FpuState94 = 36,
465	/// Memory location contains a 108-byte FPU environment (32/64-bit `FSAVE`/`FRSTOR`)
466	FpuState108 = 37,
467	/// Memory location contains 512-bytes of `FXSAVE`/`FXRSTOR` data
468	Fxsave_512Byte = 38,
469	/// Memory location contains 512-bytes of `FXSAVE64`/`FXRSTOR64` data
470	Fxsave64_512Byte = 39,
471	/// 32-bit `XSAVE` area
472	Xsave = 40,
473	/// 64-bit `XSAVE` area
474	Xsave64 = 41,
475	/// Memory location contains a 10-byte `bcd` value (`FBLD`/`FBSTP`)
476	Bcd = 42,
477	/// 64-bit location: TILECFG (`LDTILECFG`/`STTILECFG`)
478	Tilecfg = 43,
479	/// Tile data
480	Tile = 44,
481	/// 80-bit segment descriptor and selector: 0-7 = descriptor, 8-9 = selector
482	SegmentDescSelector = 45,
483	/// 384-bit AES 128 handle (Key Locker)
484	KLHandleAes128 = 46,
485	/// 512-bit AES 256 handle (Key Locker)
486	KLHandleAes256 = 47,
487	/// 16-bit location: 2 x `u8`
488	Packed16_UInt8 = 48,
489	/// 16-bit location: 2 x `i8`
490	Packed16_Int8 = 49,
491	/// 32-bit location: 4 x `u8`
492	Packed32_UInt8 = 50,
493	/// 32-bit location: 4 x `i8`
494	Packed32_Int8 = 51,
495	/// 32-bit location: 2 x `u16`
496	Packed32_UInt16 = 52,
497	/// 32-bit location: 2 x `i16`
498	Packed32_Int16 = 53,
499	/// 32-bit location: 2 x `f16`
500	Packed32_Float16 = 54,
501	/// 32-bit location: 2 x `bfloat16`
502	Packed32_BFloat16 = 55,
503	/// 64-bit location: 8 x `u8`
504	Packed64_UInt8 = 56,
505	/// 64-bit location: 8 x `i8`
506	Packed64_Int8 = 57,
507	/// 64-bit location: 4 x `u16`
508	Packed64_UInt16 = 58,
509	/// 64-bit location: 4 x `i16`
510	Packed64_Int16 = 59,
511	/// 64-bit location: 2 x `u32`
512	Packed64_UInt32 = 60,
513	/// 64-bit location: 2 x `i32`
514	Packed64_Int32 = 61,
515	/// 64-bit location: 4 x `f16`
516	Packed64_Float16 = 62,
517	/// 64-bit location: 2 x `f32`
518	Packed64_Float32 = 63,
519	/// 128-bit location: 16 x `u8`
520	Packed128_UInt8 = 64,
521	/// 128-bit location: 16 x `i8`
522	Packed128_Int8 = 65,
523	/// 128-bit location: 8 x `u16`
524	Packed128_UInt16 = 66,
525	/// 128-bit location: 8 x `i16`
526	Packed128_Int16 = 67,
527	/// 128-bit location: 4 x `u32`
528	Packed128_UInt32 = 68,
529	/// 128-bit location: 4 x `i32`
530	Packed128_Int32 = 69,
531	/// 128-bit location: 2 x `u52`
532	Packed128_UInt52 = 70,
533	/// 128-bit location: 2 x `u64`
534	Packed128_UInt64 = 71,
535	/// 128-bit location: 2 x `i64`
536	Packed128_Int64 = 72,
537	/// 128-bit location: 8 x `f16`
538	Packed128_Float16 = 73,
539	/// 128-bit location: 4 x `f32`
540	Packed128_Float32 = 74,
541	/// 128-bit location: 2 x `f64`
542	Packed128_Float64 = 75,
543	/// 128-bit location: 8 x `bfloat16`
544	Packed128_BFloat16 = 76,
545	/// 128-bit location: 4 x (2 x `f16`)
546	Packed128_2xFloat16 = 77,
547	/// 128-bit location: 4 x (2 x `bfloat16`)
548	Packed128_2xBFloat16 = 78,
549	/// 256-bit location: 32 x `u8`
550	Packed256_UInt8 = 79,
551	/// 256-bit location: 32 x `i8`
552	Packed256_Int8 = 80,
553	/// 256-bit location: 16 x `u16`
554	Packed256_UInt16 = 81,
555	/// 256-bit location: 16 x `i16`
556	Packed256_Int16 = 82,
557	/// 256-bit location: 8 x `u32`
558	Packed256_UInt32 = 83,
559	/// 256-bit location: 8 x `i32`
560	Packed256_Int32 = 84,
561	/// 256-bit location: 4 x `u52`
562	Packed256_UInt52 = 85,
563	/// 256-bit location: 4 x `u64`
564	Packed256_UInt64 = 86,
565	/// 256-bit location: 4 x `i64`
566	Packed256_Int64 = 87,
567	/// 256-bit location: 2 x `u128`
568	Packed256_UInt128 = 88,
569	/// 256-bit location: 2 x `i128`
570	Packed256_Int128 = 89,
571	/// 256-bit location: 16 x `f16`
572	Packed256_Float16 = 90,
573	/// 256-bit location: 8 x `f32`
574	Packed256_Float32 = 91,
575	/// 256-bit location: 4 x `f64`
576	Packed256_Float64 = 92,
577	/// 256-bit location: 2 x `f128`
578	Packed256_Float128 = 93,
579	/// 256-bit location: 16 x `bfloat16`
580	Packed256_BFloat16 = 94,
581	/// 256-bit location: 8 x (2 x `f16`)
582	Packed256_2xFloat16 = 95,
583	/// 256-bit location: 8 x (2 x `bfloat16`)
584	Packed256_2xBFloat16 = 96,
585	/// 512-bit location: 64 x `u8`
586	Packed512_UInt8 = 97,
587	/// 512-bit location: 64 x `i8`
588	Packed512_Int8 = 98,
589	/// 512-bit location: 32 x `u16`
590	Packed512_UInt16 = 99,
591	/// 512-bit location: 32 x `i16`
592	Packed512_Int16 = 100,
593	/// 512-bit location: 16 x `u32`
594	Packed512_UInt32 = 101,
595	/// 512-bit location: 16 x `i32`
596	Packed512_Int32 = 102,
597	/// 512-bit location: 8 x `u52`
598	Packed512_UInt52 = 103,
599	/// 512-bit location: 8 x `u64`
600	Packed512_UInt64 = 104,
601	/// 512-bit location: 8 x `i64`
602	Packed512_Int64 = 105,
603	/// 256-bit location: 4 x `u128`
604	Packed512_UInt128 = 106,
605	/// 512-bit location: 32 x `f16`
606	Packed512_Float16 = 107,
607	/// 512-bit location: 16 x `f32`
608	Packed512_Float32 = 108,
609	/// 512-bit location: 8 x `f64`
610	Packed512_Float64 = 109,
611	/// 512-bit location: 16 x (2 x `f16`)
612	Packed512_2xFloat16 = 110,
613	/// 512-bit location: 16 x (2 x `bfloat16`)
614	Packed512_2xBFloat16 = 111,
615	/// Broadcast `f16` to 32-bits
616	Broadcast32_Float16 = 112,
617	/// Broadcast `u32` to 64-bits
618	Broadcast64_UInt32 = 113,
619	/// Broadcast `i32` to 64-bits
620	Broadcast64_Int32 = 114,
621	/// Broadcast `f16` to 64-bits
622	Broadcast64_Float16 = 115,
623	/// Broadcast `f32` to 64-bits
624	Broadcast64_Float32 = 116,
625	/// Broadcast `i16` to 128-bits
626	Broadcast128_Int16 = 117,
627	/// Broadcast `u16` to 128-bits
628	Broadcast128_UInt16 = 118,
629	/// Broadcast `u32` to 128-bits
630	Broadcast128_UInt32 = 119,
631	/// Broadcast `i32` to 128-bits
632	Broadcast128_Int32 = 120,
633	/// Broadcast `u52` to 128-bits
634	Broadcast128_UInt52 = 121,
635	/// Broadcast `u64` to 128-bits
636	Broadcast128_UInt64 = 122,
637	/// Broadcast `i64` to 128-bits
638	Broadcast128_Int64 = 123,
639	/// Broadcast `f16` to 128-bits
640	Broadcast128_Float16 = 124,
641	/// Broadcast `f32` to 128-bits
642	Broadcast128_Float32 = 125,
643	/// Broadcast `f64` to 128-bits
644	Broadcast128_Float64 = 126,
645	/// Broadcast 2 x `i16` to 128-bits
646	Broadcast128_2xInt16 = 127,
647	/// Broadcast 2 x `i32` to 128-bits
648	Broadcast128_2xInt32 = 128,
649	/// Broadcast 2 x `u32` to 128-bits
650	Broadcast128_2xUInt32 = 129,
651	/// Broadcast 2 x `f16` to 128-bits
652	Broadcast128_2xFloat16 = 130,
653	/// Broadcast 2 x `bfloat16` to 128-bits
654	Broadcast128_2xBFloat16 = 131,
655	/// Broadcast `i16` to 256-bits
656	Broadcast256_Int16 = 132,
657	/// Broadcast `u16` to 256-bits
658	Broadcast256_UInt16 = 133,
659	/// Broadcast `u32` to 256-bits
660	Broadcast256_UInt32 = 134,
661	/// Broadcast `i32` to 256-bits
662	Broadcast256_Int32 = 135,
663	/// Broadcast `u52` to 256-bits
664	Broadcast256_UInt52 = 136,
665	/// Broadcast `u64` to 256-bits
666	Broadcast256_UInt64 = 137,
667	/// Broadcast `i64` to 256-bits
668	Broadcast256_Int64 = 138,
669	/// Broadcast `f16` to 256-bits
670	Broadcast256_Float16 = 139,
671	/// Broadcast `f32` to 256-bits
672	Broadcast256_Float32 = 140,
673	/// Broadcast `f64` to 256-bits
674	Broadcast256_Float64 = 141,
675	/// Broadcast 2 x `i16` to 256-bits
676	Broadcast256_2xInt16 = 142,
677	/// Broadcast 2 x `i32` to 256-bits
678	Broadcast256_2xInt32 = 143,
679	/// Broadcast 2 x `u32` to 256-bits
680	Broadcast256_2xUInt32 = 144,
681	/// Broadcast 2 x `f16` to 256-bits
682	Broadcast256_2xFloat16 = 145,
683	/// Broadcast 2 x `bfloat16` to 256-bits
684	Broadcast256_2xBFloat16 = 146,
685	/// Broadcast `i16` to 512-bits
686	Broadcast512_Int16 = 147,
687	/// Broadcast `u16` to 512-bits
688	Broadcast512_UInt16 = 148,
689	/// Broadcast `u32` to 512-bits
690	Broadcast512_UInt32 = 149,
691	/// Broadcast `i32` to 512-bits
692	Broadcast512_Int32 = 150,
693	/// Broadcast `u52` to 512-bits
694	Broadcast512_UInt52 = 151,
695	/// Broadcast `u64` to 512-bits
696	Broadcast512_UInt64 = 152,
697	/// Broadcast `i64` to 512-bits
698	Broadcast512_Int64 = 153,
699	/// Broadcast `f16` to 512-bits
700	Broadcast512_Float16 = 154,
701	/// Broadcast `f32` to 512-bits
702	Broadcast512_Float32 = 155,
703	/// Broadcast `f64` to 512-bits
704	Broadcast512_Float64 = 156,
705	/// Broadcast 2 x `f16` to 512-bits
706	Broadcast512_2xFloat16 = 157,
707	/// Broadcast 2 x `i16` to 512-bits
708	Broadcast512_2xInt16 = 158,
709	/// Broadcast 2 x `u32` to 512-bits
710	Broadcast512_2xUInt32 = 159,
711	/// Broadcast 2 x `i32` to 512-bits
712	Broadcast512_2xInt32 = 160,
713	/// Broadcast 2 x `bfloat16` to 512-bits
714	Broadcast512_2xBFloat16 = 161,
715}
716#[rustfmt::skip]
717static GEN_DEBUG_MEMORY_SIZE: [&str; 162] = [
718	"Unknown",
719	"UInt8",
720	"UInt16",
721	"UInt32",
722	"UInt52",
723	"UInt64",
724	"UInt128",
725	"UInt256",
726	"UInt512",
727	"Int8",
728	"Int16",
729	"Int32",
730	"Int64",
731	"Int128",
732	"Int256",
733	"Int512",
734	"SegPtr16",
735	"SegPtr32",
736	"SegPtr64",
737	"WordOffset",
738	"DwordOffset",
739	"QwordOffset",
740	"Bound16_WordWord",
741	"Bound32_DwordDword",
742	"Bnd32",
743	"Bnd64",
744	"Fword6",
745	"Fword10",
746	"Float16",
747	"Float32",
748	"Float64",
749	"Float80",
750	"Float128",
751	"BFloat16",
752	"FpuEnv14",
753	"FpuEnv28",
754	"FpuState94",
755	"FpuState108",
756	"Fxsave_512Byte",
757	"Fxsave64_512Byte",
758	"Xsave",
759	"Xsave64",
760	"Bcd",
761	"Tilecfg",
762	"Tile",
763	"SegmentDescSelector",
764	"KLHandleAes128",
765	"KLHandleAes256",
766	"Packed16_UInt8",
767	"Packed16_Int8",
768	"Packed32_UInt8",
769	"Packed32_Int8",
770	"Packed32_UInt16",
771	"Packed32_Int16",
772	"Packed32_Float16",
773	"Packed32_BFloat16",
774	"Packed64_UInt8",
775	"Packed64_Int8",
776	"Packed64_UInt16",
777	"Packed64_Int16",
778	"Packed64_UInt32",
779	"Packed64_Int32",
780	"Packed64_Float16",
781	"Packed64_Float32",
782	"Packed128_UInt8",
783	"Packed128_Int8",
784	"Packed128_UInt16",
785	"Packed128_Int16",
786	"Packed128_UInt32",
787	"Packed128_Int32",
788	"Packed128_UInt52",
789	"Packed128_UInt64",
790	"Packed128_Int64",
791	"Packed128_Float16",
792	"Packed128_Float32",
793	"Packed128_Float64",
794	"Packed128_BFloat16",
795	"Packed128_2xFloat16",
796	"Packed128_2xBFloat16",
797	"Packed256_UInt8",
798	"Packed256_Int8",
799	"Packed256_UInt16",
800	"Packed256_Int16",
801	"Packed256_UInt32",
802	"Packed256_Int32",
803	"Packed256_UInt52",
804	"Packed256_UInt64",
805	"Packed256_Int64",
806	"Packed256_UInt128",
807	"Packed256_Int128",
808	"Packed256_Float16",
809	"Packed256_Float32",
810	"Packed256_Float64",
811	"Packed256_Float128",
812	"Packed256_BFloat16",
813	"Packed256_2xFloat16",
814	"Packed256_2xBFloat16",
815	"Packed512_UInt8",
816	"Packed512_Int8",
817	"Packed512_UInt16",
818	"Packed512_Int16",
819	"Packed512_UInt32",
820	"Packed512_Int32",
821	"Packed512_UInt52",
822	"Packed512_UInt64",
823	"Packed512_Int64",
824	"Packed512_UInt128",
825	"Packed512_Float16",
826	"Packed512_Float32",
827	"Packed512_Float64",
828	"Packed512_2xFloat16",
829	"Packed512_2xBFloat16",
830	"Broadcast32_Float16",
831	"Broadcast64_UInt32",
832	"Broadcast64_Int32",
833	"Broadcast64_Float16",
834	"Broadcast64_Float32",
835	"Broadcast128_Int16",
836	"Broadcast128_UInt16",
837	"Broadcast128_UInt32",
838	"Broadcast128_Int32",
839	"Broadcast128_UInt52",
840	"Broadcast128_UInt64",
841	"Broadcast128_Int64",
842	"Broadcast128_Float16",
843	"Broadcast128_Float32",
844	"Broadcast128_Float64",
845	"Broadcast128_2xInt16",
846	"Broadcast128_2xInt32",
847	"Broadcast128_2xUInt32",
848	"Broadcast128_2xFloat16",
849	"Broadcast128_2xBFloat16",
850	"Broadcast256_Int16",
851	"Broadcast256_UInt16",
852	"Broadcast256_UInt32",
853	"Broadcast256_Int32",
854	"Broadcast256_UInt52",
855	"Broadcast256_UInt64",
856	"Broadcast256_Int64",
857	"Broadcast256_Float16",
858	"Broadcast256_Float32",
859	"Broadcast256_Float64",
860	"Broadcast256_2xInt16",
861	"Broadcast256_2xInt32",
862	"Broadcast256_2xUInt32",
863	"Broadcast256_2xFloat16",
864	"Broadcast256_2xBFloat16",
865	"Broadcast512_Int16",
866	"Broadcast512_UInt16",
867	"Broadcast512_UInt32",
868	"Broadcast512_Int32",
869	"Broadcast512_UInt52",
870	"Broadcast512_UInt64",
871	"Broadcast512_Int64",
872	"Broadcast512_Float16",
873	"Broadcast512_Float32",
874	"Broadcast512_Float64",
875	"Broadcast512_2xFloat16",
876	"Broadcast512_2xInt16",
877	"Broadcast512_2xUInt32",
878	"Broadcast512_2xInt32",
879	"Broadcast512_2xBFloat16",
880];
881impl fmt::Debug for MemorySize {
882	#[inline]
883	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
884		write!(f, "{}", GEN_DEBUG_MEMORY_SIZE[*self as usize])
885	}
886}
887impl Default for MemorySize {
888	#[must_use]
889	#[inline]
890	fn default() -> Self {
891		MemorySize::Unknown
892	}
893}
894#[allow(non_camel_case_types)]
895#[allow(dead_code)]
896pub(crate) type MemorySizeUnderlyingType = u8;
897#[rustfmt::skip]
898impl MemorySize {
899	/// Iterates over all `MemorySize` enum values
900	#[inline]
901	pub fn values() -> impl Iterator<Item = MemorySize> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
902		// SAFETY: all values 0-max are valid enum values
903		(0..IcedConstants::MEMORY_SIZE_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, MemorySize>(x as u8) })
904	}
905}
906#[test]
907#[rustfmt::skip]
908fn test_memorysize_values() {
909	let mut iter = MemorySize::values();
910	assert_eq!(iter.size_hint(), (IcedConstants::MEMORY_SIZE_ENUM_COUNT, Some(IcedConstants::MEMORY_SIZE_ENUM_COUNT)));
911	assert_eq!(iter.len(), IcedConstants::MEMORY_SIZE_ENUM_COUNT);
912	assert!(iter.next().is_some());
913	assert_eq!(iter.size_hint(), (IcedConstants::MEMORY_SIZE_ENUM_COUNT - 1, Some(IcedConstants::MEMORY_SIZE_ENUM_COUNT - 1)));
914	assert_eq!(iter.len(), IcedConstants::MEMORY_SIZE_ENUM_COUNT - 1);
915
916	let values: Vec<MemorySize> = MemorySize::values().collect();
917	assert_eq!(values.len(), IcedConstants::MEMORY_SIZE_ENUM_COUNT);
918	for (i, value) in values.into_iter().enumerate() {
919		assert_eq!(i, value as usize);
920	}
921
922	let values1: Vec<MemorySize> = MemorySize::values().collect();
923	let mut values2: Vec<MemorySize> = MemorySize::values().rev().collect();
924	values2.reverse();
925	assert_eq!(values1, values2);
926}
927#[rustfmt::skip]
928impl TryFrom<usize> for MemorySize {
929	type Error = IcedError;
930	#[inline]
931	fn try_from(value: usize) -> Result<Self, Self::Error> {
932		if value < IcedConstants::MEMORY_SIZE_ENUM_COUNT {
933			// SAFETY: all values 0-max are valid enum values
934			Ok(unsafe { mem::transmute(value as u8) })
935		} else {
936			Err(IcedError::new("Invalid MemorySize value"))
937		}
938	}
939}
940#[test]
941#[rustfmt::skip]
942fn test_memorysize_try_from_usize() {
943	for value in MemorySize::values() {
944		let converted = <MemorySize as TryFrom<usize>>::try_from(value as usize).unwrap();
945		assert_eq!(converted, value);
946	}
947	assert!(<MemorySize as TryFrom<usize>>::try_from(IcedConstants::MEMORY_SIZE_ENUM_COUNT).is_err());
948	assert!(<MemorySize as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
949}
950#[cfg(feature = "serde")]
951#[rustfmt::skip]
952#[allow(clippy::zero_sized_map_values)]
953const _: () = {
954	use core::marker::PhantomData;
955	use serde::de;
956	use serde::{Deserialize, Deserializer, Serialize, Serializer};
957	type EnumType = MemorySize;
958	impl Serialize for EnumType {
959		#[inline]
960		fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
961		where
962			S: Serializer,
963		{
964			serializer.serialize_u8(*self as u8)
965		}
966	}
967	impl<'de> Deserialize<'de> for EnumType {
968		#[inline]
969		fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
970		where
971			D: Deserializer<'de>,
972		{
973			struct Visitor<'de> {
974				marker: PhantomData<EnumType>,
975				lifetime: PhantomData<&'de ()>,
976			}
977			impl<'de> de::Visitor<'de> for Visitor<'de> {
978				type Value = EnumType;
979				#[inline]
980				fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
981					formatter.write_str("enum MemorySize")
982				}
983				#[inline]
984				fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
985				where
986					E: de::Error,
987				{
988					if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
989						if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
990							return Ok(value);
991						}
992					}
993					Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid MemorySize variant value"))
994				}
995			}
996			deserializer.deserialize_u8(Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
997		}
998	}
999};
1000// GENERATOR-END: MemorySize
1001
1002#[cfg(any(feature = "instr_info", feature = "encoder"))]
1003impl MemorySize {
1004	/// Gets the memory size info
1005	///
1006	/// # Examples
1007	///
1008	/// ```
1009	/// use iced_x86::*;
1010	/// let info = MemorySize::Packed256_UInt16.info();
1011	/// assert_eq!(info.size(), 32);
1012	/// ```
1013	#[must_use]
1014	#[inline]
1015	pub fn info(self) -> &'static MemorySizeInfo {
1016		&MEMORY_SIZE_INFOS[self as usize]
1017	}
1018
1019	/// Gets the size in bytes of the memory location or 0 if it's not accessed by the instruction or unknown or variable sized
1020	///
1021	/// # Examples
1022	///
1023	/// ```
1024	/// use iced_x86::*;
1025	/// assert_eq!(MemorySize::UInt32.size(), 4);
1026	/// assert_eq!(MemorySize::Packed256_UInt16.size(), 32);
1027	/// assert_eq!(MemorySize::Broadcast512_UInt64.size(), 8);
1028	/// ```
1029	#[must_use]
1030	#[inline]
1031	pub fn size(self) -> usize {
1032		self.info().size()
1033	}
1034
1035	/// Gets the size in bytes of the packed element. If it's not a packed data type, it's equal to [`size()`].
1036	///
1037	/// [`size()`]: #method.size
1038	///
1039	/// # Examples
1040	///
1041	/// ```
1042	/// use iced_x86::*;
1043	/// assert_eq!(MemorySize::UInt32.element_size(), 4);
1044	/// assert_eq!(MemorySize::Packed256_UInt16.element_size(), 2);
1045	/// assert_eq!(MemorySize::Broadcast512_UInt64.element_size(), 8);
1046	/// ```
1047	#[must_use]
1048	#[inline]
1049	pub fn element_size(self) -> usize {
1050		self.info().element_size()
1051	}
1052
1053	/// Gets the element type if it's packed data or `self` if it's not packed data
1054	///
1055	/// # Examples
1056	///
1057	/// ```
1058	/// use iced_x86::*;
1059	/// assert_eq!(MemorySize::UInt32.element_type(), MemorySize::UInt32);
1060	/// assert_eq!(MemorySize::Packed256_UInt16.element_type(), MemorySize::UInt16);
1061	/// assert_eq!(MemorySize::Broadcast512_UInt64.element_type(), MemorySize::UInt64);
1062	/// ```
1063	#[must_use]
1064	#[inline]
1065	pub fn element_type(self) -> Self {
1066		self.info().element_type()
1067	}
1068
1069	/// Gets the element type info if it's packed data or `self` if it's not packed data
1070	///
1071	/// # Examples
1072	///
1073	/// ```
1074	/// use iced_x86::*;
1075	/// assert_eq!(MemorySize::UInt32.element_type_info().memory_size(), MemorySize::UInt32);
1076	/// assert_eq!(MemorySize::Packed256_UInt16.element_type_info().memory_size(), MemorySize::UInt16);
1077	/// assert_eq!(MemorySize::Broadcast512_UInt64.element_type_info().memory_size(), MemorySize::UInt64);
1078	/// ```
1079	#[must_use]
1080	#[inline]
1081	pub fn element_type_info(self) -> &'static MemorySizeInfo {
1082		self.info().element_type().info()
1083	}
1084
1085	/// `true` if it's signed data (signed integer or a floating point value)
1086	///
1087	/// # Examples
1088	///
1089	/// ```
1090	/// use iced_x86::*;
1091	/// assert!(!MemorySize::UInt32.is_signed());
1092	/// assert!(MemorySize::Int32.is_signed());
1093	/// assert!(MemorySize::Float64.is_signed());
1094	/// ```
1095	#[must_use]
1096	#[inline]
1097	pub fn is_signed(self) -> bool {
1098		self.info().is_signed()
1099	}
1100
1101	/// `true` if this is a packed data type, eg. [`MemorySize::Packed128_Float32`]
1102	///
1103	/// [`MemorySize::Packed128_Float32`]: #variant.Packed128_Float32
1104	///
1105	/// # Examples
1106	///
1107	/// ```
1108	/// use iced_x86::*;
1109	/// assert!(!MemorySize::UInt32.is_packed());
1110	/// assert!(MemorySize::Packed256_UInt16.is_packed());
1111	/// assert!(!MemorySize::Broadcast512_UInt64.is_packed());
1112	/// ```
1113	#[must_use]
1114	#[inline]
1115	pub fn is_packed(self) -> bool {
1116		self.info().is_packed()
1117	}
1118
1119	/// Gets the number of elements in the packed data type or `1` if it's not packed data ([`is_packed()`])
1120	///
1121	/// [`is_packed()`]: #method.is_packed
1122	///
1123	/// # Examples
1124	///
1125	/// ```
1126	/// use iced_x86::*;
1127	/// assert_eq!(MemorySize::UInt32.element_count(), 1);
1128	/// assert_eq!(MemorySize::Packed256_UInt16.element_count(), 16);
1129	/// assert_eq!(MemorySize::Broadcast512_UInt64.element_count(), 1);
1130	/// ```
1131	#[must_use]
1132	#[inline]
1133	pub fn element_count(self) -> usize {
1134		self.info().element_count()
1135	}
1136}
1137
1138#[cfg(any(feature = "instr_info", feature = "encoder", feature = "fast_fmt"))]
1139impl MemorySize {
1140	/// Checks if it is a broadcast memory type
1141	///
1142	/// # Examples
1143	///
1144	/// ```
1145	/// use iced_x86::*;
1146	/// assert!(!MemorySize::Packed64_Float16.is_broadcast());
1147	/// assert!(MemorySize::Broadcast512_UInt64.is_broadcast());
1148	/// ```
1149	#[must_use]
1150	#[inline]
1151	pub fn is_broadcast(self) -> bool {
1152		self >= IcedConstants::FIRST_BROADCAST_MEMORY_SIZE
1153	}
1154}