some cleanups

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93853 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-19 04:53:18 +00:00
parent 7517b249ca
commit cfd910ebc4
2 changed files with 21 additions and 20 deletions

View File

@ -1173,11 +1173,9 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
const Type *Type = C->getType(); const Type *Type = C->getType();
unsigned Size = TD->getTypeAllocSize(Type); unsigned Size = TD->getTypeAllocSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(GVar); unsigned Align = TD->getPreferredAlignmentLog(GVar);
bool isDarwin = Subtarget->isTargetDarwin();
printVisibility(GVarSym, GVar->getVisibility()); printVisibility(GVarSym, GVar->getVisibility());
if (Subtarget->isTargetELF()) if (MAI->hasDotTypeDotSizeDirective())
O << "\t.type " << *GVarSym << ",%object\n"; O << "\t.type " << *GVarSym << ",%object\n";
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM); SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM);
@ -1243,7 +1241,7 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
if (isDarwin) { if (Subtarget->isTargetDarwin()) {
O << "\t.globl " << *GVarSym O << "\t.globl " << *GVarSym
<< "\n\t.weak_definition " << *GVarSym << "\n"; << "\n\t.weak_definition " << *GVarSym << "\n";
} else { } else {

View File

@ -647,29 +647,32 @@ void X86AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
} }
void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
Constant *C = GVar->getInitializer();
const Type *Type = C->getType();
const TargetData *TD = TM.getTargetData();
unsigned Size = TD->getTypeAllocSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(GVar);
printVisibility(GVarSym, GVar->getVisibility()); printVisibility(GVarSym, GVar->getVisibility());
if (MAI->hasDotTypeDotSizeDirective()) if (MAI->hasDotTypeDotSizeDirective()) {
O << "\t.type\t" << *GVarSym << ",@object\n"; O << "\t.type\t" << *GVarSym;
if (MAI->getCommentString()[0] != '@')
O << ",@object\n";
else
O << ",%object\n";
}
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM); SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM);
const Type *Type = GVar->getType()->getElementType();
const TargetData *TD = TM.getTargetData();
unsigned Size = TD->getTypeAllocSize(Type);
unsigned AlignLog = TD->getPreferredAlignmentLog(GVar);
// Handle normal common symbols. // Handle normal common symbols.
if (GVKind.isCommon()) { if (GVKind.isCommon()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
O << ".comm " << *GVarSym << ',' << Size; O << ".comm " << *GVarSym << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment()) if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << AlignLog) : AlignLog);
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t" << MAI->getCommentString() << " '"; O << "\t\t" << MAI->getCommentString() << " '";
@ -687,14 +690,14 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (GVar->hasLocalLinkage()) { if (GVar->hasLocalLinkage()) {
O << LComm << *GVarSym << ',' << Size; O << LComm << *GVarSym << ',' << Size;
if (MAI->getLCOMMDirectiveTakesAlignment()) if (MAI->getLCOMMDirectiveTakesAlignment())
O << ',' << Align; O << ',' << AlignLog;
} }
} else { } else {
if (!Subtarget->isTargetCygMing()) if (!Subtarget->isTargetCygMing())
O << "\t.local\t" << *GVarSym << '\n'; O << "\t.local\t" << *GVarSym << '\n';
O << MAI->getCOMMDirective() << *GVarSym << ',' << Size; O << MAI->getCOMMDirective() << *GVarSym << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment()) if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << AlignLog) : AlignLog);
} }
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
@ -714,7 +717,7 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
// .globl _foo // .globl _foo
OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global); OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
// .zerofill __DATA, __common, _foo, 400, 5 // .zerofill __DATA, __common, _foo, 400, 5
OutStreamer.EmitZerofill(TheSection, GVarSym, Size, 1 << Align); OutStreamer.EmitZerofill(TheSection, GVarSym, Size, 1 << AlignLog);
return; return;
} }
@ -751,7 +754,7 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
llvm_unreachable("Unknown linkage type!"); llvm_unreachable("Unknown linkage type!");
} }
EmitAlignment(Align, GVar); EmitAlignment(AlignLog, GVar);
O << *GVarSym << ":"; O << *GVarSym << ":";
if (VerboseAsm){ if (VerboseAsm){
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
@ -760,7 +763,7 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
} }
O << '\n'; O << '\n';
EmitGlobalConstant(C); EmitGlobalConstant(GVar->getInitializer());
if (MAI->hasDotTypeDotSizeDirective()) if (MAI->hasDotTypeDotSizeDirective())
O << "\t.size\t" << *GVarSym << ", " << Size << '\n'; O << "\t.size\t" << *GVarSym << ", " << Size << '\n';