[llvm-commits] [llvm] r103757 - in /llvm/trunk: include/llvm/MC/MCParser/AsmParser.h include/llvm/MC/MCStreamer.h lib/MC/MCAsmStreamer.cpp lib/MC/MCMachOStreamer.cpp lib/MC/MCNullStreamer.cpp lib/MC/MCParser/AsmParser.cpp test/MC/AsmParser/directive_tbss.s

Chris Lattner clattner at apple.com
Sat May 15 10:08:38 PDT 2010


On May 13, 2010, at 6:50 PM, Eric Christopher wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=103757&view=rev
> Log:
> Add AsmParser support for darwin tbss directive.

Hi Eric, thanks for working on this:

> +void MCAsmStreamer::EmitTBSSSymbol(MCSymbol *Symbol, uint64_t Size,
> +                                   unsigned ByteAlignment) {
> +  assert(Symbol != NULL && "Symbol shouldn't be NULL!");
> +  OS << ".tbss ";
> +  
> +  // This is a mach-o specific directive and the name requires some mangling.
> +  OS << *Symbol << "$tlv$init, " << Size;

The $tlv$init suffix should be added by the caller, and be part of the MCSymbol.

> +  
> +  // Demangle the name output.  The trailing characters are guaranteed to be
> +  // $tlv$init so just strip that off.
> +  StringRef DemName = Name.substr(0, Name.size() - strlen("$tlv$init"));

That allows elimination of this logic from the parser, which isn't safe if the suffix doesn't exist.

> +  // FIXME: Diagnose overflow.
> +  if (Pow2Alignment < 0)
> +    return Error(Pow2AlignmentLoc, "invalid '.tbss' alignment, can't be less"
> +                 "than zero");

How about "negative" instead of "less than zero" :)

> 
> +++ llvm/trunk/test/MC/AsmParser/directive_tbss.s Thu May 13 20:50:28 2010
> @@ -0,0 +1,7 @@
> +# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s

This is a darwin-specific directive, you should force a darwin triple.

-Chris

> +
> +# CHECK: .tbss _a$tlv$init, 4
> +# CHECK: .tbss _b$tlv$init, 4, 3
> +
> +.tbss _a$tlv$init, 4
> +.tbss _b$tlv$init, 4, 3
> 
> 
> _______________________________________________
> 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