aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2010-12-15 01:22:25 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2010-12-15 01:22:25 +0000
commit42db997688664c0d3c59cd4e61b3d1275b714386 (patch)
tree7da4f49c4c275b99c4fd5bc420a06e46eabd7b3b /tools
parent2ac7eb8c61fe74e1477b201d7220a148ee281c3f (diff)
llvmc: Support -march arguments that should be forwarded to llc as -mcpu.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121827 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvmc/src/Hooks.cpp52
1 files changed, 42 insertions, 10 deletions
diff --git a/tools/llvmc/src/Hooks.cpp b/tools/llvmc/src/Hooks.cpp
index 8755b1a3fb..99b79e5576 100644
--- a/tools/llvmc/src/Hooks.cpp
+++ b/tools/llvmc/src/Hooks.cpp
@@ -26,8 +26,13 @@ typedef llvm::StringMap<const char*> ArgMap;
/// ConvertToMAttr. The optional Args parameter contains information about how
/// to transform special-cased values (for example, '-march=armv6' must be
/// forwarded as '-mattr=+v6').
-std::string ConvertToMAttrImpl(const StrVec& Opts, const ArgMap* Args = 0) {
- std::string out("-mattr=");
+std::string ConvertToMAttrImpl(const StrVec& Opts,
+ const ArgMap* Args = 0,
+ const ArgMap* MCpuArgs = 0) {
+ std::string mattr("-mattr=");
+ 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) {
@@ -36,31 +41,48 @@ std::string ConvertToMAttrImpl(const StrVec& Opts, const ArgMap* Args = 0) {
if (firstIter)
firstIter = false;
else
- out += ",";
+ mattr += ",";
// Check if the argument is a special case.
if (Args != 0) {
ArgMap::const_iterator I = Args->find(Arg);
if (I != Args->end()) {
- out += '+';
- out += I->getValue();
+ mattr += '+';
+ mattr += I->getValue();
+ continue;
+ }
+ }
+
+ // Check if the argument should be forwarded to -mcpu instead of -mattr.
+ if (MCpuArgs != 0 && !mcpuTouched) {
+ ArgMap::const_iterator I = MCpuArgs->find(Arg);
+
+ if (I != MCpuArgs->end()) {
+ mcpuTouched = true;
+ mcpu += I->getValue();
continue;
}
}
// Convert 'no-foo' to '-foo'.
if (Arg.find("no-") == 0 && Arg[3] != 0) {
- out += '-';
- out += Arg.c_str() + 3;
+ mattr += '-';
+ mattr += Arg.c_str() + 3;
}
// Convert 'foo' to '+foo'.
else {
- out += '+';
- out += Arg;
+ mattr += '+';
+ mattr += Arg;
}
}
+ std::string out;
+ if (mattrTouched)
+ out += mattr;
+ if (mcpuTouched)
+ out += (mattrTouched ? " " : "") + mcpu;
+
return out;
}
@@ -72,6 +94,13 @@ const char* MArchValuesARM[] = { "v4t", "v5t", "v5te", "v6", "v6m", "v6t2",
const unsigned MArchNumKeysARM = NUM_KEYS(MArchKeysARM);
const unsigned MArchMapSize = NextHighestPowerOf2(MArchNumKeysARM);
+// -march values that should be forwarded as -mcpu
+const char* MArchMCpuKeysARM[] = { "iwmmxt", "ep9312" };
+const char* MArchMCpuValuesARM[] = { "iwmmxt", "ep9312"};
+const unsigned MArchMCpuNumKeysARM = NUM_KEYS(MArchMCpuKeysARM);
+const unsigned MArchMCpuMapSize = NextHighestPowerOf2(MArchMCpuNumKeysARM);
+
+
void FillInArgMap(ArgMap& Args, const char* Keys[],
const char* Values[], unsigned NumKeys)
{
@@ -86,14 +115,17 @@ void FillInArgMap(ArgMap& Args, const char* Keys[],
/// something llc can understand.
std::string ConvertMArchToMAttr(const StrVec& Opts) {
static ArgMap MArchMap(MArchMapSize);
+ static ArgMap MArchMCpuMap(MArchMapSize);
static bool StaticDataInitialized = false;
if (!StaticDataInitialized) {
FillInArgMap(MArchMap, MArchKeysARM, MArchValuesARM, MArchNumKeysARM);
+ FillInArgMap(MArchMCpuMap, MArchMCpuKeysARM,
+ MArchMCpuValuesARM, MArchMCpuNumKeysARM);
StaticDataInitialized = true;
}
- return ConvertToMAttrImpl(Opts, &MArchMap);
+ return ConvertToMAttrImpl(Opts, &MArchMap, &MArchMCpuMap);
}
// -mcpu values that need to be special-cased.