ARM target now also recognize triplets like thumbv6-apple-darwin and set thumb mode...
authorEvan Cheng <evan.cheng@apple.com>
Mon, 9 Mar 2009 20:25:39 +0000 (20:25 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Mon, 9 Mar 2009 20:25:39 +0000 (20:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66435 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMSubtarget.cpp
lib/Target/ARM/ARMTargetMachine.cpp

index f5a18405f9ea4357dfe0ab4af4f6b3cd42474cb4..2415a85051aa47cb416b7e17bf786a03b9861463 100644 (file)
@@ -36,23 +36,30 @@ ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS, bool thumb)
   // if one cannot be determined, to true.
   const std::string& TT = M.getTargetTriple();
   unsigned Len = TT.length();
-  if (Len >= 5) {
-    if (TT.substr(0, 4) == "armv") {
-      unsigned SubVer = TT[4];
-      if (SubVer > '4' && SubVer <= '9') {
-        if (SubVer >= '6')
-          ARMArchVersion = V6;
-        else if (SubVer == '5') {
-          ARMArchVersion = V5T;
-          if (Len >= 7 && TT[5] == 't' && TT[6] == 'e')
-            ARMArchVersion = V5TE;
-        }
+  unsigned Idx = 0;
+  if (Len >= 5 && TT.substr(0, 4) == "armv")
+    Idx = 4;
+  else if (Len >= 6 && TT.substr(0, 6) == "thumb") {
+    IsThumb = true;
+    if (Len >= 7 && TT[5] == 'v')
+      Idx = 6;
+  }
+  if (Idx) {
+    unsigned SubVer = TT[Idx];
+    if (SubVer > '4' && SubVer <= '9') {
+      if (SubVer >= '6')
+        ARMArchVersion = V6;
+      else if (SubVer == '5') {
+        ARMArchVersion = V5T;
+        if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
+          ARMArchVersion = V5TE;
       }
     }
   }
 
-  if (Len > 5) {
+  if (Len >= 10) {
     if (TT.find("-darwin") != std::string::npos)
+      // arm-darwin
       TargetType = isDarwin;
   } else if (TT.empty()) {
 #if defined(__APPLE__)
index 919c2ffaf8fd43de45fed34fd204a0268da728bf..6bb0b2e3cca3a97d294d5b1c1c15ce6facf3e397 100644 (file)
@@ -53,7 +53,9 @@ unsigned ThumbTargetMachine::getJITMatchQuality() {
 
 unsigned ThumbTargetMachine::getModuleMatchQuality(const Module &M) {
   std::string TT = M.getTargetTriple();
-  if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "thumb-")
+  // Match thumb-foo-bar, as well as things like thumbv5blah-*
+  if (TT.size() >= 6 &&
+      (TT.substr(0, 6) == "thumb-" || TT.substr(0, 6) == "thumbv"))
     return 20;
 
   // If the target triple is something non-thumb, we don't match.
@@ -105,7 +107,8 @@ unsigned ARMTargetMachine::getJITMatchQuality() {
 
 unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) {
   std::string TT = M.getTargetTriple();
-  if (TT.size() >= 4 && // Match arm-foo-bar, as well as things like armv5blah-*
+  // Match arm-foo-bar, as well as things like armv5blah-*
+  if (TT.size() >= 4 &&
       (TT.substr(0, 4) == "arm-" || TT.substr(0, 4) == "armv"))
     return 20;
   // If the target triple is something non-arm, we don't match.