@@ -12,66 +12,93 @@ use crate::AbiFromStrErr;
12
12
#[ cfg( test) ]
13
13
mod tests;
14
14
15
- use ExternAbi as Abi ;
16
-
15
+ /// ABI we expect to see within `extern "{abi}"`
17
16
#[ derive( Clone , Copy , Debug ) ]
18
17
#[ cfg_attr( feature = "nightly" , derive( Encodable , Decodable ) ) ]
19
18
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
24
21
C {
25
22
unwind : bool ,
26
23
} ,
27
- Cdecl {
24
+ /// ABI of the "system" interface, e.g. the Win32 API, always "aliasing"
25
+ System {
28
26
unwind : bool ,
29
27
} ,
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 {
31
50
unwind : bool ,
32
51
} ,
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 {
34
76
unwind : bool ,
35
77
} ,
36
- Vectorcall {
78
+ /// gnu-stdcall on "unix" and win-stdcall on "windows"
79
+ Stdcall {
37
80
unwind : bool ,
38
81
} ,
39
- Thiscall {
82
+ /// gnu-fastcall on "unix" and win-fastcall on "windows"
83
+ Fastcall {
40
84
unwind : bool ,
41
85
} ,
42
- Aapcs {
86
+ /// windows C++ ABI
87
+ Thiscall {
43
88
unwind : bool ,
44
89
} ,
45
- Win64 {
90
+ /// uses AVX and stuff
91
+ Vectorcall {
46
92
unwind : bool ,
47
93
} ,
94
+
95
+ /* x86_64 */
48
96
SysV64 {
49
97
unwind : bool ,
50
98
} ,
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 {
63
100
unwind : bool ,
64
101
} ,
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 ,
75
102
}
76
103
77
104
macro_rules! abi_impls {
@@ -224,7 +251,7 @@ pub fn all_names() -> Vec<&'static str> {
224
251
225
252
impl ExternAbi {
226
253
/// 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 } ;
228
255
229
256
pub fn name ( self ) -> & ' static str {
230
257
self . as_str ( )
0 commit comments