diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-07-09 17:25:12 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-07-09 17:25:12 +0000 |
| commit | 28ad7547d20e605ee5545a100750c0ef5d6ea005 (patch) | |
| tree | 6c7e87ea3465492ec9e26eab427bba75838f5828 /llvm/tools/llvm-mc/AsmParser.cpp | |
| parent | 71278012019a402de4611f694ddcdd83c37cb7ed (diff) | |
| download | bcm5719-llvm-28ad7547d20e605ee5545a100750c0ef5d6ea005.tar.gz bcm5719-llvm-28ad7547d20e605ee5545a100750c0ef5d6ea005.zip | |
add llvm-mc support for parsing the .lcomm directive, patch by Kevin Enderby!
llvm-svn: 75148
Diffstat (limited to 'llvm/tools/llvm-mc/AsmParser.cpp')
| -rw-r--r-- | llvm/tools/llvm-mc/AsmParser.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/llvm/tools/llvm-mc/AsmParser.cpp b/llvm/tools/llvm-mc/AsmParser.cpp index 1a3543aac77..65ec9628a38 100644 --- a/llvm/tools/llvm-mc/AsmParser.cpp +++ b/llvm/tools/llvm-mc/AsmParser.cpp @@ -521,7 +521,9 @@ bool AsmParser::ParseStatement() { return ParseDirectiveSymbolAttribute(MCStreamer::WeakReference); if (!strcmp(IDVal, ".comm")) - return ParseDirectiveComm(); + return ParseDirectiveComm(/*IsLocal=*/false); + if (!strcmp(IDVal, ".lcomm")) + return ParseDirectiveComm(/*IsLocal=*/true); Warning(IDLoc, "ignoring directive for now"); EatToEndOfStatement(); @@ -901,8 +903,8 @@ bool AsmParser::ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr) { } /// ParseDirectiveComm -/// ::= .comm identifier , size_expression [ , align_expression ] -bool AsmParser::ParseDirectiveComm() { +/// ::= ( .comm | .lcomm ) identifier , size_expression [ , align_expression ] +bool AsmParser::ParseDirectiveComm(bool IsLocal) { if (Lexer.isNot(asmtok::Identifier)) return TokError("expected identifier in directive"); @@ -930,28 +932,29 @@ bool AsmParser::ParseDirectiveComm() { } if (Lexer.isNot(asmtok::EndOfStatement)) - return TokError("unexpected token in '.comm' directive"); + return TokError("unexpected token in '.comm' or '.lcomm' directive"); Lexer.Lex(); - // NOTE: a size of zero should create a undefined symbol + // NOTE: a size of zero for a .comm should create a undefined symbol + // but a size of .lcomm creates a bss symbol of size zero. if (Size < 0) - return Error(SizeLoc, "invalid '.comm' size, can't be less than zero"); + return Error(SizeLoc, "invalid '.comm' or '.lcomm' directive size, can't " + "be less than zero"); // NOTE: The alignment in the directive is a power of 2 value, the assember // may internally end up wanting an alignment in bytes. // FIXME: Diagnose overflow. if (Pow2Alignment < 0) - return Error(Pow2AlignmentLoc, "invalid '.comm' alignment, can't be less " - "than zero"); + return Error(Pow2AlignmentLoc, "invalid '.comm' or '.lcomm' directive " + "alignment, can't be less than zero"); // TODO: Symbol must be undefined or it is a error to re-defined the symbol if (Sym->getSection() || Ctx.GetSymbolValue(Sym)) return Error(IDLoc, "invalid symbol redefinition"); - // TODO: Symbol to be made into a common with this Size and Pow2Alignment - - Out.EmitCommonSymbol(Sym, Size, Pow2Alignment); + // Create the Symbol as a common or local common with Size and Pow2Alignment + Out.EmitCommonSymbol(Sym, Size, Pow2Alignment, IsLocal); return false; } |

