Auto merge of #38579 - whitequark:min_atomic_width, r=alexcrichton
Add a min_atomic_width target option, like max_atomic_width Rationale: some ISAs, e.g. OR1K, do not have atomic instructions for byte and halfword access, and at the same time do not have a fixed endianness, which makes it unreasonable to implement these through word-sized atomic accesses.
This commit is contained in:
commit
0807104c8f
@ -943,6 +943,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
|||||||
let os = &sess.target.target.target_os;
|
let os = &sess.target.target.target_os;
|
||||||
let env = &sess.target.target.target_env;
|
let env = &sess.target.target.target_env;
|
||||||
let vendor = &sess.target.target.target_vendor;
|
let vendor = &sess.target.target.target_vendor;
|
||||||
|
let min_atomic_width = sess.target.target.min_atomic_width();
|
||||||
let max_atomic_width = sess.target.target.max_atomic_width();
|
let max_atomic_width = sess.target.target.max_atomic_width();
|
||||||
|
|
||||||
let mut ret = HashSet::new();
|
let mut ret = HashSet::new();
|
||||||
@ -963,7 +964,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
|||||||
ret.insert((Symbol::intern("target_thread_local"), None));
|
ret.insert((Symbol::intern("target_thread_local"), None));
|
||||||
}
|
}
|
||||||
for &i in &[8, 16, 32, 64, 128] {
|
for &i in &[8, 16, 32, 64, 128] {
|
||||||
if i <= max_atomic_width {
|
if i >= min_atomic_width && i <= max_atomic_width {
|
||||||
let s = i.to_string();
|
let s = i.to_string();
|
||||||
ret.insert((Symbol::intern("target_has_atomic"), Some(Symbol::intern(&s))));
|
ret.insert((Symbol::intern("target_has_atomic"), Some(Symbol::intern(&s))));
|
||||||
if &s == wordsz {
|
if &s == wordsz {
|
||||||
|
@ -376,6 +376,9 @@ pub struct TargetOptions {
|
|||||||
// file
|
// file
|
||||||
pub no_integrated_as: bool,
|
pub no_integrated_as: bool,
|
||||||
|
|
||||||
|
/// Don't use this field; instead use the `.min_atomic_width()` method.
|
||||||
|
pub min_atomic_width: Option<u64>,
|
||||||
|
|
||||||
/// Don't use this field; instead use the `.max_atomic_width()` method.
|
/// Don't use this field; instead use the `.max_atomic_width()` method.
|
||||||
pub max_atomic_width: Option<u64>,
|
pub max_atomic_width: Option<u64>,
|
||||||
|
|
||||||
@ -439,6 +442,7 @@ impl Default for TargetOptions {
|
|||||||
has_elf_tls: false,
|
has_elf_tls: false,
|
||||||
obj_is_bitcode: false,
|
obj_is_bitcode: false,
|
||||||
no_integrated_as: false,
|
no_integrated_as: false,
|
||||||
|
min_atomic_width: None,
|
||||||
max_atomic_width: None,
|
max_atomic_width: None,
|
||||||
panic_strategy: PanicStrategy::Unwind,
|
panic_strategy: PanicStrategy::Unwind,
|
||||||
abi_blacklist: vec![],
|
abi_blacklist: vec![],
|
||||||
@ -462,6 +466,12 @@ impl Target {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Minimum integer size in bits that this target can perform atomic
|
||||||
|
/// operations on.
|
||||||
|
pub fn min_atomic_width(&self) -> u64 {
|
||||||
|
self.options.min_atomic_width.unwrap_or(8)
|
||||||
|
}
|
||||||
|
|
||||||
/// Maximum integer size in bits that this target can perform atomic
|
/// Maximum integer size in bits that this target can perform atomic
|
||||||
/// operations on.
|
/// operations on.
|
||||||
pub fn max_atomic_width(&self) -> u64 {
|
pub fn max_atomic_width(&self) -> u64 {
|
||||||
@ -604,6 +614,7 @@ impl Target {
|
|||||||
key!(obj_is_bitcode, bool);
|
key!(obj_is_bitcode, bool);
|
||||||
key!(no_integrated_as, bool);
|
key!(no_integrated_as, bool);
|
||||||
key!(max_atomic_width, Option<u64>);
|
key!(max_atomic_width, Option<u64>);
|
||||||
|
key!(min_atomic_width, Option<u64>);
|
||||||
try!(key!(panic_strategy, PanicStrategy));
|
try!(key!(panic_strategy, PanicStrategy));
|
||||||
key!(crt_static_default, bool);
|
key!(crt_static_default, bool);
|
||||||
|
|
||||||
@ -766,6 +777,7 @@ impl ToJson for Target {
|
|||||||
target_option_val!(has_elf_tls);
|
target_option_val!(has_elf_tls);
|
||||||
target_option_val!(obj_is_bitcode);
|
target_option_val!(obj_is_bitcode);
|
||||||
target_option_val!(no_integrated_as);
|
target_option_val!(no_integrated_as);
|
||||||
|
target_option_val!(min_atomic_width);
|
||||||
target_option_val!(max_atomic_width);
|
target_option_val!(max_atomic_width);
|
||||||
target_option_val!(panic_strategy);
|
target_option_val!(panic_strategy);
|
||||||
target_option_val!(crt_static_default);
|
target_option_val!(crt_static_default);
|
||||||
|
Loading…
Reference in New Issue
Block a user