Skip to content

Commit ba0d71d

Browse files
committed
Add Swift function ABI to rustc
Maps to LLVM's Swift calling convention, which is listed as 16.
1 parent 0221e26 commit ba0d71d

File tree

9 files changed

+15
-0
lines changed

9 files changed

+15
-0
lines changed

src/librustc/ich/impls_syntax.rs

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl_stable_hash_for!(enum ::rustc_target::spec::abi::Abi {
8181
AmdGpuKernel,
8282
Rust,
8383
C,
84+
Swift,
8485
System,
8586
RustIntrinsic,
8687
RustCall,

src/librustc/ty/layout.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2599,6 +2599,7 @@ where
25992599
Vectorcall => Conv::X86VectorCall,
26002600
Thiscall => Conv::X86ThisCall,
26012601
C => Conv::C,
2602+
Swift => Conv::Swift,
26022603
Unadjusted => Conv::C,
26032604
Win64 => Conv::X86_64Win64,
26042605
SysV64 => Conv::X86_64SysV,

src/librustc_codegen_llvm/abi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ impl<'tcx> FnTypeLlvmExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
374374
fn llvm_cconv(&self) -> llvm::CallConv {
375375
match self.conv {
376376
Conv::C => llvm::CCallConv,
377+
Conv::Swift => llvm::SwiftCallConv,
377378
Conv::AmdGpuKernel => llvm::AmdGpuKernel,
378379
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
379380
Conv::Msp430Intr => llvm::Msp430Intr,

src/librustc_codegen_llvm/llvm/ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub enum CallConv {
3636
CCallConv = 0,
3737
FastCallConv = 8,
3838
ColdCallConv = 9,
39+
SwiftCallConv = 16,
3940
X86StdcallCallConv = 64,
4041
X86FastcallCallConv = 65,
4142
ArmAapcsCallConv = 67,

src/librustc_target/abi/call/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ impl<'a, Ty> ArgType<'a, Ty> {
491491
#[derive(Copy, Clone, PartialEq, Debug)]
492492
pub enum Conv {
493493
C,
494+
Swift,
494495

495496
ArmAapcs,
496497

src/librustc_target/spec/abi.rs

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub enum Abi {
2525
// Multiplatform / generic ABIs
2626
Rust,
2727
C,
28+
Swift,
2829
System,
2930
RustIntrinsic,
3031
RustCall,
@@ -62,6 +63,7 @@ const AbiDatas: &[AbiData] = &[
6263
// Cross-platform ABIs
6364
AbiData {abi: Abi::Rust, name: "Rust", generic: true },
6465
AbiData {abi: Abi::C, name: "C", generic: true },
66+
AbiData {abi: Abi::Swift, name: "Swift", generic: true },
6567
AbiData {abi: Abi::System, name: "system", generic: true },
6668
AbiData {abi: Abi::RustIntrinsic, name: "rust-intrinsic", generic: true },
6769
AbiData {abi: Abi::RustCall, name: "rust-call", generic: true },

src/libsyntax/feature_gate/active.rs

+3
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,9 @@ declare_features! (
519519
/// Allows the use of or-patterns (e.g., `0 | 1`).
520520
(active, or_patterns, "1.38.0", Some(54883), None),
521521

522+
/// Allows using the `Swift` ABI.
523+
(active, abi_swift, "1.38.0", Some(0), None),
524+
522525
// -------------------------------------------------------------------------
523526
// feature-group-end: actual feature gates
524527
// -------------------------------------------------------------------------

src/libsyntax/feature_gate/check.rs

+4
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ impl<'a> PostExpansionVisitor<'a> {
234234
gate_feature_post!(&self, abi_amdgpu_kernel, span,
235235
"amdgpu-kernel ABI is experimental and subject to change");
236236
},
237+
Abi::Swift => {
238+
gate_feature_post!(&self, abi_swift, span,
239+
"Swift ABI is experimental and subject to change");
240+
},
237241
// Stable
238242
Abi::Cdecl |
239243
Abi::Stdcall |

src/libsyntax_pos/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ symbols! {
109109
Symbols {
110110
aarch64_target_feature,
111111
abi,
112+
abi_swift,
112113
abi_amdgpu_kernel,
113114
abi_msp430_interrupt,
114115
abi_ptx,

0 commit comments

Comments
 (0)