Add #[cfg(target_has_atomic)] to get atomic support for the current target

This commit is contained in:
Amanieu d'Antras 2016-04-15 20:16:19 +01:00
parent 50909f2d50
commit 04835ea5ec
45 changed files with 90 additions and 10 deletions

View file

@ -24,6 +24,7 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+neon,+fp-armv8,+cyclone".to_string(),
eliminate_frame_pointer: false,
max_atomic_width: 128,
.. opts(Arch::Arm64)
},
}

View file

@ -11,6 +11,8 @@
use target::Target;
pub fn target() -> Target {
let mut base = super::android_base::opts();
base.max_atomic_width = 128;
Target {
llvm_target: "aarch64-linux-android".to_string(),
target_endian: "little".to_string(),
@ -20,6 +22,6 @@ pub fn target() -> Target {
target_os: "android".to_string(),
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: super::android_base::opts(),
options: base,
}
}

View file

@ -11,7 +11,8 @@
use target::Target;
pub fn target() -> Target {
let base = super::linux_base::opts();
let mut base = super::linux_base::opts();
base.max_atomic_width = 128;
Target {
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::android_base::opts();
base.features = "+v7,+vfp3,+d16".to_string();
base.max_atomic_width = 64;
Target {
llvm_target: "arm-linux-androideabi".to_string(),

View file

@ -11,7 +11,8 @@
use target::{Target, TargetOptions};
pub fn target() -> Target {
let base = super::linux_base::opts();
let mut base = super::linux_base::opts();
base.max_atomic_width = 64;
Target {
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
target_endian: "little".to_string(),

View file

@ -11,7 +11,8 @@
use target::{Target, TargetOptions};
pub fn target() -> Target {
let base = super::linux_base::opts();
let mut base = super::linux_base::opts();
base.max_atomic_width = 64;
Target {
llvm_target: "arm-unknown-linux-gnueabihf".to_string(),
target_endian: "little".to_string(),

View file

@ -23,6 +23,7 @@ pub fn target() -> Target {
target_vendor: "apple".to_string(),
options: TargetOptions {
features: "+v7,+vfp3,+neon".to_string(),
max_atomic_width: 64,
.. opts(Arch::Armv7)
}
}

View file

@ -25,6 +25,7 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+v7,+vfp3,+neon".to_string(),
cpu: "cortex-a8".to_string(),
max_atomic_width: 64,
.. base
}
}

View file

@ -23,6 +23,7 @@ pub fn target() -> Target {
target_vendor: "apple".to_string(),
options: TargetOptions {
features: "+v7,+vfp4,+neon".to_string(),
max_atomic_width: 64,
.. opts(Arch::Armv7s)
}
}

View file

@ -22,6 +22,7 @@ pub fn target() -> Target {
linker_is_gnu: true,
allow_asm: false,
obj_is_bitcode: true,
max_atomic_width: 32,
.. Default::default()
};
Target {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetOptions};
use super::apple_ios_base::{opts, Arch};
pub fn target() -> Target {
@ -21,6 +21,9 @@ pub fn target() -> Target {
target_os: "ios".to_string(),
target_env: "".to_string(),
target_vendor: "apple".to_string(),
options: opts(Arch::I386)
options: TargetOptions {
max_atomic_width: 64,
.. opts(Arch::I386)
}
}
}

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::apple_base::opts();
base.cpu = "yonah".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m32".to_string());
Target {

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::android_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
Target {
llvm_target: "i686-linux-android".to_string(),

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::windows_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
// space available to x86 Windows binaries on x86_64.

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::windows_msvc_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
// space available to x86 Windows binaries on x86_64.

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::dragonfly_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m32".to_string());
Target {

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::freebsd_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m32".to_string());
Target {

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::linux_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m32".to_string());
Target {

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m32".to_string());
base.pre_link_args.push("-Wl,-melf_i386".to_string());

View file

@ -25,6 +25,7 @@ pub fn target() -> Target {
no_compiler_rt: false,
linker_is_gnu: true,
allow_asm: false,
max_atomic_width: 32,
.. Default::default()
};
Target {

View file

@ -23,6 +23,7 @@ pub fn target() -> Target {
options: TargetOptions {
cpu: "mips32r2".to_string(),
features: "+mips32r2,+soft-float".to_string(),
max_atomic_width: 32,
..super::linux_base::opts()
},
}

View file

@ -23,6 +23,7 @@ pub fn target() -> Target {
options: TargetOptions {
cpu: "mips32r2".to_string(),
features: "+mips32r2,+soft-float".to_string(),
max_atomic_width: 32,
..super::linux_base::opts()
}
}

View file

@ -24,6 +24,7 @@ pub fn target() -> Target {
options: TargetOptions {
cpu: "mips32".to_string(),
features: "+mips32".to_string(),
max_atomic_width: 32,
..super::linux_base::opts()
},
}

View file

@ -23,6 +23,7 @@ pub fn target() -> Target {
options: TargetOptions {
cpu: "mips32".to_string(),
features: "+mips32".to_string(),
max_atomic_width: 32,
..super::linux_base::opts()
}
}

View file

@ -292,6 +292,10 @@ pub struct TargetOptions {
// If we give emcc .o files that are actually .bc files it
// will 'just work'.
pub obj_is_bitcode: bool,
/// Maximum integer size in bits that this target can perform atomic
/// operations on.
pub max_atomic_width: u64,
}
impl Default for TargetOptions {
@ -340,6 +344,7 @@ impl Default for TargetOptions {
allow_asm: true,
has_elf_tls: false,
obj_is_bitcode: false,
max_atomic_width: 0,
}
}
}
@ -392,6 +397,9 @@ impl Target {
options: Default::default(),
};
// Default max-atomic-width to target-pointer-width
base.options.max_atomic_width = base.target_pointer_width.parse().unwrap();
macro_rules! key {
($key_name:ident) => ( {
let name = (stringify!($key_name)).replace("_", "-");
@ -404,6 +412,12 @@ impl Target {
.map(|o| o.as_boolean()
.map(|s| base.options.$key_name = s));
} );
($key_name:ident, u64) => ( {
let name = (stringify!($key_name)).replace("_", "-");
obj.find(&name[..])
.map(|o| o.as_u64()
.map(|s| base.options.$key_name = s));
} );
($key_name:ident, list) => ( {
let name = (stringify!($key_name)).replace("_", "-");
obj.find(&name[..]).map(|o| o.as_array()
@ -451,6 +465,7 @@ impl Target {
key!(archive_format);
key!(allow_asm, bool);
key!(custom_unwind_resume, bool);
key!(max_atomic_width, u64);
base
}

View file

@ -14,6 +14,7 @@ pub fn target() -> Target {
let mut base = super::linux_base::opts();
base.cpu = "ppc64".to_string();
base.pre_link_args.push("-m64".to_string());
base.max_atomic_width = 64;
Target {
llvm_target: "powerpc64-unknown-linux-gnu".to_string(),

View file

@ -14,6 +14,7 @@ pub fn target() -> Target {
let mut base = super::linux_base::opts();
base.cpu = "ppc64le".to_string();
base.pre_link_args.push("-m64".to_string());
base.max_atomic_width = 64;
Target {
llvm_target: "powerpc64le-unknown-linux-gnu".to_string(),

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::linux_base::opts();
base.pre_link_args.push("-m32".to_string());
base.max_atomic_width = 32;
Target {
llvm_target: "powerpc-unknown-linux-gnu".to_string(),

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::apple_base::opts();
base.cpu = "core2".to_string();
base.max_atomic_width = 128; // core2 support cmpxchg16b
base.eliminate_frame_pointer = false;
base.pre_link_args.push("-m64".to_string());

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetOptions};
use super::apple_ios_base::{opts, Arch};
pub fn target() -> Target {
@ -21,6 +21,9 @@ pub fn target() -> Target {
target_os: "ios".to_string(),
target_env: "".to_string(),
target_vendor: "apple".to_string(),
options: opts(Arch::X86_64)
options: TargetOptions {
max_atomic_width: 64,
.. opts(Arch::X86_64)
}
}
}

View file

@ -14,6 +14,7 @@ pub fn target() -> Target {
let mut base = super::windows_base::opts();
base.cpu = "x86-64".to_string();
base.pre_link_args.push("-m64".to_string());
base.max_atomic_width = 64;
Target {
llvm_target: "x86_64-pc-windows-gnu".to_string(),

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::windows_msvc_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
Target {
llvm_target: "x86_64-pc-windows-msvc".to_string(),

View file

@ -15,6 +15,7 @@ pub fn target() -> Target {
base.pre_link_args.push("-m64".to_string());
base.linker = "x86_64-rumprun-netbsd-gcc".to_string();
base.ar = "x86_64-rumprun-netbsd-ar".to_string();
base.max_atomic_width = 64;
base.dynamic_linking = false;
base.has_rpath = false;

View file

@ -14,6 +14,7 @@ pub fn target() -> Target {
let mut base = super::solaris_base::opts();
base.pre_link_args.push("-m64".to_string());
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
Target {
llvm_target: "x86_64-pc-solaris".to_string(),

View file

@ -12,6 +12,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::bitrig_base::opts();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::dragonfly_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::freebsd_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::linux_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {

View file

@ -12,6 +12,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::netbsd_base::opts();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {

View file

@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::openbsd_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {