1515#ifndef LLVM_MC_MCSECTIONGOFF_H
1616#define LLVM_MC_MCSECTIONGOFF_H
1717
18+ #include " llvm/ADT/BitmaskEnum.h"
1819#include " llvm/BinaryFormat/GOFF.h"
20+ #include " llvm/MC/MCGOFFAttributes.h"
1921#include " llvm/MC/MCSection.h"
2022#include " llvm/Support/raw_ostream.h"
2123
@@ -25,13 +27,38 @@ class MCExpr;
2527
2628class MCSectionGOFF final : public MCSection {
2729private:
28- MCSection *Parent;
29- uint32_t Subsection;
30+ // The names of the GOFF symbols.
31+ StringRef SDName;
32+ StringRef EDName;
33+ StringRef LDorPRName;
34+
35+ // The attributes of the GOFF symbols.
36+ GOFF::SDAttr SDAttributes;
37+ GOFF::EDAttr EDAttributes;
38+ GOFF::LDAttr LDAttributes;
39+ GOFF::PRAttr PRAttributes;
40+
41+ public:
42+ enum SectionFlags {
43+ UsesRootSD = 1 , // Uses the common root SD.
44+ HasLD = 2 , // Has a LD symbol.
45+ HasPR = 4 , // Has a PR symbol.
46+ LDorPRNameIsSD = 8 , // The LD or PR name is the same as the SD name.
47+ LLVM_MARK_AS_BITMASK_ENUM (/* LargestValue = */ 8 )
48+ };
49+
50+ private:
51+ SectionFlags Flags;
52+ bool IsADA;
3053
3154 friend class MCContext ;
32- MCSectionGOFF (StringRef Name, SectionKind K, MCSection *P, uint32_t Sub)
33- : MCSection(SV_GOFF, Name, K.isText(), /* IsVirtual=*/ false , nullptr ),
34- Parent (P), Subsection(Sub) {}
55+ MCSectionGOFF (StringRef SynName, SectionKind K, SectionFlags Flags,
56+ StringRef SDName, GOFF::SDAttr SDAttributes, StringRef EDName,
57+ GOFF::EDAttr EDAttributes, StringRef LDorPRName,
58+ GOFF::LDAttr LDAttributes, GOFF::PRAttr PRAttributes)
59+ : MCSection(SV_GOFF, SynName, K.isText(), /* IsVirtual=*/ false , nullptr ),
60+ SDName (SDName), EDName(EDName), LDorPRName(LDorPRName),
61+ SDAttributes(SDAttributes), EDAttributes(EDAttributes), Flags(Flags) {}
3562
3663public:
3764 void printSwitchToSection (const MCAsmInfo &MAI, const Triple &T,
@@ -42,8 +69,38 @@ class MCSectionGOFF final : public MCSection {
4269
4370 bool useCodeAlign () const override { return false ; }
4471
45- MCSection *getParent () const { return Parent; }
46- uint32_t getSubsection () const { return Subsection; }
72+ // Accessors to the various symbol names.
73+ StringRef getSDName () const { return SDName; };
74+ StringRef getEDName () const { return EDName; };
75+ StringRef getLDorPRName () const {
76+ assert (Flags & (HasLD | HasPR) && " LD/PR name not available" );
77+ return (Flags & LDorPRNameIsSD) ? SDName : LDorPRName;
78+ };
79+
80+ // Setters for the SD and LD/PR symbol names.
81+ void setSDName (StringRef Name) { SDName = Name; }
82+ void setLDorPRName (StringRef Name) { LDorPRName = Name; }
83+
84+ // Accessors to the various attributes.
85+ GOFF::SDAttr getSDAttributes () const { return SDAttributes; }
86+ GOFF::EDAttr getEDAttributes () const { return EDAttributes; }
87+ GOFF::LDAttr getLDAttributes () const {
88+ assert (Flags & HasLD && " LD not available" );
89+ return LDAttributes;
90+ }
91+ GOFF::PRAttr getPRAttributes () const {
92+ assert (Flags & HasPR && " PR not available" );
93+ return PRAttributes;
94+ }
95+
96+ // Query various flags.
97+ bool usesRootSD () const { return Flags & UsesRootSD; }
98+ bool hasLD () const { return Flags & HasLD; }
99+ bool hasPR () const { return Flags & HasPR; }
100+ bool isLDorPRNameTheSD () const { return Flags & LDorPRNameIsSD; }
101+
102+ bool isADA () const { return IsADA; }
103+ void setADA () { IsADA = true ; }
47104
48105 static bool classof (const MCSection *S) { return S->getVariant () == SV_GOFF; }
49106};
0 commit comments