restructure code a bit to make use of continue (simplifying things). Generalize

the .zerofill directive emission to not be darwin-specific


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33304 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2007-01-17 17:44:25 +00:00
parent 42ca450a57
commit 8e13e90052

View File

@@ -138,18 +138,26 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
unsigned Size = TD->getTypeSize(C->getType()); unsigned Size = TD->getTypeSize(C->getType());
unsigned Align = TD->getPreferredAlignmentLog(I); unsigned Align = TD->getPreferredAlignmentLog(I);
if (C->isNullValue() && /* FIXME: Verify correct */ if (I->hasHiddenVisibility())
!I->hasSection() && if (const char *Directive = TAI->getHiddenDirective())
(I->hasInternalLinkage() || I->hasWeakLinkage() || O << Directive << name << "\n";
I->hasLinkOnceLinkage() || if (Subtarget->isTargetELF())
(Subtarget->isTargetDarwin() && O << "\t.type " << name << ",@object\n";
I->hasExternalLinkage()))) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (C->isNullValue()) {
if (I->hasExternalLinkage()) { if (I->hasExternalLinkage()) {
if (const char *Directive = TAI->getZeroFillDirective()) {
O << "\t.globl\t" << name << "\n"; O << "\t.globl\t" << name << "\n";
O << "\t.zerofill __DATA__, __common, " << name << ", " O << Directive << "__DATA__, __common, " << name << ", "
<< Size << ", " << Align; << Size << ", " << Align;
} else { continue;
}
}
if (!I->hasSection() &&
(I->hasInternalLinkage() || I->hasWeakLinkage() ||
I->hasLinkOnceLinkage())) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
if (!NoZerosInBSS && TAI->getBSSSection()) if (!NoZerosInBSS && TAI->getBSSSection())
SwitchToDataSection(TAI->getBSSSection(), I); SwitchToDataSection(TAI->getBSSSection(), I);
else else
@@ -170,9 +178,11 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
if (TAI->getCOMMDirectiveTakesAlignment()) if (TAI->getCOMMDirectiveTakesAlignment())
O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align); O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
} }
}
O << "\t\t" << TAI->getCommentString() << " " << I->getName() << "\n"; O << "\t\t" << TAI->getCommentString() << " " << I->getName() << "\n";
} else { continue;
}
}
switch (I->getLinkage()) { switch (I->getLinkage()) {
case GlobalValue::LinkOnceLinkage: case GlobalValue::LinkOnceLinkage:
case GlobalValue::WeakLinkage: case GlobalValue::WeakLinkage:
@@ -254,13 +264,6 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
EmitGlobalConstant(C); EmitGlobalConstant(C);
O << '\n'; O << '\n';
} }
if (I->hasHiddenVisibility())
if (const char *Directive = TAI->getHiddenDirective())
O << Directive << name << "\n";
if (Subtarget->isTargetELF())
O << "\t.type " << name << ",@object\n";
}
// Output linker support code for dllexported globals // Output linker support code for dllexported globals
if (DLLExportedGVs.begin() != DLLExportedGVs.end()) { if (DLLExportedGVs.begin() != DLLExportedGVs.end()) {