[PATCH] D97748: [SystemZ][z/OS
Anirudh Prasad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 1 16:42:34 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.
https://reviews.llvm.org/D97748
Files:
llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h
Index: llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h
===================================================================
--- llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h
+++ llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h
@@ -14,6 +14,7 @@
namespace llvm {
class Triple;
+enum AsmDialect { AD_ATT = 0, AD_HLASM = 1 };
class SystemZMCAsmInfo : public MCAsmInfoELF {
public:
Index: llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
===================================================================
--- llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
+++ llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
@@ -12,8 +12,6 @@
using namespace llvm;
-enum AsmDialect { AD_ATT = 0, AD_HLASM = 1 };
-
SystemZMCAsmInfo::SystemZMCAsmInfo(const Triple &TT) {
CodePointerSize = 8;
CalleeSaveStackSlotSize = 8;
Index: llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
===================================================================
--- llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
+++ llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "MCTargetDesc/SystemZInstPrinter.h"
+#include "MCTargetDesc/SystemZMCAsmInfo.h"
#include "MCTargetDesc/SystemZMCTargetDesc.h"
#include "TargetInfo/SystemZTargetInfo.h"
#include "llvm/ADT/STLExtras.h"
@@ -477,6 +478,7 @@
OperandVector &Operands, MCStreamer &Out,
uint64_t &ErrorInfo,
bool MatchingInlineAsm) override;
+ bool isLabel(AsmToken &Token) override;
// Used by the TableGen code to parse particular operand types.
OperandMatchResultTy parseGR32(OperandVector &Operands) {
@@ -1594,6 +1596,45 @@
return MatchOperand_Success;
}
+bool SystemZAsmParser::isLabel(AsmToken &Token) {
+ if (getMAIAssemblerDialect() == AD_HLASM) {
+ // HLASM Labels are ordinary symbols
+ // An HLASM always starts at column 1.
+ // An ordinary symbol syntax is laid out as follows:
+ // Rules:
+ // 1. Starts with an alphabetic character, followed by 62-alphanumberic
+ // characters
+ // Exception: "_" is treated as an alphabetical character
+ // 2. Maximum length of the symbol is 63 characters
+ // 3. Labels are case insiginficant . Eg. "lab123", "LAB123", "lAb123" etc.
+ // are all treated as the same symbols. However the processing for the case
+ // will not be done in this function.
+ StringRef RawLabel = Token.getString();
+ SMLoc Loc = Token.getLoc();
+
+ // An HLASM label cannot exceed greater than 63 characters.
+ if (RawLabel.size() > 63)
+ return !Error(Loc, "Maximum length for HLASM Label is 63 characters");
+
+ // A label must start with an alphabetic character or '_'
+ // '_' is treated as an alphabetic character.
+ if (!isalpha(RawLabel[0]) && RawLabel[0] != '_')
+ return !Error(Loc, "HLASM Label has to start with an alphabetic "
+ "character or the underscore character");
+
+ // Now, we've established that the length is valid
+ // and the first character is an alphabet.
+ // Check whether remaining string is alphanumeric.
+ for (unsigned I = 1; I < RawLabel.size(); I++)
+ if (!isalnum(RawLabel[I]) && RawLabel[I] != '_')
+ return !Error(Loc, "HLASM Label has to be alphanumeric");
+
+ return true;
+ }
+
+ return true;
+}
+
// Force static initialization.
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZAsmParser() {
RegisterMCAsmParser<SystemZAsmParser> X(getTheSystemZTarget());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97748.327323.patch
Type: text/x-patch
Size: 3688 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210302/7b5f688a/attachment.bin>
More information about the llvm-commits
mailing list