Skip to content

Commit d11e396

Browse files
committed
Hexagon: add scalar arch-version target features (v60-v79, audio)
Add target features corresponding to Hexagon LLVM CPU generations to complement the existing HVX vector features. These are needed for gating scalar intrinsics by architecture version. New features: audio, v60, v62, v65, v66, v67, v68, v69, v71, v73, v75, v79 Each version implies the previous (e.g. v68 implies v67 which implies v66, etc.), matching LLVM's ArchV60-ArchV79 subtarget features. Also adds hexagon revisions to the feature-hierarchy test to verify the implied feature chains work correctly.
1 parent 033b925 commit d11e396

6 files changed

Lines changed: 86 additions & 0 deletions

File tree

compiler/rustc_target/src/target_features.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
477477

478478
const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
479479
// tidy-alphabetical-start
480+
("audio", Unstable(sym::hexagon_target_feature), &[]),
480481
("hvx", Unstable(sym::hexagon_target_feature), &[]),
481482
("hvx-ieee-fp", Unstable(sym::hexagon_target_feature), &["hvx"]),
482483
("hvx-length64b", Unstable(sym::hexagon_target_feature), &["hvx"]),
@@ -493,6 +494,17 @@ const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
493494
("hvxv73", Unstable(sym::hexagon_target_feature), &["hvxv71"]),
494495
("hvxv75", Unstable(sym::hexagon_target_feature), &["hvxv73"]),
495496
("hvxv79", Unstable(sym::hexagon_target_feature), &["hvxv75"]),
497+
("v60", Unstable(sym::hexagon_target_feature), &[]),
498+
("v62", Unstable(sym::hexagon_target_feature), &["v60"]),
499+
("v65", Unstable(sym::hexagon_target_feature), &["v62"]),
500+
("v66", Unstable(sym::hexagon_target_feature), &["v65"]),
501+
("v67", Unstable(sym::hexagon_target_feature), &["v66"]),
502+
("v68", Unstable(sym::hexagon_target_feature), &["v67"]),
503+
("v69", Unstable(sym::hexagon_target_feature), &["v68"]),
504+
("v71", Unstable(sym::hexagon_target_feature), &["v69"]),
505+
("v73", Unstable(sym::hexagon_target_feature), &["v71"]),
506+
("v75", Unstable(sym::hexagon_target_feature), &["v73"]),
507+
("v79", Unstable(sym::hexagon_target_feature), &["v75"]),
496508
("zreg", Unstable(sym::hexagon_target_feature), &[]),
497509
// tidy-alphabetical-end
498510
];

tests/ui/check-cfg/target_feature.stderr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
3131
`amx-tile`
3232
`apxf`
3333
`atomics`
34+
`audio`
3435
`avx`
3536
`avx10.1`
3637
`avx10.2`
@@ -359,9 +360,20 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
359360
`v`
360361
`v5te`
361362
`v6`
363+
`v60`
364+
`v62`
365+
`v65`
366+
`v66`
367+
`v67`
368+
`v68`
369+
`v69`
362370
`v6k`
363371
`v6t2`
364372
`v7`
373+
`v71`
374+
`v73`
375+
`v75`
376+
`v79`
365377
`v8`
366378
`v8.1a`
367379
`v8.2a`
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: unstable feature specified for `-Ctarget-feature`: `hvxv66`
2+
|
3+
= note: this feature is not stably supported; its behavior can change in the future
4+
5+
warning: 1 warning emitted
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: unstable feature specified for `-Ctarget-feature`: `v60`
2+
|
3+
= note: this feature is not stably supported; its behavior can change in the future
4+
5+
warning: 1 warning emitted
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: unstable feature specified for `-Ctarget-feature`: `v68`
2+
|
3+
= note: this feature is not stably supported; its behavior can change in the future
4+
5+
warning: 1 warning emitted
6+

tests/ui/target-feature/feature-hierarchy.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
//@ revisions: aarch64-neon aarch64-sve2
2+
//@ revisions: hexagon-v60 hexagon-v68 hexagon-hvxv66
23
//@ [aarch64-neon] compile-flags: -Ctarget-feature=+neon --target=aarch64-unknown-linux-gnu
34
//@ [aarch64-neon] needs-llvm-components: aarch64
45
//@ [aarch64-sve2] compile-flags: -Ctarget-feature=-neon,+sve2 --target=aarch64-unknown-linux-gnu
56
//@ [aarch64-sve2] needs-llvm-components: aarch64
7+
//@ [hexagon-v60] compile-flags: -Ctarget-feature=+v60 --target=hexagon-unknown-linux-musl
8+
//@ [hexagon-v60] needs-llvm-components: hexagon
9+
//@ [hexagon-v68] compile-flags: -Ctarget-feature=+v68 --target=hexagon-unknown-linux-musl
10+
//@ [hexagon-v68] needs-llvm-components: hexagon
11+
//@ [hexagon-hvxv66] compile-flags: -Ctarget-feature=+hvxv66 --target=hexagon-unknown-linux-musl
12+
//@ [hexagon-hvxv66] needs-llvm-components: hexagon
613
//@ build-pass
714
//@ add-minicore
815
//@ ignore-backends: gcc
916
#![no_core]
1017
#![crate_type = "rlib"]
1118
#![feature(intrinsics, rustc_attrs, no_core, staged_api)]
19+
#![cfg_attr(any(hexagon_v60, hexagon_v68, hexagon_hvxv66), feature(hexagon_target_feature))]
1220
#![stable(feature = "test", since = "1.0.0")]
1321

1422
// Tests vetting "feature hierarchies" in the cases where we impose them.
@@ -54,3 +62,39 @@ fn check_sve2_includes_neon() {
5462
assert!(cfg!(target_feature = "neon"));
5563
assert!(cfg!(target_feature = "sve2"));
5664
}
65+
66+
//[hexagon-v60]~? WARN unstable feature specified for `-Ctarget-feature`: `v60`
67+
//[hexagon-v68]~? WARN unstable feature specified for `-Ctarget-feature`: `v68`
68+
//[hexagon-hvxv66]~? WARN unstable feature specified for `-Ctarget-feature`: `hvxv66`
69+
70+
#[cfg(hexagon_v60)]
71+
fn check_v60_not_v68() {
72+
// Enabling v60 should not jump up the scalar feature hierarchy.
73+
assert!(cfg!(target_feature = "v60"));
74+
assert!(cfg!(not(target_feature = "v62")));
75+
assert!(cfg!(not(target_feature = "v68")));
76+
}
77+
78+
#[cfg(hexagon_v68)]
79+
fn check_v68_implies_v60() {
80+
// v68 implies all lower scalar arch versions.
81+
assert!(cfg!(target_feature = "v60"));
82+
assert!(cfg!(target_feature = "v62"));
83+
assert!(cfg!(target_feature = "v65"));
84+
assert!(cfg!(target_feature = "v66"));
85+
assert!(cfg!(target_feature = "v67"));
86+
assert!(cfg!(target_feature = "v68"));
87+
assert!(cfg!(not(target_feature = "v69")));
88+
}
89+
90+
#[cfg(hexagon_hvxv66)]
91+
fn check_hvxv66_implies_hvx_and_zreg() {
92+
// hvxv66 implies hvx, hvxv60..v65, and zreg.
93+
assert!(cfg!(target_feature = "hvx"));
94+
assert!(cfg!(target_feature = "hvxv60"));
95+
assert!(cfg!(target_feature = "hvxv62"));
96+
assert!(cfg!(target_feature = "hvxv65"));
97+
assert!(cfg!(target_feature = "hvxv66"));
98+
assert!(cfg!(target_feature = "zreg"));
99+
assert!(cfg!(not(target_feature = "hvxv67")));
100+
}

0 commit comments

Comments
 (0)