1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

now that elf weak bss symbols are handled correctly, simplify a bunch of code.

llvm-svn: 93845
This commit is contained in:
Chris Lattner 2010-01-19 03:13:44 +00:00
parent c42d723862
commit eeebf5a580
3 changed files with 18 additions and 89 deletions

View File

@ -1238,39 +1238,14 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal() &&
// Don't put things that should go in the cstring section into "comm".
!TheSection->getKind().isMergeableCString() &&
(GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
(GVar->hasLocalLinkage() || GVar->hasLocalLinkage())) {
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;
}
O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size
<< ',' << Align;
} 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);
}
O << MAI->getLCOMMDirective() << *GVarSym << "," << Size;
} else {
if (GVar->hasLocalLinkage())
O << "\t.local\t" << *GVarSym << '\n';

View File

@ -736,22 +736,11 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
OutStreamer.SwitchSection(getObjFileLowering().
SectionForGlobal(GVar, GVKind, Mang, TM));
if (C->isNullValue() && /* FIXME: Verify correct */
!GVar->hasSection() &&
(GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
GVar->isWeakForLinker())) {
if (C->isNullValue() && !GVar->hasSection() && GVar->hasLocalLinkage()) {
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;
}
O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size;
if (VerboseAsm) {
O << "\t\t" << MAI->getCommentString() << " '";
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
@ -1003,34 +992,19 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
/// FIXME: Drive this off the section!
if (C->isNullValue() && /* FIXME: Verify correct */
!GVar->hasSection() &&
(GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
GVar->isWeakForLinker()) &&
!GVar->hasSection() && GVar->hasLocalLinkage() &&
// Don't put things that should go in the cstring section into "comm".
!TheSection->getKind().isMergeableCString()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
if (GVar->hasLocalLinkage()) {
O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size << ',' << Align;
if (VerboseAsm) {
O << "\t\t" << MAI->getCommentString() << " '";
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
O << "'";
}
O << '\n';
} else {
O << "\t.globl " << *GVarSym << '\n' << MAI->getWeakDefDirective();
O << *GVarSym << '\n';
EmitAlignment(Align, GVar);
O << *GVarSym << ":";
if (VerboseAsm) {
O << "\t\t\t\t" << MAI->getCommentString() << " ";
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
}
O << '\n';
EmitGlobalConstant(C);
O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size << ',' << Align;
if (VerboseAsm) {
O << "\t\t" << MAI->getCommentString() << " '";
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
O << "'";
}
O << '\n';
return;
}

View File

@ -717,8 +717,7 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (C->isNullValue() && !GVar->hasSection() &&
// Don't put things that should go in the cstring section into "comm".
!TheSection->getKind().isMergeableCString() &&
!GVar->isThreadLocal() &&
(GVar->hasLocalLinkage())) {
!GVar->isThreadLocal() && GVar->hasLocalLinkage()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
if (const char *LComm = MAI->getLCOMMDirective()) {
@ -726,29 +725,10 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
O << LComm << *GVarSym << ',' << Size;
if (Subtarget->isTargetDarwin())
O << ',' << Align;
} else if (Subtarget->isTargetDarwin()) {
OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
O << MAI->getWeakDefDirective() << *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 {
O << MAI->getCOMMDirective() << *GVarSym << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
}
} else {
if (!Subtarget->isTargetCygMing()) {
if (GVar->hasLocalLinkage())
O << "\t.local\t" << *GVarSym << '\n';
}
if (!Subtarget->isTargetCygMing())
O << "\t.local\t" << *GVarSym << '\n';
O << MAI->getCOMMDirective() << *GVarSym << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);