From: Bruno Cardoso Lopes Date: Wed, 4 Aug 2010 22:29:13 +0000 (+0000) Subject: Add -mavx and -mno-avx command line support X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7377ed985bb2a529d1abb4ebea88586e5d195d1b;p=clang Add -mavx and -mno-avx command line support git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110265 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index ccf55ef8af..e6204f77ad 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -462,6 +462,7 @@ def mno_sse4_2 : Flag<"-mno-sse4.2">, Group; def mno_sse : Flag<"-mno-sse">, Group; def mno_ssse3 : Flag<"-mno-ssse3">, Group; def mno_aes : Flag<"-mno-aes">, Group; +def mno_avx : Flag<"-mno-avx">, Group; def mno_thumb : Flag<"-mno-thumb">, Group; def marm : Flag<"-marm">, Alias; @@ -482,6 +483,7 @@ def msse4_2 : Flag<"-msse4.2">, Group; def msse : Flag<"-msse">, Group; def mssse3 : Flag<"-mssse3">, Group; def maes : Flag<"-maes">, Group; +def mavx : Flag<"-mavx">, 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 d7f3989a36..eb8358aab1 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -912,11 +912,12 @@ class X86TargetInfo : public TargetInfo { } AMD3DNowLevel; bool HasAES; - + bool HasAVX; + public: X86TargetInfo(const std::string& triple) : TargetInfo(triple), SSELevel(NoMMXSSE), AMD3DNowLevel(NoAMD3DNow), - HasAES(false) { + HasAES(false), HasAVX(false) { LongDoubleFormat = &llvm::APFloat::x87DoubleExtended; } virtual void getTargetBuiltins(const Builtin::Info *&Records, @@ -963,6 +964,7 @@ void X86TargetInfo::getDefaultFeatures(const std::string &CPU, Features["sse41"] = false; Features["sse42"] = false; Features["aes"] = false; + Features["avx"] = false; // LLVM does not currently recognize this. // Features["sse4a"] = false; @@ -1046,6 +1048,8 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap &Features, Features["3dnow"] = Features["3dnowa"] = true; else if (Name == "aes") Features["aes"] = true; + else if (Name == "avx") + Features["avx"] = true; } else { if (Name == "mmx") Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = @@ -1073,6 +1077,8 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap &Features, Features["3dnowa"] = false; else if (Name == "aes") Features["aes"] = false; + else if (Name == "avx") + Features["avx"] = false; } return true; @@ -1092,6 +1098,13 @@ void X86TargetInfo::HandleTargetFeatures(std::vector &Features) { 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) == "avx") { + HasAVX = true; + continue; + } + assert(Features[i][0] == '+' && "Invalid target feature!"); X86SSEEnum Level = llvm::StringSwitch(Features[i].substr(1)) .Case("sse42", SSE42) @@ -1133,6 +1146,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, if (HasAES) Builder.defineMacro("__AES__"); + if (HasAVX) + Builder.defineMacro("__AVX__"); + // Target properties. Builder.defineMacro("__LITTLE_ENDIAN__");