llvm-6502/tools/llvmc/plugins/Base/Hooks.cpp
Mikhail Glushenkov 8461202767 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
2009-12-07 17:03:21 +00:00

34 lines
623 B
C++

#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;
}
}