LLVM 22.0.0git
MCSectionGOFF.h
Go to the documentation of this file.
1//===-- llvm/MC/MCSectionGOFF.h - GOFF Machine Code Sections ----*- 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 declares the MCSectionGOFF class, which contains all of the
11/// necessary machine code sections for the GOFF file format.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_MC_MCSECTIONGOFF_H
16#define LLVM_MC_MCSECTIONGOFF_H
17
20#include "llvm/MC/MCSection.h"
24
25namespace llvm {
26
27class MCExpr;
28
29class LLVM_ABI MCSectionGOFF final : public MCSection {
30 // Parent of this section. Implies that the parent is emitted first.
31 MCSectionGOFF *Parent;
32
33 // The attributes of the GOFF symbols.
34 union {
38 };
39
40 // The type of this section.
42
43 // This section is a BSS section.
44 unsigned IsBSS : 1;
45
46 // Indicates that the PR symbol needs to set the length of the section to a
47 // non-zero value. This is only a problem with the ADA PR - the binder will
48 // generate an error in this case.
49 unsigned RequiresNonZeroLength : 1;
50
51 // Set to true if the section definition was already emitted.
52 mutable unsigned Emitted : 1;
53
54 friend class MCContext;
55 friend class MCAsmInfoGOFF;
56 friend class MCSymbolGOFF;
57
58 MCSectionGOFF(StringRef Name, SectionKind K, bool IsVirtual,
59 GOFF::SDAttr SDAttributes, MCSectionGOFF *Parent)
60 : MCSection(Name, K.isText(), IsVirtual, nullptr), Parent(Parent),
61 SDAttributes(SDAttributes), SymbolType(GOFF::ESD_ST_SectionDefinition),
62 IsBSS(K.isBSS()), RequiresNonZeroLength(0), Emitted(0) {}
63
64 MCSectionGOFF(StringRef Name, SectionKind K, bool IsVirtual,
65 GOFF::EDAttr EDAttributes, MCSectionGOFF *Parent)
66 : MCSection(Name, K.isText(), IsVirtual, nullptr), Parent(Parent),
67 EDAttributes(EDAttributes), SymbolType(GOFF::ESD_ST_ElementDefinition),
68 IsBSS(K.isBSS()), RequiresNonZeroLength(0), Emitted(0) {}
69
70 MCSectionGOFF(StringRef Name, SectionKind K, bool IsVirtual,
71 GOFF::PRAttr PRAttributes, MCSectionGOFF *Parent)
72 : MCSection(Name, K.isText(), IsVirtual, nullptr), Parent(Parent),
73 PRAttributes(PRAttributes), SymbolType(GOFF::ESD_ST_PartReference),
74 IsBSS(K.isBSS()), RequiresNonZeroLength(0), Emitted(0) {}
75
76public:
77 // Return the parent section.
78 MCSectionGOFF *getParent() const { return Parent; }
79
80 // Returns true if this is a BSS section.
81 bool isBSS() const { return IsBSS; }
82
83 // Returns the type of this section.
85
86 bool isSD() const { return SymbolType == GOFF::ESD_ST_SectionDefinition; }
87 bool isED() const { return SymbolType == GOFF::ESD_ST_ElementDefinition; }
88 bool isPR() const { return SymbolType == GOFF::ESD_ST_PartReference; }
89
90 // Accessors to the attributes.
92 assert(isSD() && "Not a SD section");
93 return SDAttributes;
94 }
96 assert(isED() && "Not a ED section");
97 return EDAttributes;
98 }
100 assert(isPR() && "Not a PR section");
101 return PRAttributes;
102 }
103
104 // Returns the text style for a section. Only defined for ED and PR sections.
106 assert((isED() || isPR() || isBssSection()) && "Expect ED or PR section");
107 if (isED())
108 return EDAttributes.TextStyle;
109 if (isPR())
110 return getParent()->getEDAttributes().TextStyle;
111 // Virtual sections have no data, so byte orientation is fine.
112 return GOFF::ESD_TS_ByteOriented;
113 }
114
115 bool requiresNonZeroLength() const { return RequiresNonZeroLength; }
116
118};
119} // end namespace llvm
120
121#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static const Function * getParent(const Value *V)
#define LLVM_ABI
Definition: Compiler.h:213
std::string Name
Context object for machine code objects.
Definition: MCContext.h:83
GOFF::SDAttr getSDAttributes() const
Definition: MCSectionGOFF.h:91
GOFF::ESDSymbolType getSymbolType() const
Definition: MCSectionGOFF.h:84
GOFF::SDAttr SDAttributes
Definition: MCSectionGOFF.h:35
bool isPR() const
Definition: MCSectionGOFF.h:88
GOFF::EDAttr getEDAttributes() const
Definition: MCSectionGOFF.h:95
GOFF::PRAttr getPRAttributes() const
Definition: MCSectionGOFF.h:99
bool requiresNonZeroLength() const
GOFF::PRAttr PRAttributes
Definition: MCSectionGOFF.h:37
void setName(StringRef SectionName)
bool isBSS() const
Definition: MCSectionGOFF.h:81
GOFF::ESDTextStyle getTextStyle() const
bool isSD() const
Definition: MCSectionGOFF.h:86
bool isED() const
Definition: MCSectionGOFF.h:87
GOFF::EDAttr EDAttributes
Definition: MCSectionGOFF.h:36
MCSectionGOFF * getParent() const
Definition: MCSectionGOFF.h:78
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:496
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
ESDTextStyle
Definition: GOFF.h:91
ESDSymbolType
Definition: GOFF.h:53
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18