|
1 | 1 | use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd}; |
2 | 2 | use std::fmt; |
3 | 3 | use std::hash::{Hash, Hasher}; |
4 | | -use std::str::FromStr; |
5 | 4 |
|
6 | 5 | #[cfg(feature = "nightly")] |
7 | 6 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd}; |
8 | 7 |
|
9 | | -use crate::{AbiConvErr, ExternAbi}; |
| 8 | +use crate::ExternAbi; |
10 | 9 |
|
11 | 10 | /// Calling convention to determine codegen |
12 | 11 | /// |
@@ -134,69 +133,6 @@ impl CanonAbi { |
134 | 133 | }, |
135 | 134 | } |
136 | 135 | } |
137 | | - |
138 | | - /// convert an ExternAbi to a CanonAbi if it maps directly |
139 | | - /// |
140 | | - /// A target-insensitive mapping of ExternAbi to CanonAbi. This is a partial function, |
141 | | - /// and mostly serves as a way to reuse ExternAbi's code. |
142 | | - const fn try_from_extern_abi(extern_abi: ExternAbi) -> Result<Self, AbiConvErr> { |
143 | | - match extern_abi { |
144 | | - ExternAbi::C { unwind: false } => Ok(Self::C), |
145 | | - ExternAbi::Rust => Ok(Self::Rust), |
146 | | - ExternAbi::RustCold => Ok(Self::RustCold), |
147 | | - |
148 | | - // arm |
149 | | - ExternAbi::Aapcs { unwind: false } => Ok(Self::Arm(ArmCall::Aapcs)), |
150 | | - ExternAbi::CCmseNonSecureCall => Ok(Self::Arm(ArmCall::CCmseNonSecureCall)), |
151 | | - ExternAbi::CCmseNonSecureEntry => Ok(Self::Arm(ArmCall::CCmseNonSecureEntry)), |
152 | | - // gpu |
153 | | - ExternAbi::GpuKernel => Ok(Self::GpuKernel), |
154 | | - // interrupt |
155 | | - ExternAbi::AvrInterrupt => Ok(Self::Interrupt(InterruptKind::Avr)), |
156 | | - ExternAbi::AvrNonBlockingInterrupt => { |
157 | | - Ok(Self::Interrupt(InterruptKind::AvrNonBlocking)) |
158 | | - } |
159 | | - ExternAbi::Msp430Interrupt => Ok(Self::Interrupt(InterruptKind::Msp430)), |
160 | | - ExternAbi::RiscvInterruptM => Ok(Self::Interrupt(InterruptKind::RiscvMachine)), |
161 | | - ExternAbi::RiscvInterruptS => Ok(Self::Interrupt(InterruptKind::RiscvSupervisor)), |
162 | | - ExternAbi::X86Interrupt => Ok(Self::Interrupt(InterruptKind::X86)), |
163 | | - |
164 | | - // x86 |
165 | | - ExternAbi::Stdcall { unwind: false } => Ok(Self::X86(X86Call::Stdcall)), |
166 | | - ExternAbi::Fastcall { unwind: false } => Ok(Self::X86(X86Call::Fastcall)), |
167 | | - ExternAbi::Vectorcall { unwind: false } => Ok(Self::X86(X86Call::Vectorcall)), |
168 | | - ExternAbi::Thiscall { unwind: false } => Ok(Self::X86(X86Call::Thiscall)), |
169 | | - ExternAbi::Win64 { unwind: false } => Ok(Self::X86(X86Call::Win64)), |
170 | | - ExternAbi::SysV64 { unwind: false } => Ok(Self::X86(X86Call::SysV64)), |
171 | | - |
172 | | - // fanon |
173 | | - ExternAbi::Cdecl { unwind: _ } |
174 | | - | ExternAbi::EfiApi |
175 | | - | ExternAbi::PtxKernel |
176 | | - | ExternAbi::RustCall |
177 | | - | ExternAbi::System { unwind: _ } |
178 | | - | ExternAbi::Unadjusted => Err(AbiConvErr::Unknown), |
179 | | - // unwind where it should not unwind |
180 | | - ExternAbi::Aapcs { unwind: true } |
181 | | - | ExternAbi::C { unwind: true } |
182 | | - | ExternAbi::Stdcall { unwind: true } |
183 | | - | ExternAbi::Fastcall { unwind: true } |
184 | | - | ExternAbi::Vectorcall { unwind: true } |
185 | | - | ExternAbi::Thiscall { unwind: true } |
186 | | - | ExternAbi::Win64 { unwind: true } |
187 | | - | ExternAbi::SysV64 { unwind: true } => Err(AbiConvErr::UnwindInvalid), |
188 | | - } |
189 | | - } |
190 | | -} |
191 | | - |
192 | | -impl FromStr for CanonAbi { |
193 | | - type Err = AbiConvErr; |
194 | | - |
195 | | - fn from_str(s: &str) -> Result<Self, Self::Err> { |
196 | | - // parse as ExternAbi and propagate out errors, as CanonAbi uses the same errors |
197 | | - let extern_abi = s.parse()?; |
198 | | - CanonAbi::try_from_extern_abi(extern_abi) |
199 | | - } |
200 | 136 | } |
201 | 137 |
|
202 | 138 | /// Callee codegen for interrupts |
|
0 commit comments