Implement Display for rustc_target::callconv::Conv
by tiif · Pull Request #135808 · rust-lang/rust (original) (raw)
According to conv_from_spec_abi, the reverse mapping of Conv::Rust
can potentially be ExternAbi::RustIntrinsic / RustCall / Rust
. Similarly, Conv::C
can be mapped to ExternAbi::C / Unadjusted / Cdecl
.
Also, in adjust_abi, ExternAbi::StdCall / Thiscall / Fastcall / VectorCall
can occasionally get mapped to ExternAbi::C
. That means the reverse mapping of Conv::C
to ExternAbi
can possibly be any of them.
If I ignore all of the issues above, the simplest reverse mapping that I can think of is:
- Conv::Rust => ExternAbi::Rust
- Conv::PreserveMost => ExternAbi::RustCold
- Conv::X86Stdcall => ExternAbi::Stdcall
- Conv::X86Fastcall => ExternAbi::Fastcall
- Conv::X86VectorCall => ExternAbi::Vectorcall
- Conv::X86ThisCall => ExternAbi::Thiscall
- Conv::C => ExternAbi::C
- Conv::X86_64Win64 => ExternAbi::Win64
- Conv::X86_64SysV => ExternAbi::SysV64
- Conv::ArmAapcs => ExternAbi::Aapcs
- Conv::CCmseNonSecureCall => ExternAbi::CCmseNonSecureCall
- Conv::CCmseNonSecureEntry => ExternAbi::CCmseNonSecureEntry
- Conv::PtxKernel => ExternAbi::PtxKernel
- Conv::Msp430Intr => ExternAbi::Msp430Interrupt
- Conv::X86Intr => ExternAbi::X86Interrupt
- Conv::GpuKernel => ExternAbi::GpuKernel
- Conv::AvrInterrupt => ExternAbi::AvrInterrupt
- Conv::AvrNonBlockingInterrupt => ExternAbi::AvrNonBlockingInterrupt
- Conv::RiscvInterrupt { kind: RiscvInterruptKind::Machine } => ExternAbi::RiscvInterruptM
- Conv::RiscvInterrupt { kind: RiscvInterruptKind::Supervisor } => ExternAbi::RiscvInterruptS
- Conv::Cold and Conv::PreserveAll: Not sure how to deal with them, can we ignore them?
But I am not sure if this is still correct, so cc @workingjubilee for a vibe check :)