aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Driver/ToolChains/Arch/ARM.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Driver/ToolChains/Arch/ARM.cpp')
-rw-r--r--lib/Driver/ToolChains/Arch/ARM.cpp50
1 files changed, 32 insertions, 18 deletions
diff --git a/lib/Driver/ToolChains/Arch/ARM.cpp b/lib/Driver/ToolChains/Arch/ARM.cpp
index d1db583e5280..68a57310ad40 100644
--- a/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -13,6 +13,7 @@
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/TargetParser.h"
+#include "llvm/Support/Host.h"
using namespace clang::driver;
using namespace clang::driver::tools;
@@ -460,11 +461,12 @@ fp16_fml_fallthrough:
// now just be explicit and disable all known dependent features
// as well.
for (std::string Feature : {
- "vfp2", "vfp2sp", "vfp2d16", "vfp2d16sp",
+ "vfp2", "vfp2sp",
"vfp3", "vfp3sp", "vfp3d16", "vfp3d16sp",
"vfp4", "vfp4sp", "vfp4d16", "vfp4d16sp",
"fp-armv8", "fp-armv8sp", "fp-armv8d16", "fp-armv8d16sp",
"fullfp16", "neon", "crypto", "dotprod", "fp16fml",
+ "mve", "mve.fp",
"fp64", "d32", "fpregs"})
Features.push_back(Args.MakeArgString("-" + Feature));
}
@@ -477,23 +479,35 @@ fp16_fml_fallthrough:
Features.push_back("-crc");
}
- // For Arch >= ARMv8.0: crypto = sha2 + aes
+ // For Arch >= ARMv8.0 && A profile: crypto = sha2 + aes
// FIXME: this needs reimplementation after the TargetParser rewrite
- if (ArchName.find_lower("armv8a") != StringRef::npos ||
- ArchName.find_lower("armv8.1a") != StringRef::npos ||
- ArchName.find_lower("armv8.2a") != StringRef::npos ||
- ArchName.find_lower("armv8.3a") != StringRef::npos ||
- ArchName.find_lower("armv8.4a") != StringRef::npos) {
- if (ArchName.find_lower("+crypto") != StringRef::npos) {
- if (ArchName.find_lower("+nosha2") == StringRef::npos)
- Features.push_back("+sha2");
- if (ArchName.find_lower("+noaes") == StringRef::npos)
- Features.push_back("+aes");
- } else if (ArchName.find_lower("-crypto") != StringRef::npos) {
- if (ArchName.find_lower("+sha2") == StringRef::npos)
- Features.push_back("-sha2");
- if (ArchName.find_lower("+aes") == StringRef::npos)
- Features.push_back("-aes");
+ auto CryptoIt = llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
+ return F.contains("crypto");
+ });
+ if (CryptoIt != Features.rend()) {
+ if (CryptoIt->take_front() == "+") {
+ StringRef ArchSuffix = arm::getLLVMArchSuffixForARM(
+ arm::getARMTargetCPU(CPUName, ArchName, Triple), ArchName, Triple);
+ if (llvm::ARM::parseArchVersion(ArchSuffix) >= 8 &&
+ llvm::ARM::parseArchProfile(ArchSuffix) ==
+ llvm::ARM::ProfileKind::A) {
+ if (ArchName.find_lower("+nosha2") == StringRef::npos &&
+ CPUName.find_lower("+nosha2") == StringRef::npos)
+ Features.push_back("+sha2");
+ if (ArchName.find_lower("+noaes") == StringRef::npos &&
+ CPUName.find_lower("+noaes") == StringRef::npos)
+ Features.push_back("+aes");
+ } else {
+ D.Diag(clang::diag::warn_target_unsupported_extension)
+ << "crypto"
+ << llvm::ARM::getArchName(llvm::ARM::parseArch(ArchSuffix));
+ // With -fno-integrated-as -mfpu=crypto-neon-fp-armv8 some assemblers such as the GNU assembler
+ // will permit the use of crypto instructions as the fpu will override the architecture.
+ // We keep the crypto feature in this case to preserve compatibility.
+ // In all other cases we remove the crypto feature.
+ if (!Args.hasArg(options::OPT_fno_integrated_as))
+ Features.push_back("-crypto");
+ }
}
}
@@ -655,7 +669,7 @@ std::string arm::getARMTargetCPU(StringRef CPU, StringRef Arch,
llvm::ARM::ArchKind arm::getLLVMArchKindForARM(StringRef CPU, StringRef Arch,
const llvm::Triple &Triple) {
llvm::ARM::ArchKind ArchKind;
- if (CPU == "generic") {
+ if (CPU == "generic" || CPU.empty()) {
std::string ARMArch = tools::arm::getARMArch(Arch, Triple);
ArchKind = llvm::ARM::parseArch(ARMArch);
if (ArchKind == llvm::ARM::ArchKind::INVALID)