1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#[derive(Debug)]
pub struct X86FeatureFromStrError;
impl core::fmt::Display for X86FeatureFromStrError {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.write_str("Unknown x86 feature")
}
}
impl std::error::Error for X86FeatureFromStrError {}
macro_rules! define_x86_features{
{
$(($enum:ident, $feature:literal)),* $(,)?
} => {
#[derive(Copy,Clone,Debug,Hash,PartialEq,Eq)]
#[non_exhaustive]
#[repr(i32)]
pub enum X86Feature{
$($enum,)*
}
impl X86Feature{
pub fn feature_name(&self) -> &'static str{
match self{
$(#[allow(unreachable_patterns)] Self::$enum => $feature,)*
}
}
}
impl core::str::FromStr for X86Feature{
type Err = X86FeatureFromStrError;
fn from_str(x: &str) -> Result<Self,Self::Err>{
match x{
$(#[allow(unreachable_patterns)] $feature => Ok(X86Feature::$enum),)*
_ => Err(X86FeatureFromStrError)
}
}
}
impl core::fmt::Display for X86Feature{
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result{
match self{
$(Self::$enum => f.write_str($feature),)*
}
}
}
}
}
define_x86_features! {
(Sce, "sce"),
(Mmx, "mmx"),
(Sse, "sse"),
(Sse2, "sse2"),
(Sse3, "sse3"),
(Ssse3, "ssse3"),
(Sse4, "sse4"),
(Sse4_1,"sse4.1"),
(Sse4_2, "sse4.2"),
(Avx, "avx"),
(Avx2,"avx2"),
(Avx512f,"avx512f"),
(Avx512pf,"avx512pf"),
(Avx512er, "avx512er"),
(Avx512cd, "avx512cd"),
(Avx512vl, "avx512vl"),
(Avx512bw, "avx512bw"),
(Avx512dq,"avx512dq"),
(Avx512ifma, "avx512ifma"),
(Avx512vbmi, "avx512vbmi"),
(Sha, "sha"),
(Aes, "aes"),
(Pclmul, "pclmul"),
(ClFlushOpt, "clflushopt"),
(Clwb, "clwb"),
(FsGsBase, "fsgsbase"),
(Ptwrite, "ptwrite"),
(Rdrand, "rdrand"),
(F16c, "f16c"),
(Fma, "fma"),
(Pconfig,"pconfig"),
(Wbnoinvd, "wbnoinvd"),
(Fma4, "fma4"),
(Prfchw,"prfchw"),
(Rdpid, "rdpid"),
(PrefetchWt11,"prefetchwt11"),
(Rdseed, "rdseed"),
(Sgx, "sgx"),
(Xop, "xop"),
(Lwp, "lwp"),
(M3dNow, "3dnow"),
(M3dNowA, "3dnowa"),
(Popcnt, "popcnt"),
(Abm, "abm"),
(Adx, "adx"),
(Bmi, "bmi"),
(Bmi2, "bmi2"),
(Lzcnt, "lzcnt"),
(Fxsr, "fxsr"),
(XSave, "xsave"),
(XSaveOpt, "xsaveopt"),
(XSaveC, "xsavec"),
(XSaveS,"xsaves"),
(Rtm, "rtm"),
(Hle, "hle"),
(Tbm, "tbm"),
(MWaitX, "mwaitx"),
(ClZero, "clzero"),
(Pku, "pku"),
(Avx512vbmi2, "avx512vbmi"),
(Avx512bf16, "avx512bf16"),
(Avx512fp16, "avx512fp16"),
(Gfni, "gfni"),
(Vaes, "vaes"),
(WaitPkg, "waitpkg"),
(VpclMulQdq, "vpclmulqdq"),
(Avx512BitAlg, "avx512bitalg"),
(MovDirI,"movdiri"),
(MovDir64b, "movdir64b"),
(Enqcmd, "enqcmd"),
(Uintr, "uintr"),
(Tsxldtrk, "tsxldtrk"),
(Avx512VPopcntDq, "avx512vpopcntdq"),
(Avx512Vp2Intersect, "avx512vp2intersect"),
(Avx5124Fmaps, "avx5124fmaps"),
(Avx512Vnni, "avx512vnni"),
(AvxVnni, "avxvnni"),
(Avx5124VnniW, "avx512fvnniw"),
(ClDemote, "cldemote"),
(Serialize, "serialize"),
(AmxTile, "amx-tile"),
(AmxInt8, "amx-int8"),
(AmxBf16, "amx-bf16"),
(HReset, "hreset"),
(Kl, "kl"),
(WideKl, "widekl"),
(X87, "x87"),
(Cx8, "cx8"),
(Cx16, "cx16")
}