[llvm] a9ae243 - [SystemZ][z/OS] Introduce the GOFFMCAsmInfo Interface for z/OS
Anirudh Prasad via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 24 13:25:45 PDT 2021
Author: Anirudh Prasad
Date: 2021-09-24T16:25:41-04:00
New Revision: a9ae2436fc0dcb68ef8a478948e46d0a9998b0c9
URL: https://github.com/llvm/llvm-project/commit/a9ae2436fc0dcb68ef8a478948e46d0a9998b0c9
DIFF: https://github.com/llvm/llvm-project/commit/a9ae2436fc0dcb68ef8a478948e46d0a9998b0c9.diff
LOG: [SystemZ][z/OS] Introduce the GOFFMCAsmInfo Interface for z/OS
- This patch adds in the GOFFMCAsmInfo interfaces for the z/OS target.
- This patch decouples the previously existing SystemZMCAsmInfo interface for the ELF target and the z/OS target.
- This patch also removes a small test in the SystemZAsmLexerTest.cpp. The reason for this is because, the test is set up for the s390x-ibm-linux (SystemZ ELF triple), and the test checks a function which is overridden only for the z/OS target. The reason we can't change the test to use a z/OS triple outright is because there is still missing support which prevents the successful running of a test (assert in AsmParser.cpp due to missing GOFFAsmParser support)
Reviewed By: uweigand, abhina.sreeskantharajan
Differential Revision: https://reviews.llvm.org/D110077
Added:
llvm/include/llvm/MC/MCAsmInfoGOFF.h
llvm/lib/MC/MCAsmInfoGOFF.cpp
Modified:
llvm/lib/MC/CMakeLists.txt
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAsmInfoGOFF.h b/llvm/include/llvm/MC/MCAsmInfoGOFF.h
new file mode 100644
index 0000000000000..1f3b26311b37e
--- /dev/null
+++ b/llvm/include/llvm/MC/MCAsmInfoGOFF.h
@@ -0,0 +1,29 @@
+//===- MCAsmInfoGOFF.h - GOFF Asm Info Fields -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file defines certain target specific asm properties for GOFF (z/OS)
+/// based targets.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_MC_MCASMINFOGOFF_H
+#define LLVM_MC_MCASMINFOGOFF_H
+
+#include "llvm/MC/MCAsmInfo.h"
+
+namespace llvm {
+class MCAsmInfoGOFF : public MCAsmInfo {
+ virtual void anchor();
+
+protected:
+ MCAsmInfoGOFF();
+};
+} // end namespace llvm
+
+#endif // LLVM_MC_MCASMINFOGOFF_H
diff --git a/llvm/lib/MC/CMakeLists.txt b/llvm/lib/MC/CMakeLists.txt
index 811cee309e110..4d82ce3d111e1 100644
--- a/llvm/lib/MC/CMakeLists.txt
+++ b/llvm/lib/MC/CMakeLists.txt
@@ -6,6 +6,7 @@ add_llvm_component_library(LLVMMC
MCAsmInfoCOFF.cpp
MCAsmInfoDarwin.cpp
MCAsmInfoELF.cpp
+ MCAsmInfoGOFF.cpp
MCAsmInfoWasm.cpp
MCAsmInfoXCOFF.cpp
MCAsmMacro.cpp
diff --git a/llvm/lib/MC/MCAsmInfoGOFF.cpp b/llvm/lib/MC/MCAsmInfoGOFF.cpp
new file mode 100644
index 0000000000000..81704ffe4b246
--- /dev/null
+++ b/llvm/lib/MC/MCAsmInfoGOFF.cpp
@@ -0,0 +1,27 @@
+//===- MCAsmInfoGOFF.cpp - MCGOFFAsmInfo properties -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file defines certain target specific asm properties for GOFF (z/OS)
+/// based targets.
+///
+//===----------------------------------------------------------------------===//
+
+#include "llvm/MC/MCAsmInfoGOFF.h"
+
+using namespace llvm;
+
+void MCAsmInfoGOFF::anchor() {}
+
+MCAsmInfoGOFF::MCAsmInfoGOFF() {
+ Data64bitsDirective = "\t.quad\t";
+ HasDotTypeDotSizeDirective = false;
+ PrivateGlobalPrefix = "@@";
+ PrivateLabelPrefix = "@";
+ ZeroDirective = "\t.space\t";
+}
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
index fa48642995869..e61b07e973e93 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
@@ -12,37 +12,39 @@
using namespace llvm;
-SystemZMCAsmInfo::SystemZMCAsmInfo(const Triple &TT) {
- CodePointerSize = 8;
+SystemZMCAsmInfoELF::SystemZMCAsmInfoELF(const Triple &TT) {
+ AssemblerDialect = AD_ATT;
CalleeSaveStackSlotSize = 8;
+ CodePointerSize = 8;
+ Data64bitsDirective = "\t.quad\t";
+ ExceptionsType = ExceptionHandling::DwarfCFI;
IsLittleEndian = false;
-
- AssemblerDialect = TT.isOSzOS() ? AD_HLASM : AD_ATT;
-
MaxInstLength = 6;
-
- CommentString = AssemblerDialect == AD_HLASM ? "*" : "#";
- RestrictCommentStringToStartOfStatement = (AssemblerDialect == AD_HLASM);
- AllowAdditionalComments = (AssemblerDialect == AD_ATT);
- AllowAtAtStartOfIdentifier = (AssemblerDialect == AD_HLASM);
- AllowDollarAtStartOfIdentifier = (AssemblerDialect == AD_HLASM);
- AllowHashAtStartOfIdentifier = (AssemblerDialect == AD_HLASM);
- DotIsPC = (AssemblerDialect == AD_ATT);
- StarIsPC = (AssemblerDialect == AD_HLASM);
- EmitGNUAsmStartIndentationMarker = (AssemblerDialect == AD_ATT);
- AllowAtInName = (AssemblerDialect == AD_HLASM);
- EmitLabelsInUpperCase = (AssemblerDialect == AD_HLASM);
-
- ZeroDirective = "\t.space\t";
- Data64bitsDirective = "\t.quad\t";
- UsesELFSectionDirectiveForBSS = true;
SupportsDebugInformation = true;
- ExceptionsType = ExceptionHandling::DwarfCFI;
+ UsesELFSectionDirectiveForBSS = true;
+ ZeroDirective = "\t.space\t";
}
-bool SystemZMCAsmInfo::isAcceptableChar(char C) const {
- if (AssemblerDialect == AD_ATT)
- return MCAsmInfo::isAcceptableChar(C);
+SystemZMCAsmInfoGOFF::SystemZMCAsmInfoGOFF(const Triple &TT) {
+ AllowAdditionalComments = false;
+ AllowAtInName = true;
+ AllowAtAtStartOfIdentifier = true;
+ AllowDollarAtStartOfIdentifier = true;
+ AllowHashAtStartOfIdentifier = true;
+ AssemblerDialect = AD_HLASM;
+ CalleeSaveStackSlotSize = 8;
+ CodePointerSize = 8;
+ CommentString = "*";
+ DotIsPC = false;
+ EmitGNUAsmStartIndentationMarker = false;
+ EmitLabelsInUpperCase = true;
+ IsLittleEndian = false;
+ MaxInstLength = 6;
+ RestrictCommentStringToStartOfStatement = true;
+ StarIsPC = true;
+ SupportsDebugInformation = true;
+}
+bool SystemZMCAsmInfoGOFF::isAcceptableChar(char C) const {
return MCAsmInfo::isAcceptableChar(C) || C == '#';
}
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h
index 389575d146790..b2f191424d01c 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h
@@ -10,15 +10,21 @@
#define LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZMCASMINFO_H
#include "llvm/MC/MCAsmInfoELF.h"
+#include "llvm/MC/MCAsmInfoGOFF.h"
#include "llvm/Support/Compiler.h"
namespace llvm {
class Triple;
enum SystemZAsmDialect { AD_ATT = 0, AD_HLASM = 1 };
-class SystemZMCAsmInfo : public MCAsmInfoELF {
+class SystemZMCAsmInfoELF : public MCAsmInfoELF {
public:
- explicit SystemZMCAsmInfo(const Triple &TT);
+ explicit SystemZMCAsmInfoELF(const Triple &TT);
+};
+
+class SystemZMCAsmInfoGOFF : public MCAsmInfoGOFF {
+public:
+ explicit SystemZMCAsmInfoGOFF(const Triple &TT);
bool isAcceptableChar(char C) const override;
};
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
index 5401854891399..1241f18326b80 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
@@ -151,7 +151,10 @@ unsigned SystemZMC::getFirstReg(unsigned Reg) {
static MCAsmInfo *createSystemZMCAsmInfo(const MCRegisterInfo &MRI,
const Triple &TT,
const MCTargetOptions &Options) {
- MCAsmInfo *MAI = new SystemZMCAsmInfo(TT);
+ if (TT.isOSzOS())
+ return new SystemZMCAsmInfoGOFF(TT);
+
+ MCAsmInfo *MAI = new SystemZMCAsmInfoELF(TT);
MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(
nullptr, MRI.getDwarfRegNum(SystemZ::R15D, true),
SystemZMC::ELFCFAOffsetFromInitialSP);
diff --git a/llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp b/llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
index 63d6b52deb913..dd95b047d5bb8 100644
--- a/llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ b/llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -744,14 +744,6 @@ TEST_F(SystemZAsmLexerTest, CheckPrintAcceptableSymbol) {
EXPECT_EQ(false, MUPMAI->isValidUnquotedName(AsmStr));
}
-TEST_F(SystemZAsmLexerTest, CheckPrintAcceptableSymbol2) {
- MUPMAI->setAssemblerDialect(1);
- std::string AsmStr = "ab13_$.@";
- EXPECT_EQ(true, MUPMAI->isValidUnquotedName(AsmStr));
- AsmStr += "#";
- EXPECT_EQ(true, MUPMAI->isValidUnquotedName(AsmStr));
-}
-
TEST_F(SystemZAsmLexerTest, CheckLabelCaseUpperCase2) {
StringRef AsmStr = "label\nlabel";
More information about the llvm-commits
mailing list