[PATCH] D99286: [AsmParser][SystemZ][z/OS] Add in support to only use CommentString as a possible comment syntax

Anirudh Prasad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 24 11:24:17 PDT 2021


anirudhp created this revision.
Herald added a subscriber: hiraditya.
anirudhp requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

- Currently, MCAsmInfo provides a CommentString attribute, that various targets can set, so that the AsmLexer can appropriately lex a string as a comment based on the set value of the attribute.
- However, AsmLexer also supports a few additional comment syntaxes, in addition to what's specified as a CommentString attribute. This includes regular C-style block comments (/* ... */), regular C-style line comments (// .... ) and #. While I'm not sure as to why this behaviour exists, I am assuming it does to maintain backward compatibility with GNU AS (see https://sourceware.org/binutils/docs/as/Comments.html#Comments for reference)

For example:
Consider a target which sets the CommentString attribute to '*'.
The following strings are all lexed as comments.

  "# abc" -> comment
  "// abc" -> comment
  "/* abc */ -> comment
  "* abc" -> comment



- In HLASM however, only "*" is accepted as a comment string, and nothing else.
- To achieve this, an additional attribute has been added to MCAsmInfo. If this attribute is set to true, then only the string specified by the CommentString attribute is used as a possible comment string to be lexed by the AsmLexer. The regular C-style block comments, line comments and "#" are disabled. As a final note, "#" will still be treated as a comment, if the CommentString attribute is set to "#".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99286

Files:
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/lib/MC/MCParser/AsmLexer.cpp
  llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99286.333063.patch
Type: text/x-patch
Size: 8456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210324/48113c76/attachment.bin>


More information about the llvm-commits mailing list