Skip to content

Commit 05b64c3

Browse files
author
Jorge Aparicio
committed
add thumb* targets to the compiler
1 parent 9298f84 commit 05b64c3

File tree

6 files changed

+148
-2
lines changed

6 files changed

+148
-2
lines changed

src/librustc_back/target/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ mod netbsd_base;
6363
mod solaris_base;
6464
mod windows_base;
6565
mod windows_msvc_base;
66+
mod thumb_base;
6667

6768
pub type TargetResult = Result<Target, String>;
6869

6970
macro_rules! supported_targets {
70-
( $(($triple:expr, $module:ident)),+ ) => (
71+
( $(($triple:expr, $module:ident)),+, ) => (
7172
$(mod $module;)*
7273

7374
/// List of supported targets
@@ -184,7 +185,12 @@ supported_targets! {
184185
("i586-pc-windows-msvc", i586_pc_windows_msvc),
185186

186187
("le32-unknown-nacl", le32_unknown_nacl),
187-
("asmjs-unknown-emscripten", asmjs_unknown_emscripten)
188+
("asmjs-unknown-emscripten", asmjs_unknown_emscripten),
189+
190+
("thumbv6m-none-eabi", thumbv6m_none_eabi),
191+
("thumbv7m-none-eabi", thumbv7m_none_eabi),
192+
("thumbv7em-none-eabi", thumbv7em_none_eabi),
193+
("thumbv7em-none-eabihf", thumbv7em_none_eabihf),
188194
}
189195

190196
/// Everything `rustc` knows about how to compile for a specific target.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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::TargetOptions;
12+
use std::default::Default;
13+
14+
pub fn opts() -> TargetOptions {
15+
TargetOptions {
16+
executables: true,
17+
linker: "arm-none-eabi-gcc".to_string(),
18+
max_atomic_width: 32,
19+
.. Default::default()
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2016 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, TargetOptions, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
let mut base = super::thumb_base::opts();
15+
// There are no atomic instructions in the ARMv6-M architecture
16+
base.max_atomic_width = 0;
17+
Ok(Target {
18+
llvm_target: "thumbv6m-none-eabi".to_string(),
19+
target_endian: "little".to_string(),
20+
target_pointer_width: "32".to_string(),
21+
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
22+
arch: "arm".to_string(),
23+
target_os: "none".to_string(),
24+
target_env: "".to_string(),
25+
target_vendor: "".to_string(),
26+
27+
options: TargetOptions {
28+
// NOTE prevents mis-optimizations of `ptr::copy_nonoverlapping` when unaligned loads
29+
// are involved
30+
features: "+strict-align".to_string(),
31+
.. base
32+
}
33+
})
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2016 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, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
let base = super::thumb_base::opts();
15+
Ok(Target {
16+
llvm_target: "thumbv7em-none-eabi".to_string(),
17+
target_endian: "little".to_string(),
18+
target_pointer_width: "32".to_string(),
19+
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
20+
arch: "arm".to_string(),
21+
target_os: "none".to_string(),
22+
target_env: "".to_string(),
23+
target_vendor: "".to_string(),
24+
25+
options: base,
26+
})
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2016 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, TargetOptions, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
let base = super::thumb_base::opts();
15+
Ok(Target {
16+
llvm_target: "thumbv7em-none-eabihf".to_string(),
17+
target_endian: "little".to_string(),
18+
target_pointer_width: "32".to_string(),
19+
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
20+
arch: "arm".to_string(),
21+
target_os: "none".to_string(),
22+
target_env: "".to_string(),
23+
target_vendor: "".to_string(),
24+
25+
options: TargetOptions {
26+
// NOTE lowest common denominator between the Cortex-M4 (vfp4) and the Cortex-M7 (vfp5)
27+
features: "+vfp4".to_string(),
28+
.. base
29+
}
30+
})
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2016 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, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
let base = super::thumb_base::opts();
15+
Ok(Target {
16+
llvm_target: "thumbv7m-none-eabi".to_string(),
17+
target_endian: "little".to_string(),
18+
target_pointer_width: "32".to_string(),
19+
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
20+
arch: "arm".to_string(),
21+
target_os: "none".to_string(),
22+
target_env: "".to_string(),
23+
target_vendor: "".to_string(),
24+
25+
options: base,
26+
})
27+
}

0 commit comments

Comments
 (0)