3 use rustc_macros::HashStable_Generic;
8 #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Clone, Copy, Debug)]
9 #[derive(HashStable_Generic)]
11 // N.B., this ordering MUST match the AbiDatas array below.
12 // (This is ensured by the test indices_are_correct().)
14 // Single platform ABIs
29 // Multiplatform / generic ABIs
39 #[derive(Copy, Clone)]
43 /// Name of this ABI as we like it called.
46 /// A generic ABI is supported on all platforms.
50 #[allow(non_upper_case_globals)]
51 const AbiDatas: &[AbiData] = &[
52 // Platform-specific ABIs
53 AbiData { abi: Abi::Cdecl, name: "cdecl", generic: false },
54 AbiData { abi: Abi::Stdcall, name: "stdcall", generic: false },
55 AbiData { abi: Abi::Fastcall, name: "fastcall", generic: false },
56 AbiData { abi: Abi::Vectorcall, name: "vectorcall", generic: false },
57 AbiData { abi: Abi::Thiscall, name: "thiscall", generic: false },
58 AbiData { abi: Abi::Aapcs, name: "aapcs", generic: false },
59 AbiData { abi: Abi::Win64, name: "win64", generic: false },
60 AbiData { abi: Abi::SysV64, name: "sysv64", generic: false },
61 AbiData { abi: Abi::PtxKernel, name: "ptx-kernel", generic: false },
62 AbiData { abi: Abi::Msp430Interrupt, name: "msp430-interrupt", generic: false },
63 AbiData { abi: Abi::X86Interrupt, name: "x86-interrupt", generic: false },
64 AbiData { abi: Abi::AmdGpuKernel, name: "amdgpu-kernel", generic: false },
65 AbiData { abi: Abi::EfiApi, name: "efiapi", generic: false },
66 // Cross-platform ABIs
67 AbiData { abi: Abi::Rust, name: "Rust", generic: true },
68 AbiData { abi: Abi::C, name: "C", generic: true },
69 AbiData { abi: Abi::System, name: "system", generic: true },
70 AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic", generic: true },
71 AbiData { abi: Abi::RustCall, name: "rust-call", generic: true },
72 AbiData { abi: Abi::PlatformIntrinsic, name: "platform-intrinsic", generic: true },
73 AbiData { abi: Abi::Unadjusted, name: "unadjusted", generic: true },
76 /// Returns the ABI with the given name (if any).
77 pub fn lookup(name: &str) -> Option<Abi> {
78 AbiDatas.iter().find(|abi_data| name == abi_data.name).map(|&x| x.abi)
81 pub fn all_names() -> Vec<&'static str> {
82 AbiDatas.iter().map(|d| d.name).collect()
87 pub fn index(self) -> usize {
92 pub fn data(self) -> &'static AbiData {
93 &AbiDatas[self.index()]
96 pub fn name(self) -> &'static str {
100 pub fn generic(self) -> bool {
105 impl fmt::Display for Abi {
106 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
107 write!(f, "\"{}\"", self.name())