summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2017-08-10 20:28:30 +0000
committerCraig Topper <craig.topper@intel.com>2017-08-10 20:28:30 +0000
commit699ae0c173bd9f9a38523a7de354f5e9cc602ecc (patch)
treeef9abdeee56670c011dd15c7696f954d59bc1f00 /clang/lib/Basic
parent4d28c0ff4f1790edf49b41ebc368de95223ea259 (diff)
downloadbcm5719-llvm-699ae0c173bd9f9a38523a7de354f5e9cc602ecc.tar.gz
bcm5719-llvm-699ae0c173bd9f9a38523a7de354f5e9cc602ecc.zip
[X86] Implement __builtin_cpu_is
This patch adds support for __builtin_cpu_is. I've tried to match the strings supported to the latest version of gcc. Differential Revision: https://reviews.llvm.org/D35449 llvm-svn: 310657
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r--clang/lib/Basic/Targets/X86.cpp38
-rw-r--r--clang/lib/Basic/Targets/X86.h2
2 files changed, 40 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 5c48850cb41..fc0c9c85efe 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -1307,6 +1307,44 @@ bool X86TargetInfo::validateCpuSupports(StringRef FeatureStr) const {
.Default(false);
}
+// We can't use a generic validation scheme for the cpus accepted here
+// versus subtarget cpus accepted in the target attribute because the
+// variables intitialized by the runtime only support the below currently
+// rather than the full range of cpus.
+bool X86TargetInfo::validateCpuIs(StringRef FeatureStr) const {
+ return llvm::StringSwitch<bool>(FeatureStr)
+ .Case("amd", true)
+ .Case("amdfam10h", true)
+ .Case("amdfam15h", true)
+ .Case("atom", true)
+ .Case("barcelona", true)
+ .Case("bdver1", true)
+ .Case("bdver2", true)
+ .Case("bdver3", true)
+ .Case("bdver4", true)
+ .Case("bonnell", true)
+ .Case("broadwell", true)
+ .Case("btver1", true)
+ .Case("btver2", true)
+ .Case("core2", true)
+ .Case("corei7", true)
+ .Case("haswell", true)
+ .Case("intel", true)
+ .Case("istanbul", true)
+ .Case("ivybridge", true)
+ .Case("knl", true)
+ .Case("nehalem", true)
+ .Case("sandybridge", true)
+ .Case("shanghai", true)
+ .Case("silvermont", true)
+ .Case("skylake", true)
+ .Case("skylake-avx512", true)
+ .Case("slm", true)
+ .Case("westmere", true)
+ .Case("znver1", true)
+ .Default(false);
+}
+
bool X86TargetInfo::validateAsmConstraint(
const char *&Name, TargetInfo::ConstraintInfo &Info) const {
switch (*Name) {
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 671b8c9c170..34c7bdfbe3d 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -382,6 +382,8 @@ public:
bool validateCpuSupports(StringRef Name) const override;
+ bool validateCpuIs(StringRef Name) const override;
+
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override;
OpenPOWER on IntegriCloud