aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvmc
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2010-12-15 01:22:34 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2010-12-15 01:22:34 +0000
commit24d7fa2b6ed7956c4d3c5d778c2dd7dac1165e36 (patch)
treed75299ffd3e20eb5c055f89519a7a13c13f9b9b3 /tools/llvmc
parent36604a60e8509a38cbfaeca779048cb6cd6f6682 (diff)
downloadexternal_llvm-24d7fa2b6ed7956c4d3c5d778c2dd7dac1165e36.zip
external_llvm-24d7fa2b6ed7956c4d3c5d778c2dd7dac1165e36.tar.gz
external_llvm-24d7fa2b6ed7956c4d3c5d778c2dd7dac1165e36.tar.bz2
Copy-pastos.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121829 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvmc')
-rw-r--r--tools/llvmc/src/Hooks.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/tools/llvmc/src/Hooks.cpp b/tools/llvmc/src/Hooks.cpp
index bcf4a53..5aa250e 100644
--- a/tools/llvmc/src/Hooks.cpp
+++ b/tools/llvmc/src/Hooks.cpp
@@ -10,19 +10,19 @@ namespace hooks {
// See http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
inline unsigned NextHighestPowerOf2 (unsigned i) {
+ --i;
i |= i >> 1;
i |= i >> 2;
i |= i >> 4;
i |= i >> 8;
i |= i >> 16;
- i++;
+ ++i;
return i;
}
typedef std::vector<std::string> StrVec;
typedef llvm::StringMap<const char*> ArgMap;
-
/// AddPlusOrMinus - Convert 'no-foo' to '-foo' and 'foo' to '+foo'.
void AddPlusOrMinus (const std::string& Arg, std::string& out) {
if (Arg.find("no-") == 0 && Arg[3] != 0) {
@@ -78,14 +78,22 @@ std::string ConvertMArchToMAttr(const StrVec& Opts) {
std::string mcpu("-mcpu=");
bool mattrTouched = false;
bool mcpuTouched = false;
- 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
+ // Check if the argument should be forwarded to -mcpu instead of -mattr.
+ {
+ ArgMap::const_iterator I = MArchMCpuMap.find(Arg);
+
+ if (I != MArchMCpuMap.end()) {
+ mcpuTouched = true;
+ mcpu += I->getValue();
+ continue;
+ }
+ }
+
+ if (mattrTouched)
mattr += ",";
// Check if the argument is a special case.
@@ -93,23 +101,13 @@ std::string ConvertMArchToMAttr(const StrVec& Opts) {
ArgMap::const_iterator I = MArchMap.find(Arg);
if (I != MArchMap.end()) {
+ mattrTouched = true;
mattr += '+';
mattr += I->getValue();
continue;
}
}
- // Check if the argument should be forwarded to -mcpu instead of -mattr.
- {
- ArgMap::const_iterator I = MArchMCpuMap.find(Arg);
-
- if (I != MArchMCpuMap.end()) {
- mcpuTouched = true;
- mcpu += I->getValue();
- continue;
- }
- }
-
AddPlusOrMinus(Arg, mattr);
}