[llvm-commits] [llvm] r93859 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Chris Lattner
sabre at nondot.org
Mon Jan 18 21:51:54 PST 2010
Author: lattner
Date: Mon Jan 18 23:51:42 2010
New Revision: 93859
URL: http://llvm.org/viewvc/llvm-project?rev=93859&view=rev
Log:
factor this code better.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93859&r1=93858&r2=93859&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Jan 18 23:51:42 2010
@@ -161,41 +161,33 @@
unsigned Size = TD->getTypeAllocSize(GV->getType()->getElementType());
unsigned AlignLog = TD->getPreferredAlignmentLog(GV);
- // Handle normal common symbols.
- if (GVKind.isCommon()) {
+ // Handle common and BSS local symbols (.lcomm).
+ if (GVKind.isCommon() || GVKind.isBSSLocal()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
- O << MAI->getCOMMDirective() << *GVSym << ',' << Size;
- if (MAI->getCOMMDirectiveTakesAlignment())
- O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << AlignLog) : AlignLog);
-
if (VerboseAsm) {
- O << "\t\t" << MAI->getCommentString() << " '";
+ O.PadToColumn(MAI->getCommentColumn());
+ O << MAI->getCommentString() << ' ';
WriteAsOperand(O, GV, /*PrintType=*/false, GV->getParent());
- O << '\'';
}
- O << '\n';
- return;
- }
-
- if (GVKind.isBSSLocal()) {
- if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
-
- if (const char *LComm = MAI->getLCOMMDirective()) {
+ if (GVKind.isCommon()) {
+ // .comm _foo, 42, 4
+ O << MAI->getCOMMDirective() << *GVSym << ',' << Size;
+ if (MAI->getCOMMDirectiveTakesAlignment())
+ O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << AlignLog) : AlignLog);
+ } else if (const char *LComm = MAI->getLCOMMDirective()) {
+ // .lcomm _foo, 42, 4
O << LComm << *GVSym << ',' << Size;
if (MAI->getLCOMMDirectiveTakesAlignment())
O << ',' << AlignLog;
} else {
+ // .local _foo
O << "\t.local\t" << *GVSym << '\n';
+ // .comm _foo, 42, 4
O << MAI->getCOMMDirective() << *GVSym << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << AlignLog) : AlignLog);
}
- if (VerboseAsm) {
- O.PadToColumn(MAI->getCommentColumn());
- O << MAI->getCommentString() << ' ';
- WriteAsOperand(O, GV, /*PrintType=*/false, GV->getParent());
- }
O << '\n';
return;
}
More information about the llvm-commits
mailing list