Skip to main content

target_spec_json/gen/
target_spec.rs

1// SPDX-License-Identifier: Apache-2.0 OR MIT
2// This file is @generated by target_spec.sh.
3// It is not intended for manual editing.
4
5#![allow(non_camel_case_types)]
6
7use serde_derive::{Deserialize, Serialize};
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
10#[non_exhaustive]
11pub enum Arch {
12    aarch64,
13    amdgpu,
14    arm,
15    arm64ec,
16    avr,
17    bpf,
18    csky,
19    hexagon,
20    loongarch32,
21    loongarch64,
22    m68k,
23    mips,
24    mips32r6,
25    mips64,
26    mips64r6,
27    msp430,
28    nvptx64,
29    powerpc,
30    powerpc64,
31    riscv32,
32    riscv64,
33    s390x,
34    sparc,
35    sparc64,
36    spirv,
37    wasm32,
38    wasm64,
39    x86,
40    x86_64,
41    xtensa,
42}
43impl Arch {
44    #[must_use]
45    pub fn as_str(self) -> &'static str {
46        match self {
47            Self::aarch64 => "aarch64",
48            Self::amdgpu => "amdgpu",
49            Self::arm => "arm",
50            Self::arm64ec => "arm64ec",
51            Self::avr => "avr",
52            Self::bpf => "bpf",
53            Self::csky => "csky",
54            Self::hexagon => "hexagon",
55            Self::loongarch32 => "loongarch32",
56            Self::loongarch64 => "loongarch64",
57            Self::m68k => "m68k",
58            Self::mips => "mips",
59            Self::mips32r6 => "mips32r6",
60            Self::mips64 => "mips64",
61            Self::mips64r6 => "mips64r6",
62            Self::msp430 => "msp430",
63            Self::nvptx64 => "nvptx64",
64            Self::powerpc => "powerpc",
65            Self::powerpc64 => "powerpc64",
66            Self::riscv32 => "riscv32",
67            Self::riscv64 => "riscv64",
68            Self::s390x => "s390x",
69            Self::sparc => "sparc",
70            Self::sparc64 => "sparc64",
71            Self::spirv => "spirv",
72            Self::wasm32 => "wasm32",
73            Self::wasm64 => "wasm64",
74            Self::x86 => "x86",
75            Self::x86_64 => "x86_64",
76            Self::xtensa => "xtensa",
77        }
78    }
79}
80impl core::fmt::Display for Arch {
81    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
82        f.write_str(self.as_str())
83    }
84}
85
86#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
87#[non_exhaustive]
88pub enum Os {
89    aix,
90    amdhsa,
91    android,
92    cuda,
93    cygwin,
94    dragonfly,
95    emscripten,
96    espidf,
97    freebsd,
98    fuchsia,
99    haiku,
100    helenos,
101    hermit,
102    horizon,
103    hurd,
104    illumos,
105    ios,
106    l4re,
107    linux,
108    lynxos178,
109    macos,
110    managarm,
111    motor,
112    netbsd,
113    #[default]
114    none,
115    nto,
116    nuttx,
117    openbsd,
118    ps3,
119    psp,
120    psx,
121    qnx,
122    qurt,
123    redox,
124    rtems,
125    solaris,
126    solid_asp3,
127    teeos,
128    trusty,
129    tvos,
130    uefi,
131    unknown,
132    vexos,
133    visionos,
134    vita,
135    vxworks,
136    wasi,
137    watchos,
138    windows,
139    xous,
140    zephyr,
141    zkvm,
142}
143impl Os {
144    #[must_use]
145    pub fn as_str(self) -> &'static str {
146        match self {
147            Self::aix => "aix",
148            Self::amdhsa => "amdhsa",
149            Self::android => "android",
150            Self::cuda => "cuda",
151            Self::cygwin => "cygwin",
152            Self::dragonfly => "dragonfly",
153            Self::emscripten => "emscripten",
154            Self::espidf => "espidf",
155            Self::freebsd => "freebsd",
156            Self::fuchsia => "fuchsia",
157            Self::haiku => "haiku",
158            Self::helenos => "helenos",
159            Self::hermit => "hermit",
160            Self::horizon => "horizon",
161            Self::hurd => "hurd",
162            Self::illumos => "illumos",
163            Self::ios => "ios",
164            Self::l4re => "l4re",
165            Self::linux => "linux",
166            Self::lynxos178 => "lynxos178",
167            Self::macos => "macos",
168            Self::managarm => "managarm",
169            Self::motor => "motor",
170            Self::netbsd => "netbsd",
171            Self::none => "none",
172            Self::nto => "nto",
173            Self::nuttx => "nuttx",
174            Self::openbsd => "openbsd",
175            Self::ps3 => "ps3",
176            Self::psp => "psp",
177            Self::psx => "psx",
178            Self::qnx => "qnx",
179            Self::qurt => "qurt",
180            Self::redox => "redox",
181            Self::rtems => "rtems",
182            Self::solaris => "solaris",
183            Self::solid_asp3 => "solid_asp3",
184            Self::teeos => "teeos",
185            Self::trusty => "trusty",
186            Self::tvos => "tvos",
187            Self::uefi => "uefi",
188            Self::unknown => "unknown",
189            Self::vexos => "vexos",
190            Self::visionos => "visionos",
191            Self::vita => "vita",
192            Self::vxworks => "vxworks",
193            Self::wasi => "wasi",
194            Self::watchos => "watchos",
195            Self::windows => "windows",
196            Self::xous => "xous",
197            Self::zephyr => "zephyr",
198            Self::zkvm => "zkvm",
199        }
200    }
201}
202impl Os {
203    #[allow(clippy::trivially_copy_pass_by_ref)]
204    pub(crate) fn is_none(&self) -> bool {
205        matches!(self, Self::none)
206    }
207}
208impl core::fmt::Display for Os {
209    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
210        f.write_str(self.as_str())
211    }
212}
213
214#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
215#[non_exhaustive]
216pub enum Env {
217    gnu,
218    libnx,
219    macabi,
220    mlibc,
221    msvc,
222    musl,
223    newlib,
224    #[default]
225    none,
226    nto70,
227    nto71,
228    nto71_iosock,
229    nto80,
230    ohos,
231    p1,
232    p2,
233    p3,
234    relibc,
235    sgx,
236    sim,
237    uclibc,
238    v5,
239}
240impl Env {
241    #[must_use]
242    pub fn as_str(self) -> &'static str {
243        match self {
244            Self::gnu => "gnu",
245            Self::libnx => "libnx",
246            Self::macabi => "macabi",
247            Self::mlibc => "mlibc",
248            Self::msvc => "msvc",
249            Self::musl => "musl",
250            Self::newlib => "newlib",
251            Self::none => "",
252            Self::nto70 => "nto70",
253            Self::nto71 => "nto71",
254            Self::nto71_iosock => "nto71_iosock",
255            Self::nto80 => "nto80",
256            Self::ohos => "ohos",
257            Self::p1 => "p1",
258            Self::p2 => "p2",
259            Self::p3 => "p3",
260            Self::relibc => "relibc",
261            Self::sgx => "sgx",
262            Self::sim => "sim",
263            Self::uclibc => "uclibc",
264            Self::v5 => "v5",
265        }
266    }
267}
268impl Env {
269    #[allow(clippy::trivially_copy_pass_by_ref)]
270    pub(crate) fn is_none(&self) -> bool {
271        matches!(self, Self::none)
272    }
273}
274impl core::fmt::Display for Env {
275    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
276        f.write_str(self.as_str())
277    }
278}
279
280#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
281#[non_exhaustive]
282pub enum TargetFamily {
283    unix,
284    wasm,
285    windows,
286}
287impl TargetFamily {
288    #[must_use]
289    pub fn as_str(self) -> &'static str {
290        match self {
291            Self::unix => "unix",
292            Self::wasm => "wasm",
293            Self::windows => "windows",
294        }
295    }
296}
297impl core::fmt::Display for TargetFamily {
298    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
299        f.write_str(self.as_str())
300    }
301}
302
303#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
304#[non_exhaustive]
305pub enum Sanitizer {
306    address,
307    cfi,
308    dataflow,
309    hwaddress,
310    kcfi,
311    #[serde(rename = "kernel-address")]
312    kernel_address,
313    #[serde(rename = "kernel-hwaddress")]
314    kernel_hwaddress,
315    leak,
316    memory,
317    memtag,
318    realtime,
319    safestack,
320    #[serde(rename = "shadow-call-stack")]
321    shadow_call_stack,
322    thread,
323}
324impl Sanitizer {
325    #[must_use]
326    pub fn as_str(self) -> &'static str {
327        match self {
328            Self::address => "address",
329            Self::cfi => "cfi",
330            Self::dataflow => "dataflow",
331            Self::hwaddress => "hwaddress",
332            Self::kcfi => "kcfi",
333            Self::kernel_address => "kernel-address",
334            Self::kernel_hwaddress => "kernel-hwaddress",
335            Self::leak => "leak",
336            Self::memory => "memory",
337            Self::memtag => "memtag",
338            Self::realtime => "realtime",
339            Self::safestack => "safestack",
340            Self::shadow_call_stack => "shadow-call-stack",
341            Self::thread => "thread",
342        }
343    }
344}
345impl core::fmt::Display for Sanitizer {
346    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
347        f.write_str(self.as_str())
348    }
349}
350
351#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
352#[non_exhaustive]
353pub enum BinaryFormat {
354    coff,
355    #[default]
356    elf,
357    #[serde(rename = "mach-o")]
358    mach_o,
359    wasm,
360    xcoff,
361}
362impl BinaryFormat {
363    #[must_use]
364    pub fn as_str(self) -> &'static str {
365        match self {
366            Self::coff => "coff",
367            Self::elf => "elf",
368            Self::mach_o => "mach-o",
369            Self::wasm => "wasm",
370            Self::xcoff => "xcoff",
371        }
372    }
373}
374impl BinaryFormat {
375    #[allow(clippy::trivially_copy_pass_by_ref)]
376    pub(crate) fn is_elf(&self) -> bool {
377        matches!(self, Self::elf)
378    }
379}
380impl core::fmt::Display for BinaryFormat {
381    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
382        f.write_str(self.as_str())
383    }
384}
385
386#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
387#[allow(clippy::exhaustive_enums)]
388pub enum TargetEndian {
389    big,
390    #[default]
391    little,
392}
393impl TargetEndian {
394    #[must_use]
395    pub fn as_str(self) -> &'static str {
396        match self {
397            Self::big => "big",
398            Self::little => "little",
399        }
400    }
401}
402impl TargetEndian {
403    #[allow(clippy::trivially_copy_pass_by_ref)]
404    pub(crate) fn is_little(&self) -> bool {
405        matches!(self, Self::little)
406    }
407}
408impl core::fmt::Display for TargetEndian {
409    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
410        f.write_str(self.as_str())
411    }
412}
413
414#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
415#[allow(clippy::exhaustive_enums)]
416pub enum PanicStrategy {
417    abort,
418    #[default]
419    unwind,
420}
421impl PanicStrategy {
422    #[must_use]
423    pub fn as_str(self) -> &'static str {
424        match self {
425            Self::abort => "abort",
426            Self::unwind => "unwind",
427        }
428    }
429}
430impl PanicStrategy {
431    #[allow(clippy::trivially_copy_pass_by_ref)]
432    pub(crate) fn is_unwind(&self) -> bool {
433        matches!(self, Self::unwind)
434    }
435}
436impl core::fmt::Display for PanicStrategy {
437    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
438        f.write_str(self.as_str())
439    }
440}