[llvm-commits] [llvm] r45493 - in /llvm/trunk/lib/Target/PowerPC: PPCAsmPrinter.cpp PPCSubtarget.cpp PPCSubtarget.h

Chris Lattner sabre at nondot.org
Wed Jan 2 11:35:18 PST 2008


Author: lattner
Date: Wed Jan  2 13:35:16 2008
New Revision: 45493

URL: http://llvm.org/viewvc/llvm-project?rev=45493&view=rev
Log:
leopard and above support alignment for common symbols.

Modified:
    llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
    llvm/trunk/lib/Target/PowerPC/PPCSubtarget.cpp
    llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h

Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=45493&r1=45492&r2=45493&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Wed Jan  2 13:35:16 2008
@@ -930,6 +930,9 @@
       } else {
         SwitchToDataSection("\t.data", I);
         O << ".comm " << name << "," << Size;
+        // Darwin 9 and above support aligned common data.
+        if (Subtarget.isDarwin9())
+          O << "," << Align;
       }
       O << "\t\t" << TAI->getCommentString() << " '" << I->getName() << "'\n";
     } else {

Modified: llvm/trunk/lib/Target/PowerPC/PPCSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCSubtarget.cpp?rev=45493&r1=45492&r2=45493&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCSubtarget.cpp Wed Jan  2 13:35:16 2008
@@ -67,8 +67,8 @@
   , HasAltivec(false)
   , HasFSQRT(false)
   , HasSTFIWX(false)
-  , IsDarwin(false)
-  , HasLazyResolverStubs(false) {
+  , HasLazyResolverStubs(false)
+  , DarwinVers(0) {
 
   // Determine default and user specified characteristics
   std::string CPU = "generic";
@@ -100,17 +100,29 @@
   
   // Set the boolean corresponding to the current target triple, or the default
   // if one cannot be determined, to true.
-  const std::string& TT = M.getTargetTriple();
-  if (TT.length() > 5) {
-    IsDarwin = TT.find("-darwin") != std::string::npos;
+  const std::string &TT = M.getTargetTriple();
+  if (TT.length() > 7) {
+    // Determine which version of darwin this is.
+    unsigned DarwinPos = TT.find("-darwin");
+    if (DarwinPos != std::string::npos) {
+      if (isdigit(TT[DarwinPos+7]))
+        DarwinVers = atoi(&TT[DarwinPos+7]);
+      else
+        DarwinVers = 8;  // Minimum supported darwin is Tiger.
+    }
   } else if (TT.empty()) {
+    // Try to autosense the subtarget from the host compiler.
 #if defined(__APPLE__)
-    IsDarwin = true;
+#if __APPLE_CC__ > 5400
+    DarwinVers = 9;  // GCC 5400+ is Leopard.
+#else
+    DarwinVers = 8;  // Minimum supported darwin is Tiger.
+#endif
 #endif
   }
 
   // Set up darwin-specific properties.
-  if (IsDarwin) {
+  if (isDarwin()) {
     HasLazyResolverStubs = true;
     AsmFlavor = NewMnemonic;
   } else {

Modified: llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h?rev=45493&r1=45492&r2=45493&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h Wed Jan  2 13:35:16 2008
@@ -71,8 +71,11 @@
   bool HasAltivec;
   bool HasFSQRT;
   bool HasSTFIWX;
-  bool IsDarwin;
   bool HasLazyResolverStubs;
+  
+  /// DarwinVers - Nonzero if this is a darwin platform.  Otherwise, the numeric
+  /// version of the platform, e.g. 8 = 10.4 (Tiger), 9 = 10.5 (Leopard), etc.
+  unsigned char DarwinVers; // Is any darwin-ppc platform.
 public:
   /// This constructor initializes the data members to match that
   /// of the specified module.
@@ -132,10 +135,13 @@
   bool hasAltivec() const { return HasAltivec; }
   bool isGigaProcessor() const { return IsGigaProcessor; }
 
-  bool isDarwin() const { return IsDarwin; }
+  /// isDarwin - True if this is any darwin platform.
+  bool isDarwin() const { return DarwinVers != 0; }
+  /// isDarwin - True if this is darwin9 (leopard, 10.5) or above.
+  bool isDarwin9() const { return DarwinVers >= 9; }
 
-  bool isMachoABI() const { return IsDarwin || IsPPC64; }
-  bool isELF32_ABI() const { return !IsDarwin && !IsPPC64; }
+  bool isMachoABI() const { return isDarwin() || IsPPC64; }
+  bool isELF32_ABI() const { return !isDarwin() && !IsPPC64; }
 
   unsigned getAsmFlavor() const {
     return AsmFlavor != Unset ? unsigned(AsmFlavor) : 0;





More information about the llvm-commits mailing list