@@ -14,64 +14,93 @@ mod tests;
14
14
15
15
use ExternAbi as Abi ;
16
16
17
+ /// ABI we expect to see within `extern "{abi}"`
17
18
#[ derive( Clone , Copy , Debug ) ]
18
19
#[ cfg_attr( feature = "nightly" , derive( Encodable , Decodable ) ) ]
19
20
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 ,
21
+ /* universal */
22
+ /// presumed C ABI for the platform
24
23
C {
25
24
unwind : bool ,
26
25
} ,
27
- Cdecl {
26
+ /// ABI of the "system" interface, e.g. the Win32 API, always "aliasing"
27
+ System {
28
28
unwind : bool ,
29
29
} ,
30
- Stdcall {
30
+
31
+ /// that's us!
32
+ Rust ,
33
+ /// the mostly-unused `unboxed_closures` ABI, effectively now an impl detail unless someone
34
+ /// puts in the work to make it viable again... but would we need a special ABI?
35
+ RustCall ,
36
+ /// For things unlikely to be called, where reducing register pressure in
37
+ /// `extern "Rust"` callers is worth paying extra cost in the callee.
38
+ /// Stronger than just `#[cold]` because `fn` pointers might be incompatible.
39
+ RustCold ,
40
+
41
+ /// Unstable impl detail that directly uses Rust types to describe the ABI to LLVM.
42
+ /// Even normally-compatible Rust types can become ABI-incompatible with this ABI!
43
+ Unadjusted ,
44
+
45
+ /// UEFI ABI, usually an alias of C, but sometimes an arch-specific alias
46
+ /// and only valid on platforms that have a UEFI standard
47
+ EfiApi ,
48
+
49
+ /* arm */
50
+ /// Arm Architecture Procedure Call Standard, sometimes `ExternAbi::C` is an alias for this
51
+ Aapcs {
31
52
unwind : bool ,
32
53
} ,
33
- Fastcall {
54
+ /// extremely constrained barely-C ABI for TrustZone
55
+ CCmseNonSecureCall ,
56
+ /// extremely constrained barely-C ABI for TrustZone
57
+ CCmseNonSecureEntry ,
58
+
59
+ /* gpu */
60
+ /// An entry-point function called by the GPU's host
61
+ // FIXME: should not be callable from Rust on GPU targets, is for host's use only
62
+ GpuKernel ,
63
+ /// An entry-point function called by the GPU's host
64
+ // FIXME: why do we have two of these?
65
+ PtxKernel ,
66
+
67
+ /* interrupt */
68
+ AvrInterrupt ,
69
+ AvrNonBlockingInterrupt ,
70
+ Msp430Interrupt ,
71
+ RiscvInterruptM ,
72
+ RiscvInterruptS ,
73
+ X86Interrupt ,
74
+
75
+ /* x86 */
76
+ /// `ExternAbi::C` but spelled funny because x86
77
+ Cdecl {
34
78
unwind : bool ,
35
79
} ,
36
- Vectorcall {
80
+ /// gnu-stdcall on "unix" and win-stdcall on "windows"
81
+ Stdcall {
37
82
unwind : bool ,
38
83
} ,
39
- Thiscall {
84
+ /// gnu-fastcall on "unix" and win-fastcall on "windows"
85
+ Fastcall {
40
86
unwind : bool ,
41
87
} ,
42
- Aapcs {
88
+ /// windows C++ ABI
89
+ Thiscall {
43
90
unwind : bool ,
44
91
} ,
45
- Win64 {
92
+ /// uses AVX and stuff
93
+ Vectorcall {
46
94
unwind : bool ,
47
95
} ,
96
+
97
+ /* x86_64 */
48
98
SysV64 {
49
99
unwind : bool ,
50
100
} ,
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 {
101
+ Win64 {
63
102
unwind : bool ,
64
103
} ,
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
104
}
76
105
77
106
macro_rules! abi_impls {
0 commit comments