add a bool for whether .lcomm takes an alignment instead of basing this on "isdarwin".

llvm-svn: 93852
This commit is contained in:
Chris Lattner 2010-01-19 04:48:20 +00:00
parent 6a160517a0
commit dccbb28bca
6 changed files with 21 additions and 11 deletions

View File

@ -202,6 +202,10 @@ namespace llvm {
/// argument that specifies the alignment of the declaration.
bool COMMDirectiveTakesAlignment; // Defaults to true.
/// LCOMMDirectiveTakesAlignment - True if LCOMMDirective takes a third
/// argument that specifies the alignment of the declaration.
bool LCOMMDirectiveTakesAlignment; // Defaults to false.
/// HasDotTypeDotSizeDirective - True if the target has .type and .size
/// directives, this is true for most ELF targets.
bool HasDotTypeDotSizeDirective; // Defaults to true.
@ -410,6 +414,9 @@ namespace llvm {
bool getCOMMDirectiveTakesAlignment() const {
return COMMDirectiveTakesAlignment;
}
bool getLCOMMDirectiveTakesAlignment() const {
return LCOMMDirectiveTakesAlignment;
}
bool hasDotTypeDotSizeDirective() const {
return HasDotTypeDotSizeDirective;
}

View File

@ -56,6 +56,7 @@ MCAsmInfo::MCAsmInfo() {
LCOMMDirective = 0;
COMMDirective = "\t.comm\t";
COMMDirectiveTakesAlignment = true;
LCOMMDirectiveTakesAlignment = false;
HasDotTypeDotSizeDirective = true;
HasSingleParameterDotFile = true;
UsedDirective = 0;

View File

@ -37,6 +37,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
HasMachoZeroFillDirective = true; // Uses .zerofill
HasStaticCtorDtorReferenceInStaticMode = true;
LCOMMDirectiveTakesAlignment = true;
SetDirective = "\t.set";
ProtectedDirective = "\t.globl\t";
HasDotTypeDotSizeDirective = false;

View File

@ -1202,13 +1202,11 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (GVKind.isBSSLocal()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
if (isDarwin) {
O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size
<< ',' << Align;
} else if (MAI->getLCOMMDirective() != NULL) {
O << MAI->getLCOMMDirective() << *GVarSym << "," << Size;
if (const char *LCOMM = MAI->getLCOMMDirective()) {
O << LCOMM << *GVarSym << "," << Size;
if (MAI->getLCOMMDirectiveTakesAlignment())
O << ',' << Align;
} else {
if (GVar->hasLocalLinkage())
O << "\t.local\t" << *GVarSym << '\n';
O << MAI->getCOMMDirective() << *GVarSym << "," << Size;
if (MAI->getCOMMDirectiveTakesAlignment())

View File

@ -951,7 +951,9 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
if (GVKind.isBSSLocal()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size << ',' << Align;
O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size;
if (MAI->getLCOMMDirectiveTakesAlignment())
O << ',' << Align;
if (VerboseAsm) {
O << "\t\t" << MAI->getCommentString() << " '";

View File

@ -647,17 +647,18 @@ void X86AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
}
void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
const TargetData *TD = TM.getTargetData();
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());
if (Subtarget->isTargetELF())
if (MAI->hasDotTypeDotSizeDirective())
O << "\t.type\t" << *GVarSym << ",@object\n";
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM);
@ -685,7 +686,7 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (const char *LComm = MAI->getLCOMMDirective()) {
if (GVar->hasLocalLinkage()) {
O << LComm << *GVarSym << ',' << Size;
if (Subtarget->isTargetDarwin())
if (MAI->getLCOMMDirectiveTakesAlignment())
O << ',' << Align;
}
} else {