[PATCH] D76962: [MC] Parse directives with arguments as macro arguments
Jian Cai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 27 17:40:33 PDT 2020
jcai19 updated this revision to Diff 253264.
jcai19 added a comment.
Update summary to include the bug reported.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76962/new/
https://reviews.llvm.org/D76962
Files:
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/test/MC/X86/expand-macro-directive-arguments.s
Index: llvm/test/MC/X86/expand-macro-directive-arguments.s
===================================================================
--- /dev/null
+++ llvm/test/MC/X86/expand-macro-directive-arguments.s
@@ -0,0 +1,10 @@
+# RUN: llvm-mc -filetype=obj -triple=i386 %s -o - | llvm-readelf --sections | FileCheck %s
+
+.macro alternative_insn insn1, insn2
+# CHECK: .foo PROGBITS 00000000 000034 000000 00 0 0 1
+\insn1
+# CHECK: .bar PROGBITS 00000000 000034 000000 00 0 0 1
+\insn2
+.endm
+
+alternative_insn .section .foo, .section .bar
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -2611,6 +2611,7 @@
continue;
}
}
+
if (SpaceEaten)
break;
}
@@ -2629,6 +2630,15 @@
// Append the token to the current argument list.
MA.push_back(getTok());
Lexer.Lex();
+
+ // If the token is a directive, append all the following arguments if there is any
+ AsmToken &Tok = MA.back();
+ if (Tok.is(AsmToken::Identifier) && Tok.getString().startswith(".")) {
+ while (!Lexer.is(AsmToken::Comma) && !Lexer.is(AsmToken::EndOfStatement)) {
+ MA.push_back(getTok());
+ Lexer.Lex();
+ }
+ }
}
if (ParenLevel != 0)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76962.253264.patch
Type: text/x-patch
Size: 1380 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200328/3ab6bab2/attachment.bin>
More information about the llvm-commits
mailing list