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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 23:57:55 PDT 2020


MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

This change looks more like a hack rather than a proper solution. It does not even improve GNU as compatibility. With this patch, MC will accept `alternative_insn .section .foo, .section .bar`, however, this is rejected by GNU as.

GNU as preprocesses a line with `do_scrub_chars`. For the input `.inst (0)`, `do_scrub_chars` will delete the space before `(` and make it `.inst(0)`.
`macro_expand` will read `.inst(0)` as an actual parameter (the process is rather hacky: `.init` is tokenized first but then `get_any_string` reads `.inst(0)`)

This change just makes the code even harder to understand, I think. I don't know how to fix the problem in general. We probably should work around it in the Linux kernel. One approach is to take ihalip's suggestion on https://github.com/ClangBuiltLinux/linux/issues/939#issuecomment-601776123. Another is to quote actual parameters with double quotes, i.e. `alternative_insn ".section .foo", ".section .bar"`


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