Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.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
19
20using namespace llvm;
21
23 Data64bitsDirective = "\t.quad\t";
26 PrivateLabelPrefix = "L#";
27 ZeroDirective = "\t.space\t";
28}
29
30static void emitCATTR(raw_ostream &OS, StringRef Name, GOFF::ESDRmode Rmode,
31 GOFF::ESDAlignment Alignment,
32 GOFF::ESDLoadingBehavior LoadBehavior,
33 GOFF::ESDExecutable Executable, bool IsReadOnly,
34 uint32_t SortKey, uint8_t FillByteValue,
35 StringRef PartName) {
36 OS << Name << " CATTR ";
37 OS << "ALIGN(" << static_cast<unsigned>(Alignment) << "),"
38 << "FILL(" << static_cast<unsigned>(FillByteValue) << ")";
39 switch (LoadBehavior) {
41 OS << ",DEFLOAD";
42 break;
44 OS << ",NOLOAD";
45 break;
46 default:
47 break;
48 }
49 switch (Executable) {
51 OS << ",EXECUTABLE";
52 break;
54 OS << ",NOTEXECUTABLE";
55 break;
56 default:
57 break;
58 }
59 if (IsReadOnly)
60 OS << ",READONLY";
61 if (Rmode != GOFF::ESD_RMODE_None) {
62 OS << ',';
63 OS << "RMODE(";
64 switch (Rmode) {
68 OS << "24";
69 break;
71 OS << "31";
72 break;
74 OS << "64";
75 break;
76 }
77 OS << ')';
78 }
79 if (SortKey)
80 OS << ",PRIORITY(" << SortKey << ")";
81 if (!PartName.empty())
82 OS << ",PART(" << PartName << ")";
83 OS << '\n';
84}
85
86static void emitXATTR(raw_ostream &OS, StringRef Name,
88 GOFF::ESDExecutable Executable,
89 GOFF::ESDBindingScope BindingScope) {
90 OS << Name << " XATTR ";
91 OS << "LINKAGE(" << (Linkage == GOFF::ESD_LT_OS ? "OS" : "XPLINK") << "),";
92 if (Executable != GOFF::ESD_EXE_Unspecified)
93 OS << "REFERENCE(" << (Executable == GOFF::ESD_EXE_CODE ? "CODE" : "DATA")
94 << "),";
95 if (BindingScope != GOFF::ESD_BSC_Unspecified) {
96 OS << "SCOPE(";
97 switch (BindingScope) {
99 OS << "SECTION";
100 break;
102 OS << "MODULE";
103 break;
105 OS << "LIBRARY";
106 break;
108 OS << "EXPORT";
109 break;
110 default:
111 break;
112 }
113 OS << ')';
114 }
115 OS << '\n';
116}
117
118void MCAsmInfoGOFF::printSwitchToSection(const MCSection &Section,
119 uint32_t Subsection, const Triple &T,
120 raw_ostream &OS) const {
121 auto &Sec =
122 const_cast<MCSectionGOFF &>(static_cast<const MCSectionGOFF &>(Section));
123 switch (Sec.SymbolType) {
125 OS << Sec.getName() << " CSECT\n";
126 Sec.Emitted = true;
127 break;
128 }
130 printSwitchToSection(*Sec.getParent(), Subsection, T, OS);
131 if (!Sec.Emitted) {
132 emitCATTR(OS, Sec.getName(), Sec.EDAttributes.Rmode,
133 Sec.EDAttributes.Alignment, Sec.EDAttributes.LoadBehavior,
134 GOFF::ESD_EXE_Unspecified, Sec.EDAttributes.IsReadOnly, 0,
135 Sec.EDAttributes.FillByteValue, StringRef());
136 Sec.Emitted = true;
137 } else
138 OS << Sec.getName() << " CATTR\n";
139 break;
140 }
142 MCSectionGOFF *ED = Sec.getParent();
143 printSwitchToSection(*ED->getParent(), Subsection, T, OS);
144 if (!Sec.Emitted) {
145 emitCATTR(OS, ED->getName(), ED->getEDAttributes().Rmode,
147 Sec.PRAttributes.Executable, ED->EDAttributes.IsReadOnly,
148 Sec.PRAttributes.SortKey, ED->EDAttributes.FillByteValue,
149 Sec.getName());
150 emitXATTR(OS, Sec.getName(), Sec.PRAttributes.Linkage,
151 Sec.PRAttributes.Executable, Sec.PRAttributes.BindingScope);
152 ED->Emitted = true;
153 Sec.Emitted = true;
154 } else
155 OS << ED->getName() << " CATTR PART(" << Sec.getName() << ")\n";
156 break;
157 }
158 default:
159 llvm_unreachable("Wrong section type");
160 }
161}
DXIL Finalize Linkage
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, 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...
#define T
const char * Data64bitsDirective
Definition MCAsmInfo.h:250
StringRef PrivateGlobalPrefix
This prefix is used for globals like constant pool entries that are completely private to the ....
Definition MCAsmInfo.h:160
StringRef PrivateLabelPrefix
This prefix is used for labels for basic blocks.
Definition MCAsmInfo.h:164
bool HasDotTypeDotSizeDirective
True if the target has .type and .size directives, this is true for most ELF targets.
Definition MCAsmInfo.h:306
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:226
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:521
StringRef getName() const
Definition MCSection.h:590
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
constexpr bool empty() const
empty - Check if the string is empty.
Definition StringRef.h:143
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_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