Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion arm-targets/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

No changes
### Added

- Added support for legacy Arm targets: Armv5TE and Armv4T, including proper arch, isa, and profile handling.

## [v0.2.0]

Expand Down
21 changes: 19 additions & 2 deletions arm-targets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl Isa {
pub fn get(target: &str) -> Option<Isa> {
let arch = Arch::get(target)?;
Some(match arch {
Arch::Armv4T | Arch::Armv5TE => Isa::A32,
Arch::Armv6M => Isa::T32,
Arch::Armv7M => Isa::T32,
Arch::Armv7EM => Isa::T32,
Expand Down Expand Up @@ -118,6 +119,10 @@ impl core::fmt::Display for Isa {
/// As defined by a particular revision of the Arm Architecture Reference Manual (ARM).
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Arch {
/// Armv4T (legacy, also known as ARMv4T)
Armv4T,
/// Armv5TE (also known as ARMv5TE)
Armv5TE,
/// Armv6-M (also known as ARMv6-M)
Armv6M,
/// Armv7-M (also known as ARMv7-M)
Expand All @@ -141,7 +146,11 @@ pub enum Arch {
impl Arch {
/// Decode a target string
pub fn get(target: &str) -> Option<Arch> {
if target.starts_with("thumbv6m-") {
if target.starts_with("armv4t-") {
Some(Arch::Armv4T)
} else if target.starts_with("armv5te-") {
Some(Arch::Armv5TE)
} else if target.starts_with("thumbv6m-") {
Some(Arch::Armv6M)
} else if target.starts_with("thumbv7m-") {
Some(Arch::Armv7M)
Expand Down Expand Up @@ -170,6 +179,7 @@ impl Arch {
Arch::Armv6M | Arch::Armv7M | Arch::Armv7EM | Arch::Armv8MBase | Arch::Armv8MMain => {
Profile::M
}
Arch::Armv4T | Arch::Armv5TE => Profile::Legacy,
Arch::Armv7R | Arch::Armv8R => Profile::R,
Arch::Armv7A | Arch::Armv8A => Profile::A,
}
Expand All @@ -178,6 +188,8 @@ impl Arch {
/// Get a comma-separated list of values, suitable for cfg-check
pub fn values() -> String {
let string_versions: Vec<String> = [
Arch::Armv4T,
Arch::Armv5TE,
Arch::Armv6M,
Arch::Armv7M,
Arch::Armv7EM,
Expand All @@ -201,6 +213,8 @@ impl core::fmt::Display for Arch {
f,
"{}",
match self {
Arch::Armv4T => "v4t",
Arch::Armv5TE => "v5te",
Arch::Armv6M => "v6-m",
Arch::Armv7M => "v7-m",
Arch::Armv7EM => "v7e-m",
Expand All @@ -224,6 +238,8 @@ pub enum Profile {
R,
/// Applications
A,
/// Legacy
Legacy,
}

impl Profile {
Expand All @@ -235,7 +251,7 @@ impl Profile {

/// Get a comma-separated list of values, suitable for cfg-check
pub fn values() -> String {
let string_versions: Vec<String> = [Profile::A, Profile::R, Profile::M]
let string_versions: Vec<String> = [Profile::A, Profile::R, Profile::M, Profile::Legacy]
.iter()
.map(|i| format!(r#""{i}""#))
.collect();
Expand All @@ -252,6 +268,7 @@ impl core::fmt::Display for Profile {
Profile::M => "m",
Profile::R => "r",
Profile::A => "a",
Profile::Legacy => "legacy",
}
)
}
Expand Down