add a bool for whether .lcomm takes an alignment instead of basing this on "isdarwin".
authorChris Lattner <sabre@nondot.org>
Tue, 19 Jan 2010 04:48:20 +0000 (04:48 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 19 Jan 2010 04:48:20 +0000 (04:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93852 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCAsmInfo.h
lib/MC/MCAsmInfo.cpp
lib/MC/MCAsmInfoDarwin.cpp
lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp

index 1368e1f424973e54f11556ba9ad1a88da1880343..a340a12138481730d0cf33a44c671526c3bd0a70 100644 (file)
@@ -202,6 +202,10 @@ namespace llvm {
     /// argument that specifies the alignment of the declaration.
     bool COMMDirectiveTakesAlignment;        // Defaults to true.
     
+    /// LCOMMDirectiveTakesAlignment - True if LCOMMDirective takes a third
+    /// argument that specifies the alignment of the declaration.
+    bool LCOMMDirectiveTakesAlignment;       // Defaults to false.
+    
     /// HasDotTypeDotSizeDirective - True if the target has .type and .size
     /// directives, this is true for most ELF targets.
     bool HasDotTypeDotSizeDirective;         // Defaults to true.
@@ -410,6 +414,9 @@ namespace llvm {
     bool getCOMMDirectiveTakesAlignment() const {
       return COMMDirectiveTakesAlignment;
     }
+    bool getLCOMMDirectiveTakesAlignment() const {
+      return LCOMMDirectiveTakesAlignment;
+    }
     bool hasDotTypeDotSizeDirective() const {
       return HasDotTypeDotSizeDirective;
     }
index 277a09e9e9a1391156767299f99e999fff8b6db6..4c53d7a284aadd8be3eeb9aa004e5f7260f1cdd9 100644 (file)
@@ -56,6 +56,7 @@ MCAsmInfo::MCAsmInfo() {
   LCOMMDirective = 0;
   COMMDirective = "\t.comm\t";
   COMMDirectiveTakesAlignment = true;
+  LCOMMDirectiveTakesAlignment = false;
   HasDotTypeDotSizeDirective = true;
   HasSingleParameterDotFile = true;
   UsedDirective = 0;
index 5de86e0c901ee23f1e32261bd2bf719dffbecff7..a1f6051990e7a39522dd7cf2482f8051f5d6a70c 100644 (file)
@@ -37,6 +37,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
   ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
   HasMachoZeroFillDirective = true;  // Uses .zerofill
   HasStaticCtorDtorReferenceInStaticMode = true;
+  LCOMMDirectiveTakesAlignment = true;
   SetDirective = "\t.set";
   ProtectedDirective = "\t.globl\t";
   HasDotTypeDotSizeDirective = false;
index b1c1f55f17fde2f0f5e979aa57488d2184b965f5..4485ad75efcac06dd71c710c0e8ebc95dd0dbdca 100644 (file)
@@ -1202,14 +1202,12 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
   if (GVKind.isBSSLocal()) {
     if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
     
-    if (isDarwin) {
-      O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size
-      << ',' << Align;
-    } else if (MAI->getLCOMMDirective() != NULL) {
-      O << MAI->getLCOMMDirective() << *GVarSym << "," << Size;
+    if (const char *LCOMM = MAI->getLCOMMDirective()) {
+      O << LCOMM << *GVarSym << "," << Size;
+      if (MAI->getLCOMMDirectiveTakesAlignment())
+        O << ',' << Align;
     } else {
-      if (GVar->hasLocalLinkage())
-        O << "\t.local\t" << *GVarSym << '\n';
+      O << "\t.local\t" << *GVarSym << '\n';
       O << MAI->getCOMMDirective() << *GVarSym << "," << Size;
       if (MAI->getCOMMDirectiveTakesAlignment())
         O << "," << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
index 6b8408f08a330cf2883d5b9319a9ff5e030b0e05..3698949ca4c65e31506737026d4444a50800b49e 100644 (file)
@@ -951,7 +951,9 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
   if (GVKind.isBSSLocal()) {
     if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
     
-    O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size << ',' << Align;
+    O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size;
+    if (MAI->getLCOMMDirectiveTakesAlignment())
+      O << ',' << Align;
     
     if (VerboseAsm) {
       O << "\t\t" << MAI->getCommentString() << " '";
index 22e2573c1c0b791c733d224b15cd9a32c36811e9..14deafe65a49faf2366f8cbe867d9c6c6757469f 100644 (file)
@@ -647,17 +647,18 @@ void X86AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
 }
 
 void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
-  const TargetData *TD = TM.getTargetData();
 
   MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
   Constant *C = GVar->getInitializer();
   const Type *Type = C->getType();
+  
+  const TargetData *TD = TM.getTargetData();
   unsigned Size = TD->getTypeAllocSize(Type);
   unsigned Align = TD->getPreferredAlignmentLog(GVar);
 
   printVisibility(GVarSym, GVar->getVisibility());
 
-  if (Subtarget->isTargetELF())
+  if (MAI->hasDotTypeDotSizeDirective())
     O << "\t.type\t" << *GVarSym << ",@object\n";
   
   SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM);
@@ -685,7 +686,7 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
     if (const char *LComm = MAI->getLCOMMDirective()) {
       if (GVar->hasLocalLinkage()) {
         O << LComm << *GVarSym << ',' << Size;
-        if (Subtarget->isTargetDarwin())
+        if (MAI->getLCOMMDirectiveTakesAlignment())
           O << ',' << Align;
       }
     } else {