Skip to content

Commit a9ae243

Browse files
committed
[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
1 parent 5969e57 commit a9ae243

File tree

7 files changed

+96
-36
lines changed

7 files changed

+96
-36
lines changed

llvm/include/llvm/MC/MCAsmInfoGOFF.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===- MCAsmInfoGOFF.h - GOFF Asm Info Fields -------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
///
9+
/// \file
10+
/// This file defines certain target specific asm properties for GOFF (z/OS)
11+
/// based targets.
12+
///
13+
//===----------------------------------------------------------------------===//
14+
15+
#ifndef LLVM_MC_MCASMINFOGOFF_H
16+
#define LLVM_MC_MCASMINFOGOFF_H
17+
18+
#include "llvm/MC/MCAsmInfo.h"
19+
20+
namespace llvm {
21+
class MCAsmInfoGOFF : public MCAsmInfo {
22+
virtual void anchor();
23+
24+
protected:
25+
MCAsmInfoGOFF();
26+
};
27+
} // end namespace llvm
28+
29+
#endif // LLVM_MC_MCASMINFOGOFF_H

llvm/lib/MC/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ add_llvm_component_library(LLVMMC
66
MCAsmInfoCOFF.cpp
77
MCAsmInfoDarwin.cpp
88
MCAsmInfoELF.cpp
9+
MCAsmInfoGOFF.cpp
910
MCAsmInfoWasm.cpp
1011
MCAsmInfoXCOFF.cpp
1112
MCAsmMacro.cpp

llvm/lib/MC/MCAsmInfoGOFF.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===- MCAsmInfoGOFF.cpp - MCGOFFAsmInfo properties -----------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
///
9+
/// \file
10+
/// This file defines certain target specific asm properties for GOFF (z/OS)
11+
/// based targets.
12+
///
13+
//===----------------------------------------------------------------------===//
14+
15+
#include "llvm/MC/MCAsmInfoGOFF.h"
16+
17+
using namespace llvm;
18+
19+
void MCAsmInfoGOFF::anchor() {}
20+
21+
MCAsmInfoGOFF::MCAsmInfoGOFF() {
22+
Data64bitsDirective = "\t.quad\t";
23+
HasDotTypeDotSizeDirective = false;
24+
PrivateGlobalPrefix = "@@";
25+
PrivateLabelPrefix = "@";
26+
ZeroDirective = "\t.space\t";
27+
}

llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,39 @@
1212

1313
using namespace llvm;
1414

15-
SystemZMCAsmInfo::SystemZMCAsmInfo(const Triple &TT) {
16-
CodePointerSize = 8;
15+
SystemZMCAsmInfoELF::SystemZMCAsmInfoELF(const Triple &TT) {
16+
AssemblerDialect = AD_ATT;
1717
CalleeSaveStackSlotSize = 8;
18+
CodePointerSize = 8;
19+
Data64bitsDirective = "\t.quad\t";
20+
ExceptionsType = ExceptionHandling::DwarfCFI;
1821
IsLittleEndian = false;
19-
20-
AssemblerDialect = TT.isOSzOS() ? AD_HLASM : AD_ATT;
21-
2222
MaxInstLength = 6;
23-
24-
CommentString = AssemblerDialect == AD_HLASM ? "*" : "#";
25-
RestrictCommentStringToStartOfStatement = (AssemblerDialect == AD_HLASM);
26-
AllowAdditionalComments = (AssemblerDialect == AD_ATT);
27-
AllowAtAtStartOfIdentifier = (AssemblerDialect == AD_HLASM);
28-
AllowDollarAtStartOfIdentifier = (AssemblerDialect == AD_HLASM);
29-
AllowHashAtStartOfIdentifier = (AssemblerDialect == AD_HLASM);
30-
DotIsPC = (AssemblerDialect == AD_ATT);
31-
StarIsPC = (AssemblerDialect == AD_HLASM);
32-
EmitGNUAsmStartIndentationMarker = (AssemblerDialect == AD_ATT);
33-
AllowAtInName = (AssemblerDialect == AD_HLASM);
34-
EmitLabelsInUpperCase = (AssemblerDialect == AD_HLASM);
35-
36-
ZeroDirective = "\t.space\t";
37-
Data64bitsDirective = "\t.quad\t";
38-
UsesELFSectionDirectiveForBSS = true;
3923
SupportsDebugInformation = true;
40-
ExceptionsType = ExceptionHandling::DwarfCFI;
24+
UsesELFSectionDirectiveForBSS = true;
25+
ZeroDirective = "\t.space\t";
4126
}
4227

43-
bool SystemZMCAsmInfo::isAcceptableChar(char C) const {
44-
if (AssemblerDialect == AD_ATT)
45-
return MCAsmInfo::isAcceptableChar(C);
28+
SystemZMCAsmInfoGOFF::SystemZMCAsmInfoGOFF(const Triple &TT) {
29+
AllowAdditionalComments = false;
30+
AllowAtInName = true;
31+
AllowAtAtStartOfIdentifier = true;
32+
AllowDollarAtStartOfIdentifier = true;
33+
AllowHashAtStartOfIdentifier = true;
34+
AssemblerDialect = AD_HLASM;
35+
CalleeSaveStackSlotSize = 8;
36+
CodePointerSize = 8;
37+
CommentString = "*";
38+
DotIsPC = false;
39+
EmitGNUAsmStartIndentationMarker = false;
40+
EmitLabelsInUpperCase = true;
41+
IsLittleEndian = false;
42+
MaxInstLength = 6;
43+
RestrictCommentStringToStartOfStatement = true;
44+
StarIsPC = true;
45+
SupportsDebugInformation = true;
46+
}
4647

48+
bool SystemZMCAsmInfoGOFF::isAcceptableChar(char C) const {
4749
return MCAsmInfo::isAcceptableChar(C) || C == '#';
4850
}

llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,21 @@
1010
#define LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZMCASMINFO_H
1111

1212
#include "llvm/MC/MCAsmInfoELF.h"
13+
#include "llvm/MC/MCAsmInfoGOFF.h"
1314
#include "llvm/Support/Compiler.h"
1415

1516
namespace llvm {
1617
class Triple;
1718
enum SystemZAsmDialect { AD_ATT = 0, AD_HLASM = 1 };
1819

19-
class SystemZMCAsmInfo : public MCAsmInfoELF {
20+
class SystemZMCAsmInfoELF : public MCAsmInfoELF {
2021
public:
21-
explicit SystemZMCAsmInfo(const Triple &TT);
22+
explicit SystemZMCAsmInfoELF(const Triple &TT);
23+
};
24+
25+
class SystemZMCAsmInfoGOFF : public MCAsmInfoGOFF {
26+
public:
27+
explicit SystemZMCAsmInfoGOFF(const Triple &TT);
2228
bool isAcceptableChar(char C) const override;
2329
};
2430

llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ unsigned SystemZMC::getFirstReg(unsigned Reg) {
151151
static MCAsmInfo *createSystemZMCAsmInfo(const MCRegisterInfo &MRI,
152152
const Triple &TT,
153153
const MCTargetOptions &Options) {
154-
MCAsmInfo *MAI = new SystemZMCAsmInfo(TT);
154+
if (TT.isOSzOS())
155+
return new SystemZMCAsmInfoGOFF(TT);
156+
157+
MCAsmInfo *MAI = new SystemZMCAsmInfoELF(TT);
155158
MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(
156159
nullptr, MRI.getDwarfRegNum(SystemZ::R15D, true),
157160
SystemZMC::ELFCFAOffsetFromInitialSP);

llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -744,14 +744,6 @@ TEST_F(SystemZAsmLexerTest, CheckPrintAcceptableSymbol) {
744744
EXPECT_EQ(false, MUPMAI->isValidUnquotedName(AsmStr));
745745
}
746746

747-
TEST_F(SystemZAsmLexerTest, CheckPrintAcceptableSymbol2) {
748-
MUPMAI->setAssemblerDialect(1);
749-
std::string AsmStr = "ab13_$.@";
750-
EXPECT_EQ(true, MUPMAI->isValidUnquotedName(AsmStr));
751-
AsmStr += "#";
752-
EXPECT_EQ(true, MUPMAI->isValidUnquotedName(AsmStr));
753-
}
754-
755747
TEST_F(SystemZAsmLexerTest, CheckLabelCaseUpperCase2) {
756748
StringRef AsmStr = "label\nlabel";
757749

0 commit comments

Comments
 (0)