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 | aac138e84dee1cb3ffc1035b2a1e4361fe0b4f80 (patch) | |
tree | f62498c8c571448790a13d39837f8691fd77e21f /lib/Target/PowerPC/AsmPrinter | |
parent | 60a17740b845565f664e81a91b7019a520af88d7 (diff) | |
download | external_llvm-aac138e84dee1cb3ffc1035b2a1e4361fe0b4f80.zip external_llvm-aac138e84dee1cb3ffc1035b2a1e4361fe0b4f80.tar.gz external_llvm-aac138e84dee1cb3ffc1035b2a1e4361fe0b4f80.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/AsmPrinter')
-rw-r--r-- | lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index db37a1a..fad1c27 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -721,25 +721,25 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { !GVar->hasSection() && (GVar->hasLocalLinkage() || GVar->hasExternalLinkage() || GVar->isWeakForLinker())) { - if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - - if (GVar->hasExternalLinkage()) { - O << "\t.global " << *GVarSym << '\n'; - O << "\t.type " << *GVarSym << ", @object\n"; - O << *GVarSym << ":\n"; - O << "\t.zero " << Size << '\n'; - } else if (GVar->hasLocalLinkage()) { - O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size; - } else { - O << ".comm " << *GVarSym << ',' << Size; - } - if (VerboseAsm) { - O << "\t\t" << MAI->getCommentString() << " '"; - WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); - O << "'"; - } - O << '\n'; - return; + if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. + + if (GVar->hasExternalLinkage()) { + O << "\t.global " << *GVarSym << '\n'; + O << "\t.type " << *GVarSym << ", @object\n"; + O << *GVarSym << ":\n"; + O << "\t.zero " << Size << '\n'; + } else if (GVar->hasLocalLinkage()) { + O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size; + } else { + O << ".comm " << *GVarSym << ',' << Size; + } + if (VerboseAsm) { + O << "\t\t" << MAI->getCommentString() << " '"; + WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); + O << "'"; + } + O << '\n'; + return; } switch (GVar->getLinkage()) { @@ -944,10 +944,25 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { unsigned Size = TD->getTypeAllocSize(Type); unsigned Align = TD->getPreferredAlignmentLog(GVar); + 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: Drive this off the section! if (C->isNullValue() && /* FIXME: Verify correct */ !GVar->hasSection() && @@ -957,11 +972,7 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { !TheSection->getKind().isMergeableCString()) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - if (GVar->hasExternalLinkage()) { - O << "\t.globl " << *GVarSym << '\n'; - O << "\t.zerofill __DATA, __common, " << *GVarSym << ", " - << Size << ", " << Align; - } else if (GVar->hasLocalLinkage()) { + if (GVar->hasLocalLinkage()) { O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size << ',' << Align; } else if (!GVar->hasCommonLinkage()) { O << "\t.globl " << *GVarSym << '\n' << MAI->getWeakDefDirective(); |