Skip to content

Commit a50ed7e

Browse files
committedDec 19, 2014
Initial version of AArch64 support.
1 parent bd90b93 commit a50ed7e

File tree

25 files changed

+506
-33
lines changed

25 files changed

+506
-33
lines changed
 

‎src/liballoc/heap.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ unsafe fn exchange_free(ptr: *mut u8, old_size: uint, align: uint) {
120120
target_arch = "mipsel"))]
121121
const MIN_ALIGN: uint = 8;
122122
#[cfg(any(target_arch = "x86",
123-
target_arch = "x86_64"))]
123+
target_arch = "x86_64",
124+
target_arch = "aarch64"))]
124125
const MIN_ALIGN: uint = 16;
125126

126127
#[cfg(external_funcs)]

‎src/libcore/hash/sip.rs

+6
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@ mod tests {
424424
}
425425
}
426426

427+
#[test] #[cfg(target_arch = "aarch64")]
428+
fn test_hash_uint() {
429+
let val = 0xdeadbeef_deadbeef_u64;
430+
assert_eq!(hash(&(val as u64)), hash(&(val as uint)));
431+
assert!(hash(&(val as u32)) != hash(&(val as uint)));
432+
}
427433
#[test] #[cfg(target_arch = "arm")]
428434
fn test_hash_uint() {
429435
let val = 0xdeadbeef_deadbeef_u64;

‎src/libcoretest/mem.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ fn size_of_32() {
2929
}
3030

3131
#[test]
32-
#[cfg(target_arch = "x86_64")]
32+
#[cfg(any(target_arch = "x86_64",
33+
target_arch = "aarch64"))]
3334
fn size_of_64() {
3435
assert_eq!(size_of::<uint>(), 8u);
3536
assert_eq!(size_of::<*const uint>(), 8u);
@@ -61,7 +62,8 @@ fn align_of_32() {
6162
}
6263

6364
#[test]
64-
#[cfg(target_arch = "x86_64")]
65+
#[cfg(any(target_arch = "x86_64",
66+
target_arch = "aarch64"))]
6567
fn align_of_64() {
6668
assert_eq!(align_of::<uint>(), 8u);
6769
assert_eq!(align_of::<*const uint>(), 8u);

‎src/liblibc/lib.rs

+63-4
Original file line numberDiff line numberDiff line change
@@ -720,10 +720,14 @@ pub mod types {
720720

721721
}
722722

723-
#[cfg(target_arch = "x86_64")]
723+
#[cfg(any(target_arch = "x86_64",
724+
target_arch = "aarch64"))]
724725
pub mod arch {
725726
pub mod c95 {
727+
#[cfg(not(target_arch = "aarch64"))]
726728
pub type c_char = i8;
729+
#[cfg(target_arch = "aarch64")]
730+
pub type c_char = u8;
727731
pub type c_schar = i8;
728732
pub type c_uchar = u8;
729733
pub type c_short = i16;
@@ -739,7 +743,10 @@ pub mod types {
739743
pub type clock_t = i64;
740744
pub type time_t = i64;
741745
pub type suseconds_t = i64;
746+
#[cfg(not(target_arch = "aarch64"))]
742747
pub type wchar_t = i32;
748+
#[cfg(target_arch = "aarch64")]
749+
pub type wchar_t = u32;
743750
}
744751
pub mod c99 {
745752
pub type c_longlong = i64;
@@ -760,6 +767,7 @@ pub mod types {
760767
pub type mode_t = u32;
761768
pub type ssize_t = i64;
762769
}
770+
#[cfg(not(target_arch = "aarch64"))]
763771
pub mod posix01 {
764772
use types::os::arch::c95::{c_int, c_long, time_t};
765773
use types::os::arch::posix88::{dev_t, gid_t, ino_t};
@@ -769,6 +777,7 @@ pub mod types {
769777
pub type nlink_t = u64;
770778
pub type blksize_t = i64;
771779
pub type blkcnt_t = i64;
780+
772781
#[repr(C)]
773782
#[deriving(Copy)] pub struct stat {
774783
pub st_dev: dev_t,
@@ -802,6 +811,51 @@ pub mod types {
802811
pub __size: [u64, ..7]
803812
}
804813
}
814+
#[cfg(target_arch = "aarch64")]
815+
pub mod posix01 {
816+
use types::os::arch::c95::{c_int, c_long, time_t};
817+
use types::os::arch::posix88::{dev_t, gid_t, ino_t};
818+
use types::os::arch::posix88::{mode_t, off_t};
819+
use types::os::arch::posix88::{uid_t};
820+
821+
pub type nlink_t = u32;
822+
pub type blksize_t = i32;
823+
pub type blkcnt_t = i64;
824+
825+
#[repr(C)]
826+
#[deriving(Copy)] pub struct stat {
827+
pub st_dev: dev_t,
828+
pub st_ino: ino_t,
829+
pub st_mode: mode_t,
830+
pub st_nlink: nlink_t,
831+
pub st_uid: uid_t,
832+
pub st_gid: gid_t,
833+
pub st_rdev: dev_t,
834+
pub __pad1: dev_t,
835+
pub st_size: off_t,
836+
pub st_blksize: blksize_t,
837+
pub __pad2: c_int,
838+
pub st_blocks: blkcnt_t,
839+
pub st_atime: time_t,
840+
pub st_atime_nsec: c_long,
841+
pub st_mtime: time_t,
842+
pub st_mtime_nsec: c_long,
843+
pub st_ctime: time_t,
844+
pub st_ctime_nsec: c_long,
845+
pub __unused: [c_int, ..2],
846+
}
847+
848+
#[repr(C)]
849+
#[deriving(Copy)] pub struct utimbuf {
850+
pub actime: time_t,
851+
pub modtime: time_t,
852+
}
853+
854+
#[repr(C)]
855+
#[deriving(Copy)] pub struct pthread_attr_t {
856+
pub __size: [u64, ..8]
857+
}
858+
}
805859
pub mod posix08 {
806860
}
807861
pub mod bsd44 {
@@ -2432,7 +2486,8 @@ pub mod consts {
24322486
}
24332487
#[cfg(any(target_arch = "x86",
24342488
target_arch = "x86_64",
2435-
target_arch = "arm"))]
2489+
target_arch = "arm",
2490+
target_arch = "aarch64"))]
24362491
pub mod posix88 {
24372492
use types::os::arch::c95::c_int;
24382493
use types::common::c95::c_void;
@@ -2927,7 +2982,9 @@ pub mod consts {
29272982
pub const PTHREAD_STACK_MIN: size_t = 16384;
29282983

29292984
#[cfg(all(target_os = "linux",
2930-
any(target_arch = "mips", target_arch = "mipsel")))]
2985+
any(target_arch = "mips",
2986+
target_arch = "mipsel",
2987+
target_arch = "aarch64")))]
29312988
pub const PTHREAD_STACK_MIN: size_t = 131072;
29322989

29332990
pub const CLOCK_REALTIME: c_int = 0;
@@ -2936,6 +2993,7 @@ pub mod consts {
29362993
pub mod posix08 {
29372994
}
29382995
#[cfg(any(target_arch = "arm",
2996+
target_arch = "aarch64",
29392997
target_arch = "x86",
29402998
target_arch = "x86_64"))]
29412999
pub mod bsd44 {
@@ -3031,7 +3089,8 @@ pub mod consts {
30313089
}
30323090
#[cfg(any(target_arch = "x86",
30333091
target_arch = "x86_64",
3034-
target_arch = "arm"))]
3092+
target_arch = "arm",
3093+
target_arch = "aarch64"))]
30353094
pub mod extra {
30363095
use types::os::arch::c95::c_int;
30373096

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use target::Target;
12+
13+
pub fn target() -> Target {
14+
let base = super::linux_base::opts();
15+
Target {
16+
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
17+
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-\
18+
n32:64-S128".to_string(),
19+
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
20+
target_endian: "little".to_string(),
21+
target_word_size: "64".to_string(),
22+
arch: "aarch64".to_string(),
23+
target_os: "linux".to_string(),
24+
options: base,
25+
}
26+
}

‎src/librustc_back/target/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ mod arm_apple_ios;
6060
mod arm_linux_androideabi;
6161
mod arm_unknown_linux_gnueabi;
6262
mod arm_unknown_linux_gnueabihf;
63+
mod aarch64_unknown_linux_gnu;
6364
mod i686_apple_darwin;
6465
mod i386_apple_ios;
6566
mod i686_pc_windows_gnu;
@@ -88,8 +89,8 @@ pub struct Target {
8889
pub target_word_size: String,
8990
/// OS name to use for conditional compilation.
9091
pub target_os: String,
91-
/// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm", and
92-
/// "mips". "mips" includes "mipsel".
92+
/// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm",
93+
/// "aarch64", and "mips". "mips" includes "mipsel".
9394
pub arch: String,
9495
/// Optional settings with defaults.
9596
pub options: TargetOptions,
@@ -335,6 +336,7 @@ impl Target {
335336
arm_linux_androideabi,
336337
arm_unknown_linux_gnueabi,
337338
arm_unknown_linux_gnueabihf,
339+
aarch64_unknown_linux_gnu,
338340

339341
x86_64_unknown_freebsd,
340342

‎src/librustc_llvm/lib.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,11 @@ extern {
19861986
pub fn LLVMInitializeARMTargetMC();
19871987
pub fn LLVMInitializeARMAsmPrinter();
19881988
pub fn LLVMInitializeARMAsmParser();
1989+
pub fn LLVMInitializeAArch64TargetInfo();
1990+
pub fn LLVMInitializeAArch64Target();
1991+
pub fn LLVMInitializeAArch64TargetMC();
1992+
pub fn LLVMInitializeAArch64AsmPrinter();
1993+
pub fn LLVMInitializeAArch64AsmParser();
19891994
pub fn LLVMInitializeMipsTargetInfo();
19901995
pub fn LLVMInitializeMipsTarget();
19911996
pub fn LLVMInitializeMipsTargetMC();
@@ -2255,6 +2260,12 @@ pub unsafe fn static_link_hack_this_sucks() {
22552260
LLVMInitializeARMAsmPrinter();
22562261
LLVMInitializeARMAsmParser();
22572262

2263+
LLVMInitializeAArch64TargetInfo();
2264+
LLVMInitializeAArch64Target();
2265+
LLVMInitializeAArch64TargetMC();
2266+
LLVMInitializeAArch64AsmPrinter();
2267+
LLVMInitializeAArch64AsmParser();
2268+
22582269
LLVMInitializeMipsTargetInfo();
22592270
LLVMInitializeMipsTarget();
22602271
LLVMInitializeMipsTargetMC();

‎src/librustc_trans/back/write.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,12 @@ unsafe fn configure_llvm(sess: &Session) {
10261026
llvm::LLVMInitializeARMAsmPrinter();
10271027
llvm::LLVMInitializeARMAsmParser();
10281028

1029+
llvm::LLVMInitializeAArch64TargetInfo();
1030+
llvm::LLVMInitializeAArch64Target();
1031+
llvm::LLVMInitializeAArch64TargetMC();
1032+
llvm::LLVMInitializeAArch64AsmPrinter();
1033+
llvm::LLVMInitializeAArch64AsmParser();
1034+
10291035
llvm::LLVMInitializeMipsTargetInfo();
10301036
llvm::LLVMInitializeMipsTarget();
10311037
llvm::LLVMInitializeMipsTargetMC();

‎src/librustc_trans/trans/asm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
165165
// Basically what clang does
166166

167167
#[cfg(any(target_arch = "arm",
168+
target_arch = "aarch64",
168169
target_arch = "mips",
169170
target_arch = "mipsel"))]
170171
fn get_clobbers() -> String {

‎src/librustc_trans/trans/cabi.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -17,6 +17,7 @@ use trans::cabi_x86;
1717
use trans::cabi_x86_64;
1818
use trans::cabi_x86_win64;
1919
use trans::cabi_arm;
20+
use trans::cabi_aarch64;
2021
use trans::cabi_mips;
2122
use trans::type_::Type;
2223

@@ -119,6 +120,7 @@ pub fn compute_abi_info(ccx: &CrateContext,
119120
cabi_x86_64::compute_abi_info(ccx, atys, rty, ret_def)
120121
},
121122
"arm" => cabi_arm::compute_abi_info(ccx, atys, rty, ret_def),
123+
"aarch64" => cabi_aarch64::compute_abi_info(ccx, atys, rty, ret_def),
122124
"mips" => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def),
123125
a => ccx.sess().fatal((format!("unrecognized arch \"{}\" in target specification", a))
124126
.as_slice()),

0 commit comments

Comments
 (0)
Please sign in to comment.