mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-19 04:31:17 +00:00
The canonical CPU variant for ARM according to config.guess uses a
suffix it seems: # ./config.guess earmv7hfeb-unknown-netbsd7.99.4 Extend the triple parsing to support this. Avoid running the ARM parser multiple times because StringSwitch is not lazy. Reviewers: Renato Golin, Tim Northover Differential Revision: http://reviews.llvm.org/D7166 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227085 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c211591e17
commit
d546b25ddb
@ -251,13 +251,21 @@ static Triple::ArchType parseARMArch(StringRef ArchName) {
|
||||
|
||||
if (ArchName.startswith("armv")) {
|
||||
offset = 3;
|
||||
arch = Triple::arm;
|
||||
if (ArchName.endswith("eb")) {
|
||||
arch = Triple::armeb;
|
||||
ArchName = ArchName.substr(0, ArchName.size() - 2);
|
||||
} else
|
||||
arch = Triple::arm;
|
||||
} else if (ArchName.startswith("armebv")) {
|
||||
offset = 5;
|
||||
arch = Triple::armeb;
|
||||
} else if (ArchName.startswith("thumbv")) {
|
||||
offset = 5;
|
||||
arch = Triple::thumb;
|
||||
if (ArchName.endswith("eb")) {
|
||||
arch = Triple::thumbeb;
|
||||
ArchName = ArchName.substr(0, ArchName.size() - 2);
|
||||
} else
|
||||
arch = Triple::thumb;
|
||||
} else if (ArchName.startswith("thumbebv")) {
|
||||
offset = 7;
|
||||
arch = Triple::thumbeb;
|
||||
@ -276,6 +284,8 @@ static Triple::ArchType parseARMArch(StringRef ArchName) {
|
||||
}
|
||||
|
||||
static Triple::ArchType parseArch(StringRef ArchName) {
|
||||
Triple::ArchType ARMArch(parseARMArch(ArchName));
|
||||
|
||||
return StringSwitch<Triple::ArchType>(ArchName)
|
||||
.Cases("i386", "i486", "i586", "i686", Triple::x86)
|
||||
// FIXME: Do we need to support these?
|
||||
@ -285,9 +295,10 @@ static Triple::ArchType parseArch(StringRef ArchName) {
|
||||
.Cases("powerpc64", "ppu", Triple::ppc64)
|
||||
.Case("powerpc64le", Triple::ppc64le)
|
||||
.Case("xscale", Triple::arm)
|
||||
.StartsWith("arm", parseARMArch(ArchName))
|
||||
.StartsWith("thumb", parseARMArch(ArchName))
|
||||
.StartsWith("aarch64", parseARMArch(ArchName))
|
||||
.Case("xscaleeb", Triple::armeb)
|
||||
.StartsWith("arm", ARMArch)
|
||||
.StartsWith("thumb", ARMArch)
|
||||
.StartsWith("aarch64", ARMArch)
|
||||
.Case("msp430", Triple::msp430)
|
||||
.Cases("mips", "mipseb", "mipsallegrex", Triple::mips)
|
||||
.Cases("mipsel", "mipsallegrexel", Triple::mipsel)
|
||||
@ -386,6 +397,9 @@ static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
|
||||
}
|
||||
|
||||
static Triple::SubArchType parseSubArch(StringRef SubArchName) {
|
||||
if (SubArchName.endswith("eb"))
|
||||
SubArchName = SubArchName.substr(0, SubArchName.size() - 2);
|
||||
|
||||
return StringSwitch<Triple::SubArchType>(SubArchName)
|
||||
.EndsWith("v8", Triple::ARMSubArch_v8)
|
||||
.EndsWith("v8a", Triple::ARMSubArch_v8)
|
||||
@ -1032,6 +1046,8 @@ const char *Triple::getARMCPUForArch(StringRef MArch) const {
|
||||
offset = 5;
|
||||
if (offset != StringRef::npos && MArch.substr(offset, 2) == "eb")
|
||||
offset += 2;
|
||||
if (MArch.endswith("eb"))
|
||||
MArch = MArch.substr(0, MArch.size() - 2);
|
||||
if (offset != StringRef::npos)
|
||||
result = llvm::StringSwitch<const char *>(MArch.substr(offset))
|
||||
.Cases("v2", "v2a", "arm2")
|
||||
|
@ -665,3 +665,20 @@ TEST(TripleTest, getARMCPUForArch) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(TripleTest, NormalizeARM) {
|
||||
EXPECT_EQ("armv6--netbsd-eabi", Triple::normalize("armv6-netbsd-eabi"));
|
||||
EXPECT_EQ("armv7--netbsd-eabi", Triple::normalize("armv7-netbsd-eabi"));
|
||||
EXPECT_EQ("armv6eb--netbsd-eabi", Triple::normalize("armv6eb-netbsd-eabi"));
|
||||
EXPECT_EQ("armv7eb--netbsd-eabi", Triple::normalize("armv7eb-netbsd-eabi"));
|
||||
EXPECT_EQ("armv6--netbsd-eabihf", Triple::normalize("armv6-netbsd-eabihf"));
|
||||
EXPECT_EQ("armv7--netbsd-eabihf", Triple::normalize("armv7-netbsd-eabihf"));
|
||||
EXPECT_EQ("armv6eb--netbsd-eabihf", Triple::normalize("armv6eb-netbsd-eabihf"));
|
||||
EXPECT_EQ("armv7eb--netbsd-eabihf", Triple::normalize("armv7eb-netbsd-eabihf"));
|
||||
|
||||
Triple T;
|
||||
T = Triple("armv6--netbsd-eabi");
|
||||
EXPECT_EQ(Triple::arm, T.getArch());
|
||||
T = Triple("armv6eb--netbsd-eabi");
|
||||
EXPECT_EQ(Triple::armeb, T.getArch());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user