diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-01-19 02:09:44 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-01-19 02:09:44 +0000 |
| commit | 1d371882b6da32538d198004be1b272567b150a3 (patch) | |
| tree | d47549c7355b82b45fc88deac1208f457f218712 /llvm/lib/Target/ARM | |
| parent | 5e1a83c19672d57ad20a10bc415eb43572a21554 (diff) | |
| download | bcm5719-llvm-1d371882b6da32538d198004be1b272567b150a3.tar.gz bcm5719-llvm-1d371882b6da32538d198004be1b272567b150a3.zip | |
Cleanup handling of .zerofill on darwin:
1. TargetLoweringObjectFileMachO should decide if something
goes in zerofill instead of having every target do it.
2. TargetLoweringObjectFileMachO should assign said symbols to
the right MCSection, the asmprinters should just emit to the
right section.
3. Since all zerofill stuff goes through mcstreamer anymore,
MAI can have a bool "haszerofill" instead of having the textual
directive to emit.
llvm-svn: 93838
Diffstat (limited to 'llvm/lib/Target/ARM')
| -rw-r--r-- | llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 109 |
1 files changed, 57 insertions, 52 deletions
diff --git a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index ef2d460fab7..30f9fec867e 100644 --- a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -1196,71 +1196,76 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { if (Subtarget->isTargetELF()) O << "\t.type " << *GVarSym << ",%object\n"; + SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM); const MCSection *TheSection = - getObjFileLowering().SectionForGlobal(GVar, Mang, TM); + getObjFileLowering().SectionForGlobal(GVar, GVKind, Mang, TM); OutStreamer.SwitchSection(TheSection); + // Handle the zerofill directive on darwin, which is a special form of BSS + // emission. + if (GVKind.isBSS() && MAI->hasMachoZeroFillDirective()) { + TargetLoweringObjectFileMachO &TLOFMacho = + static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering()); + if (TheSection == TLOFMacho.getDataCommonSection()) { + // .globl _foo + OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global); + // .zerofill __DATA, __common, _foo, 400, 5 + OutStreamer.EmitZerofill(TheSection, GVarSym, Size, 1 << Align); + return; + } + } + // FIXME: get this stuff from section kind flags. if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal() && // Don't put things that should go in the cstring section into "comm". - !TheSection->getKind().isMergeableCString()) { - if (GVar->hasExternalLinkage()) { - if (const char *Directive = MAI->getZeroFillDirective()) { - O << "\t.globl\t" << *GVarSym << "\n"; - O << Directive << "__DATA, __common, " << *GVarSym - << ", " << Size << ", " << Align << "\n"; - return; - } - } + !TheSection->getKind().isMergeableCString() && + (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) { + if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - if (GVar->hasLocalLinkage() || GVar->isWeakForLinker()) { - if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - - if (isDarwin) { - if (GVar->hasLocalLinkage()) { - O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size - << ',' << Align; - } else if (GVar->hasCommonLinkage()) { - O << MAI->getCOMMDirective() << *GVarSym << ',' << Size - << ',' << Align; - } else { - OutStreamer.SwitchSection(TheSection); - O << "\t.globl " << *GVarSym << '\n' << MAI->getWeakDefDirective(); - O << *GVarSym << '\n'; - EmitAlignment(Align, GVar); - O << *GVarSym << ":"; - if (VerboseAsm) { - O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << ' '; - WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); - } - O << '\n'; - EmitGlobalConstant(C); - return; - } - } else if (MAI->getLCOMMDirective() != NULL) { - if (GVar->hasLocalLinkage()) { - O << MAI->getLCOMMDirective() << *GVarSym << "," << Size; - } else { - O << MAI->getCOMMDirective() << *GVarSym << "," << Size; - if (MAI->getCOMMDirectiveTakesAlignment()) - O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); + if (isDarwin) { + if (GVar->hasLocalLinkage()) { + O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size + << ',' << Align; + } else if (GVar->hasCommonLinkage()) { + O << MAI->getCOMMDirective() << *GVarSym << ',' << Size + << ',' << Align; + } else { + OutStreamer.SwitchSection(TheSection); + O << "\t.globl " << *GVarSym << '\n' << MAI->getWeakDefDirective(); + O << *GVarSym << '\n'; + EmitAlignment(Align, GVar); + O << *GVarSym << ":"; + if (VerboseAsm) { + O.PadToColumn(MAI->getCommentColumn()); + O << MAI->getCommentString() << ' '; + WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); } + O << '\n'; + EmitGlobalConstant(C); + return; + } + } else if (MAI->getLCOMMDirective() != NULL) { + if (GVar->hasLocalLinkage()) { + O << MAI->getLCOMMDirective() << *GVarSym << "," << Size; } else { - if (GVar->hasLocalLinkage()) - O << "\t.local\t" << *GVarSym << '\n'; O << MAI->getCOMMDirective() << *GVarSym << "," << Size; if (MAI->getCOMMDirectiveTakesAlignment()) - O << "," << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); - } - if (VerboseAsm) { - O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << ' '; - WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); + O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); } - O << "\n"; - return; + } else { + if (GVar->hasLocalLinkage()) + O << "\t.local\t" << *GVarSym << '\n'; + O << MAI->getCOMMDirective() << *GVarSym << "," << Size; + if (MAI->getCOMMDirectiveTakesAlignment()) + O << "," << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); + } + if (VerboseAsm) { + O.PadToColumn(MAI->getCommentColumn()); + O << MAI->getCommentString() << ' '; + WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); } + O << "\n"; + return; } switch (GVar->getLinkage()) { |

