ARMTargetParser: Make BSD Thumb/BE armv6 work
authorRenato Golin <renato.golin@linaro.org>
Wed, 27 May 2015 19:49:53 +0000 (19:49 +0000)
committerRenato Golin <renato.golin@linaro.org>
Wed, 27 May 2015 19:49:53 +0000 (19:49 +0000)
Simple change to make arch like "thumbv6" and "armbev6" to return the
correct CPU for FreeBSD and NetBSD.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238353 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Triple.cpp
unittests/ADT/TripleTest.cpp

index a63426f..a1ee188 100644 (file)
@@ -1113,8 +1113,8 @@ const char *Triple::getARMCPUForArch(StringRef MArch) const {
   switch (getOS()) {
   case llvm::Triple::FreeBSD:
   case llvm::Triple::NetBSD:
-    // FIXME: This doesn't work on BE/thumb variants.
-    if (MArch == "armv6")
+    MArch = ARMTargetParser::getCanonicalArchName(MArch);
+    if (!MArch.empty() && MArch == "v6")
       return "arm1176jzf-s";
     break;
   case llvm::Triple::Win32:
index b0f01b2..23a9128 100644 (file)
@@ -799,6 +799,14 @@ TEST(TripleTest, getARMCPUForArch) {
     llvm::Triple Triple("armv6-unknown-freebsd");
     EXPECT_STREQ("arm1176jzf-s", Triple.getARMCPUForArch());
   }
+  {
+    llvm::Triple Triple("thumbv6-unknown-freebsd");
+    EXPECT_STREQ("arm1176jzf-s", Triple.getARMCPUForArch());
+  }
+  {
+    llvm::Triple Triple("armebv6-unknown-freebsd");
+    EXPECT_STREQ("arm1176jzf-s", Triple.getARMCPUForArch());
+  }
   {
     llvm::Triple Triple("arm--win32");
     EXPECT_STREQ("cortex-a9", Triple.getARMCPUForArch());