From: Renato Golin Date: Wed, 27 May 2015 13:33:00 +0000 (+0000) Subject: ARMTargetParser FIXME: ARMv8 detection for hdiv X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25bcd92fa520f49018d39392416efbf62d428e75;p=clang ARMTargetParser FIXME: ARMv8 detection for hdiv Avoiding ugly combination of string parsing in the front-end. We still need to move away from CPU parsing at all, but that's for a different commit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238318 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 33382ce67b..ce3bd48118 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -27,6 +27,7 @@ #include "llvm/ADT/Triple.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/TargetParser.h" #include #include using namespace clang; @@ -4180,8 +4181,15 @@ public: return false; } + // FIXME: This should be based on Arch attributes, not CPU names. void getDefaultFeatures(llvm::StringMap &Features) const override { StringRef ArchName = getTriple().getArchName(); + unsigned ArchKind = + llvm::ARMTargetParser::parseArch( + llvm::ARMTargetParser::getCanonicalArchName(ArchName)); + bool IsV8 = (ArchKind == llvm::ARM::AK_ARMV8A || + ArchKind == llvm::ARM::AK_ARMV8_1A); + if (CPU == "arm1136jf-s" || CPU == "arm1176jzf-s" || CPU == "mpcore") Features["vfp2"] = true; else if (CPU == "cortex-a8" || CPU == "cortex-a9") { @@ -4206,17 +4214,7 @@ public: Features["hwdiv-arm"] = true; Features["crc"] = true; Features["crypto"] = true; - } else if (CPU == "cortex-r5" || CPU == "cortex-r7" || - // Enable the hwdiv extension for all v8a AArch32 cores by - // default. - // FIXME: Use ARMTargetParser. This would require Triple::arm/thumb - // to be recogniseable universally. - ArchName == "armv8.1a" || ArchName == "thumbv8.1a" || //v8.1a - ArchName == "armebv8.1a" || ArchName == "thumbebv8.1a" || - ArchName == "armv8a" || ArchName == "armv8" || //v8a - ArchName == "armebv8a" || ArchName == "armebv8" || - ArchName == "thumbv8a" || ArchName == "thumbv8" || - ArchName == "thumbebv8a" || ArchName == "thumbebv8") { + } else if (CPU == "cortex-r5" || CPU == "cortex-r7" || IsV8) { Features["hwdiv"] = true; Features["hwdiv-arm"] = true; } else if (CPU == "cortex-m3" || CPU == "cortex-m4" || CPU == "cortex-m7" ||