[llvm-commits] [llvm] r108606 - /llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp

Eli Friedman eli.friedman at gmail.com
Fri Jul 16 20:09:18 PDT 2010


Author: efriedma
Date: Fri Jul 16 22:09:18 2010
New Revision: 108606

URL: http://llvm.org/viewvc/llvm-project?rev=108606&view=rev
Log:
Add support for parsing .size directives for ELF.


Modified:
    llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp

Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=108606&r1=108605&r2=108606&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Fri Jul 16 22:09:18 2010
@@ -31,6 +31,8 @@
                                  &ELFAsmParser::ParseSectionDirectiveData));
     Parser.AddDirectiveHandler(this, ".text", MCAsmParser::DirectiveHandler(
                                  &ELFAsmParser::ParseSectionDirectiveText));
+    Parser.AddDirectiveHandler(this, ".size", MCAsmParser::DirectiveHandler(
+                                 &ELFAsmParser::ParseSizeDirective));
   }
 
   bool ParseSectionDirectiveData(StringRef, SMLoc) {
@@ -43,6 +45,7 @@
                               MCSectionELF::SHF_EXECINSTR |
                               MCSectionELF::SHF_ALLOC, SectionKind::getText());
   }
+  bool ParseSizeDirective(StringRef, SMLoc);
 };
 
 }
@@ -59,6 +62,27 @@
   return false;
 }
 
+bool ELFAsmParser::ParseSizeDirective(StringRef, SMLoc) {
+  StringRef Name;
+  if (getParser().ParseIdentifier(Name))
+    return TokError("expected identifier in directive");
+  MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);;
+
+  if (getLexer().isNot(AsmToken::Comma))
+    return TokError("unexpected token in directive");
+  Lex();
+
+  const MCExpr *Expr;
+  if (getParser().ParseExpression(Expr))
+    return true;
+
+  if (getLexer().isNot(AsmToken::EndOfStatement))
+    return TokError("unexpected token in directive");
+
+  getStreamer().EmitELFSize(Sym, Expr);
+  return false;
+}
+
 namespace llvm {
 
 MCAsmParserExtension *createELFAsmParser() {





More information about the llvm-commits mailing list