diff options
author | Craig Topper <craig.topper@gmail.com> | 2011-12-30 07:33:42 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2011-12-30 07:33:42 +0000 |
commit | 6a511e14074e186328020fce78fe0c33deb64d1b (patch) | |
tree | 12a44dadb22454ad682379d7128282c6fc3af5bd | |
parent | 68045b1d4de4b332b7c478e81b5c4383891ba593 (diff) |
Add FMA4 feature flag. Intrinsics coming soon. Also make sse4a feature flag imply sse3. Matches gcc behavior.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147370 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Driver/Options.td | 2 | ||||
-rw-r--r-- | lib/Basic/Targets.cpp | 32 | ||||
-rw-r--r-- | lib/Headers/x86intrin.h | 6 |
3 files changed, 32 insertions, 8 deletions
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 4dfda54c8e..892a972a62 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -616,6 +616,7 @@ def mno_lzcnt : Flag<"-mno-lzcnt">, Group<m_x86_Features_Group>; def mno_bmi : Flag<"-mno-bmi">, Group<m_x86_Features_Group>; def mno_bmi2 : Flag<"-mno-bmi2">, Group<m_x86_Features_Group>; def mno_popcnt : Flag<"-mno-popcnt">, Group<m_x86_Features_Group>; +def mno_fma4 : Flag<"-mno-fma4">, Group<m_x86_Features_Group>; def mno_thumb : Flag<"-mno-thumb">, Group<m_Group>; def marm : Flag<"-marm">, Alias<mno_thumb>; @@ -645,6 +646,7 @@ def mlzcnt : Flag<"-mlzcnt">, Group<m_x86_Features_Group>; def mbmi : Flag<"-mbmi">, Group<m_x86_Features_Group>; def mbmi2 : Flag<"-mbmi2">, Group<m_x86_Features_Group>; def mpopcnt : Flag<"-mpopcnt">, Group<m_x86_Features_Group>; +def mfma4 : Flag<"-mfma4">, Group<m_x86_Features_Group>; def mthumb : Flag<"-mthumb">, Group<m_Group>; def mtune_EQ : Joined<"-mtune=">, Group<m_Group>; def multi__module : Flag<"-multi_module">; diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index a768226b40..aebb28a68e 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -1199,6 +1199,7 @@ class X86TargetInfo : public TargetInfo { bool HasBMI; bool HasBMI2; bool HasPOPCNT; + bool HasFMA4; /// \brief Enumeration of all of the X86 CPUs supported by Clang. /// @@ -1336,7 +1337,8 @@ public: X86TargetInfo(const std::string& triple) : TargetInfo(triple), SSELevel(NoSSE), MMX3DNowLevel(NoMMX3DNow), HasAES(false), HasAVX(false), HasAVX2(false), HasLZCNT(false), - HasBMI(false), HasBMI2(false), HasPOPCNT(false), CPU(CK_Generic) { + HasBMI(false), HasBMI2(false), HasPOPCNT(false), HasFMA4(false), + CPU(CK_Generic) { BigEndian = false; LongDoubleFormat = &llvm::APFloat::x87DoubleExtended; } @@ -1521,6 +1523,7 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const { Features["bmi"] = false; Features["bmi2"] = false; Features["popcnt"] = false; + Features["fma4"] = false; // FIXME: This *really* should not be here. @@ -1690,8 +1693,13 @@ 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 == "fma4") + Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = + Features["ssse3"] = Features["sse41"] = Features["sse42"] = + Features["popcnt"] = Features["avx"] = Features["fma4"] = true; else if (Name == "sse4a") - Features["mmx"] = Features["sse4a"] = true; + Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = + Features["sse4a"] = true; else if (Name == "lzcnt") Features["lzcnt"] = true; else if (Name == "bmi") @@ -1705,13 +1713,14 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, Features["mmx"] = Features["3dnow"] = Features["3dnowa"] = false; else if (Name == "sse") Features["sse"] = Features["sse2"] = Features["sse3"] = - Features["ssse3"] = Features["sse41"] = Features["sse42"] = false; + Features["ssse3"] = Features["sse41"] = Features["sse42"] = + Features["sse4a"] = false; else if (Name == "sse2") Features["sse2"] = Features["sse3"] = Features["ssse3"] = - Features["sse41"] = Features["sse42"] = false; + Features["sse41"] = Features["sse42"] = Features["sse4a"] = false; else if (Name == "sse3") Features["sse3"] = Features["ssse3"] = Features["sse41"] = - Features["sse42"] = false; + Features["sse42"] = Features["sse4a"] = false; else if (Name == "ssse3") Features["ssse3"] = Features["sse41"] = Features["sse42"] = false; else if (Name == "sse4" || Name == "sse4.1") @@ -1725,7 +1734,7 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, else if (Name == "aes") Features["aes"] = false; else if (Name == "avx") - Features["avx"] = Features["avx2"] = false; + Features["avx"] = Features["avx2"] = Features["fma4"] = false; else if (Name == "avx2") Features["avx2"] = false; else if (Name == "sse4a") @@ -1738,6 +1747,8 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, Features["bmi2"] = false; else if (Name == "popcnt") Features["popcnt"] = false; + else if (Name == "fma4") + Features["fma4"] = false; } return true; @@ -1777,10 +1788,14 @@ void X86TargetInfo::HandleTargetFeatures(std::vector<std::string> &Features) { continue; } + if (Features[i].substr(1) == "fma4") { + HasFMA4 = true; + continue; + } + // FIXME: Not sure yet how to treat AVX in regard to SSE levels. // For now let it be enabled together with other SSE levels. if (Features[i].substr(1) == "avx2") { - HasAVX = true; HasAVX2 = true; continue; } @@ -2011,6 +2026,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, if (HasPOPCNT) Builder.defineMacro("__POPCNT__"); + if (HasFMA4) + Builder.defineMacro("__FMA4__"); + // Each case falls through to the previous one here. switch (SSELevel) { case SSE42: diff --git a/lib/Headers/x86intrin.h b/lib/Headers/x86intrin.h index 181330d0bb..5f9bea7107 100644 --- a/lib/Headers/x86intrin.h +++ b/lib/Headers/x86intrin.h @@ -42,6 +42,10 @@ #include <popcntintrin.h> #endif -// FIXME: SSE4A, 3dNOW, FMA4, XOP, LWP, ABM +#ifdef __FMA4__ +#include <fma4intrin.h> +#endif + +// FIXME: SSE4A, 3dNOW, XOP, LWP, ABM #endif /* __X86INTRIN_H */ |