diff options
| author | Craig Topper <craig.topper@gmail.com> | 2013-08-20 07:05:05 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@gmail.com> | 2013-08-20 07:05:05 +0000 |
| commit | ffb7180e962e299facbb13ff4da517782baf262a (patch) | |
| tree | c22fa7cefcf895ff30cb16fe6930123c9eb0e1a2 /clang/lib/Basic/Targets.cpp | |
| parent | b27f0f1f6bdf47ae73bc2f0b3c88fab0a547c095 (diff) | |
| download | bcm5719-llvm-ffb7180e962e299facbb13ff4da517782baf262a.tar.gz bcm5719-llvm-ffb7180e962e299facbb13ff4da517782baf262a.zip | |
Add AVX-512 feature flag and knl cpu to clang.
llvm-svn: 188756
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
| -rw-r--r-- | clang/lib/Basic/Targets.cpp | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index c4772723e90..02c5935f290 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -1570,7 +1570,7 @@ const TargetInfo::AddlRegName AddlRegNames[] = { // most of the implementation can be shared. class X86TargetInfo : public TargetInfo { enum X86SSEEnum { - NoSSE, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, AVX, AVX2 + NoSSE, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, AVX, AVX2, AVX512 } SSELevel; enum MMX3DNowEnum { NoMMX3DNow, MMX, AMD3DNow, AMD3DNowAthlon @@ -1675,6 +1675,10 @@ class X86TargetInfo : public TargetInfo { CK_CoreAVX2, //@} + /// \name Knights Landing + /// Knights Landing processor. + CK_KNL, + /// \name K6 /// K6 architecture processors. //@{ @@ -1818,6 +1822,7 @@ public: .Case("corei7-avx", CK_Corei7AVX) .Case("core-avx-i", CK_CoreAVXi) .Case("core-avx2", CK_CoreAVX2) + .Case("knl", CK_KNL) .Case("k6", CK_K6) .Case("k6-2", CK_K6_2) .Case("k6-3", CK_K6_3) @@ -1892,6 +1897,7 @@ public: case CK_Corei7AVX: case CK_CoreAVXi: case CK_CoreAVX2: + case CK_KNL: case CK_Athlon64: case CK_Athlon64SSE3: case CK_AthlonFX: @@ -1941,6 +1947,7 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const { Features["pclmul"] = false; Features["avx"] = false; Features["avx2"] = false; + Features["avx512"] = false; Features["lzcnt"] = false; Features["rdrand"] = false; Features["bmi"] = false; @@ -2024,6 +2031,18 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const { setFeatureEnabled(Features, "rtm", true); setFeatureEnabled(Features, "fma", true); break; + case CK_KNL: + setFeatureEnabled(Features, "avx512", true); + setFeatureEnabled(Features, "aes", true); + setFeatureEnabled(Features, "pclmul", true); + setFeatureEnabled(Features, "lzcnt", true); + setFeatureEnabled(Features, "rdrnd", true); + setFeatureEnabled(Features, "f16c", true); + setFeatureEnabled(Features, "bmi", true); + setFeatureEnabled(Features, "bmi2", true); + setFeatureEnabled(Features, "rtm", true); + setFeatureEnabled(Features, "fma", true); + break; case CK_K6: case CK_WinChipC6: setFeatureEnabled(Features, "mmx", true); @@ -2149,6 +2168,11 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = Features["ssse3"] = Features["sse41"] = Features["sse42"] = Features["popcnt"] = Features["avx"] = Features["avx2"] = true; + else if (Name == "avx512") + Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = + Features["ssse3"] = Features["sse41"] = Features["sse42"] = + Features["popcnt"] = Features["avx"] = Features["avx2"] = + Features["avx512"] = true; else if (Name == "fma") Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = Features["ssse3"] = Features["sse41"] = Features["sse42"] = @@ -2191,28 +2215,29 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, Features["sse"] = Features["sse2"] = Features["sse3"] = Features["ssse3"] = Features["sse41"] = Features["sse42"] = Features["sse4a"] = Features["avx"] = Features["avx2"] = - Features["fma"] = Features["fma4"] = Features["aes"] = - Features["pclmul"] = Features["xop"] = false; + Features["avx512"] = Features["fma"] = Features["fma4"] = + Features["aes"] = Features["pclmul"] = Features["xop"] = false; else if (Name == "sse2") Features["sse2"] = Features["sse3"] = Features["ssse3"] = Features["sse41"] = Features["sse42"] = Features["sse4a"] = - Features["avx"] = Features["avx2"] = Features["fma"] = - Features["fma4"] = Features["aes"] = Features["pclmul"] = - Features["xop"] = false; + Features["avx"] = Features["avx2"] = Features["avx512"] = + Features["fma"] = Features["fma4"] = Features["aes"] = + Features["pclmul"] = Features["xop"] = false; else if (Name == "sse3") Features["sse3"] = Features["ssse3"] = Features["sse41"] = Features["sse42"] = Features["sse4a"] = Features["avx"] = - Features["avx2"] = Features["fma"] = Features["fma4"] = - Features["xop"] = false; + Features["avx2"] = Features["avx512"] = Features["fma"] = + Features["fma4"] = Features["xop"] = false; else if (Name == "ssse3") Features["ssse3"] = Features["sse41"] = Features["sse42"] = - Features["avx"] = Features["avx2"] = Features["fma"] = false; + Features["avx"] = Features["avx2"] = Features["avx512"] = + Features["fma"] = false; else if (Name == "sse4" || Name == "sse4.1") Features["sse41"] = Features["sse42"] = Features["avx"] = - Features["avx2"] = Features["fma"] = false; + Features["avx2"] = Features["avx512"] = Features["fma"] = false; else if (Name == "sse4.2") Features["sse42"] = Features["avx"] = Features["avx2"] = - Features["fma"] = false; + Features["avx512"] = Features["fma"] = false; else if (Name == "3dnow") Features["3dnow"] = Features["3dnowa"] = false; else if (Name == "3dnowa") @@ -2222,10 +2247,12 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, else if (Name == "pclmul") Features["pclmul"] = false; else if (Name == "avx") - Features["avx"] = Features["avx2"] = Features["fma"] = - Features["fma4"] = Features["xop"] = false; + Features["avx"] = Features["avx2"] = Features["avx512"] = + Features["fma"] = Features["fma4"] = Features["xop"] = false; else if (Name == "avx2") - Features["avx2"] = false; + Features["avx2"] = Features["avx512"] = false; + else if (Name == "avx512") + Features["avx512"] = false; else if (Name == "fma") Features["fma"] = false; else if (Name == "sse4a") @@ -2345,6 +2372,7 @@ void X86TargetInfo::HandleTargetFeatures(std::vector<std::string> &Features) { assert(Features[i][0] == '+' && "Invalid target feature!"); X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature) + .Case("avx512", AVX512) .Case("avx2", AVX2) .Case("avx", AVX) .Case("sse42", SSE42) @@ -2455,6 +2483,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, case CK_CoreAVX2: defineCPUMacros(Builder, "corei7"); break; + case CK_KNL: + defineCPUMacros(Builder, "knl"); + break; case CK_K6_2: Builder.defineMacro("__k6_2__"); Builder.defineMacro("__tune_k6_2__"); @@ -2568,6 +2599,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, // Each case falls through to the previous one here. switch (SSELevel) { + case AVX512: + Builder.defineMacro("__AVX512__"); case AVX2: Builder.defineMacro("__AVX2__"); case AVX: @@ -2592,6 +2625,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, if (Opts.MicrosoftExt && getTriple().getArch() == llvm::Triple::x86) { switch (SSELevel) { + case AVX512: case AVX2: case AVX: case SSE42: @@ -2635,6 +2669,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const { .Case("aes", HasAES) .Case("avx", SSELevel >= AVX) .Case("avx2", SSELevel >= AVX2) + .Case("avx512", SSELevel >= AVX512) .Case("bmi", HasBMI) .Case("bmi2", HasBMI2) .Case("fma", HasFMA) |

