Add XOP feature flag.

llvm-svn: 158284
This commit is contained in:
Craig Topper 2012-06-09 22:24:14 +00:00
parent 2edfbddcf0
commit f561a9562d
2 changed files with 31 additions and 8 deletions

View File

@ -1246,6 +1246,7 @@ class X86TargetInfo : public TargetInfo {
bool HasSSE4a;
bool HasFMA4;
bool HasFMA;
bool HasXOP;
/// \brief Enumeration of all of the X86 CPUs supported by Clang.
///
@ -1392,7 +1393,7 @@ public:
: TargetInfo(triple), SSELevel(NoSSE), MMX3DNowLevel(NoMMX3DNow),
HasAES(false), HasPCLMUL(false), HasLZCNT(false), HasBMI(false),
HasBMI2(false), HasPOPCNT(false), HasSSE4a(false), HasFMA4(false),
HasFMA(false), CPU(CK_Generic) {
HasFMA(false), HasXOP(false), CPU(CK_Generic) {
BigEndian = false;
LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
}
@ -1583,6 +1584,7 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const {
Features["popcnt"] = false;
Features["fma4"] = false;
Features["fma"] = false;
Features["xop"] = false;
// FIXME: This *really* should not be here.
@ -1700,7 +1702,7 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const {
case CK_BDVER1:
case CK_BDVER2:
setFeatureEnabled(Features, "avx", true);
setFeatureEnabled(Features, "sse4a", true);
setFeatureEnabled(Features, "xop", true);
setFeatureEnabled(Features, "aes", true);
setFeatureEnabled(Features, "pclmul", true);
break;
@ -1767,6 +1769,11 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
Features["ssse3"] = Features["sse41"] = Features["sse42"] =
Features["popcnt"] = Features["avx"] = Features["sse4a"] =
Features["fma4"] = true;
else if (Name == "xop")
Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
Features["ssse3"] = Features["sse41"] = Features["sse42"] =
Features["popcnt"] = Features["avx"] = Features["sse4a"] =
Features["fma4"] = Features["xop"] = true;
else if (Name == "sse4a")
Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
Features["sse4a"] = true;
@ -1786,16 +1793,18 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
Features["ssse3"] = Features["sse41"] = Features["sse42"] =
Features["sse4a"] = Features["avx"] = Features["avx2"] =
Features["fma"] = Features["fma4"] = Features["aes"] =
Features["pclmul"] = false;
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"] = false;
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"] = false;
Features["avx2"] = Features["fma"] = Features["fma4"] =
Features["xop"] = false;
else if (Name == "ssse3")
Features["ssse3"] = Features["sse41"] = Features["sse42"] =
Features["avx"] = Features["avx2"] = Features["fma"] = false;
@ -1815,13 +1824,13 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
Features["pclmul"] = false;
else if (Name == "avx")
Features["avx"] = Features["avx2"] = Features["fma"] =
Features["fma4"] = false;
Features["fma4"] = Features["xop"] = false;
else if (Name == "avx2")
Features["avx2"] = false;
else if (Name == "fma")
Features["fma"] = false;
else if (Name == "sse4a")
Features["sse4a"] = Features["fma4"] = false;
Features["sse4a"] = Features["fma4"] = Features["xop"] = false;
else if (Name == "lzcnt")
Features["lzcnt"] = false;
else if (Name == "bmi")
@ -1831,7 +1840,9 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
else if (Name == "popcnt")
Features["popcnt"] = false;
else if (Name == "fma4")
Features["fma4"] = false;
Features["fma4"] = Features["xop"] = false;
else if (Name == "xop")
Features["xop"] = false;
}
return true;
@ -1893,6 +1904,11 @@ void X86TargetInfo::HandleTargetFeatures(std::vector<std::string> &Features) {
continue;
}
if (Feature == "xop") {
HasXOP = true;
continue;
}
assert(Features[i][0] == '+' && "Invalid target feature!");
X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature)
.Case("avx2", AVX2)
@ -2099,6 +2115,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
if (HasFMA)
Builder.defineMacro("__FMA__");
if (HasXOP)
Builder.defineMacro("__XOP__");
// Each case falls through to the previous one here.
switch (SSELevel) {
case AVX2:
@ -2180,6 +2199,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const {
.Case("x86", true)
.Case("x86_32", PointerWidth == 32)
.Case("x86_64", PointerWidth == 64)
.Case("xop", HasXOP)
.Default(false);
}

View File

@ -1025,7 +1025,9 @@
// CHECK_BDVER1_M64: #define __AVX__ 1
// CHECK_BDVER1_M64-NOT: #define __3dNOW_A__ 1
// CHECK_BDVER1_M64-NOT: #define __3dNOW__ 1
// CHECK_BDVER1_M64: #define __FMA4__ 1
// CHECK_BDVER1_M64: #define __MMX__ 1
// CHECK_BDVER1_M64: #define __PCLMUL__ 1
// CHECK_BDVER1_M64: #define __SSE2_MATH__ 1
// CHECK_BDVER1_M64: #define __SSE2__ 1
// CHECK_BDVER1_M64: #define __SSE3__ 1
@ -1035,6 +1037,7 @@
// CHECK_BDVER1_M64: #define __SSE_MATH__ 1
// CHECK_BDVER1_M64: #define __SSE__ 1
// CHECK_BDVER1_M64: #define __SSSE3__ 1
// CHECK_BDVER1_M64: #define __XOP__ 1
// CHECK_BDVER1_M64: #define __amd64 1
// CHECK_BDVER1_M64: #define __amd64__ 1
// CHECK_BDVER1_M64: #define __bdver1 1