add a note
[oota-llvm.git] / lib / Target / X86 / X86Subtarget.cpp
index 2ddf9e2d2a3f65c3fd039bc7ca07a6110b9d7ee5..1480332ef0cc316bc730fa6855e89744609b8f1f 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Nate Begeman and is distributed under the
-// University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -41,7 +41,7 @@ bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV,
       return (!isDirectCall &&
               (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
                (GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode())));
-    } else if (TM.getRelocationModel() == Reloc::PIC_ && isPICStyleGOT()) {
+    } else if (isTargetELF()) {
       // Extra load is needed for all non-statics.
       return (!isDirectCall &&
               (GV->isDeclaration() || !GV->hasInternalLinkage()));
@@ -221,6 +221,7 @@ X86Subtarget::X86Subtarget(const Module &M, const std::string &FS, bool is64Bit)
   , PICStyle(PICStyle::None)
   , X86SSELevel(NoMMXSSE)
   , HasX86_64(false)
+  , DarwinVers(0)
   , stackAlignment(8)
   // FIXME: this is a known good value for Yonah. How about others?
   , MaxInlineSizeThreshold(128)
@@ -256,14 +257,22 @@ X86Subtarget::X86Subtarget(const Module &M, const std::string &FS, bool is64Bit)
   // if one cannot be determined, to true.
   const std::string& TT = M.getTargetTriple();
   if (TT.length() > 5) {
-    if (TT.find("cygwin") != std::string::npos)
+    size_t Pos;
+    if ((Pos = TT.find("-darwin")) != std::string::npos) {
+      TargetType = isDarwin;
+      
+      // Compute the darwin version number.
+      if (isdigit(TT[Pos+7]))
+        DarwinVers = atoi(&TT[Pos+7]);
+      else
+        DarwinVers = 8;  // Minimum supported darwin is Tiger.
+    } else if (TT.find("cygwin") != std::string::npos) {
       TargetType = isCygwin;
-    else if (TT.find("mingw") != std::string::npos)
+    } else if (TT.find("mingw") != std::string::npos) {
       TargetType = isMingw;
-    else if (TT.find("darwin") != std::string::npos)
-      TargetType = isDarwin;
-    else if (TT.find("win32") != std::string::npos)
+    } else if (TT.find("win32") != std::string::npos) {
       TargetType = isWindows;
+    }
   } else if (TT.empty()) {
 #if defined(__CYGWIN__)
     TargetType = isCygwin;
@@ -271,6 +280,12 @@ X86Subtarget::X86Subtarget(const Module &M, const std::string &FS, bool is64Bit)
     TargetType = isMingw;
 #elif defined(__APPLE__)
     TargetType = isDarwin;
+#if __APPLE_CC__ > 5400
+    DarwinVers = 9;  // GCC 5400+ is Leopard.
+#else
+    DarwinVers = 8;  // Minimum supported darwin is Tiger.
+#endif
+    
 #elif defined(_WIN32)
     TargetType = isWindows;
 #endif
@@ -279,11 +294,8 @@ X86Subtarget::X86Subtarget(const Module &M, const std::string &FS, bool is64Bit)
   // If the asm syntax hasn't been overridden on the command line, use whatever
   // the target wants.
   if (AsmFlavor == X86Subtarget::Unset) {
-    if (TargetType == isWindows) {
-      AsmFlavor = X86Subtarget::Intel;
-    } else {
-      AsmFlavor = X86Subtarget::ATT;
-    }
+    AsmFlavor = (TargetType == isWindows)
+      ? X86Subtarget::Intel : X86Subtarget::ATT;
   }
 
   if (TargetType == isDarwin && Is64Bit)