Skip to content

Commit b3797c0

Browse files
authored
Unrolled build for #142140
Rollup merge of #142140 - workingjubilee:sort-extern-abi-variants, r=bjorn3 compiler: Sort and doc ExternAbi variants My personal brainworms found this ordering made the most sense while writing the CanonAbi PR. It is *an* ordering, at least, unlike the current mess. There has been no particular reason for the previous order ever since #136901, despite the comment I delete here. I just didn't change it. Because I feel weird just fussing with variant ordering in the source definition, I also documented a bunch to the best of my ability.
2 parents cdd545b + f66487b commit b3797c0

File tree

1 file changed

+63
-36
lines changed

1 file changed

+63
-36
lines changed

compiler/rustc_abi/src/extern_abi.rs

Lines changed: 63 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,66 +12,93 @@ use crate::AbiFromStrErr;
1212
#[cfg(test)]
1313
mod tests;
1414

15-
use ExternAbi as Abi;
16-
15+
/// ABI we expect to see within `extern "{abi}"`
1716
#[derive(Clone, Copy, Debug)]
1817
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable))]
1918
pub enum ExternAbi {
20-
// Some of the ABIs come first because every time we add a new ABI, we have to re-bless all the
21-
// hashing tests. These are used in many places, so giving them stable values reduces test
22-
// churn. The specific values are meaningless.
23-
Rust,
19+
/* universal */
20+
/// presumed C ABI for the platform
2421
C {
2522
unwind: bool,
2623
},
27-
Cdecl {
24+
/// ABI of the "system" interface, e.g. the Win32 API, always "aliasing"
25+
System {
2826
unwind: bool,
2927
},
30-
Stdcall {
28+
29+
/// that's us!
30+
Rust,
31+
/// the mostly-unused `unboxed_closures` ABI, effectively now an impl detail unless someone
32+
/// puts in the work to make it viable again... but would we need a special ABI?
33+
RustCall,
34+
/// For things unlikely to be called, where reducing register pressure in
35+
/// `extern "Rust"` callers is worth paying extra cost in the callee.
36+
/// Stronger than just `#[cold]` because `fn` pointers might be incompatible.
37+
RustCold,
38+
39+
/// Unstable impl detail that directly uses Rust types to describe the ABI to LLVM.
40+
/// Even normally-compatible Rust types can become ABI-incompatible with this ABI!
41+
Unadjusted,
42+
43+
/// UEFI ABI, usually an alias of C, but sometimes an arch-specific alias
44+
/// and only valid on platforms that have a UEFI standard
45+
EfiApi,
46+
47+
/* arm */
48+
/// Arm Architecture Procedure Call Standard, sometimes `ExternAbi::C` is an alias for this
49+
Aapcs {
3150
unwind: bool,
3251
},
33-
Fastcall {
52+
/// extremely constrained barely-C ABI for TrustZone
53+
CCmseNonSecureCall,
54+
/// extremely constrained barely-C ABI for TrustZone
55+
CCmseNonSecureEntry,
56+
57+
/* gpu */
58+
/// An entry-point function called by the GPU's host
59+
// FIXME: should not be callable from Rust on GPU targets, is for host's use only
60+
GpuKernel,
61+
/// An entry-point function called by the GPU's host
62+
// FIXME: why do we have two of these?
63+
PtxKernel,
64+
65+
/* interrupt */
66+
AvrInterrupt,
67+
AvrNonBlockingInterrupt,
68+
Msp430Interrupt,
69+
RiscvInterruptM,
70+
RiscvInterruptS,
71+
X86Interrupt,
72+
73+
/* x86 */
74+
/// `ExternAbi::C` but spelled funny because x86
75+
Cdecl {
3476
unwind: bool,
3577
},
36-
Vectorcall {
78+
/// gnu-stdcall on "unix" and win-stdcall on "windows"
79+
Stdcall {
3780
unwind: bool,
3881
},
39-
Thiscall {
82+
/// gnu-fastcall on "unix" and win-fastcall on "windows"
83+
Fastcall {
4084
unwind: bool,
4185
},
42-
Aapcs {
86+
/// windows C++ ABI
87+
Thiscall {
4388
unwind: bool,
4489
},
45-
Win64 {
90+
/// uses AVX and stuff
91+
Vectorcall {
4692
unwind: bool,
4793
},
94+
95+
/* x86_64 */
4896
SysV64 {
4997
unwind: bool,
5098
},
51-
PtxKernel,
52-
Msp430Interrupt,
53-
X86Interrupt,
54-
/// An entry-point function called by the GPU's host
55-
// FIXME: should not be callable from Rust on GPU targets, is for host's use only
56-
GpuKernel,
57-
EfiApi,
58-
AvrInterrupt,
59-
AvrNonBlockingInterrupt,
60-
CCmseNonSecureCall,
61-
CCmseNonSecureEntry,
62-
System {
99+
Win64 {
63100
unwind: bool,
64101
},
65-
RustCall,
66-
/// *Not* a stable ABI, just directly use the Rust types to describe the ABI for LLVM. Even
67-
/// normally ABI-compatible Rust types can become ABI-incompatible with this ABI!
68-
Unadjusted,
69-
/// For things unlikely to be called, where reducing register pressure in
70-
/// `extern "Rust"` callers is worth paying extra cost in the callee.
71-
/// Stronger than just `#[cold]` because `fn` pointers might be incompatible.
72-
RustCold,
73-
RiscvInterruptM,
74-
RiscvInterruptS,
75102
}
76103

77104
macro_rules! abi_impls {
@@ -224,7 +251,7 @@ pub fn all_names() -> Vec<&'static str> {
224251

225252
impl ExternAbi {
226253
/// Default ABI chosen for `extern fn` declarations without an explicit ABI.
227-
pub const FALLBACK: Abi = Abi::C { unwind: false };
254+
pub const FALLBACK: ExternAbi = ExternAbi::C { unwind: false };
228255

229256
pub fn name(self) -> &'static str {
230257
self.as_str()

0 commit comments

Comments
 (0)