[PATCH] Parse EB variant as suffix for ARM triples
Joerg Sonnenberger
joerg at NetBSD.org
Sun Jan 25 11:55:50 PST 2015
Hi t.p.northover,
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.
http://reviews.llvm.org/D7166
Files:
lib/Support/Triple.cpp
unittests/ADT/TripleTest.cpp
Index: lib/Support/Triple.cpp
===================================================================
--- lib/Support/Triple.cpp
+++ lib/Support/Triple.cpp
@@ -246,13 +246,21 @@
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;
@@ -271,6 +279,8 @@
}
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?
@@ -280,9 +290,10 @@
.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)
@@ -379,6 +390,9 @@
}
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)
@@ -1022,6 +1036,8 @@
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")
Index: unittests/ADT/TripleTest.cpp
===================================================================
--- unittests/ADT/TripleTest.cpp
+++ unittests/ADT/TripleTest.cpp
@@ -665,3 +665,20 @@
}
}
}
+
+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());
+}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7166.18732.patch
Type: text/x-patch
Size: 3478 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150125/8877d974/attachment.bin>
More information about the llvm-commits
mailing list