[cfe-commits] r147370 - in /cfe/trunk: include/clang/Driver/Options.td lib/Basic/Targets.cpp lib/Headers/x86intrin.h

Craig Topper craig.topper at gmail.com
Thu Dec 29 23:33:43 PST 2011


Author: ctopper
Date: Fri Dec 30 01:33:42 2011
New Revision: 147370

URL: http://llvm.org/viewvc/llvm-project?rev=147370&view=rev
Log:
Add FMA4 feature flag. Intrinsics coming soon. Also make sse4a feature flag imply sse3. Matches gcc behavior.

Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/Headers/x86intrin.h

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=147370&r1=147369&r2=147370&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Dec 30 01:33:42 2011
@@ -616,6 +616,7 @@
 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 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">;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=147370&r1=147369&r2=147370&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Dec 30 01:33:42 2011
@@ -1199,6 +1199,7 @@
   bool HasBMI;
   bool HasBMI2;
   bool HasPOPCNT;
+  bool HasFMA4;
 
   /// \brief Enumeration of all of the X86 CPUs supported by Clang.
   ///
@@ -1336,7 +1337,8 @@
   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 @@
   Features["bmi"] = false;
   Features["bmi2"] = false;
   Features["popcnt"] = false;
+  Features["fma4"] = false;
 
   // FIXME: This *really* should not be here.
 
@@ -1690,8 +1693,13 @@
       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 @@
       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 @@
     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 @@
       Features["bmi2"] = false;
     else if (Name == "popcnt")
       Features["popcnt"] = false;
+    else if (Name == "fma4")
+      Features["fma4"] = false;
   }
 
   return true;
@@ -1777,10 +1788,14 @@
       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 @@
   if (HasPOPCNT)
     Builder.defineMacro("__POPCNT__");
 
+  if (HasFMA4)
+    Builder.defineMacro("__FMA4__");
+
   // Each case falls through to the previous one here.
   switch (SSELevel) {
   case SSE42:

Modified: cfe/trunk/lib/Headers/x86intrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/x86intrin.h?rev=147370&r1=147369&r2=147370&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/x86intrin.h (original)
+++ cfe/trunk/lib/Headers/x86intrin.h Fri Dec 30 01:33:42 2011
@@ -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 */





More information about the cfe-commits mailing list