Skip to content

Commit 982fdcf

Browse files
committed
Add ARMv6 bare-metal targets
Three targets, covering A32 and T32 instructions, and soft-float and hard-float ABIs. Hard-float and atomics not available in Thumb mode.
1 parent ed0006a commit 982fdcf

File tree

13 files changed

+156
-6
lines changed

13 files changed

+156
-6
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,10 +1741,14 @@ supported_targets! {
17411741
("mipsel-unknown-none", mipsel_unknown_none),
17421742
("mips-mti-none-elf", mips_mti_none_elf),
17431743
("mipsel-mti-none-elf", mipsel_mti_none_elf),
1744-
("thumbv4t-none-eabi", thumbv4t_none_eabi),
1744+
17451745
("armv4t-none-eabi", armv4t_none_eabi),
1746-
("thumbv5te-none-eabi", thumbv5te_none_eabi),
17471746
("armv5te-none-eabi", armv5te_none_eabi),
1747+
("armv6-none-eabi", armv6_none_eabi),
1748+
("armv6-none-eabihf", armv6_none_eabihf),
1749+
("thumbv4t-none-eabi", thumbv4t_none_eabi),
1750+
("thumbv5te-none-eabi", thumbv5te_none_eabi),
1751+
("thumbv6-none-eabi", thumbv6_none_eabi),
17481752

17491753
("aarch64_be-unknown-linux-gnu", aarch64_be_unknown_linux_gnu),
17501754
("aarch64-unknown-linux-gnu_ilp32", aarch64_unknown_linux_gnu_ilp32),

compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Targets the ARMv4T, with code as `a32` code by default.
1+
//! Targets the ARMv4T, with `a32` code by default.
22
//!
33
//! Primarily of use for the GBA, but usable with other devices too.
44
//!

compiler/rustc_target/src/spec/targets/armv5te_none_eabi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Targets the ARMv5TE, with code as `a32` code by default.
1+
//! Targets the ARMv5TE, with `a32` code by default.
22
33
use crate::spec::{Abi, Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs};
44

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! Targets the ARMv6K architecture, with `a32` code by default.
2+
3+
use crate::spec::{Abi, Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs};
4+
5+
pub(crate) fn target() -> Target {
6+
Target {
7+
llvm_target: "armv6-none-eabi".into(),
8+
metadata: TargetMetadata {
9+
description: Some("Bare ARMv6 soft-float".into()),
10+
tier: Some(3),
11+
host_tools: Some(false),
12+
std: Some(false),
13+
},
14+
pointer_width: 32,
15+
arch: Arch::Arm,
16+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
17+
options: TargetOptions {
18+
abi: Abi::Eabi,
19+
llvm_floatabi: Some(FloatAbi::Soft),
20+
asm_args: cvs!["-mthumb-interwork", "-march=armv6", "-mlittle-endian",],
21+
features: "+soft-float,+strict-align,+v6k".into(),
22+
atomic_cas: true,
23+
has_thumb_interworking: true,
24+
..base::arm_none::opts()
25+
},
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! Targets the ARMv6K architecture, with `a32` code by default, and hard-float ABI
2+
3+
use crate::spec::{Abi, Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs};
4+
5+
pub(crate) fn target() -> Target {
6+
Target {
7+
llvm_target: "armv6-none-eabihf".into(),
8+
metadata: TargetMetadata {
9+
description: Some("Bare ARMv6 hard-float".into()),
10+
tier: Some(3),
11+
host_tools: Some(false),
12+
std: Some(false),
13+
},
14+
pointer_width: 32,
15+
arch: Arch::Arm,
16+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
17+
options: TargetOptions {
18+
abi: Abi::EabiHf,
19+
llvm_floatabi: Some(FloatAbi::Hard),
20+
asm_args: cvs!["-mthumb-interwork", "-march=armv6", "-mlittle-endian",],
21+
features: "+strict-align,+v6k,+vfp2,-d32".into(),
22+
atomic_cas: true,
23+
has_thumb_interworking: true,
24+
..base::arm_none::opts()
25+
},
26+
}
27+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//! Targets the ARMv6K architecture, with `t32` code by default.
2+
3+
use crate::spec::{Abi, Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs};
4+
5+
pub(crate) fn target() -> Target {
6+
Target {
7+
llvm_target: "thumbv6-none-eabi".into(),
8+
metadata: TargetMetadata {
9+
description: Some("Thumb-mode Bare ARMv6 soft-float".into()),
10+
tier: Some(3),
11+
host_tools: Some(false),
12+
std: Some(false),
13+
},
14+
pointer_width: 32,
15+
arch: Arch::Arm,
16+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
17+
options: TargetOptions {
18+
abi: Abi::Eabi,
19+
llvm_floatabi: Some(FloatAbi::Soft),
20+
asm_args: cvs!["-mthumb-interwork", "-march=armv6", "-mlittle-endian",],
21+
features: "+soft-float,+strict-align,+v6k".into(),
22+
// atomics not available until ARMv6T2
23+
atomic_cas: false,
24+
max_atomic_width: Some(0),
25+
has_thumb_interworking: true,
26+
..base::arm_none::opts()
27+
},
28+
}
29+
}

library/core/src/hint.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,15 @@ pub fn spin_loop() {
292292
// SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets.
293293
unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) }
294294
}
295-
all(target_arch = "arm", target_feature = "v6") => {
295+
all(
296+
target_arch = "arm",
297+
any(
298+
all(target_feature = "v6k", not(target_feature = "thumb-mode")),
299+
target_feature = "v6t2",
300+
all(target_feature = "v6", target_feature = "mclass"),
301+
target_feature = "v7",
302+
)
303+
) => {
296304
// SAFETY: the `cfg` attr ensures that we only execute this on arm targets
297305
// with support for the v6 feature.
298306
unsafe { crate::arch::arm::__yield() }

library/stdarch/crates/core_arch/src/arm_shared/hints.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ pub unsafe fn __sevl() {
8383
/// improve overall system performance.
8484
// Section 10.1 of ACLE says that the supported arches are: 8, 6K, 6-M
8585
// LLVM says "instruction requires: armv6k"
86+
// On ARMv6 in Thumb mode, T2 is required.
8687
#[cfg(any(
87-
target_feature = "v6",
88+
all(target_feature = "v6k", not(target_feature = "thumb-mode")),
89+
target_feature = "v6t2",
90+
all(target_feature = "v6", target_feature = "mclass"),
91+
target_feature = "v7",
8892
target_arch = "aarch64",
8993
target_arch = "arm64ec",
9094
doc

src/bootstrap/src/core/sanity.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[
4343
"riscv64gc-unknown-redox",
4444
"riscv64im-unknown-none-elf",
4545
"hexagon-unknown-qurt",
46+
"armv6-none-eabi",
47+
"armv6-none-eabihf",
48+
"thumbv6-none-eabi",
4649
];
4750

4851
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
- [arm-none-eabi](platform-support/arm-none-eabi.md)
5757
- [{arm,thumb}v4t-none-eabi](platform-support/armv4t-none-eabi.md)
5858
- [{arm,thumb}v5te-none-eabi](platform-support/armv5te-none-eabi.md)
59+
- [{arm,thumb}v6-none-eabi{,hf}](platform-support/armv6-none-eabi.md)
5960
- [armv7a-none-eabi{,hf}](platform-support/armv7a-none-eabi.md)
6061
- [armv7r-none-eabi{,hf}](platform-support/armv7r-none-eabi.md)
6162
- [armebv7r-none-eabi{,hf}](platform-support/armebv7r-none-eabi.md)

0 commit comments

Comments
 (0)