Skip to content

Commit

Permalink
Fold aarch64 feature +fp into +neon
Browse files Browse the repository at this point in the history
Arm's FEAT_FP and Feat_AdvSIMD describe the same thing on AArch64:
The Neon unit, which handles both floating point and SIMD instructions.
Moreover, a configuration for AArch64 must include both or neither.
Arm says "entirely proprietary" toolchains may omit floating point:
https://developer.arm.com/documentation/102374/0101/Data-processing---floating-point
In the Programmer's Guide for Armv8-A, Arm says AArch64 can have
both FP and Neon or neither in custom implementations:
https://developer.arm.com/documentation/den0024/a/AArch64-Floating-point-and-NEON

In "Bare metal boot code for Armv8-A", enabling Neon and FP
is just disabling the same trap flag:
https://developer.arm.com/documentation/dai0527/a

In an unlikely future where "Neon and FP" become unrelated,
we can add "[+-]fp" as its own feature flag.
Until then, we can simplify programming with Rust on AArch64 by
folding both into "[+-]neon", which is valid as it supersets both.

"[+-]neon" is retained for niche uses such as firmware, kernels,
"I just hate floats", and so on.
  • Loading branch information
workingjubilee committed Mar 22, 2022
1 parent 58f1179 commit b807d59
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 9 deletions.
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]
("x86", "avx512vaes") => smallvec!["vaes"],
("x86", "avx512gfni") => smallvec!["gfni"],
("x86", "avx512vpclmulqdq") => smallvec!["vpclmulqdq"],
("aarch64", "fp") => smallvec!["fp-armv8"],
("aarch64", "rcpc2") => smallvec!["rcpc-immo"],
("aarch64", "dpb") => smallvec!["ccpp"],
("aarch64", "dpb2") => smallvec!["ccdp"],
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ const ARM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
];

const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
// FEAT_AdvSimd
// FEAT_AdvSimd & FEAT_FP
("neon", None),
// FEAT_FP
("fp", None),
// FEAT_FP16
("fp16", None),
// FEAT_SVE
Expand Down Expand Up @@ -143,7 +141,6 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
];

const AARCH64_TIED_FEATURES: &[&[&str]] = &[
&["fp", "neon"], // Silicon always has both, so avoid needless complications
&["paca", "pacg"], // Together these represent `pauth` in LLVM
];

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/asm/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl AArch64InlineAsmRegClass {
match self {
Self::reg => types! { _: I8, I16, I32, I64, F32, F64; },
Self::vreg | Self::vreg_low16 => types! {
fp: I8, I16, I32, I64, F32, F64,
neon: I8, I16, I32, I64, F32, F64,
VecI8(8), VecI16(4), VecI32(2), VecI64(1), VecF32(2), VecF64(1),
VecI8(16), VecI16(8), VecI32(4), VecI64(2), VecF32(4), VecF64(2);
},
Expand Down
1 change: 0 additions & 1 deletion library/std/tests/run-time-detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ fn aarch64_linux() {
println!("neon: {}", is_aarch64_feature_detected!("neon"));
println!("asimd: {}", is_aarch64_feature_detected!("asimd"));
println!("pmull: {}", is_aarch64_feature_detected!("pmull"));
println!("fp: {}", is_aarch64_feature_detected!("fp"));
println!("fp16: {}", is_aarch64_feature_detected!("fp16"));
println!("sve: {}", is_aarch64_feature_detected!("sve"));
println!("crc: {}", is_aarch64_feature_detected!("crc"));
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-make-fulldeps/simd-ffi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ define MK_TARGETS
# now.
$(1): simd.rs
$$(RUSTC) --target=$(1) --emit=llvm-ir,asm simd.rs \
-C target-feature='+fp,+neon,+sse2' -C extra-filename=-$(1)
-C target-feature='+neon,+sse2' -C extra-filename=-$(1)
endef

$(foreach targetxxx,$(TARGETS),$(eval $(call MK_TARGETS,$(targetxxx))))
2 changes: 1 addition & 1 deletion src/test/ui/asm/aarch64/bad-reg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// only-aarch64
// compile-flags: -C target-feature=+fp
// compile-flags: -C target-feature=+neon

#![feature(asm_const, asm_sym)]

Expand Down

0 comments on commit b807d59

Please sign in to comment.