From: Chris Lattner Date: Sat, 23 Jan 2010 07:47:02 +0000 (+0000) Subject: mcize lcomm, simplify .comm, extend both to support 64-bit sizes. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=9eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7;p=oota-llvm.git mcize lcomm, simplify .comm, extend both to support 64-bit sizes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94299 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index 22939b52cf4..5e31dfeb0da 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -191,15 +191,10 @@ namespace llvm { /// the assembler to set the value of a variable to some expression. const char *SetDirective; // Defaults to null. - /// LCOMMDirective - This is the name of a directive (if supported) that can - /// be used to efficiently declare a local (internal) block of zero - /// initialized data in the .bss/.data section. The syntax expected is: - /// @verbatim SYMBOLNAME LENGTHINBYTES - /// @endverbatim - const char *LCOMMDirective; // Defaults to null. + /// HasLCOMMDirective - This is true if the target supports the .lcomm + /// directive. + bool HasLCOMMDirective; // Defaults to false. - const char *COMMDirective; // Defaults to "\t.comm\t". - /// COMMDirectiveTakesAlignment - True if COMMDirective take a third /// argument that specifies the alignment of the declaration. bool COMMDirectiveTakesAlignment; // Defaults to true. @@ -404,12 +399,7 @@ namespace llvm { const char *getSetDirective() const { return SetDirective; } - const char *getLCOMMDirective() const { - return LCOMMDirective; - } - const char *getCOMMDirective() const { - return COMMDirective; - } + bool hasLCOMMDirective() const { return HasLCOMMDirective; } bool getCOMMDirectiveTakesAlignment() const { return COMMDirectiveTakesAlignment; } diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 2e55f99df29..2bcb594dc3c 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -129,15 +129,21 @@ namespace llvm { /// @param DescValue - The value to set into the n_desc field. virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0; - /// EmitCommonSymbol - Emit a common or local common symbol. + /// EmitCommonSymbol - Emit a common symbol. /// /// @param Symbol - The common symbol to emit. /// @param Size - The size of the common symbol. /// @param ByteAlignment - The alignment of the symbol if - /// non-zero. This must be a power of 2 on some targets. - virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, + /// non-zero. This must be a power of 2. + virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) = 0; + /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol. + /// + /// @param Symbol - The common symbol to emit. + /// @param Size - The size of the common symbol. + virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) = 0; + /// EmitZerofill - Emit a the zerofill section and an option symbol. /// /// @param Section - The zerofill section to create and or to put the symbol diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index fc2c5a00dae..f4d886492c5 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -196,9 +196,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { return; } - if (const char *LComm = MAI->getLCOMMDirective()) { + if (MAI->hasLCOMMDirective()) { // .lcomm _foo, 42 - O << LComm << *GVSym << ',' << Size << '\n'; + OutStreamer.EmitLocalCommonSymbol(GVSym, Size); return; } diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp index b96b4e9156f..547f904d70f 100644 --- a/lib/MC/MCAsmInfo.cpp +++ b/lib/MC/MCAsmInfo.cpp @@ -52,8 +52,7 @@ MCAsmInfo::MCAsmInfo() { PICJumpTableDirective = 0; GlobalDirective = "\t.globl\t"; SetDirective = 0; - LCOMMDirective = 0; - COMMDirective = "\t.comm\t"; + HasLCOMMDirective = false; COMMDirectiveTakesAlignment = true; HasDotTypeDotSizeDirective = true; HasSingleParameterDotFile = true; diff --git a/lib/MC/MCAsmInfoCOFF.cpp b/lib/MC/MCAsmInfoCOFF.cpp index 5ca66b56d57..e395acdd313 100644 --- a/lib/MC/MCAsmInfoCOFF.cpp +++ b/lib/MC/MCAsmInfoCOFF.cpp @@ -18,7 +18,7 @@ using namespace llvm; MCAsmInfoCOFF::MCAsmInfoCOFF() { GlobalPrefix = "_"; - LCOMMDirective = "\t.lcomm\t"; + HasLCOMMDirective = true; COMMDirectiveTakesAlignment = false; HasDotTypeDotSizeDirective = false; HasSingleParameterDotFile = false; diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index ded2b42bd8c..bf39239e7a7 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -93,9 +93,15 @@ public: virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue); - virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, + virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment); + /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol. + /// + /// @param Symbol - The common symbol to emit. + /// @param Size - The size of the common symbol. + virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size); + virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, unsigned Size = 0, unsigned ByteAlignment = 0); @@ -245,9 +251,9 @@ void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { EmitEOL(); } -void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, +void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { - OS << MAI.getCOMMDirective() << *Symbol << ',' << Size; + OS << "\t.comm\t" << *Symbol << ',' << Size; if (ByteAlignment != 0 && MAI.getCOMMDirectiveTakesAlignment()) { if (MAI.getAlignmentIsInBytes()) OS << ',' << ByteAlignment; @@ -257,6 +263,16 @@ void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, EmitEOL(); } +/// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol. +/// +/// @param Symbol - The common symbol to emit. +/// @param Size - The size of the common symbol. +void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) { + assert(MAI.hasLCOMMDirective() && "Doesn't have .lcomm, can't emit it!"); + OS << "\t.lcomm\t" << *Symbol << ',' << Size; + EmitEOL(); +} + void MCAsmStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol, unsigned Size, unsigned ByteAlignment) { // Note: a .zerofill directive does not switch sections. diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index 14301824ba8..e559c65f2c1 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -122,8 +122,11 @@ public: virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value); virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute); virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue); - virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, + virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment); + virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) { + assert(0 && "macho doesn't support this directive"); + } virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, unsigned Size = 0, unsigned ByteAlignment = 0); virtual void EmitBytes(StringRef Data, unsigned AddrSpace); @@ -270,7 +273,7 @@ void MCMachOStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { getSymbolData(*Symbol).setFlags(DescValue & SF_DescFlagsMask); } -void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, +void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { // FIXME: Darwin 'as' does appear to allow redef of a .comm by itself. assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); diff --git a/lib/MC/MCNullStreamer.cpp b/lib/MC/MCNullStreamer.cpp index 46da4c4f9ce..7c219b324a9 100644 --- a/lib/MC/MCNullStreamer.cpp +++ b/lib/MC/MCNullStreamer.cpp @@ -39,8 +39,9 @@ namespace { virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {} - virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, + virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) {} + virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) {} virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, unsigned Size = 0, unsigned ByteAlignment = 0) {} diff --git a/lib/Target/ARM/ARMMCAsmInfo.cpp b/lib/Target/ARM/ARMMCAsmInfo.cpp index 0ff65d2af88..3dd87c07239 100644 --- a/lib/Target/ARM/ARMMCAsmInfo.cpp +++ b/lib/Target/ARM/ARMMCAsmInfo.cpp @@ -64,7 +64,7 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo() { PrivateGlobalPrefix = ".L"; WeakRefDirective = "\t.weak\t"; SetDirective = "\t.set\t"; - LCOMMDirective = "\t.lcomm\t"; + HasLCOMMDirective = true; DwarfRequiresFrameSection = false; diff --git a/lib/Target/CellSPU/SPUMCAsmInfo.cpp b/lib/Target/CellSPU/SPUMCAsmInfo.cpp index 1c921ab87ff..03cdb2931db 100644 --- a/lib/Target/CellSPU/SPUMCAsmInfo.cpp +++ b/lib/Target/CellSPU/SPUMCAsmInfo.cpp @@ -19,7 +19,7 @@ SPULinuxMCAsmInfo::SPULinuxMCAsmInfo(const Target &T, const StringRef &TT) { SetDirective = "\t.set"; Data64bitsDirective = "\t.quad\t"; AlignmentIsInBytes = false; - LCOMMDirective = "\t.lcomm\t"; + HasLCOMMDirective = true; PCSymbol = "."; CommentString = "#"; diff --git a/lib/Target/PowerPC/PPCMCAsmInfo.cpp b/lib/Target/PowerPC/PPCMCAsmInfo.cpp index ba9937b4c52..d2ff3b7827b 100644 --- a/lib/Target/PowerPC/PPCMCAsmInfo.cpp +++ b/lib/Target/PowerPC/PPCMCAsmInfo.cpp @@ -52,7 +52,7 @@ PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) { SetDirective = "\t.set"; Data64bitsDirective = is64Bit ? "\t.quad\t" : 0; AlignmentIsInBytes = false; - LCOMMDirective = "\t.lcomm\t"; + HasLCOMMDirective = true; AssemblerDialect = 0; // Old-Style mnemonics. }