From: Zijiao Ma Date: Thu, 28 Jul 2016 06:24:48 +0000 (+0000) Subject: [AArch64] Using AArch64TargetParser in Clang. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1c2616b8e06a1492c71e4ae61b81b8c2eddad11;p=clang [AArch64] Using AArch64TargetParser in Clang. This resubmit r270688 which broke some specific buildbots.That's because there is incorrect indexing problem in the targetparser,and the problem is fixed in r276957. Differential Revision: https://reviews.llvm.org/D21277 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276958 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 001c04483e..a9c9ece3d3 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -5726,19 +5726,9 @@ public: } bool setCPU(const std::string &Name) override { - bool CPUKnown = llvm::StringSwitch(Name) - .Case("cortex-a35", true) - .Case("cortex-a53", true) - .Case("cortex-a57", true) - .Case("cortex-a72", true) - .Case("cortex-a73", true) - .Case("cyclone", true) - .Case("exynos-m1", true) - .Case("generic", true) - .Case("kryo", true) - .Case("vulcan", true) - .Default(false); - return CPUKnown; + return Name == "generic" || + llvm::AArch64::parseCPUArch(Name) != + static_cast(llvm::AArch64::ArchKind::AK_INVALID); } void getTargetDefines(const LangOptions &Opts, diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index e485a86191..4bf0e718fa 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2340,24 +2340,8 @@ static bool DecodeAArch64Features(const Driver &D, StringRef text, text.split(Split, StringRef("+"), -1, false); for (StringRef Feature : Split) { - const char *result = llvm::StringSwitch(Feature) - .Case("fp", "+fp-armv8") - .Case("simd", "+neon") - .Case("crc", "+crc") - .Case("crypto", "+crypto") - .Case("fp16", "+fullfp16") - .Case("profile", "+spe") - .Case("ras", "+ras") - .Case("nofp", "-fp-armv8") - .Case("nosimd", "-neon") - .Case("nocrc", "-crc") - .Case("nocrypto", "-crypto") - .Case("nofp16", "-fullfp16") - .Case("noprofile", "-spe") - .Case("noras", "-ras") - .Default(nullptr); - if (result) - Features.push_back(result); + if (const char *FeatureName = llvm::AArch64::getArchExtFeature(Feature)) + Features.push_back(FeatureName); else if (Feature == "neon" || Feature == "noneon") D.Diag(diag::err_drv_no_neon_modifier); else @@ -2372,20 +2356,16 @@ static bool DecodeAArch64Mcpu(const Driver &D, StringRef Mcpu, StringRef &CPU, std::vector &Features) { std::pair Split = Mcpu.split("+"); CPU = Split.first; - if (CPU == "cortex-a53" || CPU == "cortex-a57" || - CPU == "cortex-a72" || CPU == "cortex-a35" || CPU == "exynos-m1" || - CPU == "kryo" || CPU == "cortex-a73" || CPU == "vulcan") { - Features.push_back("+neon"); - Features.push_back("+crc"); - Features.push_back("+crypto"); - } else if (CPU == "cyclone") { - Features.push_back("+neon"); - Features.push_back("+crypto"); - } else if (CPU == "generic") { + + if (CPU == "generic") { Features.push_back("+neon"); } else { - return false; - } + unsigned ArchKind = llvm::AArch64::parseCPUArch(CPU); + unsigned Extersion = llvm::AArch64::getDefaultExtensions(CPU, ArchKind); + + if (!llvm::AArch64::getExtensionFeatures(Extersion, Features)) + return false; + } if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features)) return false; @@ -2400,17 +2380,10 @@ getAArch64ArchFeaturesFromMarch(const Driver &D, StringRef March, std::string MarchLowerCase = March.lower(); std::pair Split = StringRef(MarchLowerCase).split("+"); - if (Split.first == "armv8-a" || Split.first == "armv8a") { - // ok, no additional features. - } else if (Split.first == "armv8.1-a" || Split.first == "armv8.1a") { - Features.push_back("+v8.1a"); - } else if (Split.first == "armv8.2-a" || Split.first == "armv8.2a" ) { - Features.push_back("+v8.2a"); - } else { - return false; - } - - if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features)) + unsigned ArchKind = llvm::AArch64::parseArch(Split.first); + if (ArchKind == static_cast(llvm::AArch64::ArchKind::AK_INVALID) || + !llvm::AArch64::getArchFeatures(ArchKind, Features) || + (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features))) return false; return true;