From 41e516af8959ebc60606dc7cc6f95c5c29fea000 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 19 Jan 2010 04:48:20 +0000 Subject: add a bool for whether .lcomm takes an alignment instead of basing this on "isdarwin". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93852 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCAsmInfo.cpp | 1 + lib/MC/MCAsmInfoDarwin.cpp | 1 + lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 12 +++++------- lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 4 +++- lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp | 7 ++++--- 5 files changed, 14 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp index 277a09e..4c53d7a 100644 --- a/lib/MC/MCAsmInfo.cpp +++ b/lib/MC/MCAsmInfo.cpp @@ -56,6 +56,7 @@ MCAsmInfo::MCAsmInfo() { LCOMMDirective = 0; COMMDirective = "\t.comm\t"; COMMDirectiveTakesAlignment = true; + LCOMMDirectiveTakesAlignment = false; HasDotTypeDotSizeDirective = true; HasSingleParameterDotFile = true; UsedDirective = 0; diff --git a/lib/MC/MCAsmInfoDarwin.cpp b/lib/MC/MCAsmInfoDarwin.cpp index 5de86e0..a1f6051 100644 --- a/lib/MC/MCAsmInfoDarwin.cpp +++ b/lib/MC/MCAsmInfoDarwin.cpp @@ -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; diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index b1c1f55..4485ad7 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -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); diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index 6b8408f..3698949 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -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() << " '"; diff --git a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp index 22e2573..14deafe 100644 --- a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp @@ -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 { -- cgit v1.1