[clang] [ARM][Driver] Ensure NEON is enabled and disabled correctly (PR #137595)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 28 05:23:15 PDT 2025
================
@@ -781,6 +781,30 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
if (FPUKind == llvm::ARM::FK_FPV5_D16 || FPUKind == llvm::ARM::FK_FPV5_SP_D16)
Features.push_back("-mve.fp");
+ // If SIMD has been disabled and the selected FPU support NEON, then features
+ // that rely on NEON Instructions should also be disabled. Cases where NEON
+ // needs activating to support another feature is handled below with the
+ // crypto feature.
+ bool HasSimd = false;
+ const auto ItSimd =
+ llvm::find_if(llvm::reverse(Features),
+ [](const StringRef F) { return F.contains("neon"); });
+ const bool FoundSimd = ItSimd != Features.rend();
+ const bool FPUSupportsNeon = (llvm::ARM::FPUNames[FPUKind].NeonSupport ==
+ llvm::ARM::NeonSupportLevel::Neon) ||
+ (llvm::ARM::FPUNames[FPUKind].NeonSupport ==
+ llvm::ARM::NeonSupportLevel::Crypto);
+ if (FoundSimd)
+ HasSimd = ItSimd->take_front() == "+";
----------------
sivan-shani wrote:
The function that should be used here is `starts_with("+")` and not `take_front()`
Even though the existing code below:
`HasSHA2 = ItSHA2->take_front() == "+";` already use `take_front()`. I think it might be better to change all, including existing one, to `starts_with`
https://github.com/llvm/llvm-project/pull/137595
More information about the cfe-commits
mailing list