From: Daniel Dunbar Date: Wed, 6 May 2009 21:56:32 +0000 (+0000) Subject: Handle -march for the LLVM recognized cpu names. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ac79049abf396487546e8807e8763403f444a07;p=clang Handle -march for the LLVM recognized cpu names. - x86 target feature handling should not be feature complete, even if the code quality is lacking. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71123 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 4e9c3a57a9..0c905d4d0b 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -562,16 +562,41 @@ void X86TargetInfo::getDefaultFeatures(const std::string &CPU, if (PointerWidth == 64) Features["sse2"] = Features["sse"] = Features["mmx"] = true; - // FIXME: LLVM says core2 has SSSE3, but gcc doesn't define - // __SSSE3__ with it? What else is going on here? - if (CPU == "core2") - Features["ssse3"] = Features["sse3"] = Features["sse2"] = Features["sse"] = - Features["mmx"] = true; - else if (CPU == "yonah") - Features["sse3"] = Features["sse2"] = Features["sse"] = - Features["mmx"] = true; - else if (CPU == "pentium4") - Features["sse2"] = Features["sse"] = Features["mmx"] = true; + if (CPU == "generic" || CPU == "i386" || CPU == "i486" || CPU == "i586" || + CPU == "pentium" || CPU == "i686" || CPU == "pentiumpro") + ; + else if (CPU == "pentium-mmx" || CPU == "pentium2") + setFeatureEnabled(Features, "mmx", true); + else if (CPU == "pentium3") + setFeatureEnabled(Features, "sse", true); + else if (CPU == "pentium-m" || CPU == "pentium4" || CPU == "x86-64") + setFeatureEnabled(Features, "sse2", true); + else if (CPU == "yonah" || CPU == "prescott" || CPU == "nocona") + setFeatureEnabled(Features, "sse3", true); + else if (CPU == "core2") + setFeatureEnabled(Features, "ssse3", true); + else if (CPU == "penryn") { + setFeatureEnabled(Features, "sse4", true); + Features["sse42"] = false; + } else if (CPU == "atom") + setFeatureEnabled(Features, "sse3", true); + else if (CPU == "corei7") + setFeatureEnabled(Features, "sse4", true); + else if (CPU == "k6" || CPU == "winchip-c6") + setFeatureEnabled(Features, "mmx", true); + else if (CPU == "k6-2" || CPU == "k6-3" || CPU == "athlon" || + CPU == "athlon-tbird" || CPU == "winchip2" || CPU == "c3") { + setFeatureEnabled(Features, "mmx", true); + setFeatureEnabled(Features, "3dnow", true); + } else if (CPU == "athlon-4" || CPU == "athlon-xp" || CPU == "athlon-mp") { + setFeatureEnabled(Features, "sse", true); + setFeatureEnabled(Features, "3dnowa", true); + } else if (CPU == "k8" || CPU == "opteron" || CPU == "athlon64" || + CPU == "athlon-fx") { + setFeatureEnabled(Features, "sse2", true); + setFeatureEnabled(Features, "3dnowa", true); + } else if (CPU == "c3-2") + setFeatureEnabled(Features, "sse", true); } bool X86TargetInfo::setFeatureEnabled(llvm::StringMap &Features, diff --git a/test/Preprocessor/x86_target_features.c b/test/Preprocessor/x86_target_features.c index 456c4fcf3a..90a717b81e 100644 --- a/test/Preprocessor/x86_target_features.c +++ b/test/Preprocessor/x86_target_features.c @@ -20,6 +20,16 @@ // RUN: grep '#define __SSE__ 1' %t && // RUN: grep '#define __SSSE3__ 1' %t | count 0 && +// RUN: clang -ccc-host-triple i386-unknown-unknown -march=pentium-m -x c -E -dM -o %t %s && +// RUN: grep '#define __SSE2_MATH__ 1' %t && +// RUN: grep '#define __SSE2__ 1' %t && +// RUN: grep '#define __SSE3__ 1' %t | count 0 && +// RUN: grep '#define __SSE4_1__ 1' %t | count 0 && +// RUN: grep '#define __SSE4_2__ 1' %t | count 0 && +// RUN: grep '#define __SSE_MATH__ 1' %t && +// RUN: grep '#define __SSE__ 1' %t && +// RUN: grep '#define __SSSE3__ 1' %t | count 0 && + // RUN: true