Skip to content

Commit 8fa4ae8

Browse files
Test SVE2 includes NEON and not vice versa
Required by #95122
1 parent 7d6415c commit 8fa4ae8

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// revisions: aarch64-neon aarch64-sve2
2+
// [aarch64-neon] compile-flags: -Ctarget-feature=+neon --target=aarch64-unknown-linux-gnu
3+
// [aarch64-neon] needs-llvm-components: aarch64
4+
// [aarch64-sve2] compile-flags: -Ctarget-feature=-neon,+sve2 --target=aarch64-unknown-linux-gnu
5+
// [aarch64-sve2] needs-llvm-components: aarch64
6+
// build-pass
7+
#![no_core]
8+
#![crate_type = "rlib"]
9+
#![feature(intrinsics, rustc_attrs, no_core, lang_items, staged_api)]
10+
#![stable(feature = "test", since = "1.0.0")]
11+
12+
// Tests vetting "feature hierarchies" in the cases where we impose them.
13+
14+
// Supporting minimal rust core code
15+
#[lang = "sized"]
16+
trait Sized {}
17+
#[lang = "copy"]
18+
trait Copy {}
19+
impl Copy for bool {}
20+
21+
extern "rust-intrinsic" {
22+
#[rustc_const_stable(feature = "test", since = "1.0.0")]
23+
fn unreachable() -> !;
24+
}
25+
26+
#[rustc_builtin_macro]
27+
macro_rules! cfg {
28+
($($cfg:tt)*) => {};
29+
}
30+
31+
// Test code
32+
const fn do_or_die(cond: bool) {
33+
if cond {
34+
} else {
35+
unsafe { unreachable() }
36+
}
37+
}
38+
39+
macro_rules! assert {
40+
($x:expr $(,)?) => {
41+
const _: () = do_or_die($x);
42+
};
43+
}
44+
45+
46+
#[cfg(aarch64_neon)]
47+
fn check_neon_not_sve2() {
48+
// This checks that a normal aarch64 target doesn't suddenly jump up the feature hierarchy.
49+
assert!(cfg!(target_feature = "neon"));
50+
assert!(cfg!(not(target_feature = "sve2")));
51+
}
52+
53+
#[cfg(aarch64_sve2)]
54+
fn check_sve2_includes_neon() {
55+
// This checks that aarch64's sve2 includes neon
56+
assert!(cfg!(target_feature = "neon"));
57+
assert!(cfg!(target_feature = "sve2"));
58+
}

0 commit comments

Comments
 (0)