From 8461202767684d57f5f43eb613ac5c56301c7586 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Mon, 7 Dec 2009 17:03:21 +0000 Subject: [PATCH] Pass '-msse' and friends to llc as '-mattr=+/-'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90771 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvmc/plugins/Base/Base.td.in | 7 +++++- tools/llvmc/plugins/Base/Hooks.cpp | 33 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tools/llvmc/plugins/Base/Hooks.cpp diff --git a/tools/llvmc/plugins/Base/Base.td.in b/tools/llvmc/plugins/Base/Base.td.in index e2b6eca4b48..69b41ed2520 100644 --- a/tools/llvmc/plugins/Base/Base.td.in +++ b/tools/llvmc/plugins/Base/Base.td.in @@ -82,7 +82,10 @@ def OptList : OptionList<[ (prefix_list_option "Wl,", (help "Pass options to linker")), (prefix_list_option "Wo,", - (help "Pass options to opt")) + (help "Pass options to opt")), + (prefix_list_option "m", + (help "Enable or disable various extensions (-mmmx, -msse, etc.)"), + (hidden)) ]>; // Option preprocessor. @@ -132,6 +135,7 @@ class llvm_gcc_based : Tool< (not_empty "march"), (forward "march"), (not_empty "mtune"), (forward "mtune"), (not_empty "mcpu"), (forward "mcpu"), + (not_empty "m"), (forward "m"), (switch_on "m32"), (forward "m32"), (switch_on "m64"), (forward "m64"), (switch_on "O1"), (forward "O1"), @@ -197,6 +201,7 @@ def llc : Tool< (not_empty "march"), (forward "mcpu"), (not_empty "mtune"), (forward "mcpu"), (not_empty "mcpu"), (forward "mcpu"), + (not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"), (not_empty "Wllc,"), (unpack_values "Wllc,"))) ]>; diff --git a/tools/llvmc/plugins/Base/Hooks.cpp b/tools/llvmc/plugins/Base/Hooks.cpp new file mode 100644 index 00000000000..661a914489d --- /dev/null +++ b/tools/llvmc/plugins/Base/Hooks.cpp @@ -0,0 +1,33 @@ +#include +#include + +namespace hooks { +typedef std::vector StrVec; + +/// ConvertToMAttr - Convert -m* and -mno-* to -mattr=+*,-* +std::string ConvertToMAttr(const StrVec& Opts) { + std::string out("-mattr="); + + bool firstIter = true; + for (StrVec::const_iterator B = Opts.begin(), E = Opts.end(); B!=E; ++B) { + const std::string& Arg = *B; + + if (firstIter) + firstIter = false; + else + out += ","; + + if (Arg.find("no-") == 0 && Arg[3] != 0) { + out += '-'; + out += Arg.c_str() + 3; + } + else { + out += '+'; + out += Arg; + } + } + + return out; +} + +}