diff --git a/llvm/include/llvm/MC/MCAsmInfoGOFF.h b/llvm/include/llvm/MC/MCAsmInfoGOFF.h new file mode 100644 --- /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 --- a/llvm/lib/MC/CMakeLists.txt +++ b/llvm/lib/MC/CMakeLists.txt @@ -6,6 +6,7 @@ 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 --- /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.h b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.h --- 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/SystemZMCAsmInfo.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp --- 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/SystemZMCTargetDesc.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp @@ -151,7 +151,10 @@ 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 --- a/llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp +++ b/llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp @@ -744,14 +744,6 @@ 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";