[PATCH] D98276: [AsmParser][SystemZ][z/OS] Introducing HLASM Parser support to AsmParser

Anirudh Prasad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 9 11:29:09 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 (is one in a series of patches) which introduces HLASM Parser support to LLVM (main RFC here <https://lists.llvm.org/pipermail/llvm-dev/2021-January/147686.html>)
- This patch in particular introduces HLASM Parser support for Z machine instructions.
- The approach taken here was to subclass `AsmParser`, and make various functions and variables as "protected" wherever appropriate.
- The `HLASMAsmParser` class overrides the `parseStatement` function. Two new private functions `parseAsHLASMLabel` and `parseAsMachineInstruction` are introduced as well.

The general syntax is laid out as follows (more information available in HLASM V1R6 Language Reference Manual <https://www.ibm.com/support/knowledgecenter/SSENW6_1.6.0/com.ibm.hlasm.v1r6.asm/asmr1023.pdf> - Chapter 2 - Instruction Statement Format):

  <TokA><spaces.*><TokB><spaces.*><TokC><spaces.*><TokD>



1. TokA is referred to as the Name Entry. This token is optional
2. TokB is referred to as the Operation Entry. This token is mandatory.
3. TokC is referred to as the Operand Entry. This token is mandatory
4. TokD is referred to as the Remarks Entry. This token is optional

- If TokA is provided, then we either parse TokA as a possible comment or as a label (Name Entry), Tok B as the Operation Entry and so on.
- If TokA is not provided (i.e. we have one or more spaces and then the first token), then we will parse the first token (i.e TokB) as a possible Z machine instruction, TokC as the operands to the Z machine instruction and TokD as a possible Remark field
- TokC (Operand Entry), no spaces are allowed between OperandEntries. If a space occurs it is classified as an error.
- TokD if provided is taken as is, and emitted as a comment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98276

Files:
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
  llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98276.329406.patch
Type: text/x-patch
Size: 16522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210309/409b5a8b/attachment.bin>


More information about the llvm-commits mailing list