summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2009-07-14 18:17:10 +0000
committerKevin Enderby <enderby@apple.com>2009-07-14 18:17:10 +0000
commit95cf30c444707634bbd950f13405b6c8bcfe496b (patch)
treef8b86c6506b9c2e4d8a70f01241070a5048560b0 /tools
parent533c67ba9802123f08946ac8002d1223067318ca (diff)
downloadllvm-95cf30c444707634bbd950f13405b6c8bcfe496b.tar.gz
llvm-95cf30c444707634bbd950f13405b6c8bcfe496b.tar.bz2
llvm-95cf30c444707634bbd950f13405b6c8bcfe496b.tar.xz
Added llvm-mc support for parsing the .desc directive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75645 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-mc/AsmParser.cpp33
-rw-r--r--tools/llvm-mc/AsmParser.h1
2 files changed, 34 insertions, 0 deletions
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index c105801632..d94b7b3270 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/tools/llvm-mc/AsmParser.cpp
@@ -526,6 +526,8 @@ bool AsmParser::ParseStatement() {
return ParseDirectiveComm(/*IsLocal=*/true);
if (!strcmp(IDVal, ".zerofill"))
return ParseDirectiveDarwinZerofill();
+ if (!strcmp(IDVal, ".desc"))
+ return ParseDirectiveDarwinSymbolDesc();
if (!strcmp(IDVal, ".subsections_via_symbols"))
return ParseDirectiveDarwinSubsectionsViaSymbols();
@@ -909,6 +911,37 @@ bool AsmParser::ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr) {
return false;
}
+/// ParseDirectiveDarwinSymbolDesc
+/// ::= .desc identifier , expression
+bool AsmParser::ParseDirectiveDarwinSymbolDesc() {
+ if (Lexer.isNot(asmtok::Identifier))
+ return TokError("expected identifier in directive");
+
+ // handle the identifier as the key symbol.
+ SMLoc IDLoc = Lexer.getLoc();
+ MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
+ Lexer.Lex();
+
+ if (Lexer.isNot(asmtok::Comma))
+ return TokError("unexpected token in '.desc' directive");
+ Lexer.Lex();
+
+ SMLoc DescLoc = Lexer.getLoc();
+ int64_t DescValue;
+ if (ParseAbsoluteExpression(DescValue))
+ return true;
+
+ if (Lexer.isNot(asmtok::EndOfStatement))
+ return TokError("unexpected token in '.desc' directive");
+
+ Lexer.Lex();
+
+ // Set the n_desc field of this Symbol to this DescValue
+ Out.EmitSymbolDesc(Sym, DescValue);
+
+ return false;
+}
+
/// ParseDirectiveComm
/// ::= ( .comm | .lcomm ) identifier , size_expression [ , align_expression ]
bool AsmParser::ParseDirectiveComm(bool IsLocal) {
diff --git a/tools/llvm-mc/AsmParser.h b/tools/llvm-mc/AsmParser.h
index da546732a7..b4f5e2d428 100644
--- a/tools/llvm-mc/AsmParser.h
+++ b/tools/llvm-mc/AsmParser.h
@@ -109,6 +109,7 @@ private:
/// ParseDirectiveSymbolAttribute - Parse a directive like ".globl" which
/// accepts a single symbol (which should be a label or an external).
bool ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr);
+ bool ParseDirectiveDarwinSymbolDesc(); // Darwin specific ".desc"
bool ParseDirectiveComm(bool IsLocal); // ".comm" and ".lcomm"
bool ParseDirectiveDarwinZerofill(); // Darwin specific ".zerofill"