From: Craig Topper Date: Fri, 30 Dec 2011 07:33:42 +0000 (+0000) Subject: Add FMA4 feature flag. Intrinsics coming soon. Also make sse4a feature flag imply... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6a511e14074e186328020fce78fe0c33deb64d1b;p=clang 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 --- 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; def mno_bmi : Flag<"-mno-bmi">, Group; def mno_bmi2 : Flag<"-mno-bmi2">, Group; def mno_popcnt : Flag<"-mno-popcnt">, Group; +def mno_fma4 : Flag<"-mno-fma4">, Group; def mno_thumb : Flag<"-mno-thumb">, Group; def marm : Flag<"-marm">, Alias; @@ -645,6 +646,7 @@ def mlzcnt : Flag<"-mlzcnt">, Group; def mbmi : Flag<"-mbmi">, Group; def mbmi2 : Flag<"-mbmi2">, Group; def mpopcnt : Flag<"-mpopcnt">, Group; +def mfma4 : Flag<"-mfma4">, Group; def mthumb : Flag<"-mthumb">, Group; def mtune_EQ : Joined<"-mtune=">, 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 &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 &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 &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 &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 &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 &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 #endif -// FIXME: SSE4A, 3dNOW, FMA4, XOP, LWP, ABM +#ifdef __FMA4__ +#include +#endif + +// FIXME: SSE4A, 3dNOW, XOP, LWP, ABM #endif /* __X86INTRIN_H */