[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
This commit is contained in:
Anirudh Prasad committed 2021-09-24 16:25:41 -04:00
1 parent 5969e5743a
commit a9ae2436fc
7 files changed
+97 -37

No files matched your search

+29
View File
@@ -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
+1
View File
@@ -6,6 +6,7 @@ add_llvm_component_library(LLVMMC
MCAsmInfoCOFF.cpp
MCAsmInfoDarwin.cpp
MCAsmInfoELF.cpp
MCAsmInfoGOFF.cpp
MCAsmInfoWasm.cpp
MCAsmInfoXCOFF.cpp
MCAsmMacro.cpp
+27
View File
@@ -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";
}
@@ -12,37 +12,39 @@
using namespace llvm;
SystemZMCAsmInfo::SystemZMCAsmInfo(const Triple &TT) {
CodePointerSize = 8;
SystemZMCAsmInfoELF::SystemZMCAsmInfoELF(const Triple &TT) {
AssemblerDialect = AD_ATT;
CalleeSaveStackSlotSize = 8;
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";
CodePointerSize = 8;
Data64bitsDirective = "\t.quad\t";
UsesELFSectionDirectiveForBSS = true;
SupportsDebugInformation = true;
ExceptionsType = ExceptionHandling::DwarfCFI;
IsLittleEndian = false;
MaxInstLength = 6;
SupportsDebugInformation = true;
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 == '#';
}
@@ -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;
};
@@ -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);
@@ -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";