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
This commit is contained in:
Mikhail Glushenkov 2009-12-07 17:03:21 +00:00
parent 8245a1dd53
commit 8461202767
2 changed files with 39 additions and 1 deletions

View File

@ -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 <string cmd_prefix, string in_lang, string E_ext> : 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,")))
]>;

View File

@ -0,0 +1,33 @@
#include <string>
#include <vector>
namespace hooks {
typedef std::vector<std::string> 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;
}
}