[PATCH] D76962: [MC] Parse directives with arguments as macro arguments

Jian Cai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 29 15:32:50 PDT 2020


jcai19 marked an inline comment as done.
jcai19 added a comment.

This patch is not for GNU-compatibility. GNU's handling of spaces between directives and their arguments when expanding macros are confusing IMO -- it only supports selective directives. For example, it supports .inst (XXX) for aarch64, but not .section .foo or .space 0xf on x86 as you mentioned. For .section, if works if you do not have any space between .section and the argument, and surround it with parenthesis, but them will also be included as part of the section name, e.g. alternative_insn .section(.foo), .section(.bar) will work on gcc, but the object file will have (.foo) and (.bar) sections. I think we should either unconditionally support all of such directives, or not at all. I am fine with either option, and would happily close this if one of the workarounds is accepted into Linux.



================
Comment at: llvm/lib/MC/MCParser/AsmParser.cpp:2636
+    AsmToken &Tok = MA.back();
+    if (Tok.is(AsmToken::Identifier) && Tok.getString().startswith(".")) {
+      while (!Lexer.is(AsmToken::Comma) && !Lexer.is(AsmToken::EndOfStatement)) {
----------------
jcai19 wrote:
> nickdesaulniers wrote:
> > Is this the most precise way to check for directives?  I see `DirectiveKind`, and `DirectiveKindMap`, maybe there's a way to verify that the `Tok` is a valid directive?
> Right that's a good point I'll investigate further.
DirectiveKindMap does not include all the directives, such .section used in this example or .inst for aarch64.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76962/new/

https://reviews.llvm.org/D76962





More information about the llvm-commits mailing list