forked from OSchip/llvm-project
parent
a59a53f455
commit
224404f851
|
@ -10,19 +10,19 @@ namespace hooks {
|
||||||
|
|
||||||
// See http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
|
// See http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
|
||||||
inline unsigned NextHighestPowerOf2 (unsigned i) {
|
inline unsigned NextHighestPowerOf2 (unsigned i) {
|
||||||
|
--i;
|
||||||
i |= i >> 1;
|
i |= i >> 1;
|
||||||
i |= i >> 2;
|
i |= i >> 2;
|
||||||
i |= i >> 4;
|
i |= i >> 4;
|
||||||
i |= i >> 8;
|
i |= i >> 8;
|
||||||
i |= i >> 16;
|
i |= i >> 16;
|
||||||
i++;
|
++i;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::vector<std::string> StrVec;
|
typedef std::vector<std::string> StrVec;
|
||||||
typedef llvm::StringMap<const char*> ArgMap;
|
typedef llvm::StringMap<const char*> ArgMap;
|
||||||
|
|
||||||
|
|
||||||
/// AddPlusOrMinus - Convert 'no-foo' to '-foo' and 'foo' to '+foo'.
|
/// AddPlusOrMinus - Convert 'no-foo' to '-foo' and 'foo' to '+foo'.
|
||||||
void AddPlusOrMinus (const std::string& Arg, std::string& out) {
|
void AddPlusOrMinus (const std::string& Arg, std::string& out) {
|
||||||
if (Arg.find("no-") == 0 && Arg[3] != 0) {
|
if (Arg.find("no-") == 0 && Arg[3] != 0) {
|
||||||
|
@ -78,27 +78,10 @@ std::string ConvertMArchToMAttr(const StrVec& Opts) {
|
||||||
std::string mcpu("-mcpu=");
|
std::string mcpu("-mcpu=");
|
||||||
bool mattrTouched = false;
|
bool mattrTouched = false;
|
||||||
bool mcpuTouched = false;
|
bool mcpuTouched = false;
|
||||||
bool firstIter = true;
|
|
||||||
|
|
||||||
for (StrVec::const_iterator B = Opts.begin(), E = Opts.end(); B!=E; ++B) {
|
for (StrVec::const_iterator B = Opts.begin(), E = Opts.end(); B!=E; ++B) {
|
||||||
const std::string& Arg = *B;
|
const std::string& Arg = *B;
|
||||||
|
|
||||||
if (firstIter)
|
|
||||||
firstIter = false;
|
|
||||||
else
|
|
||||||
mattr += ",";
|
|
||||||
|
|
||||||
// Check if the argument is a special case.
|
|
||||||
{
|
|
||||||
ArgMap::const_iterator I = MArchMap.find(Arg);
|
|
||||||
|
|
||||||
if (I != MArchMap.end()) {
|
|
||||||
mattr += '+';
|
|
||||||
mattr += I->getValue();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the argument should be forwarded to -mcpu instead of -mattr.
|
// Check if the argument should be forwarded to -mcpu instead of -mattr.
|
||||||
{
|
{
|
||||||
ArgMap::const_iterator I = MArchMCpuMap.find(Arg);
|
ArgMap::const_iterator I = MArchMCpuMap.find(Arg);
|
||||||
|
@ -110,6 +93,21 @@ std::string ConvertMArchToMAttr(const StrVec& Opts) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mattrTouched)
|
||||||
|
mattr += ",";
|
||||||
|
|
||||||
|
// Check if the argument is a special case.
|
||||||
|
{
|
||||||
|
ArgMap::const_iterator I = MArchMap.find(Arg);
|
||||||
|
|
||||||
|
if (I != MArchMap.end()) {
|
||||||
|
mattrTouched = true;
|
||||||
|
mattr += '+';
|
||||||
|
mattr += I->getValue();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AddPlusOrMinus(Arg, mattr);
|
AddPlusOrMinus(Arg, mattr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue