[all-commits] [llvm/llvm-project] f7eec8: [AsmParser][SystemZ][z/OS] Add in support to allow...

Anirudh Prasad via All-commits all-commits at lists.llvm.org
Tue Apr 13 08:15:29 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f7eec83932b541f6db295284d7c23731d8db9ce3
      https://github.com/llvm/llvm-project/commit/f7eec83932b541f6db295284d7c23731d8db9ce3
  Author: Anirudh Prasad <anirudh_prasad at hotmail.com>
  Date:   2021-04-13 (Tue, 13 Apr 2021)

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

  Log Message:
  -----------
  [AsmParser][SystemZ][z/OS] Add in support to allow use of additional comment strings.

- 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 (`AllowAdditionalComments`) has been added to MCAsmInfo. If this attribute is set to false, 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 "#".

Depends on https://reviews.llvm.org/D99277

Reviewed By: abhina.sreeskantharajan, myiwanch

Differential Revision: https://reviews.llvm.org/D99286




More information about the All-commits mailing list