From: Erich Keane Date: Thu, 8 Feb 2018 23:15:02 +0000 (+0000) Subject: Add X86 Support to ValidCPUList (enabling march notes) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=548d966602aed10d78f46402e094b810ae9aa181;p=clang Add X86 Support to ValidCPUList (enabling march notes) A followup to: https://reviews.llvm.org/D42978 This patch adds X86 and X86_64 support for enabling the march notes. Differential Revision: https://reviews.llvm.org/D43041 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324674 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets/X86.cpp b/lib/Basic/Targets/X86.cpp index 484a83a494..5f9f6bb2f0 100644 --- a/lib/Basic/Targets/X86.cpp +++ b/lib/Basic/Targets/X86.cpp @@ -15,6 +15,7 @@ #include "clang/Basic/Builtins.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/TargetBuiltins.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/TargetParser.h" @@ -1648,8 +1649,6 @@ std::string X86TargetInfo::convertConstraint(const char *&Constraint) const { bool X86TargetInfo::checkCPUKind(CPUKind Kind) const { // Perform any per-CPU checks necessary to determine if this CPU is // acceptable. - // FIXME: This results in terrible diagnostics. Clang just says the CPU is - // invalid without explaining *why*. switch (Kind) { case CK_Generic: // No processor selected! @@ -1662,6 +1661,18 @@ bool X86TargetInfo::checkCPUKind(CPUKind Kind) const { llvm_unreachable("Unhandled CPU kind"); } +void X86TargetInfo::fillValidCPUList(SmallVectorImpl &Values) const { +#define PROC(ENUM, STRING, IS64BIT) \ + if (IS64BIT || getTriple().getArch() == llvm::Triple::x86) \ + Values.emplace_back(STRING); + // Go through CPUKind checking to ensure that the alias is de-aliased and + // 64 bit-ness is checked. +#define PROC_ALIAS(ENUM, ALIAS) \ + if (checkCPUKind(getCPUKind(ALIAS))) \ + Values.emplace_back(ALIAS); +#include "clang/Basic/X86Target.def" +} + X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU) const { return llvm::StringSwitch(CPU) #define PROC(ENUM, STRING, IS64BIT) .Case(STRING, CK_##ENUM) diff --git a/lib/Basic/Targets/X86.h b/lib/Basic/Targets/X86.h index be831ba7e6..b46778f3da 100644 --- a/lib/Basic/Targets/X86.h +++ b/lib/Basic/Targets/X86.h @@ -264,6 +264,8 @@ public: return checkCPUKind(getCPUKind(Name)); } + void fillValidCPUList(SmallVectorImpl &Values) const override; + bool setCPU(const std::string &Name) override { return checkCPUKind(CPU = getCPUKind(Name)); }