[llvm-commits] [llvm] r108190 - in /llvm/trunk: include/llvm/MC/MCParser/AsmParser.h lib/MC/MCParser/AsmParser.cpp

Daniel Dunbar daniel at zuster.org
Mon Jul 12 13:42:34 PDT 2010


Author: ddunbar
Date: Mon Jul 12 15:42:34 2010
New Revision: 108190

URL: http://llvm.org/viewvc/llvm-project?rev=108190&view=rev
Log:
MC/AsmParser: Move .section parsing to Darwin specific parser.

Modified:
    llvm/trunk/include/llvm/MC/MCParser/AsmParser.h
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp

Modified: llvm/trunk/include/llvm/MC/MCParser/AsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/AsmParser.h?rev=108190&r1=108189&r2=108190&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/AsmParser.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/AsmParser.h Mon Jul 12 15:42:34 2010
@@ -118,7 +118,6 @@
   bool ParseIdentifier(StringRef &Res);
   
   // Directive Parsing.
-  bool ParseDirectiveDarwinSection(); // Darwin specific ".section".
   bool ParseDirectiveAscii(bool ZeroTerminated); // ".ascii", ".asciiz"
   bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ...
   bool ParseDirectiveFill(); // ".fill"

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=108190&r1=108189&r2=108190&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Mon Jul 12 15:42:34 2010
@@ -82,6 +82,8 @@
                                  &DarwinAsmParser::ParseDirectiveDumpOrLoad));
     Parser.AddDirectiveHandler(this, ".load", MCAsmParser::DirectiveHandler(
                                  &DarwinAsmParser::ParseDirectiveDumpOrLoad));
+    Parser.AddDirectiveHandler(this, ".section", MCAsmParser::DirectiveHandler(
+                                 &DarwinAsmParser::ParseDirectiveSection));
     Parser.AddDirectiveHandler(this, ".secure_log_unique",
                                MCAsmParser::DirectiveHandler(
                              &DarwinAsmParser::ParseDirectiveSecureLogUnique));
@@ -230,6 +232,7 @@
   bool ParseDirectiveDesc(StringRef, SMLoc);
   bool ParseDirectiveDumpOrLoad(StringRef, SMLoc);
   bool ParseDirectiveLsym(StringRef, SMLoc);
+  bool ParseDirectiveSection();
   bool ParseDirectiveSecureLogReset(StringRef, SMLoc);
   bool ParseDirectiveSecureLogUnique(StringRef, SMLoc);
   bool ParseDirectiveSubsectionsViaSymbols(StringRef, SMLoc);
@@ -947,10 +950,6 @@
   
   // Otherwise, we have a normal instruction or directive.  
   if (IDVal[0] == '.') {
-    // FIXME: This should be driven based on a hash lookup and callback.
-    if (IDVal == ".section")
-      return ParseDirectiveDarwinSection();
-
     // Assembler features
     if (IDVal == ".set")
       return ParseDirectiveSet();
@@ -1168,13 +1167,11 @@
 
 /// ParseDirectiveSection:
 ///   ::= .section identifier (',' identifier)*
-/// FIXME: This should actually parse out the segment, section, attributes and
-/// sizeof_stub fields.
-bool AsmParser::ParseDirectiveDarwinSection() {
+bool DarwinAsmParser::ParseDirectiveSection() {
   SMLoc Loc = getLexer().getLoc();
 
   StringRef SectionName;
-  if (ParseIdentifier(SectionName))
+  if (getParser().ParseIdentifier(SectionName))
     return Error(Loc, "expected identifier after '.section' directive");
 
   // Verify there is a following comma.
@@ -1186,7 +1183,7 @@
 
   // Add all the tokens until the end of the line, ParseSectionSpecifier will
   // handle this.
-  StringRef EOL = Lexer.LexUntilEndOfStatement();
+  StringRef EOL = getLexer().LexUntilEndOfStatement();
   SectionSpec.append(EOL.begin(), EOL.end());
 
   Lex();
@@ -1197,16 +1194,16 @@
 
   StringRef Segment, Section;
   unsigned TAA, StubSize;
-  std::string ErrorStr = 
+  std::string ErrorStr =
     MCSectionMachO::ParseSectionSpecifier(SectionSpec, Segment, Section,
                                           TAA, StubSize);
-  
+
   if (!ErrorStr.empty())
     return Error(Loc, ErrorStr.c_str());
-  
+
   // FIXME: Arch specific.
   bool isText = Segment == "__TEXT";  // FIXME: Hack.
-  getStreamer().SwitchSection(Ctx.getMachOSection(
+  getStreamer().SwitchSection(getContext().getMachOSection(
                                 Segment, Section, TAA, StubSize,
                                 isText ? SectionKind::getText()
                                 : SectionKind::getDataRel()));





More information about the llvm-commits mailing list