/// 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.
bool getCOMMDirectiveTakesAlignment() const {
return COMMDirectiveTakesAlignment;
}
+ bool getLCOMMDirectiveTakesAlignment() const {
+ return LCOMMDirectiveTakesAlignment;
+ }
bool hasDotTypeDotSizeDirective() const {
return HasDotTypeDotSizeDirective;
}
LCOMMDirective = 0;
COMMDirective = "\t.comm\t";
COMMDirectiveTakesAlignment = true;
+ LCOMMDirectiveTakesAlignment = false;
HasDotTypeDotSizeDirective = true;
HasSingleParameterDotFile = true;
UsedDirective = 0;
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;
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 << "\t.local\t" << *GVarSym << '\n';
O << MAI->getCOMMDirective() << *GVarSym << "," << Size;
if (MAI->getCOMMDirectiveTakesAlignment())
O << "," << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
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() << " '";
}
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);
if (const char *LComm = MAI->getLCOMMDirective()) {
if (GVar->hasLocalLinkage()) {
O << LComm << *GVarSym << ',' << Size;
- if (Subtarget->isTargetDarwin())
+ if (MAI->getLCOMMDirectiveTakesAlignment())
O << ',' << Align;
}
} else {