llvm.org GIT mirror llvm / 32d3823
Merging r227085: ------------------------------------------------------------------------ r227085 | joerg | 2015-01-26 03:41:48 -0800 (Mon, 26 Jan 2015) | 13 lines 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/branches/release_36@227394 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 4 years ago
2 changed file(s) with 38 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
245245
246246 if (ArchName.startswith("armv")) {
247247 offset = 3;
248 arch = Triple::arm;
248 if (ArchName.endswith("eb")) {
249 arch = Triple::armeb;
250 ArchName = ArchName.substr(0, ArchName.size() - 2);
251 } else
252 arch = Triple::arm;
249253 } else if (ArchName.startswith("armebv")) {
250254 offset = 5;
251255 arch = Triple::armeb;
252256 } else if (ArchName.startswith("thumbv")) {
253257 offset = 5;
254 arch = Triple::thumb;
258 if (ArchName.endswith("eb")) {
259 arch = Triple::thumbeb;
260 ArchName = ArchName.substr(0, ArchName.size() - 2);
261 } else
262 arch = Triple::thumb;
255263 } else if (ArchName.startswith("thumbebv")) {
256264 offset = 7;
257265 arch = Triple::thumbeb;
270278 }
271279
272280 static Triple::ArchType parseArch(StringRef ArchName) {
281 Triple::ArchType ARMArch(parseARMArch(ArchName));
282
273283 return StringSwitch(ArchName)
274284 .Cases("i386", "i486", "i586", "i686", Triple::x86)
275285 // FIXME: Do we need to support these?
279289 .Cases("powerpc64", "ppu", Triple::ppc64)
280290 .Case("powerpc64le", Triple::ppc64le)
281291 .Case("xscale", Triple::arm)
282 .StartsWith("arm", parseARMArch(ArchName))
283 .StartsWith("thumb", parseARMArch(ArchName))
284 .StartsWith("aarch64", parseARMArch(ArchName))
292 .Case("xscaleeb", Triple::armeb)
293 .StartsWith("arm", ARMArch)
294 .StartsWith("thumb", ARMArch)
295 .StartsWith("aarch64", ARMArch)
285296 .Case("msp430", Triple::msp430)
286297 .Cases("mips", "mipseb", "mipsallegrex", Triple::mips)
287298 .Cases("mipsel", "mipsallegrexel", Triple::mipsel)
378389 }
379390
380391 static Triple::SubArchType parseSubArch(StringRef SubArchName) {
392 if (SubArchName.endswith("eb"))
393 SubArchName = SubArchName.substr(0, SubArchName.size() - 2);
394
381395 return StringSwitch(SubArchName)
382396 .EndsWith("v8", Triple::ARMSubArch_v8)
383397 .EndsWith("v8a", Triple::ARMSubArch_v8)
10211035 offset = 5;
10221036 if (offset != StringRef::npos && MArch.substr(offset, 2) == "eb")
10231037 offset += 2;
1038 if (MArch.endswith("eb"))
1039 MArch = MArch.substr(0, MArch.size() - 2);
10241040 if (offset != StringRef::npos)
10251041 result = llvm::StringSwitch(MArch.substr(offset))
10261042 .Cases("v2", "v2a", "arm2")
664664 }
665665 }
666666 }
667
668 TEST(TripleTest, NormalizeARM) {
669 EXPECT_EQ("armv6--netbsd-eabi", Triple::normalize("armv6-netbsd-eabi"));
670 EXPECT_EQ("armv7--netbsd-eabi", Triple::normalize("armv7-netbsd-eabi"));
671 EXPECT_EQ("armv6eb--netbsd-eabi", Triple::normalize("armv6eb-netbsd-eabi"));
672 EXPECT_EQ("armv7eb--netbsd-eabi", Triple::normalize("armv7eb-netbsd-eabi"));
673 EXPECT_EQ("armv6--netbsd-eabihf", Triple::normalize("armv6-netbsd-eabihf"));
674 EXPECT_EQ("armv7--netbsd-eabihf", Triple::normalize("armv7-netbsd-eabihf"));
675 EXPECT_EQ("armv6eb--netbsd-eabihf", Triple::normalize("armv6eb-netbsd-eabihf"));
676 EXPECT_EQ("armv7eb--netbsd-eabihf", Triple::normalize("armv7eb-netbsd-eabihf"));
677
678 Triple T;
679 T = Triple("armv6--netbsd-eabi");
680 EXPECT_EQ(Triple::arm, T.getArch());
681 T = Triple("armv6eb--netbsd-eabi");
682 EXPECT_EQ(Triple::armeb, T.getArch());
683 }