about summary refs log tree commit diff
path: root/src/libsyntax/abi.rs
diff options
context:
space:
mode:
authorCorey Richardson <corey@octayn.net>2014-07-23 11:56:36 -0700
committerCorey Richardson <corey@octayn.net>2014-11-04 05:07:47 -0500
commit6b130e3dd9547e233dca2cfd72a5968891672d9c (patch)
treee156144ba54fbba565c602bd7f4f9d99a369c058 /src/libsyntax/abi.rs
parent82fb413d370f1f1094964ed07b65f97dba52cc30 (diff)
downloadrust-6b130e3dd9547e233dca2cfd72a5968891672d9c.tar.gz
rust-6b130e3dd9547e233dca2cfd72a5968891672d9c.zip
Implement flexible target specification
Removes all target-specific knowledge from rustc. Some targets have changed
during this, but none of these should be very visible outside of
cross-compilation. The changes make our targets more consistent.

iX86-unknown-linux-gnu is now only available as i686-unknown-linux-gnu. We
used to accept any value of X greater than 1. i686 was released in 1995, and
should encompass the bare minimum of what Rust supports on x86 CPUs.

The only two windows targets are now i686-pc-windows-gnu and
x86_64-pc-windows-gnu.

The iOS target has been renamed from arm-apple-ios to arm-apple-darwin.

A complete list of the targets we accept now:

arm-apple-darwin
arm-linux-androideabi
arm-unknown-linux-gnueabi
arm-unknown-linux-gnueabihf

i686-apple-darwin
i686-pc-windows-gnu
i686-unknown-freebsd
i686-unknown-linux-gnu

mips-unknown-linux-gnu
mipsel-unknown-linux-gnu

x86_64-apple-darwin
x86_64-unknown-freebsd
x86_64-unknown-linux-gnu
x86_64-pc-windows-gnu

Closes #16093

[breaking-change]
Diffstat (limited to 'src/libsyntax/abi.rs')
-rw-r--r--src/libsyntax/abi.rs74
1 files changed, 10 insertions, 64 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs
index dc41f3d9279..912755d0ea0 100644
--- a/src/libsyntax/abi.rs
+++ b/src/libsyntax/abi.rs
@@ -37,9 +37,6 @@ pub enum Abi {
 #[allow(non_camel_case_types)]
 #[deriving(PartialEq)]
 pub enum Architecture {
-    // NB. You cannot change the ordering of these
-    // constants without adjusting IntelBits below.
-    // (This is ensured by the test indices_are_correct().)
     X86,
     X86_64,
     Arm,
@@ -47,20 +44,11 @@ pub enum Architecture {
     Mipsel
 }
 
-#[allow(non_upper_case_globals)]
-const IntelBits: u32 = (1 << (X86 as uint)) | (1 << (X86_64 as uint));
-#[allow(non_upper_case_globals)]
-const ArmBits: u32 = (1 << (Arm as uint));
-
 pub struct AbiData {
     abi: Abi,
 
     // Name of this ABI as we like it called.
     name: &'static str,
-
-    // Is it specific to a platform? If so, which one?  Also, what is
-    // the name that LLVM gives it (in case we disagree)
-    abi_arch: AbiArchitecture
 }
 
 pub enum AbiArchitecture {
@@ -75,22 +63,21 @@ pub enum AbiArchitecture {
 #[allow(non_upper_case_globals)]
 static AbiDatas: &'static [AbiData] = &[
     // Platform-specific ABIs
-    AbiData {abi: Cdecl, name: "cdecl", abi_arch: Archs(IntelBits)},
-    AbiData {abi: Stdcall, name: "stdcall", abi_arch: Archs(IntelBits)},
-    AbiData {abi: Fastcall, name:"fastcall", abi_arch: Archs(IntelBits)},
-    AbiData {abi: Aapcs, name: "aapcs", abi_arch: Archs(ArmBits)},
-    AbiData {abi: Win64, name: "win64",
-             abi_arch: Archs(1 << (X86_64 as uint))},
+    AbiData {abi: Cdecl, name: "cdecl" },
+    AbiData {abi: Stdcall, name: "stdcall" },
+    AbiData {abi: Fastcall, name:"fastcall" },
+    AbiData {abi: Aapcs, name: "aapcs" },
+    AbiData {abi: Win64, name: "win64" },
 
     // Cross-platform ABIs
     //
     // NB: Do not adjust this ordering without
     // adjusting the indices below.
-    AbiData {abi: Rust, name: "Rust", abi_arch: RustArch},
-    AbiData {abi: C, name: "C", abi_arch: AllArch},
-    AbiData {abi: System, name: "system", abi_arch: AllArch},
-    AbiData {abi: RustIntrinsic, name: "rust-intrinsic", abi_arch: RustArch},
-    AbiData {abi: RustCall, name: "rust-call", abi_arch: RustArch},
+    AbiData {abi: Rust, name: "Rust" },
+    AbiData {abi: C, name: "C" },
+    AbiData {abi: System, name: "system" },
+    AbiData {abi: RustIntrinsic, name: "rust-intrinsic" },
+    AbiData {abi: RustCall, name: "rust-call" },
 ];
 
 /// Returns the ABI with the given name (if any).
@@ -116,28 +103,6 @@ impl Abi {
     pub fn name(&self) -> &'static str {
         self.data().name
     }
-
-    pub fn for_target(&self, os: Os, arch: Architecture) -> Option<Abi> {
-        // If this ABI isn't actually for the specified architecture, then we
-        // short circuit early
-        match self.data().abi_arch {
-            Archs(a) if a & arch.bit() == 0 => return None,
-            Archs(_) | RustArch | AllArch => {}
-        }
-        // Transform this ABI as appropriate for the requested os/arch
-        // combination.
-        Some(match (*self, os, arch) {
-            (System, OsWindows, X86) => Stdcall,
-            (System, _, _) => C,
-            (me, _, _) => me,
-        })
-    }
-}
-
-impl Architecture {
-    fn bit(&self) -> u32 {
-        1 << (*self as uint)
-    }
 }
 
 impl fmt::Show for Abi {
@@ -184,23 +149,4 @@ fn indices_are_correct() {
     for (i, abi_data) in AbiDatas.iter().enumerate() {
         assert_eq!(i, abi_data.abi.index());
     }
-
-    let bits = 1 << (X86 as uint);
-    let bits = bits | 1 << (X86_64 as uint);
-    assert_eq!(IntelBits, bits);
-
-    let bits = 1 << (Arm as uint);
-    assert_eq!(ArmBits, bits);
-}
-
-#[test]
-fn pick_uniplatform() {
-    assert_eq!(Stdcall.for_target(OsLinux, X86), Some(Stdcall));
-    assert_eq!(Stdcall.for_target(OsLinux, Arm), None);
-    assert_eq!(System.for_target(OsLinux, X86), Some(C));
-    assert_eq!(System.for_target(OsWindows, X86), Some(Stdcall));
-    assert_eq!(System.for_target(OsWindows, X86_64), Some(C));
-    assert_eq!(System.for_target(OsWindows, Arm), Some(C));
-    assert_eq!(Stdcall.for_target(OsWindows, X86), Some(Stdcall));
-    assert_eq!(Stdcall.for_target(OsWindows, X86_64), Some(Stdcall));
 }