|
| 1 | +use std::fmt::Display; |
1 | 2 | use std::str::FromStr;
|
2 | 3 | use std::{fmt, iter};
|
3 | 4 |
|
@@ -895,6 +896,37 @@ impl FromStr for Conv {
|
895 | 896 | }
|
896 | 897 | }
|
897 | 898 |
|
| 899 | +fn conv_to_externabi(conv: &Conv) -> ExternAbi { |
| 900 | + match conv { |
| 901 | + Conv::C => ExternAbi::C { unwind: false }, |
| 902 | + Conv::Rust => ExternAbi::Rust, |
| 903 | + Conv::PreserveMost => ExternAbi::RustCold, |
| 904 | + Conv::ArmAapcs => ExternAbi::Aapcs { unwind: false }, |
| 905 | + Conv::CCmseNonSecureCall => ExternAbi::CCmseNonSecureCall, |
| 906 | + Conv::CCmseNonSecureEntry => ExternAbi::CCmseNonSecureEntry, |
| 907 | + Conv::Msp430Intr => ExternAbi::Msp430Interrupt, |
| 908 | + Conv::GpuKernel => ExternAbi::GpuKernel, |
| 909 | + Conv::X86Fastcall => ExternAbi::Fastcall { unwind: false }, |
| 910 | + Conv::X86Intr => ExternAbi::X86Interrupt, |
| 911 | + Conv::X86Stdcall => ExternAbi::Stdcall { unwind: false }, |
| 912 | + Conv::X86ThisCall => ExternAbi::Thiscall { unwind: false }, |
| 913 | + Conv::X86VectorCall => ExternAbi::Vectorcall { unwind: false }, |
| 914 | + Conv::X86_64SysV => ExternAbi::SysV64 { unwind: false }, |
| 915 | + Conv::X86_64Win64 => ExternAbi::Win64 { unwind: false }, |
| 916 | + Conv::AvrInterrupt => ExternAbi::AvrInterrupt, |
| 917 | + Conv::AvrNonBlockingInterrupt => ExternAbi::AvrNonBlockingInterrupt, |
| 918 | + Conv::RiscvInterrupt { kind: RiscvInterruptKind::Machine } => ExternAbi::RiscvInterruptM, |
| 919 | + Conv::RiscvInterrupt { kind: RiscvInterruptKind::Supervisor } => ExternAbi::RiscvInterruptS, |
| 920 | + Conv::Cold | Conv::PreserveAll => unreachable!(), |
| 921 | + } |
| 922 | +} |
| 923 | + |
| 924 | +impl Display for Conv { |
| 925 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 926 | + write!(f, "{}", conv_to_externabi(self)) |
| 927 | + } |
| 928 | +} |
| 929 | + |
898 | 930 | // Some types are used a lot. Make sure they don't unintentionally get bigger.
|
899 | 931 | #[cfg(target_pointer_width = "64")]
|
900 | 932 | mod size_asserts {
|
|
0 commit comments