Simplify ARMTargetParser::getArchSynonym

Summary:
1) The only caller, ARMTargetParser::parseArch, uses the results for an "endswith" test; so, including the "arm" prefix into the result is unnecessary.
2) Most ARMTargetParser::parseArch callers pass it the output from ARMTargetParser::getCanonicalArchName; so, make this behaviour the default. Then, including the "arm" prefix into the cases is unnecessary.

Reviewers: rengolin

Reviewed By: rengolin

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10249

llvm-svn: 239099
This commit is contained in:
Artyom Skrobov 2015-06-04 21:26:58 +00:00
parent c925a905f7
commit 85aebc8c01
2 changed files with 10 additions and 12 deletions

View File

@ -293,16 +293,14 @@ StringRef ARMTargetParser::getFPUSynonym(StringRef FPU) {
StringRef ARMTargetParser::getArchSynonym(StringRef Arch) { StringRef ARMTargetParser::getArchSynonym(StringRef Arch) {
return StringSwitch<StringRef>(Arch) return StringSwitch<StringRef>(Arch)
.Cases("armv6sm", "v6sm", "armv6s-m") .Case("v6sm", "v6s-m")
.Cases("armv6m", "v6m", "armv6-m") .Case("v6m", "v6-m")
.Cases("armv7a", "v7a", "armv7-a") .Case("v7a", "v7-a")
.Cases("armv7r", "v7r", "armv7-r") .Case("v7r", "v7-r")
.Cases("armv7m", "v7m", "armv7-m") .Case("v7m", "v7-m")
.Cases("armv7em", "v7em", "armv7e-m") .Case("v7em", "v7e-m")
.Cases("armv8", "v8", "armv8-a") .Cases("v8", "v8a", "aarch64", "arm64", "armv8-a")
.Cases("armv8a", "v8a", "armv8-a") .Case("v8.1a", "v8.1-a")
.Cases("armv8.1a", "v8.1a", "armv8.1-a")
.Cases("aarch64", "arm64", "armv8-a")
.Default(Arch); .Default(Arch);
} }
@ -370,6 +368,7 @@ unsigned ARMTargetParser::parseFPU(StringRef FPU) {
// Allows partial match, ex. "v7a" matches "armv7a". // Allows partial match, ex. "v7a" matches "armv7a".
unsigned ARMTargetParser::parseArch(StringRef Arch) { unsigned ARMTargetParser::parseArch(StringRef Arch) {
Arch = getCanonicalArchName(Arch);
StringRef Syn = getArchSynonym(Arch); StringRef Syn = getArchSynonym(Arch);
for (const auto A : ARCHNames) { for (const auto A : ARCHNames) {
if (StringRef(A.Name).endswith(Syn)) if (StringRef(A.Name).endswith(Syn))

View File

@ -1147,12 +1147,12 @@ Triple Triple::get64BitArchVariant() const {
const char *Triple::getARMCPUForArch(StringRef MArch) const { const char *Triple::getARMCPUForArch(StringRef MArch) const {
if (MArch.empty()) if (MArch.empty())
MArch = getArchName(); MArch = getArchName();
MArch = ARMTargetParser::getCanonicalArchName(MArch);
// Some defaults are forced. // Some defaults are forced.
switch (getOS()) { switch (getOS()) {
case llvm::Triple::FreeBSD: case llvm::Triple::FreeBSD:
case llvm::Triple::NetBSD: case llvm::Triple::NetBSD:
MArch = ARMTargetParser::getCanonicalArchName(MArch);
if (!MArch.empty() && MArch == "v6") if (!MArch.empty() && MArch == "v6")
return "arm1176jzf-s"; return "arm1176jzf-s";
break; break;
@ -1163,7 +1163,6 @@ const char *Triple::getARMCPUForArch(StringRef MArch) const {
break; break;
} }
MArch = ARMTargetParser::getCanonicalArchName(MArch);
if (MArch.empty()) if (MArch.empty())
return nullptr; return nullptr;