Skip to content

Commit ab34913

Browse files
committed
Updates after review comments.
1 parent 19f6d04 commit ab34913

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,8 @@ Arm and AArch64 Support
601601
- The ``+nosimd`` attribute is now fully supported for ARM. Previously, this had no effect when being used with
602602
ARM targets, however this will now disable NEON instructions being generated. The ``simd`` option is
603603
also now printed when the ``--print-supported-extensions`` option is used.
604-
- NEON is correctly enabled when using features that depend on NEON , and disables all features that depend on
605-
NEON when using ``+nosimd``.
604+
- When a feature that depends on NEON (``simd``) is used, NEON is now automatically enabled.
605+
- When NEON is disabled (``+nosimd``), all features that depend on NEON will now be disabled.
606606

607607
- Support for __ptrauth type qualifier has been added.
608608

clang/lib/Driver/ToolChains/Arch/ARM.cpp

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -781,29 +781,21 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
781781
if (FPUKind == llvm::ARM::FK_FPV5_D16 || FPUKind == llvm::ARM::FK_FPV5_SP_D16)
782782
Features.push_back("-mve.fp");
783783

784-
// If SIMD has been disabled and the selected FPU support NEON, then features
785-
// that rely on NEON Instructions should also be disabled. Cases where NEON
786-
// needs activating to support another feature is handled below with the
787-
// crypto feature.
784+
// If SIMD has been disabled and the selected FPU supports NEON, then features
785+
// that rely on NEON instructions should also be disabled.
788786
bool HasSimd = false;
789787
const auto ItSimd =
790788
llvm::find_if(llvm::reverse(Features),
791789
[](const StringRef F) { return F.contains("neon"); });
792-
const bool FoundSimd = ItSimd != Features.rend();
793790
const bool FPUSupportsNeon = (llvm::ARM::FPUNames[FPUKind].NeonSupport ==
794791
llvm::ARM::NeonSupportLevel::Neon) ||
795792
(llvm::ARM::FPUNames[FPUKind].NeonSupport ==
796793
llvm::ARM::NeonSupportLevel::Crypto);
797-
if (FoundSimd)
798-
HasSimd = ItSimd->take_front() == "+";
799-
if (!HasSimd && FPUSupportsNeon) {
800-
Features.push_back("-sha2");
801-
Features.push_back("-aes");
802-
Features.push_back("-crypto");
803-
Features.push_back("-dotprod");
804-
Features.push_back("-bf16");
805-
Features.push_back("-imm8");
806-
}
794+
if (ItSimd != Features.rend())
795+
HasSimd = ItSimd->starts_with("+");
796+
if (!HasSimd && FPUSupportsNeon)
797+
for (auto &F : {"-sha2", "-aes", "-crypto", "-dotprod", "-bf16", "-imm8"})
798+
Features.push_back(F);
807799

808800
// For Arch >= ARMv8.0 && A or R profile: crypto = sha2 + aes
809801
// Rather than replace within the feature vector, determine whether each
@@ -840,15 +832,15 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
840832
llvm::find_if(llvm::reverse(Features),
841833
[](const StringRef F) { return F.contains("i8mm"); });
842834
if (ItSHA2 != Features.rend())
843-
HasSHA2 = ItSHA2->take_front() == "+";
835+
HasSHA2 = ItSHA2->starts_with("+");
844836
if (ItAES != Features.rend())
845-
HasAES = ItAES->take_front() == "+";
837+
HasAES = ItAES->starts_with("+");
846838
if (ItBF16 != Features.rend())
847-
HasBF16 = ItBF16->take_front() == "+";
839+
HasBF16 = ItBF16->starts_with("+");
848840
if (ItDotprod != Features.rend())
849-
HasDotprod = ItDotprod->take_front() == "+";
841+
HasDotprod = ItDotprod->starts_with("+");
850842
if (ItI8MM != Features.rend())
851-
HasI8MM = ItI8MM->take_front() == "+";
843+
HasI8MM = ItI8MM->starts_with("+");
852844
if (ItCrypto != Features.rend()) {
853845
if (HasSHA2 && HasAES)
854846
Features.push_back("+crypto");

clang/test/Driver/arm-features.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,11 @@
9797
// CHECK-NOSHA-DAG: "-target-feature" "-sha2"
9898
// CHECK-NOAES-DAG: "-target-feature" "-aes"
9999
//
100+
// Check that adding features that depend on NEON enable the feature
101+
// RUN: %clang -target arm-none-none-eabi -march=armv8-r+sha2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NEON-ENABLED-WITH-FEATURE %s
102+
// RUN: %clang -target arm-none-none-eabi -march=armv8-r+aes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NEON-ENABLED-WITH-FEATURE %s
103+
// RUN: %clang -target arm-none-none-eabi -march=armv8-r+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NEON-ENABLED-WITH-FEATURE %s
104+
// RUN: %clang -target arm-none-none-eabi -march=armv8-r+dotprod -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NEON-ENABLED-WITH-FEATURE %s
105+
// RUN: %clang -target arm-none-none-eabi -march=armv8-r+bf16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NEON-ENABLED-WITH-FEATURE %s
106+
// RUN: %clang -target arm-none-none-eabi -march=armv8-r+i8mm -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NEON-ENABLED-WITH-FEATURE %s
107+
// CHECK-NEON-ENABLED-WITH-FEATURE: "-target-feature" "+neon"

0 commit comments

Comments
 (0)