diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 161bb31c664e7..c0679c9552dfa 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -477,6 +477,7 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ // tidy-alphabetical-start + ("audio", Unstable(sym::hexagon_target_feature), &[]), ("hvx", Unstable(sym::hexagon_target_feature), &[]), ("hvx-ieee-fp", Unstable(sym::hexagon_target_feature), &["hvx"]), ("hvx-length64b", Unstable(sym::hexagon_target_feature), &["hvx"]), @@ -493,6 +494,17 @@ const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("hvxv73", Unstable(sym::hexagon_target_feature), &["hvxv71"]), ("hvxv75", Unstable(sym::hexagon_target_feature), &["hvxv73"]), ("hvxv79", Unstable(sym::hexagon_target_feature), &["hvxv75"]), + ("v60", Unstable(sym::hexagon_target_feature), &[]), + ("v62", Unstable(sym::hexagon_target_feature), &["v60"]), + ("v65", Unstable(sym::hexagon_target_feature), &["v62"]), + ("v66", Unstable(sym::hexagon_target_feature), &["v65"]), + ("v67", Unstable(sym::hexagon_target_feature), &["v66"]), + ("v68", Unstable(sym::hexagon_target_feature), &["v67"]), + ("v69", Unstable(sym::hexagon_target_feature), &["v68"]), + ("v71", Unstable(sym::hexagon_target_feature), &["v69"]), + ("v73", Unstable(sym::hexagon_target_feature), &["v71"]), + ("v75", Unstable(sym::hexagon_target_feature), &["v73"]), + ("v79", Unstable(sym::hexagon_target_feature), &["v75"]), ("zreg", Unstable(sym::hexagon_target_feature), &[]), // tidy-alphabetical-end ]; diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 06384c2202f1e..343b894405e97 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -31,6 +31,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `amx-tile` `apxf` `atomics` +`audio` `avx` `avx10.1` `avx10.2` @@ -359,9 +360,20 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `v` `v5te` `v6` +`v60` +`v62` +`v65` +`v66` +`v67` +`v68` +`v69` `v6k` `v6t2` `v7` +`v71` +`v73` +`v75` +`v79` `v8` `v8.1a` `v8.2a` diff --git a/tests/ui/target-feature/feature-hierarchy.hexagon-hvxv66.stderr b/tests/ui/target-feature/feature-hierarchy.hexagon-hvxv66.stderr new file mode 100644 index 0000000000000..99a6aa67e7feb --- /dev/null +++ b/tests/ui/target-feature/feature-hierarchy.hexagon-hvxv66.stderr @@ -0,0 +1,6 @@ +warning: unstable feature specified for `-Ctarget-feature`: `hvxv66` + | + = note: this feature is not stably supported; its behavior can change in the future + +warning: 1 warning emitted + diff --git a/tests/ui/target-feature/feature-hierarchy.hexagon-v60.stderr b/tests/ui/target-feature/feature-hierarchy.hexagon-v60.stderr new file mode 100644 index 0000000000000..611bf370bdfa7 --- /dev/null +++ b/tests/ui/target-feature/feature-hierarchy.hexagon-v60.stderr @@ -0,0 +1,6 @@ +warning: unstable feature specified for `-Ctarget-feature`: `v60` + | + = note: this feature is not stably supported; its behavior can change in the future + +warning: 1 warning emitted + diff --git a/tests/ui/target-feature/feature-hierarchy.hexagon-v68.stderr b/tests/ui/target-feature/feature-hierarchy.hexagon-v68.stderr new file mode 100644 index 0000000000000..67343fa798b83 --- /dev/null +++ b/tests/ui/target-feature/feature-hierarchy.hexagon-v68.stderr @@ -0,0 +1,6 @@ +warning: unstable feature specified for `-Ctarget-feature`: `v68` + | + = note: this feature is not stably supported; its behavior can change in the future + +warning: 1 warning emitted + diff --git a/tests/ui/target-feature/feature-hierarchy.rs b/tests/ui/target-feature/feature-hierarchy.rs index a14af97d7234b..65f7a1e6d3db4 100644 --- a/tests/ui/target-feature/feature-hierarchy.rs +++ b/tests/ui/target-feature/feature-hierarchy.rs @@ -1,14 +1,22 @@ //@ revisions: aarch64-neon aarch64-sve2 +//@ revisions: hexagon-v60 hexagon-v68 hexagon-hvxv66 //@ [aarch64-neon] compile-flags: -Ctarget-feature=+neon --target=aarch64-unknown-linux-gnu //@ [aarch64-neon] needs-llvm-components: aarch64 //@ [aarch64-sve2] compile-flags: -Ctarget-feature=-neon,+sve2 --target=aarch64-unknown-linux-gnu //@ [aarch64-sve2] needs-llvm-components: aarch64 +//@ [hexagon-v60] compile-flags: -Ctarget-feature=+v60 --target=hexagon-unknown-linux-musl +//@ [hexagon-v60] needs-llvm-components: hexagon +//@ [hexagon-v68] compile-flags: -Ctarget-feature=+v68 --target=hexagon-unknown-linux-musl +//@ [hexagon-v68] needs-llvm-components: hexagon +//@ [hexagon-hvxv66] compile-flags: -Ctarget-feature=+hvxv66 --target=hexagon-unknown-linux-musl +//@ [hexagon-hvxv66] needs-llvm-components: hexagon //@ build-pass //@ add-minicore //@ ignore-backends: gcc #![no_core] #![crate_type = "rlib"] #![feature(intrinsics, rustc_attrs, no_core, staged_api)] +#![cfg_attr(any(hexagon_v60, hexagon_v68, hexagon_hvxv66), feature(hexagon_target_feature))] #![stable(feature = "test", since = "1.0.0")] // Tests vetting "feature hierarchies" in the cases where we impose them. @@ -54,3 +62,39 @@ fn check_sve2_includes_neon() { assert!(cfg!(target_feature = "neon")); assert!(cfg!(target_feature = "sve2")); } + +//[hexagon-v60]~? WARN unstable feature specified for `-Ctarget-feature`: `v60` +//[hexagon-v68]~? WARN unstable feature specified for `-Ctarget-feature`: `v68` +//[hexagon-hvxv66]~? WARN unstable feature specified for `-Ctarget-feature`: `hvxv66` + +#[cfg(hexagon_v60)] +fn check_v60_not_v68() { + // Enabling v60 should not jump up the scalar feature hierarchy. + assert!(cfg!(target_feature = "v60")); + assert!(cfg!(not(target_feature = "v62"))); + assert!(cfg!(not(target_feature = "v68"))); +} + +#[cfg(hexagon_v68)] +fn check_v68_implies_v60() { + // v68 implies all lower scalar arch versions. + assert!(cfg!(target_feature = "v60")); + assert!(cfg!(target_feature = "v62")); + assert!(cfg!(target_feature = "v65")); + assert!(cfg!(target_feature = "v66")); + assert!(cfg!(target_feature = "v67")); + assert!(cfg!(target_feature = "v68")); + assert!(cfg!(not(target_feature = "v69"))); +} + +#[cfg(hexagon_hvxv66)] +fn check_hvxv66_implies_hvx_and_zreg() { + // hvxv66 implies hvx, hvxv60..v65, and zreg. + assert!(cfg!(target_feature = "hvx")); + assert!(cfg!(target_feature = "hvxv60")); + assert!(cfg!(target_feature = "hvxv62")); + assert!(cfg!(target_feature = "hvxv65")); + assert!(cfg!(target_feature = "hvxv66")); + assert!(cfg!(target_feature = "zreg")); + assert!(cfg!(not(target_feature = "hvxv67"))); +}