Added llvm-mc support for parsing the .lsym directive.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75685 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index d94b7b3..b4e0f57 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/tools/llvm-mc/AsmParser.cpp
@@ -528,6 +528,8 @@
       return ParseDirectiveDarwinZerofill();
     if (!strcmp(IDVal, ".desc"))
       return ParseDirectiveDarwinSymbolDesc();
+    if (!strcmp(IDVal, ".lsym"))
+      return ParseDirectiveDarwinLsym();
 
     if (!strcmp(IDVal, ".subsections_via_symbols"))
       return ParseDirectiveDarwinSubsectionsViaSymbols();
@@ -1126,3 +1128,33 @@
 
   return false;
 }
+
+/// ParseDirectiveLsym
+///  ::= .lsym identifier , expression
+bool AsmParser::ParseDirectiveDarwinLsym() {
+  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 '.lsym' directive");
+  Lexer.Lex();
+
+  MCValue Expr;
+  if (ParseRelocatableExpression(Expr))
+    return true;
+
+  if (Lexer.isNot(asmtok::EndOfStatement))
+    return TokError("unexpected token in '.lsym' directive");
+  
+  Lexer.Lex();
+
+  // Create the Sym with the value of the Expr
+  Out.EmitLocalSymbol(Sym, Expr);
+
+  return false;
+}