LLVM 22.0.0git
GOFF.h
Go to the documentation of this file.
1//===-- llvm/BinaryFormat/GOFF.h - GOFF definitions --------------*- 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// This header contains common, non-processor-specific data structures and
10// constants for the GOFF file format.
11//
12// GOFF specifics can be found in MVS Program Management: Advanced Facilities.
13// See
14// https://www.ibm.com/docs/en/zos/3.1.0?topic=facilities-generalized-object-file-format-goff
15//
16//===----------------------------------------------------------------------===//
17
18#ifndef LLVM_BINARYFORMAT_GOFF_H
19#define LLVM_BINARYFORMAT_GOFF_H
20
22
23namespace llvm {
24
25namespace GOFF {
26
27/// \brief Length of the parts of a physical GOFF record.
28constexpr uint8_t RecordLength = 80;
30constexpr uint8_t PayloadLength = 77;
32
33/// \brief Maximum data length before starting a new card for RLD and TXT data.
34///
35/// The maximum number of bytes that can be included in an RLD or TXT record and
36/// their continuations is a SIGNED 16 bit int despite what the spec says. The
37/// number of bytes we allow ourselves to attach to a card is thus arbitrarily
38/// limited to 32K-1 bytes.
39constexpr uint16_t MaxDataLength = 32 * 1024 - 1;
40
41/// \brief Prefix byte on every record. This indicates GOFF format.
42constexpr uint8_t PTVPrefix = 0x03;
43
45 RT_ESD = 0,
46 RT_TXT = 1,
47 RT_RLD = 2,
48 RT_LEN = 3,
49 RT_END = 4,
50 RT_HDR = 15,
51};
52
60
67
74
83
90
96
101
108
114
121
126
133
141
143
159
168
175
180
182
189
190// \brief Subsections of the primary C_CODE section in the object file.
195
196// The standard System/390 convention is to name the high-order (leftmost) bit
197// in a byte as bit zero. The Flags type helps to set bits in byte according
198// to this numeration order.
199class Flags {
200 uint8_t Val = 0;
201
202 constexpr static uint8_t bits(uint8_t BitIndex, uint8_t Length, uint8_t Value,
203 uint8_t OldValue) {
204 uint8_t Pos = 8 - BitIndex - Length;
205 uint8_t Mask = ((1 << Length) - 1) << Pos;
206 Value = Value << Pos;
207 return (OldValue & ~Mask) | Value;
208 }
209
210public:
211 constexpr Flags() = default;
212 constexpr Flags(uint8_t BitIndex, uint8_t Length, uint8_t Value)
213 : Val(bits(BitIndex, Length, Value, 0)) {}
214
215 template <typename T>
216 constexpr void set(uint8_t BitIndex, uint8_t Length, T NewValue) {
217 Val = bits(BitIndex, Length, static_cast<uint8_t>(NewValue), Val);
218 }
219
220 template <typename T>
221 constexpr T get(uint8_t BitIndex, uint8_t Length) const {
222 return static_cast<T>((Val >> (8 - BitIndex - Length)) &
223 ((1 << Length) - 1));
224 }
225
226 constexpr operator uint8_t() const { return Val; }
227};
228
229// Structure for the flag field of a symbol. See
230// https://www.ibm.com/docs/en/zos/3.1.0?topic=formats-external-symbol-definition-record
231// at offset 41 for the definition.
234
235#define GOFF_SYMBOL_FLAG(NAME, TYPE, BITINDEX, LENGTH) \
236 void set##NAME(TYPE Val) { SymFlags.set<TYPE>(BITINDEX, LENGTH, Val); } \
237 TYPE get##NAME() const { return SymFlags.get<TYPE>(BITINDEX, LENGTH); }
238
239 GOFF_SYMBOL_FLAG(FillBytePresence, bool, 0, 1)
240 GOFF_SYMBOL_FLAG(Mangled, bool, 1, 1)
241 GOFF_SYMBOL_FLAG(Renameable, bool, 2, 1)
242 GOFF_SYMBOL_FLAG(RemovableClass, bool, 3, 1)
243 GOFF_SYMBOL_FLAG(ReservedQwords, ESDReserveQwords, 5, 3)
244
245#undef GOFF_SYMBOL_FLAG
246
247 constexpr operator uint8_t() const { return static_cast<uint8_t>(SymFlags); }
248};
249
250// Structure for the behavioral attributes. See
251// https://www.ibm.com/docs/en/zos/3.1.0?topic=record-external-symbol-definition-behavioral-attributes
252// for the definition.
255
256#define GOFF_BEHAVIORAL_ATTRIBUTE(NAME, TYPE, ATTRIDX, BITINDEX, LENGTH) \
257 void set##NAME(TYPE Val) { Attr[ATTRIDX].set<TYPE>(BITINDEX, LENGTH, Val); } \
258 TYPE get##NAME() const { return Attr[ATTRIDX].get<TYPE>(BITINDEX, LENGTH); }
259
261 GOFF_BEHAVIORAL_ATTRIBUTE(Rmode, GOFF::ESDRmode, 1, 0, 8)
262 GOFF_BEHAVIORAL_ATTRIBUTE(TextStyle, GOFF::ESDTextStyle, 2, 0, 4)
264 4)
265 GOFF_BEHAVIORAL_ATTRIBUTE(TaskingBehavior, GOFF::ESDTaskingBehavior, 3, 0, 3)
266 GOFF_BEHAVIORAL_ATTRIBUTE(ReadOnly, bool, 3, 4, 1)
267 GOFF_BEHAVIORAL_ATTRIBUTE(Executable, GOFF::ESDExecutable, 3, 5, 3)
268 GOFF_BEHAVIORAL_ATTRIBUTE(DuplicateSymbolSeverity,
270 GOFF_BEHAVIORAL_ATTRIBUTE(BindingStrength, GOFF::ESDBindingStrength, 4, 4, 4)
271 GOFF_BEHAVIORAL_ATTRIBUTE(LoadingBehavior, GOFF::ESDLoadingBehavior, 5, 0, 2)
272 GOFF_BEHAVIORAL_ATTRIBUTE(COMMON, bool, 5, 2, 1)
273 GOFF_BEHAVIORAL_ATTRIBUTE(IndirectReference, bool, 5, 3, 1)
274 GOFF_BEHAVIORAL_ATTRIBUTE(BindingScope, GOFF::ESDBindingScope, 5, 4, 4)
275 GOFF_BEHAVIORAL_ATTRIBUTE(LinkageType, GOFF::ESDLinkageType, 6, 2, 1)
276 GOFF_BEHAVIORAL_ATTRIBUTE(Alignment, GOFF::ESDAlignment, 6, 3, 5)
277
278#undef GOFF_BEHAVIORAL_ATTRIBUTE
279};
280} // end namespace GOFF
281
282} // end namespace llvm
283
284#endif // LLVM_BINARYFORMAT_GOFF_H
#define GOFF_BEHAVIORAL_ATTRIBUTE(NAME, TYPE, ATTRIDX, BITINDEX, LENGTH)
Definition GOFF.h:256
#define GOFF_SYMBOL_FLAG(NAME, TYPE, BITINDEX, LENGTH)
Definition GOFF.h:235
#define T
constexpr Flags(uint8_t BitIndex, uint8_t Length, uint8_t Value)
Definition GOFF.h:212
constexpr Flags()=default
constexpr T get(uint8_t BitIndex, uint8_t Length) const
Definition GOFF.h:221
constexpr void set(uint8_t BitIndex, uint8_t Length, T NewValue)
Definition GOFF.h:216
LLVM Value Representation.
Definition Value.h:75
ESDLoadingBehavior
Definition GOFF.h:127
@ ESD_LB_Deferred
Definition GOFF.h:129
@ ESD_LB_NoLoad
Definition GOFF.h:130
@ ESD_LB_Initial
Definition GOFF.h:128
@ ESD_LB_Reserved
Definition GOFF.h:131
RecordType
Definition GOFF.h:44
@ RT_RLD
Definition GOFF.h:47
@ RT_TXT
Definition GOFF.h:46
@ RT_ESD
Definition GOFF.h:45
@ RT_LEN
Definition GOFF.h:48
@ RT_HDR
Definition GOFF.h:50
@ RT_END
Definition GOFF.h:49
ESDBindingAlgorithm
Definition GOFF.h:97
@ ESD_BA_Concatenate
Definition GOFF.h:98
@ ESD_BA_Merge
Definition GOFF.h:99
@ RLD_ACT_Subtract
Definition GOFF.h:178
@ RLD_ACT_Add
Definition GOFF.h:177
ESDDuplicateSymbolSeverity
Definition GOFF.h:115
@ ESD_DSS_NoWarning
Definition GOFF.h:116
@ ESD_DSS_Warning
Definition GOFF.h:117
@ ESD_DSS_Error
Definition GOFF.h:118
@ ESD_DSS_Reserved
Definition GOFF.h:119
constexpr uint8_t RecordPrefixLength
Definition GOFF.h:29
RLDFetchStore
Definition GOFF.h:181
@ RLD_FS_Store
Definition GOFF.h:181
@ RLD_FS_Fetch
Definition GOFF.h:181
constexpr uint8_t PayloadLength
Definition GOFF.h:30
ESDTextStyle
Definition GOFF.h:91
@ ESD_TS_Unstructured
Definition GOFF.h:94
@ ESD_TS_Structured
Definition GOFF.h:93
@ ESD_TS_ByteOriented
Definition GOFF.h:92
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
constexpr uint8_t RecordContentLength
Definition GOFF.h:31
ESDReserveQwords
Definition GOFF.h:68
@ ESD_RQ_3
Definition GOFF.h:72
@ ESD_RQ_1
Definition GOFF.h:70
@ ESD_RQ_0
Definition GOFF.h:69
@ ESD_RQ_2
Definition GOFF.h:71
constexpr uint16_t MaxDataLength
Maximum data length before starting a new card for RLD and TXT data.
Definition GOFF.h:39
ENDEntryPointRequest
Definition GOFF.h:183
@ END_EPR_EsdidOffset
Definition GOFF.h:185
@ END_EPR_ExternalName
Definition GOFF.h:186
@ END_EPR_Reserved
Definition GOFF.h:187
@ END_EPR_None
Definition GOFF.h:184
ESDAlignment
Definition GOFF.h:144
@ ESD_ALIGN_Doubleword
Definition GOFF.h:148
@ ESD_ALIGN_512byte
Definition GOFF.h:154
@ ESD_ALIGN_1024byte
Definition GOFF.h:155
@ ESD_ALIGN_Quadword
Definition GOFF.h:149
@ ESD_ALIGN_2Kpage
Definition GOFF.h:156
@ ESD_ALIGN_256byte
Definition GOFF.h:153
@ ESD_ALIGN_32byte
Definition GOFF.h:150
@ ESD_ALIGN_128byte
Definition GOFF.h:152
@ ESD_ALIGN_64byte
Definition GOFF.h:151
@ ESD_ALIGN_Byte
Definition GOFF.h:145
@ ESD_ALIGN_Fullword
Definition GOFF.h:147
@ ESD_ALIGN_4Kpage
Definition GOFF.h:157
@ ESD_ALIGN_Halfword
Definition GOFF.h:146
RLDReferenceType
Definition GOFF.h:160
@ RLD_RT_RLength
Definition GOFF.h:163
@ RLD_RT_RAddress
Definition GOFF.h:161
@ RLD_RT_RLongDisplacement
Definition GOFF.h:166
@ RLD_RT_RRelativeImmediate
Definition GOFF.h:164
@ RLD_RT_ROffset
Definition GOFF.h:162
@ RLD_RT_RTypeConstant
Definition GOFF.h:165
@ ESD_AMODE_MIN
Definition GOFF.h:81
@ ESD_AMODE_None
Definition GOFF.h:76
@ ESD_AMODE_31
Definition GOFF.h:78
@ ESD_AMODE_24
Definition GOFF.h:77
@ ESD_AMODE_ANY
Definition GOFF.h:79
@ ESD_AMODE_64
Definition GOFF.h:80
RLDReferentType
Definition GOFF.h:169
@ RLD_RO_Label
Definition GOFF.h:170
@ RLD_RO_Element
Definition GOFF.h:171
@ RLD_RO_Part
Definition GOFF.h:173
@ RLD_RO_Class
Definition GOFF.h:172
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
constexpr uint8_t PTVPrefix
Prefix byte on every record. This indicates GOFF format.
Definition GOFF.h:42
ESDLinkageType
Definition GOFF.h:142
@ ESD_LT_OS
Definition GOFF.h:142
@ ESD_LT_XPLink
Definition GOFF.h:142
constexpr uint8_t RecordLength
Length of the parts of a physical GOFF record.
Definition GOFF.h:28
SubsectionKind
Definition GOFF.h:191
@ SK_PPA1
Definition GOFF.h:192
@ SK_PPA2
Definition GOFF.h:193
ESDNameSpaceId
Definition GOFF.h:61
@ ESD_NS_Parts
Definition GOFF.h:65
@ ESD_NS_ProgramManagementBinder
Definition GOFF.h:62
@ ESD_NS_NormalName
Definition GOFF.h:63
@ ESD_NS_PseudoRegister
Definition GOFF.h:64
ESDSymbolType
Definition GOFF.h:53
@ ESD_ST_PartReference
Definition GOFF.h:57
@ ESD_ST_ElementDefinition
Definition GOFF.h:55
@ ESD_ST_LabelDefinition
Definition GOFF.h:56
@ ESD_ST_SectionDefinition
Definition GOFF.h:54
@ ESD_ST_ExternalReference
Definition GOFF.h:58
ESDTaskingBehavior
Definition GOFF.h:102
@ ESD_TA_Reus
Definition GOFF.h:105
@ ESD_TA_Unspecified
Definition GOFF.h:103
@ ESD_TA_NonReus
Definition GOFF.h:104
@ ESD_TA_Rent
Definition GOFF.h:106
ESDBindingStrength
Definition GOFF.h:122
@ ESD_BST_Strong
Definition GOFF.h:123
@ ESD_BST_Weak
Definition GOFF.h:124
@ 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.
@ Length
Definition DWP.cpp:532
GOFF_BEHAVIORAL_ATTRIBUTE(BindingAlgorithm, GOFF::ESDBindingAlgorithm, 2, 4, 4) GOFF_BEHAVIORAL_ATTRIBUTE(DuplicateSymbolSeverity