LLVM 23.0.0git
MCAsmInfoGOFF.cpp
Go to the documentation of this file.
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
21
22using namespace llvm;
23
31
32static void emitCATTR(raw_ostream &OS, StringRef Name, GOFF::ESDRmode Rmode,
33 GOFF::ESDAlignment Alignment,
34 GOFF::ESDLoadingBehavior LoadBehavior,
35 GOFF::ESDExecutable Executable, bool IsReadOnly,
36 uint32_t SortKey, uint8_t FillByteValue,
37 StringRef PartName) {
38 OS << Name << " CATTR ";
39 OS << "ALIGN(" << static_cast<unsigned>(Alignment) << "),"
40 << "FILL(" << static_cast<unsigned>(FillByteValue) << ")";
41 switch (LoadBehavior) {
43 OS << ",DEFLOAD";
44 break;
46 OS << ",NOLOAD";
47 break;
48 default:
49 break;
50 }
51 switch (Executable) {
53 OS << ",EXECUTABLE";
54 break;
56 OS << ",NOTEXECUTABLE";
57 break;
58 default:
59 break;
60 }
61 if (IsReadOnly)
62 OS << ",READONLY";
63 if (Rmode != GOFF::ESD_RMODE_None) {
64 OS << ',';
65 OS << "RMODE(";
66 switch (Rmode) {
70 OS << "24";
71 break;
73 OS << "31";
74 break;
76 OS << "64";
77 break;
78 }
79 OS << ')';
80 }
81 if (SortKey)
82 OS << ",PRIORITY(" << SortKey << ")";
83 if (!PartName.empty())
84 OS << ",PART(" << PartName << ")";
85 OS << '\n';
86}
87
88static void emitXATTR(raw_ostream &OS, StringRef Name, MCSectionGOFF *ADA,
90 GOFF::ESDExecutable Executable,
91 GOFF::ESDBindingScope BindingScope) {
92 llvm::ListSeparator Sep(",");
93 OS << Name << " XATTR ";
94 OS << Sep << "LINKAGE(" << (Linkage == GOFF::ESD_LT_OS ? "OS" : "XPLINK")
95 << ")";
96 if (Executable != GOFF::ESD_EXE_Unspecified)
97 OS << Sep << "REFERENCE("
98 << (Executable == GOFF::ESD_EXE_CODE ? "CODE" : "DATA") << ")";
99 if (ADA)
100 OS << Sep << "PSECT(" << ADA->getName() << ")";
101 if (BindingScope != GOFF::ESD_BSC_Unspecified) {
102 OS << Sep << "SCOPE(";
103 switch (BindingScope) {
105 OS << "SECTION";
106 break;
108 OS << "MODULE";
109 break;
111 OS << "LIBRARY";
112 break;
114 OS << "EXPORT";
115 break;
116 default:
117 break;
118 }
119 OS << ')';
120 }
121 OS << '\n';
122}
123
124void MCAsmInfoGOFF::printSwitchToSection(const MCSection &Section,
125 uint32_t Subsection, const Triple &T,
126 raw_ostream &OS) const {
127 auto &Sec =
128 const_cast<MCSectionGOFF &>(static_cast<const MCSectionGOFF &>(Section));
129 auto EmitExternalName = [&Sec, &OS]() {
130 if (Sec.hasExternalName())
131 OS << Sec.getName() << " ALIAS C'" << Sec.getExternalName() << "'\n";
132 };
133 switch (Sec.SymbolType) {
135 OS << Sec.getName() << " CSECT\n";
136 Sec.Emitted = true;
137 EmitExternalName();
138 break;
139 }
141 printSwitchToSection(*Sec.getParent(), Subsection, T, OS);
142 if (!Sec.Emitted) {
143 emitCATTR(OS, Sec.getName(), Sec.EDAttributes.Rmode,
144 Sec.EDAttributes.Alignment, Sec.EDAttributes.LoadBehavior,
145 GOFF::ESD_EXE_Unspecified, Sec.EDAttributes.IsReadOnly, 0,
146 Sec.EDAttributes.FillByteValue, StringRef());
147 if (auto *BeginSym = static_cast<MCSymbolGOFF *>(Sec.getBeginSymbol())) {
148 if (BeginSym->getADA())
149 emitXATTR(OS, BeginSym->getName(), BeginSym->getADA(),
152 }
153 Sec.Emitted = true;
154 EmitExternalName();
155 } else
156 OS << Sec.getName() << " CATTR\n";
157 break;
158 }
160 MCSectionGOFF *ED = Sec.getParent();
161 printSwitchToSection(*ED->getParent(), Subsection, T, OS);
162 if (!Sec.Emitted) {
163 emitCATTR(OS, ED->getName(), ED->getEDAttributes().Rmode,
165 Sec.PRAttributes.Executable, ED->EDAttributes.IsReadOnly,
166 Sec.PRAttributes.SortKey, ED->EDAttributes.FillByteValue,
167 Sec.getName());
168 MCSectionGOFF *ADA =
169 Sec.getBeginSymbol() != nullptr
170 ? static_cast<MCSymbolGOFF *>(Sec.getBeginSymbol())->getADA()
171 : nullptr;
172 emitXATTR(OS, Sec.getName(), ADA, Sec.PRAttributes.Linkage,
173 Sec.PRAttributes.Executable, Sec.PRAttributes.BindingScope);
174 ED->Emitted = true;
175 Sec.Emitted = true;
176 EmitExternalName();
177 } else
178 OS << ED->getName() << " CATTR PART(" << Sec.getName() << ")\n";
179 break;
180 }
181 default:
182 llvm_unreachable("Wrong section type");
183 }
184}
DXIL Finalize Linkage
static LVOptions Options
Definition LVOptions.cpp:25
static void emitCATTR(raw_ostream &OS, StringRef Name, GOFF::ESDRmode Rmode, GOFF::ESDAlignment Alignment, GOFF::ESDLoadingBehavior LoadBehavior, GOFF::ESDExecutable Executable, bool IsReadOnly, uint32_t SortKey, uint8_t FillByteValue, StringRef PartName)
static void emitXATTR(raw_ostream &OS, StringRef Name, MCSectionGOFF *ADA, GOFF::ESDLinkageType Linkage, GOFF::ESDExecutable Executable, GOFF::ESDBindingScope BindingScope)
This file defines certain target specific asm properties for GOFF (z/OS) based targets.
This file declares the MCSectionGOFF class, which contains all of the necessary machine code sections...
This file contains the MCSymbolGOFF class.
#define T
This file contains some functions that are useful when dealing with strings.
A helper class to return the specified delimiter string after the first invocation of operator String...
MCAsmInfoGOFF(const MCTargetOptions &Options)
StringRef InternalSymbolPrefix
For internal use by compiler and assembler, not meant to be visible externally.
Definition MCAsmInfo.h:162
const char * Data64bitsDirective
Definition MCAsmInfo.h:248
MCAsmInfo(const MCTargetOptions &Options)
Definition MCAsmInfo.cpp:44
const char * WeakRefDirective
This directive, if non-null, is used to declare a global as being a weak undefined symbol.
Definition MCAsmInfo.h:326
const char * ZeroDirective
This should be set to the directive used to get some number of zero (and non-zero if supported by the...
Definition MCAsmInfo.h:224
GOFF::EDAttr getEDAttributes() const
GOFF::EDAttr EDAttributes
MCSectionGOFF * getParent() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:573
StringRef getName() const
Definition MCSection.h:643
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ESDLoadingBehavior
Definition GOFF.h:127
@ ESD_LB_Deferred
Definition GOFF.h:129
@ ESD_LB_NoLoad
Definition GOFF.h:130
ESDExecutable
Definition GOFF.h:109
@ ESD_EXE_Unspecified
Definition GOFF.h:110
@ ESD_EXE_CODE
Definition GOFF.h:112
@ ESD_EXE_DATA
Definition GOFF.h:111
ESDAlignment
Definition GOFF.h:144
ESDBindingScope
Definition GOFF.h:134
@ ESD_BSC_Library
Definition GOFF.h:138
@ ESD_BSC_Module
Definition GOFF.h:137
@ ESD_BSC_Unspecified
Definition GOFF.h:135
@ ESD_BSC_ImportExport
Definition GOFF.h:139
@ ESD_BSC_Section
Definition GOFF.h:136
ESDLinkageType
Definition GOFF.h:142
@ ESD_LT_OS
Definition GOFF.h:142
@ ESD_LT_XPLink
Definition GOFF.h:142
@ ESD_ST_PartReference
Definition GOFF.h:57
@ ESD_ST_ElementDefinition
Definition GOFF.h:55
@ ESD_ST_SectionDefinition
Definition GOFF.h:54
@ ESD_RMODE_31
Definition GOFF.h:87
@ ESD_RMODE_None
Definition GOFF.h:85
@ ESD_RMODE_64
Definition GOFF.h:88
@ ESD_RMODE_24
Definition GOFF.h:86
This is an optimization pass for GlobalISel generic memory operations.
GOFF::ESDRmode Rmode
GOFF::ESDAlignment Alignment
GOFF::ESDLoadingBehavior LoadBehavior