summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2011-12-30 07:33:42 +0000
committerCraig Topper <craig.topper@gmail.com>2011-12-30 07:33:42 +0000
commitffdb46ceef3cc26960be36e864e657fd2a40e640 (patch)
tree1d2760352d2cef81982d49d112a67a320376ec67 /clang/lib
parenta5d1fc2cc75cd7044c61483becaeda33ed410b0f (diff)
downloadbcm5719-llvm-ffdb46ceef3cc26960be36e864e657fd2a40e640.tar.gz
bcm5719-llvm-ffdb46ceef3cc26960be36e864e657fd2a40e640.zip
Add FMA4 feature flag. Intrinsics coming soon. Also make sse4a feature flag imply sse3. Matches gcc behavior.
llvm-svn: 147370
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/Targets.cpp32
-rw-r--r--clang/lib/Headers/x86intrin.h6
2 files changed, 30 insertions, 8 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index a768226b40c..aebb28a68e5 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/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/clang/lib/Headers/x86intrin.h b/clang/lib/Headers/x86intrin.h
index 181330d0bb6..5f9bea7107a 100644
--- a/clang/lib/Headers/x86intrin.h
+++ b/clang/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 */
OpenPOWER on IntegriCloud