diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-12-06 02:00:55 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-12-06 02:00:55 +0000 |
commit | 43f73c6bd106fc8b6f63cb6908d0b1aec615631b (patch) | |
tree | 76969745fe61aa7b8bf909d59bfcf7cacec63fba /lib | |
parent | 5e215182148753c6c960924f78c48128d9274457 (diff) | |
download | external_llvm-43f73c6bd106fc8b6f63cb6908d0b1aec615631b.zip external_llvm-43f73c6bd106fc8b6f63cb6908d0b1aec615631b.tar.gz external_llvm-43f73c6bd106fc8b6f63cb6908d0b1aec615631b.tar.bz2 |
Clean up some ARM GV asm printing out; minor fixes to match what gcc does.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60621 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/ARM/ARMTargetAsmInfo.cpp | 1 | ||||
-rw-r--r-- | lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 51 |
2 files changed, 32 insertions, 20 deletions
diff --git a/lib/Target/ARM/ARMTargetAsmInfo.cpp b/lib/Target/ARM/ARMTargetAsmInfo.cpp index e0c81d6..d2965fe 100644 --- a/lib/Target/ARM/ARMTargetAsmInfo.cpp +++ b/lib/Target/ARM/ARMTargetAsmInfo.cpp @@ -56,6 +56,7 @@ ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM): ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill SetDirective = "\t.set\t"; WeakRefDirective = "\t.weak_reference\t"; + WeakDefDirective = "\t.weak_definition "; HiddenDirective = "\t.private_extern\t"; ProtectedDirective = NULL; JumpTableDataSection = ".const"; diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index 9d81acd..f44b9a1 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -29,7 +29,6 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" -#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSet.h" @@ -84,10 +83,6 @@ namespace { /// asm printer should generate stubs for. StringSet<> FnStubs; - /// PCRelGVs - Keeps the set of GlobalValues used in pc relative - /// constantpool. - SmallPtrSet<const GlobalValue*, 8> PCRelGVs; - /// True if asm printer is printing a series of CONSTPOOL_ENTRY. bool InCPMode; @@ -677,12 +672,6 @@ void ARMAsmPrinter::printCPInstOperand(const MachineInstr *MI, int OpNo, if (MCPE.isMachineConstantPoolEntry()) { EmitMachineConstantPoolValue(MCPE.Val.MachineCPVal); - ARMConstantPoolValue *ACPV = - static_cast<ARMConstantPoolValue*>(MCPE.Val.MachineCPVal); - if (ACPV->getPCAdjustment() != 0) { - const GlobalValue *GV = ACPV->getGV(); - PCRelGVs.insert(GV); - } } else { EmitGlobalConstant(MCPE.Val.ConstVal); // remember to emit the weak reference @@ -841,18 +830,18 @@ void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) { const Type *Type = C->getType(); unsigned Size = TD->getABITypeSize(Type); unsigned Align = TD->getPreferredAlignmentLog(GVar); + bool isDarwin = Subtarget->isTargetDarwin(); printVisibility(name, GVar->getVisibility()); if (Subtarget->isTargetELF()) O << "\t.type " << name << ",%object\n"; - SwitchToSection(TAI->SectionForGlobal(GVar)); - if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal()) { // FIXME: This seems to be pretty darwin-specific if (GVar->hasExternalLinkage()) { + SwitchToSection(TAI->SectionForGlobal(GVar)); if (const char *Directive = TAI->getZeroFillDirective()) { O << "\t.globl\t" << name << "\n"; O << Directive << "__DATA, __common, " << name << ", " @@ -864,14 +853,34 @@ void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) { if (GVar->hasInternalLinkage() || GVar->mayBeOverridden()) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - if (TAI->getLCOMMDirective() != NULL) { - if (PCRelGVs.count(GVar) || GVar->hasInternalLinkage()) { + if (isDarwin) { + if (GVar->hasInternalLinkage()) { + O << TAI->getLCOMMDirective() << name << "," << Size + << ',' << Align; + } else if (GVar->hasCommonLinkage()) { + O << TAI->getCOMMDirective() << name << "," << Size + << ',' << Align; + } else { + SwitchToSection(TAI->SectionForGlobal(GVar)); + O << "\t.globl " << name << '\n' + << TAI->getWeakDefDirective() << name << '\n'; + EmitAlignment(Align, GVar); + O << name << ":\t\t\t\t" << TAI->getCommentString() << ' '; + PrintUnmangledNameSafely(GVar, O); + O << '\n'; + EmitGlobalConstant(C); + return; + } + } else if (TAI->getLCOMMDirective() != NULL) { + if (GVar->hasInternalLinkage()) { O << TAI->getLCOMMDirective() << name << "," << Size; - if (Subtarget->isTargetDarwin()) - O << "," << Align; - } else + } else { O << TAI->getCOMMDirective() << name << "," << Size; + if (TAI->getCOMMDirectiveTakesAlignment()) + O << ',' << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align); + } } else { + SwitchToSection(TAI->SectionForGlobal(GVar)); if (GVar->hasInternalLinkage()) O << "\t.local\t" << name << "\n"; O << TAI->getCOMMDirective() << name << "," << Size; @@ -885,10 +894,12 @@ void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) { } } + SwitchToSection(TAI->SectionForGlobal(GVar)); switch (GVar->getLinkage()) { + case GlobalValue::CommonLinkage: case GlobalValue::LinkOnceLinkage: case GlobalValue::WeakLinkage: - if (Subtarget->isTargetDarwin()) { + if (isDarwin) { O << "\t.globl " << name << "\n" << "\t.weak_definition " << name << "\n"; } else { @@ -980,7 +991,7 @@ bool ARMAsmPrinter::doFinalization(Module &M) { // Output non-lazy-pointers for external and common global variables. if (!GVNonLazyPtrs.empty()) { - SwitchToDataSection(".non_lazy_symbol_pointer", 0); + SwitchToDataSection("\t.non_lazy_symbol_pointer", 0); for (StringSet<>::iterator i = GVNonLazyPtrs.begin(), e = GVNonLazyPtrs.end(); i != e; ++i) { const char *p = i->getKeyData(); |