Skip to content

Commit 5ff05d8

Browse files
Merge pull request #61 from KushalMeghani1644/add_armv4
Add support for legacy Armv4 and Armv4T architectures
2 parents d599edc + d7033eb commit 5ff05d8

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

arm-targets/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
No changes
10+
### Added
11+
12+
- Added support for legacy Arm targets: Armv5TE and Armv4T, including proper arch, isa, and profile handling.
1113

1214
## [v0.2.0]
1315

arm-targets/src/lib.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ impl Isa {
7777
pub fn get(target: &str) -> Option<Isa> {
7878
let arch = Arch::get(target)?;
7979
Some(match arch {
80+
Arch::Armv4T | Arch::Armv5TE => Isa::A32,
8081
Arch::Armv6M => Isa::T32,
8182
Arch::Armv7M => Isa::T32,
8283
Arch::Armv7EM => Isa::T32,
@@ -118,6 +119,10 @@ impl core::fmt::Display for Isa {
118119
/// As defined by a particular revision of the Arm Architecture Reference Manual (ARM).
119120
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
120121
pub enum Arch {
122+
/// Armv4T (legacy, also known as ARMv4T)
123+
Armv4T,
124+
/// Armv5TE (also known as ARMv5TE)
125+
Armv5TE,
121126
/// Armv6-M (also known as ARMv6-M)
122127
Armv6M,
123128
/// Armv7-M (also known as ARMv7-M)
@@ -141,7 +146,11 @@ pub enum Arch {
141146
impl Arch {
142147
/// Decode a target string
143148
pub fn get(target: &str) -> Option<Arch> {
144-
if target.starts_with("thumbv6m-") {
149+
if target.starts_with("armv4t-") {
150+
Some(Arch::Armv4T)
151+
} else if target.starts_with("armv5te-") {
152+
Some(Arch::Armv5TE)
153+
} else if target.starts_with("thumbv6m-") {
145154
Some(Arch::Armv6M)
146155
} else if target.starts_with("thumbv7m-") {
147156
Some(Arch::Armv7M)
@@ -170,6 +179,7 @@ impl Arch {
170179
Arch::Armv6M | Arch::Armv7M | Arch::Armv7EM | Arch::Armv8MBase | Arch::Armv8MMain => {
171180
Profile::M
172181
}
182+
Arch::Armv4T | Arch::Armv5TE => Profile::Legacy,
173183
Arch::Armv7R | Arch::Armv8R => Profile::R,
174184
Arch::Armv7A | Arch::Armv8A => Profile::A,
175185
}
@@ -178,6 +188,8 @@ impl Arch {
178188
/// Get a comma-separated list of values, suitable for cfg-check
179189
pub fn values() -> String {
180190
let string_versions: Vec<String> = [
191+
Arch::Armv4T,
192+
Arch::Armv5TE,
181193
Arch::Armv6M,
182194
Arch::Armv7M,
183195
Arch::Armv7EM,
@@ -201,6 +213,8 @@ impl core::fmt::Display for Arch {
201213
f,
202214
"{}",
203215
match self {
216+
Arch::Armv4T => "v4t",
217+
Arch::Armv5TE => "v5te",
204218
Arch::Armv6M => "v6-m",
205219
Arch::Armv7M => "v7-m",
206220
Arch::Armv7EM => "v7e-m",
@@ -224,6 +238,8 @@ pub enum Profile {
224238
R,
225239
/// Applications
226240
A,
241+
/// Legacy
242+
Legacy,
227243
}
228244

229245
impl Profile {
@@ -235,7 +251,7 @@ impl Profile {
235251

236252
/// Get a comma-separated list of values, suitable for cfg-check
237253
pub fn values() -> String {
238-
let string_versions: Vec<String> = [Profile::A, Profile::R, Profile::M]
254+
let string_versions: Vec<String> = [Profile::A, Profile::R, Profile::M, Profile::Legacy]
239255
.iter()
240256
.map(|i| format!(r#""{i}""#))
241257
.collect();
@@ -252,6 +268,7 @@ impl core::fmt::Display for Profile {
252268
Profile::M => "m",
253269
Profile::R => "r",
254270
Profile::A => "a",
271+
Profile::Legacy => "legacy",
255272
}
256273
)
257274
}

0 commit comments

Comments
 (0)