[llvm] r238110 - Move parseSubArch to ARMTargetParser. NFC
Renato Golin
renato.golin at linaro.org
Sun May 24 04:18:44 PDT 2015
Author: rengolin
Date: Sun May 24 06:18:44 2015
New Revision: 238110
URL: http://llvm.org/viewvc/llvm-project?rev=238110&view=rev
Log:
Move parseSubArch to ARMTargetParser. NFC
Using getCanonicalArchName() is the right way to parse ARM arch names.
Mapping ARMTargetParser IDs to Triple Arch IDs is temporary, until they
are merged into a TargetDescription class.
This was the last LLVM FIXME to move things to ARMTargetParser. Now on
to Clang and beyond.
Modified:
llvm/trunk/lib/Support/Triple.cpp
Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=238110&r1=238109&r2=238110&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Sun May 24 06:18:44 2015
@@ -409,37 +409,65 @@ static Triple::ObjectFormatType parseFor
.Default(Triple::UnknownObjectFormat);
}
-// FIXME: Use ARMTargetParser. This would require using Triple::ARMSubArch*
-// in ARMBuildAttrs and in ARCHNames' DefaultArch fields.
static Triple::SubArchType parseSubArch(StringRef SubArchName) {
- if (SubArchName.endswith("eb"))
- SubArchName = SubArchName.substr(0, SubArchName.size() - 2);
+ StringRef ARMSubArch = ARMTargetParser::getCanonicalArchName(SubArchName);
- return StringSwitch<Triple::SubArchType>(SubArchName)
- .EndsWith("v8.1a", Triple::ARMSubArch_v8_1a)
- .EndsWith("v8", Triple::ARMSubArch_v8)
- .EndsWith("v8a", Triple::ARMSubArch_v8)
- .EndsWith("v7", Triple::ARMSubArch_v7)
- .EndsWith("v7a", Triple::ARMSubArch_v7)
- .EndsWith("v7em", Triple::ARMSubArch_v7em)
- .EndsWith("v7l", Triple::ARMSubArch_v7)
- .EndsWith("v7m", Triple::ARMSubArch_v7m)
- .EndsWith("v7r", Triple::ARMSubArch_v7)
- .EndsWith("v7s", Triple::ARMSubArch_v7s)
- .EndsWith("v6", Triple::ARMSubArch_v6)
- .EndsWith("v6m", Triple::ARMSubArch_v6m)
- .EndsWith("v6sm", Triple::ARMSubArch_v6m)
- .EndsWith("v6k", Triple::ARMSubArch_v6k)
- .EndsWith("v6t2", Triple::ARMSubArch_v6t2)
- .EndsWith("v5", Triple::ARMSubArch_v5)
- .EndsWith("v5e", Triple::ARMSubArch_v5)
- .EndsWith("v5t", Triple::ARMSubArch_v5)
- .EndsWith("v5te", Triple::ARMSubArch_v5te)
- .EndsWith("v4t", Triple::ARMSubArch_v4t)
- .EndsWith("kalimba3", Triple::KalimbaSubArch_v3)
- .EndsWith("kalimba4", Triple::KalimbaSubArch_v4)
- .EndsWith("kalimba5", Triple::KalimbaSubArch_v5)
- .Default(Triple::NoSubArch);
+ // For now, this is the small part. Early return.
+ if (ARMSubArch.empty())
+ return StringSwitch<Triple::SubArchType>(SubArchName)
+ .EndsWith("kalimba3", Triple::KalimbaSubArch_v3)
+ .EndsWith("kalimba4", Triple::KalimbaSubArch_v4)
+ .EndsWith("kalimba5", Triple::KalimbaSubArch_v5)
+ .Default(Triple::NoSubArch);
+
+ // ARM sub arch.
+ switch(ARMTargetParser::parseArch(ARMSubArch)) {
+ case ARM::AK_ARMV4:
+ return Triple::NoSubArch;
+ case ARM::AK_ARMV4T:
+ return Triple::ARMSubArch_v4t;
+ case ARM::AK_ARMV5:
+ case ARM::AK_ARMV5T:
+ case ARM::AK_ARMV5E:
+ return Triple::ARMSubArch_v5;
+ case ARM::AK_ARMV5TE:
+ case ARM::AK_IWMMXT:
+ case ARM::AK_IWMMXT2:
+ case ARM::AK_XSCALE:
+ case ARM::AK_ARMV5TEJ:
+ return Triple::ARMSubArch_v5te;
+ case ARM::AK_ARMV6:
+ case ARM::AK_ARMV6J:
+ case ARM::AK_ARMV6Z:
+ return Triple::ARMSubArch_v6;
+ case ARM::AK_ARMV6K:
+ case ARM::AK_ARMV6ZK:
+ case ARM::AK_ARMV6HL:
+ return Triple::ARMSubArch_v6k;
+ case ARM::AK_ARMV6T2:
+ return Triple::ARMSubArch_v6t2;
+ case ARM::AK_ARMV6M:
+ case ARM::AK_ARMV6SM:
+ return Triple::ARMSubArch_v6m;
+ case ARM::AK_ARMV7:
+ case ARM::AK_ARMV7A:
+ case ARM::AK_ARMV7R:
+ case ARM::AK_ARMV7L:
+ case ARM::AK_ARMV7HL:
+ return Triple::ARMSubArch_v7;
+ case ARM::AK_ARMV7M:
+ return Triple::ARMSubArch_v7m;
+ case ARM::AK_ARMV7S:
+ return Triple::ARMSubArch_v7s;
+ case ARM::AK_ARMV7EM:
+ return Triple::ARMSubArch_v7em;
+ case ARM::AK_ARMV8A:
+ return Triple::ARMSubArch_v8;
+ case ARM::AK_ARMV8_1A:
+ return Triple::ARMSubArch_v8_1a;
+ default:
+ return Triple::NoSubArch;
+ }
}
static const char *getObjectFormatTypeName(Triple::ObjectFormatType Kind) {
More information about the llvm-commits
mailing list