[PATCH] D97703: [SystemZ][z/OS] Introducing HLASM Comment Syntax
Anirudh Prasad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 1 10:05:48 PST 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.
- This patch adds in support for the ordinary HLASM comment syntax asm statements (Reference <https://www.ibm.com/support/knowledgecenter/SSENW6_1.6.0/com.ibm.hlasm.v1r6.asm/asmr1023.pdf> - Chapter 7, Comment Statements, Ordinary Comment Statements)
- In brief, the ordinary comment syntax if used, must begin with the "*" character
- To achieve this, this patch makes use of the `CommentString` attribute provided in the base `MCAsmInfo` class
- In the `SystemZMCAsmInfo` class, the `CommentString` attribute was set to "*" based on the assembler dialect <https://reviews.llvm.org/D94250>
- Furthermore, a new attribute `RestrictCommentString`, is provided to only treat a string as a comment if it appears at the start of the asm statement. The reason is because we can have something like "jo *-4" which is valid in HLASM (jump back 4 bytes from current point - similar to jo -4 in gnu asm) and we don't want "*-4" to be treated as a comment.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97703
Files:
llvm/include/llvm/MC/MCAsmInfo.h
llvm/lib/MC/MCParser/AsmLexer.cpp
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
Index: llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
===================================================================
--- llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
+++ llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
@@ -23,7 +23,8 @@
MaxInstLength = 6;
- CommentString = "#";
+ CommentString = AssemblerDialect == AD_HLASM ? "*" : "#";
+ RestrictCommentString = (AssemblerDialect == AD_HLASM);
ZeroDirective = "\t.space\t";
Data64bitsDirective = "\t.quad\t";
UsesELFSectionDirectiveForBSS = true;
Index: llvm/lib/MC/MCParser/AsmLexer.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmLexer.cpp
+++ llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -660,9 +660,11 @@
bool AsmLexer::isAtStartOfComment(const char *Ptr) {
StringRef CommentString = MAI.getCommentString();
+ bool RestrictCommentString = MAI.getRestrictCommentString();
if (CommentString.size() == 1)
- return CommentString[0] == Ptr[0];
+ return CommentString[0] == Ptr[0] &&
+ (!RestrictCommentString || IsAtStartOfStatement);
// Allow # preprocessor commments also be counted as comments for "##" cases
if (CommentString[1] == '#')
Index: llvm/include/llvm/MC/MCAsmInfo.h
===================================================================
--- llvm/include/llvm/MC/MCAsmInfo.h
+++ llvm/include/llvm/MC/MCAsmInfo.h
@@ -126,6 +126,10 @@
/// "#"
StringRef CommentString;
+ /// This indicates whether the comment character is only accepted as a comment
+ /// at the beginning of statements. Defaults to false.
+ bool RestrictCommentString = false;
+
/// This is appended to emitted labels. Defaults to ":"
const char *LabelSuffix;
@@ -549,6 +553,7 @@
unsigned getCommentColumn() const { return 40; }
StringRef getCommentString() const { return CommentString; }
+ bool getRestrictCommentString() const { return RestrictCommentString; }
const char *getLabelSuffix() const { return LabelSuffix; }
bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97703.327161.patch
Type: text/x-patch
Size: 2098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210301/b24d9434/attachment.bin>
More information about the llvm-commits
mailing list