[llvm-commits] [llvm] r104057 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCAsmStreamer.cpp lib/MC/MCNullStreamer.cpp lib/MC/MCParser/AsmParser.cpp

Chris Lattner clattner at apple.com
Tue May 18 15:11:39 PDT 2010


On May 18, 2010, at 2:16 PM, Eric Christopher wrote:

> Author: echristo
> Date: Tue May 18 16:16:04 2010
> New Revision: 104057
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=104057&view=rev
> Log:
> Make EmitTBSSSymbol take a section argument so that we can find it later.
> Fix up callers and users.

Should the syntax in the .s file also allow this to be specified (like .zerofill)?  If not, it seems strange for the EmitTBSSSymbol hook to take a section.

-Chris

> 
> Modified:
>    llvm/trunk/include/llvm/MC/MCStreamer.h
>    llvm/trunk/lib/MC/MCAsmStreamer.cpp
>    llvm/trunk/lib/MC/MCNullStreamer.cpp
>    llvm/trunk/lib/MC/MCParser/AsmParser.cpp
> 
> Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=104057&r1=104056&r2=104057&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
> +++ llvm/trunk/include/llvm/MC/MCStreamer.h Tue May 18 16:16:04 2010
> @@ -190,12 +190,13 @@
> 
>     /// EmitTBSSSymbol - Emit a thread local bss (.tbss) symbol.
>     ///
> +    /// @param Section - The thread local common section.
>     /// @param Symbol - The thread local common symbol to emit.
>     /// @param Size - The size of the symbol.
>     /// @param ByteAlignment - The alignment of the thread local common symbol
>     /// if non-zero.  This must be a power of 2 on some targets.
> -    virtual void EmitTBSSSymbol(MCSymbol *Symbol, uint64_t Size,
> -                                unsigned ByteAlignment = 0) = 0;
> +    virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
> +                                uint64_t Size, unsigned ByteAlignment = 0) = 0;
>     /// @}
>     /// @name Generating Data
>     /// @{
> 
> Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=104057&r1=104056&r2=104057&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
> +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Tue May 18 16:16:04 2010
> @@ -126,8 +126,8 @@
>   virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
>                             unsigned Size = 0, unsigned ByteAlignment = 0);
> 
> -  virtual void EmitTBSSSymbol (MCSymbol *Symbol, uint64_t Size,
> -                               unsigned ByteAlignment = 0);
> +  virtual void EmitTBSSSymbol (const MCSection *Section, MCSymbol *Symbol,
> +                               uint64_t Size, unsigned ByteAlignment = 0);
> 
>   virtual void EmitBytes(StringRef Data, unsigned AddrSpace);
> 
> @@ -366,13 +366,16 @@
> // .tbss sym, size, align
> // This depends that the symbol has already been mangled from the original,
> // e.g. _a.
> -void MCAsmStreamer::EmitTBSSSymbol(MCSymbol *Symbol, uint64_t Size,
> -                                   unsigned ByteAlignment) {
> +void MCAsmStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
> +                                   uint64_t Size, unsigned ByteAlignment) {
>   assert(Symbol != NULL && "Symbol shouldn't be NULL!");
> +  // Instead of using the Section we'll just use the shortcut.
> +  // This is a mach-o specific directive and section.
>   OS << ".tbss " << *Symbol << ", " << Size;
> 
> -  // Output align if we have it.
> -  if (ByteAlignment != 0) OS << ", " << Log2_32(ByteAlignment);
> +  // Output align if we have it.  We default to 1 so don't bother printing
> +  // that.
> +  if (ByteAlignment > 1) OS << ", " << Log2_32(ByteAlignment);
> 
>   EmitEOL();
> }
> 
> Modified: llvm/trunk/lib/MC/MCNullStreamer.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCNullStreamer.cpp?rev=104057&r1=104056&r2=104057&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCNullStreamer.cpp (original)
> +++ llvm/trunk/lib/MC/MCNullStreamer.cpp Tue May 18 16:16:04 2010
> @@ -55,8 +55,8 @@
> 
>     virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
>                               unsigned Size = 0, unsigned ByteAlignment = 0) {}
> -    virtual void EmitTBSSSymbol(MCSymbol *Symbol, uint64_t Size,
> -                                unsigned ByteAlignment) {}
> +    virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
> +                                uint64_t Size, unsigned ByteAlignment) {}
>     virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {}
> 
>     virtual void EmitValue(const MCExpr *Value, unsigned Size,
> 
> Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=104057&r1=104056&r2=104057&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
> +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Tue May 18 16:16:04 2010
> @@ -1536,7 +1536,10 @@
>   if (!Sym->isUndefined())
>     return Error(IDLoc, "invalid symbol redefinition");
> 
> -  Out.EmitTBSSSymbol(Sym, Size, Pow2Alignment ? 1 << Pow2Alignment : 0);
> +  Out.EmitTBSSSymbol(Ctx.getMachOSection("__DATA", "__thread_bss",
> +                                        MCSectionMachO::S_THREAD_LOCAL_ZEROFILL,
> +                                        0, SectionKind::getThreadBSS()),
> +                     Sym, Size, 1 << Pow2Alignment);
> 
>   return false;
> }
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list