Skip to content

Commit

Permalink
Rename target_word_size to target_pointer_width
Browse files Browse the repository at this point in the history
Closes #20421

[breaking-change]
  • Loading branch information
nrc committed Jan 7, 2015
1 parent 9f1ead8 commit dd3e89a
Show file tree
Hide file tree
Showing 36 changed files with 91 additions and 69 deletions.
4 changes: 2 additions & 2 deletions src/libcore/iter.rs
Expand Up @@ -2749,9 +2749,9 @@ macro_rules! step_impl_no_between {
}

step_impl!(uint u8 u16 u32 int i8 i16 i32);
#[cfg(target_word_size = "64")]
#[cfg(any(all(stage0, target_word_size = "64"), all(not(stage0), target_pointer_width = "64")))]
step_impl!(u64 i64);
#[cfg(target_word_size = "32")]
#[cfg(any(all(stage0, target_word_size = "32"), all(not(stage0), target_pointer_width = "32")))]
step_impl_no_between!(u64 i64);


Expand Down
7 changes: 5 additions & 2 deletions src/libcore/num/int.rs
Expand Up @@ -13,5 +13,8 @@
#![stable]
#![doc(primitive = "int")]

#[cfg(target_word_size = "32")] int_module! { int, 32 }
#[cfg(target_word_size = "64")] int_module! { int, 64 }
#[cfg(stage0)] #[cfg(target_word_size = "32")] int_module! { int, 32 }
#[cfg(stage0)] #[cfg(target_word_size = "64")] int_module! { int, 64 }

#[cfg(not(stage0))] #[cfg(target_pointer_width = "32")] int_module! { int, 32 }
#[cfg(not(stage0))] #[cfg(target_pointer_width = "64")] int_module! { int, 64 }
8 changes: 4 additions & 4 deletions src/libcore/num/mod.rs
Expand Up @@ -496,7 +496,7 @@ uint_impl! { u64 = u64, 64,
intrinsics::u64_sub_with_overflow,
intrinsics::u64_mul_with_overflow }

#[cfg(target_word_size = "32")]
#[cfg(any(all(stage0, target_word_size = "32"), all(not(stage0), target_pointer_width = "32")))]
uint_impl! { uint = u32, 32,
intrinsics::ctpop32,
intrinsics::ctlz32,
Expand All @@ -506,7 +506,7 @@ uint_impl! { uint = u32, 32,
intrinsics::u32_sub_with_overflow,
intrinsics::u32_mul_with_overflow }

#[cfg(target_word_size = "64")]
#[cfg(any(all(stage0, target_word_size = "64"), all(not(stage0), target_pointer_width = "64")))]
uint_impl! { uint = u64, 64,
intrinsics::ctpop64,
intrinsics::ctlz64,
Expand Down Expand Up @@ -601,13 +601,13 @@ int_impl! { i64 = i64, u64, 64,
intrinsics::i64_sub_with_overflow,
intrinsics::i64_mul_with_overflow }

#[cfg(target_word_size = "32")]
#[cfg(any(all(stage0, target_word_size = "32"), all(not(stage0), target_pointer_width = "32")))]
int_impl! { int = i32, u32, 32,
intrinsics::i32_add_with_overflow,
intrinsics::i32_sub_with_overflow,
intrinsics::i32_mul_with_overflow }

#[cfg(target_word_size = "64")]
#[cfg(any(all(stage0, target_word_size = "64"), all(not(stage0), target_pointer_width = "64")))]
int_impl! { int = i64, u64, 64,
intrinsics::i64_add_with_overflow,
intrinsics::i64_sub_with_overflow,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/filesearch.rs
Expand Up @@ -272,12 +272,12 @@ fn find_libdir(sysroot: &Path) -> String {
}
}

#[cfg(target_word_size = "64")]
#[cfg(any(all(stage0, target_word_size = "64"), all(not(stage0), target_pointer_width = "64")))]
fn primary_libdir_name() -> String {
"lib64".to_string()
}

#[cfg(target_word_size = "32")]
#[cfg(any(all(stage0, target_word_size = "32"), all(not(stage0), target_pointer_width = "32")))]
fn primary_libdir_name() -> String {
"lib32".to_string()
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/session/config.rs
Expand Up @@ -594,7 +594,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {

let end = sess.target.target.target_endian.index(&FullRange);
let arch = sess.target.target.arch.index(&FullRange);
let wordsz = sess.target.target.target_word_size.index(&FullRange);
let wordsz = sess.target.target.target_pointer_width.index(&FullRange);
let os = sess.target.target.target_os.index(&FullRange);

let fam = match sess.target.target.options.is_like_windows {
Expand All @@ -609,7 +609,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
mk(InternedString::new("target_family"), fam),
mk(InternedString::new("target_arch"), intern(arch)),
mk(InternedString::new("target_endian"), intern(end)),
mk(InternedString::new("target_word_size"),
mk(InternedString::new("target_pointer_width"),
intern(wordsz))
);
}
Expand Down Expand Up @@ -643,7 +643,7 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
}
};

let (int_type, uint_type) = match target.target_word_size.index(&FullRange) {
let (int_type, uint_type) = match target.target_pointer_width.index(&FullRange) {
"32" => (ast::TyI32, ast::TyU32),
"64" => (ast::TyI64, ast::TyU64),
w => sp.handler().fatal((format!("target specification was invalid: unrecognized \
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/aarch64_unknown_linux_gnu.rs
Expand Up @@ -18,7 +18,7 @@ pub fn target() -> Target {
n32:64-S128".to_string(),
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_word_size: "64".to_string(),
target_pointer_width: "64".to_string(),
arch: "aarch64".to_string(),
target_os: "linux".to_string(),
options: base,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/arm_apple_ios.rs
Expand Up @@ -19,7 +19,7 @@ pub fn target() -> Target {
-a:0:64-n32".to_string(),
llvm_target: "arm-apple-ios".to_string(),
target_endian: "little".to_string(),
target_word_size: "32".to_string(),
target_pointer_width: "32".to_string(),
arch: "arm".to_string(),
target_os: "ios".to_string(),
options: TargetOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/arm_linux_androideabi.rs
Expand Up @@ -27,7 +27,7 @@ pub fn target() -> Target {
-a:0:64-n32".to_string(),
llvm_target: "arm-linux-androideabi".to_string(),
target_endian: "little".to_string(),
target_word_size: "32".to_string(),
target_pointer_width: "32".to_string(),
arch: "arm".to_string(),
target_os: "android".to_string(),
options: base,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/arm_unknown_linux_gnueabi.rs
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> Target {
-a:0:64-n32".to_string(),
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
target_endian: "little".to_string(),
target_word_size: "32".to_string(),
target_pointer_width: "32".to_string(),
arch: "arm".to_string(),
target_os: "linux".to_string(),

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/arm_unknown_linux_gnueabihf.rs
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> Target {
-a:0:64-n32".to_string(),
llvm_target: "arm-unknown-linux-gnueabihf".to_string(),
target_endian: "little".to_string(),
target_word_size: "32".to_string(),
target_pointer_width: "32".to_string(),
arch: "arm".to_string(),
target_os: "linux".to_string(),

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i386_apple_ios.rs
Expand Up @@ -19,7 +19,7 @@ pub fn target() -> Target {
-n8:16:32".to_string(),
llvm_target: "i386-apple-ios".to_string(),
target_endian: "little".to_string(),
target_word_size: "32".to_string(),
target_pointer_width: "32".to_string(),
arch: "x86".to_string(),
target_os: "ios".to_string(),

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_apple_darwin.rs
Expand Up @@ -22,7 +22,7 @@ pub fn target() -> Target {
-n8:16:32".to_string(),
llvm_target: "i686-apple-darwin".to_string(),
target_endian: "little".to_string(),
target_word_size: "32".to_string(),
target_pointer_width: "32".to_string(),
arch: "x86".to_string(),
target_os: "macos".to_string(),
options: base,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_pc_windows_gnu.rs
Expand Up @@ -26,7 +26,7 @@ pub fn target() -> Target {
data_layout: "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32".to_string(),
llvm_target: "i686-pc-windows-gnu".to_string(),
target_endian: "little".to_string(),
target_word_size: "32".to_string(),
target_pointer_width: "32".to_string(),
arch: "x86".to_string(),
target_os: "windows".to_string(),
options: options,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_unknown_dragonfly.rs
Expand Up @@ -18,7 +18,7 @@ pub fn target() -> Target {
data_layout: "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string(),
llvm_target: "i686-unknown-dragonfly".to_string(),
target_endian: "little".to_string(),
target_word_size: "32".to_string(),
target_pointer_width: "32".to_string(),
arch: "x86".to_string(),
target_os: "dragonfly".to_string(),
options: base,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_unknown_linux_gnu.rs
Expand Up @@ -18,7 +18,7 @@ pub fn target() -> Target {
data_layout: "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string(),
llvm_target: "i686-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_word_size: "32".to_string(),
target_pointer_width: "32".to_string(),
arch: "x86".to_string(),
target_os: "linux".to_string(),
options: base,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mips_unknown_linux_gnu.rs
Expand Up @@ -19,7 +19,7 @@ pub fn target() -> Target {
-a:0:64-n32".to_string(),
llvm_target: "mips-unknown-linux-gnu".to_string(),
target_endian: "big".to_string(),
target_word_size: "32".to_string(),
target_pointer_width: "32".to_string(),
arch: "mips".to_string(),
target_os: "linux".to_string(),
options: super::linux_base::opts()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mipsel_unknown_linux_gnu.rs
Expand Up @@ -19,7 +19,7 @@ pub fn target() -> Target {
-a:0:64-n32".to_string(),
llvm_target: "mipsel-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_word_size: "32".to_string(),
target_pointer_width: "32".to_string(),
arch: "mips".to_string(),
target_os: "linux".to_string(),

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_back/target/mod.rs
Expand Up @@ -85,8 +85,8 @@ pub struct Target {
pub llvm_target: String,
/// String to use as the `target_endian` `cfg` variable.
pub target_endian: String,
/// String to use as the `target_word_size` `cfg` variable.
pub target_word_size: String,
/// String to use as the `target_pointer_width` `cfg` variable.
pub target_pointer_width: String,
/// OS name to use for conditional compilation.
pub target_os: String,
/// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm",
Expand Down Expand Up @@ -233,7 +233,7 @@ impl Target {
data_layout: get_req_field("data-layout"),
llvm_target: get_req_field("llvm-target"),
target_endian: get_req_field("target-endian"),
target_word_size: get_req_field("target-word-size"),
target_pointer_width: get_req_field("target-word-size"),
arch: get_req_field("arch"),
target_os: get_req_field("os"),
options: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_apple_darwin.rs
Expand Up @@ -21,7 +21,7 @@ pub fn target() -> Target {
s0:64:64-f80:128:128-n8:16:32:64".to_string(),
llvm_target: "x86_64-apple-darwin".to_string(),
target_endian: "little".to_string(),
target_word_size: "64".to_string(),
target_pointer_width: "64".to_string(),
arch: "x86_64".to_string(),
target_os: "macos".to_string(),
options: base,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_pc_windows_gnu.rs
Expand Up @@ -23,7 +23,7 @@ pub fn target() -> Target {
s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-pc-windows-gnu".to_string(),
target_endian: "little".to_string(),
target_word_size: "64".to_string(),
target_pointer_width: "64".to_string(),
arch: "x86_64".to_string(),
target_os: "windows".to_string(),
options: base,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_dragonfly.rs
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> Target {
s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-dragonfly".to_string(),
target_endian: "little".to_string(),
target_word_size: "64".to_string(),
target_pointer_width: "64".to_string(),
arch: "x86_64".to_string(),
target_os: "dragonfly".to_string(),
options: base,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_freebsd.rs
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> Target {
s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-freebsd".to_string(),
target_endian: "little".to_string(),
target_word_size: "64".to_string(),
target_pointer_width: "64".to_string(),
arch: "x86_64".to_string(),
target_os: "freebsd".to_string(),
options: base,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/x86_64_unknown_linux_gnu.rs
Expand Up @@ -20,7 +20,7 @@ pub fn target() -> Target {
s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_word_size: "64".to_string(),
target_pointer_width: "64".to_string(),
arch: "x86_64".to_string(),
target_os: "linux".to_string(),
options: base,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/trans/base.rs
Expand Up @@ -1128,7 +1128,7 @@ pub fn call_lifetime_end(cx: Block, ptr: ValueRef) {
pub fn call_memcpy(cx: Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) {
let _icx = push_ctxt("call_memcpy");
let ccx = cx.ccx();
let key = match ccx.sess().target.target.target_word_size.index(&FullRange) {
let key = match ccx.sess().target.target.target_pointer_width.index(&FullRange) {
"32" => "llvm.memcpy.p0i8.p0i8.i32",
"64" => "llvm.memcpy.p0i8.p0i8.i64",
tws => panic!("Unsupported target word size for memcpy: {}", tws),
Expand Down Expand Up @@ -1175,7 +1175,7 @@ fn memzero<'a, 'tcx>(b: &Builder<'a, 'tcx>, llptr: ValueRef, ty: Ty<'tcx>) {

let llty = type_of::type_of(ccx, ty);

let intrinsic_key = match ccx.sess().target.target.target_word_size.index(&FullRange) {
let intrinsic_key = match ccx.sess().target.target.target_pointer_width.index(&FullRange) {
"32" => "llvm.memset.p0i8.i32",
"64" => "llvm.memset.p0i8.i64",
tws => panic!("Unsupported target word size for memset: {}", tws),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/trans/context.rs
Expand Up @@ -721,7 +721,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
/// currently conservatively bounded to 1 << 47 as that is enough to cover the current usable
/// address space on 64-bit ARMv8 and x86_64.
pub fn obj_size_bound(&self) -> u64 {
match self.sess().target.target.target_word_size.index(&FullRange) {
match self.sess().target.target.target_pointer_width.index(&FullRange) {
"32" => 1 << 31,
"64" => 1 << 47,
_ => unreachable!() // error handled by config::build_target_config
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/trans/type_.rs
Expand Up @@ -103,7 +103,7 @@ impl Type {
}

pub fn int(ccx: &CrateContext) -> Type {
match ccx.tcx().sess.target.target.target_word_size.index(&FullRange) {
match ccx.tcx().sess.target.target.target_pointer_width.index(&FullRange) {
"32" => Type::i32(ccx),
"64" => Type::i64(ccx),
tws => panic!("Unsupported target word size for int: {}", tws),
Expand Down
6 changes: 3 additions & 3 deletions src/libserialize/json.rs
Expand Up @@ -3481,7 +3481,7 @@ mod tests {
}
}
#[test]
#[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
#[cfg_attr(target_pointer_width = "32", ignore)] // FIXME(#14064)
fn test_streaming_parser() {
assert_stream_equal(
r#"{ "foo":"bar", "array" : [0, 1, 2, 3, 4, 5], "idents":[null,true,false]}"#,
Expand Down Expand Up @@ -3520,7 +3520,7 @@ mod tests {
}

#[test]
#[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
#[cfg_attr(target_pointer_width = "32", ignore)] // FIXME(#14064)
fn test_read_object_streaming() {
assert_eq!(last_event("{ "), Error(SyntaxError(EOFWhileParsingObject, 1, 3)));
assert_eq!(last_event("{1"), Error(SyntaxError(KeyMustBeAString, 1, 2)));
Expand Down Expand Up @@ -3604,7 +3604,7 @@ mod tests {
);
}
#[test]
#[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
#[cfg_attr(target_pointer_width = "32", ignore)] // FIXME(#14064)
fn test_read_array_streaming() {
assert_stream_equal(
"[]",
Expand Down

5 comments on commit dd3e89a

@bors
Copy link
Contributor

@bors bors commented on dd3e89a Jan 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at nrc@dd3e89a

@bors
Copy link
Contributor

@bors bors commented on dd3e89a Jan 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nick29581/rust/target-word = dd3e89a into auto

@bors
Copy link
Contributor

@bors bors commented on dd3e89a Jan 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status: {"merge_sha": "3eb1b277ca39473348b3ed7ede505e29e6ae29ce"}

@bors
Copy link
Contributor

@bors bors commented on dd3e89a Jan 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nick29581/rust/target-word = dd3e89a merged ok, testing candidate = 3eb1b277

@bors
Copy link
Contributor

@bors bors commented on dd3e89a Jan 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.