[llvm] r201474 - MCAsmParser: relax declaration parsing

Saleem Abdulrasool compnerd at compnerd.org
Sat Feb 15 20:56:32 PST 2014


Author: compnerd
Date: Sat Feb 15 22:56:31 2014
New Revision: 201474

URL: http://llvm.org/viewvc/llvm-project?rev=201474&view=rev
Log:
MCAsmParser: relax declaration parsing

The Linux kernel defines empty macros for compatibility with ARM UAL syntax.
The comma after the name is optional, and if present can be safely lexed.  This
improves compatibility with the GNU assembler.

Added:
    llvm/trunk/test/MC/AsmParser/macros-argument-parsing.s
Modified:
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=201474&r1=201473&r2=201474&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Sat Feb 15 22:56:31 2014
@@ -3152,12 +3152,15 @@ bool AsmParser::parseDirectiveMacrosOnOf
 }
 
 /// parseDirectiveMacro
-/// ::= .macro name [parameters]
+/// ::= .macro name[,] [parameters]
 bool AsmParser::parseDirectiveMacro(SMLoc DirectiveLoc) {
   StringRef Name;
   if (parseIdentifier(Name))
     return TokError("expected identifier in '.macro' directive");
 
+  if (getLexer().is(AsmToken::Comma))
+    Lex();
+
   MCAsmMacroParameters Parameters;
   while (getLexer().isNot(AsmToken::EndOfStatement)) {
     MCAsmMacroParameter Parameter;

Added: llvm/trunk/test/MC/AsmParser/macros-argument-parsing.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/macros-argument-parsing.s?rev=201474&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/macros-argument-parsing.s (added)
+++ llvm/trunk/test/MC/AsmParser/macros-argument-parsing.s Sat Feb 15 22:56:31 2014
@@ -0,0 +1,10 @@
+# RUN: llvm-mc -triple i386 -filetype asm -o - %s | FileCheck %s
+
+	.macro	it, cond
+	.endm
+
+	it ne
+	.long 1
+
+# CHECK: .long 1
+





More information about the llvm-commits mailing list