MC/AsmParser: Move .desc parsing to Darwin specific parser.
authorDaniel Dunbar <daniel@zuster.org>
Mon, 12 Jul 2010 19:22:53 +0000 (19:22 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 12 Jul 2010 19:22:53 +0000 (19:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108179 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCParser/AsmParser.h
lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/directive_desc.s

index 3e897b38338be0228e40284dea41970fc3bcb3df..43cb596a6686737a7d7e93abbb2b5f28b4434e6b 100644 (file)
@@ -137,7 +137,6 @@ private:
   /// accepts a single symbol (which should be a label or an external).
   bool ParseDirectiveSymbolAttribute(MCSymbolAttr Attr);
   bool ParseDirectiveELFType(); // ELF specific ".type"
-  bool ParseDirectiveDarwinSymbolDesc(); // Darwin specific ".desc"
 
   bool ParseDirectiveComm(bool IsLocal); // ".comm" and ".lcomm"
   bool ParseDirectiveDarwinZerofill(); // Darwin specific ".zerofill"
index e976c0a0b74708c2739989fe4b4d4cc93ee0dd88..b9139fe5af6dc62439b0a3e52de6ab31e80c1b4b 100644 (file)
@@ -66,6 +66,8 @@ public:
     // Call the base implementation.
     this->MCAsmParserExtension::Initialize(Parser);
 
+    Parser.AddDirectiveHandler(this, ".desc", MCAsmParser::DirectiveHandler(
+                                 &DarwinAsmParser::ParseDirectiveDesc));
     Parser.AddDirectiveHandler(this, ".lsym", MCAsmParser::DirectiveHandler(
                                  &DarwinAsmParser::ParseDirectiveLsym));
     Parser.AddDirectiveHandler(this, ".subsections_via_symbols",
@@ -83,6 +85,7 @@ public:
                              &DarwinAsmParser::ParseDirectiveSecureLogReset));
   }
 
+  bool ParseDirectiveDesc(StringRef, SMLoc);
   bool ParseDirectiveDumpOrLoad(StringRef, SMLoc);
   bool ParseDirectiveLsym(StringRef, SMLoc);
   bool ParseDirectiveSecureLogReset(StringRef, SMLoc);
@@ -837,8 +840,6 @@ bool AsmParser::ParseStatement() {
       return ParseDirectiveComm(/*IsLocal=*/true);
     if (IDVal == ".zerofill")
       return ParseDirectiveDarwinZerofill();
-    if (IDVal == ".desc")
-      return ParseDirectiveDarwinSymbolDesc();
     if (IDVal == ".tbss")
       return ParseDirectiveDarwinTBSS();
 
@@ -1431,22 +1432,22 @@ bool AsmParser::ParseDirectiveELFType() {
   return false;
 }
 
-/// ParseDirectiveDarwinSymbolDesc
+/// ParseDirectiveDesc
 ///  ::= .desc identifier , expression
-bool AsmParser::ParseDirectiveDarwinSymbolDesc() {
+bool DarwinAsmParser::ParseDirectiveDesc(StringRef, SMLoc) {
   StringRef Name;
-  if (ParseIdentifier(Name))
+  if (getParser().ParseIdentifier(Name))
     return TokError("expected identifier in directive");
   
   // Handle the identifier as the key symbol.
-  MCSymbol *Sym = CreateSymbol(Name);
+  MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
 
   if (getLexer().isNot(AsmToken::Comma))
     return TokError("unexpected token in '.desc' directive");
   Lex();
 
   int64_t DescValue;
-  if (ParseAbsoluteExpression(DescValue))
+  if (getParser().ParseAbsoluteExpression(DescValue))
     return true;
 
   if (getLexer().isNot(AsmToken::EndOfStatement))
index 992455ccdc895d69cf4b78497f5fe52ac21e8b43..4bc56155ea53570417e042d486898796f2d4476f 100644 (file)
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+# RUN: llvm-mc -triple i386-apple-darwin9 %s | FileCheck %s
 
 # CHECK: TEST0:
 # CHECK: .desc foo,16