@@ -14,64 +14,93 @@ mod tests;
1414
1515use ExternAbi as Abi ;
1616
17+ /// ABI we expect to see within `extern "{abi}"`
1718#[ derive( Clone , Copy , Debug ) ]
1819#[ cfg_attr( feature = "nightly" , derive( Encodable , Decodable ) ) ]
1920pub 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
2423 C {
2524 unwind : bool ,
2625 } ,
27- Cdecl {
26+ /// ABI of the "system" interface, e.g. the Win32 API, always "aliasing"
27+ System {
2828 unwind : bool ,
2929 } ,
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 {
3152 unwind : bool ,
3253 } ,
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 {
3478 unwind : bool ,
3579 } ,
36- Vectorcall {
80+ /// gnu-stdcall on "unix" and win-stdcall on "windows"
81+ Stdcall {
3782 unwind : bool ,
3883 } ,
39- Thiscall {
84+ /// gnu-fastcall on "unix" and win-fastcall on "windows"
85+ Fastcall {
4086 unwind : bool ,
4187 } ,
42- Aapcs {
88+ /// windows C++ ABI
89+ Thiscall {
4390 unwind : bool ,
4491 } ,
45- Win64 {
92+ /// uses AVX and stuff
93+ Vectorcall {
4694 unwind : bool ,
4795 } ,
96+
97+ /* x86_64 */
4898 SysV64 {
4999 unwind : bool ,
50100 } ,
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 {
63102 unwind : bool ,
64103 } ,
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 ,
75104}
76105
77106macro_rules! abi_impls {
0 commit comments