summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Nacke <kai.peter.nacke@ibm.com>2025-11-21 18:15:07 -0500
committerKai Nacke <kai.peter.nacke@ibm.com>2025-11-21 18:15:07 -0500
commit9c35da10f0e210ed7aac4ec6ef3e03bd4bc4c260 (patch)
tree6d26cbc56d9fddd8dbaaf18068b83816e44e9e39
parent1f4399374acfb1b4cd5a7995af0ce9d4205c2230 (diff)
Remove LDAttr/ERAttr and initAttributes.users/redstar/goffwriter-5
-rw-r--r--llvm/include/llvm/MC/MCSymbolGOFF.h30
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp7
-rw-r--r--llvm/lib/MC/MCGOFFStreamer.cpp9
-rw-r--r--llvm/lib/MC/MCSymbolGOFF.cpp46
-rw-r--r--llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.cpp25
5 files changed, 48 insertions, 69 deletions
diff --git a/llvm/include/llvm/MC/MCSymbolGOFF.h b/llvm/include/llvm/MC/MCSymbolGOFF.h
index 61a5db3d8354..7e9765330e1c 100644
--- a/llvm/include/llvm/MC/MCSymbolGOFF.h
+++ b/llvm/include/llvm/MC/MCSymbolGOFF.h
@@ -25,38 +25,22 @@ class MCSymbolGOFF : public MCSymbol {
// Associated data area of the section. Needs to be emitted first.
MCSectionGOFF *ADA = nullptr;
- GOFF::LDAttr LDAttributes;
- GOFF::ERAttr ERAttributes;
-
GOFF::ESDExecutable CodeData = GOFF::ESDExecutable::ESD_EXE_Unspecified;
GOFF::ESDLinkageType Linkage = GOFF::ESDLinkageType::ESD_LT_XPLink;
enum SymbolFlags : uint16_t {
- SF_LD = 0x01, // LD attributes are set.
- SF_ER = 0x02, // ER attributes are set.
- SF_Hidden = 0x04, // Symbol is hidden, aka not exported.
- SF_Weak = 0x08, // Symbol is weak.
+ SF_Hidden = 0x01, // Symbol is hidden, aka not exported.
+ SF_Weak = 0x02, // Symbol is weak.
};
public:
MCSymbolGOFF(const MCSymbolTableEntry *Name, bool IsTemporary)
: MCSymbol(Name, IsTemporary) {}
- void setLDAttributes(GOFF::LDAttr Attr) {
- modifyFlags(SF_LD, SF_LD);
- LDAttributes = Attr;
- }
- const GOFF::LDAttr &getLDAttributes() const { return LDAttributes; }
- GOFF::LDAttr &getLDAttributes() { return LDAttributes; }
- bool hasLDAttributes() const { return getFlags() & SF_LD; }
-
- void setERAttributes(GOFF::ERAttr Attr) {
- modifyFlags(SF_ER, SF_ER);
- ERAttributes = Attr;
- }
- const GOFF::ERAttr &getERAttributes() const { return ERAttributes; }
- GOFF::ERAttr &getERAttributes() { return ERAttributes; }
- bool hasERAttributes() const { return getFlags() & SF_ER; }
+ GOFF::LDAttr getLDAttributes() const;
+ bool hasLDAttributes() const;
+ GOFF::ERAttr getERAttributes() const;
+ bool hasERAttributes() const;
void setADA(MCSectionGOFF *AssociatedDataArea) {
ADA = AssociatedDataArea;
@@ -81,8 +65,6 @@ public:
void setLinkage(GOFF::ESDLinkageType Value) { Linkage = Value; }
GOFF::ESDLinkageType getLinkage() const { return Linkage; }
-
- void initAttributes();
};
} // end namespace llvm
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index ae681b9aebdf..5edbc4caf3fa 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -2788,9 +2788,10 @@ void TargetLoweringObjectFileGOFF::getModuleMetadata(Module &M) {
// Initialize the label for the text section.
MCSymbolGOFF *TextLD = static_cast<MCSymbolGOFF *>(
getContext().getOrCreateSymbol(RootSD->getName()));
- TextLD->setLDAttributes(GOFF::LDAttr{
- false, GOFF::ESD_EXE_CODE, GOFF::ESD_BST_Strong, GOFF::ESD_LT_XPLink,
- GOFF::ESD_AMODE_64, GOFF::ESD_BSC_Section});
+ TextLD->setCodeData(GOFF::ESD_EXE_CODE);
+ TextLD->setLinkage(GOFF::ESD_LT_XPLink);
+ TextLD->setExternal(false);
+ TextLD->setWeak(false);
TextLD->setADA(ADAPR);
TextSection->setBeginSymbol(TextLD);
}
diff --git a/llvm/lib/MC/MCGOFFStreamer.cpp b/llvm/lib/MC/MCGOFFStreamer.cpp
index e462864b5505..2fc50b0c3f11 100644
--- a/llvm/lib/MC/MCGOFFStreamer.cpp
+++ b/llvm/lib/MC/MCGOFFStreamer.cpp
@@ -57,7 +57,6 @@ void MCGOFFStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
void MCGOFFStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
MCObjectStreamer::emitLabel(Symbol, Loc);
- static_cast<MCSymbolGOFF *>(Symbol)->initAttributes();
}
bool MCGOFFStreamer::emitSymbolAttribute(MCSymbol *Sym,
@@ -121,14 +120,6 @@ bool MCGOFFStreamer::emitSymbolAttribute(MCSymbol *Sym,
}
void MCGOFFStreamer::emitExterns() {
- for (auto &Symbol : getAssembler().symbols()) {
- if (Symbol.isTemporary())
- continue;
- if (Symbol.isRegistered()) {
- auto &Sym = static_cast<MCSymbolGOFF &>(const_cast<MCSymbol &>(Symbol));
- Sym.initAttributes();
- }
- }
}
MCStreamer *llvm::createGOFFStreamer(MCContext &Context,
diff --git a/llvm/lib/MC/MCSymbolGOFF.cpp b/llvm/lib/MC/MCSymbolGOFF.cpp
index 345572418ecd..cd55c759614e 100644
--- a/llvm/lib/MC/MCSymbolGOFF.cpp
+++ b/llvm/lib/MC/MCSymbolGOFF.cpp
@@ -12,14 +12,13 @@
using namespace llvm;
-void MCSymbolGOFF::initAttributes() {
- // Temporary labels are not emitted into the object file.
- if (isTemporary())
- return;
+bool MCSymbolGOFF::hasLDAttributes() const {
+ return !isTemporary() && isDefined() &&
+ static_cast<MCSectionGOFF &>(getSection()).isED();
+}
- // Do not initialize the attributes multiple times.
- if (hasLDAttributes() || hasERAttributes())
- return;
+GOFF::LDAttr MCSymbolGOFF::getLDAttributes() const {
+ assert(hasLDAttributes() && "Symbol does not have LD attributes");
GOFF::ESDBindingScope BindingScope =
isExternal()
@@ -28,19 +27,24 @@ void MCSymbolGOFF::initAttributes() {
GOFF::ESDBindingStrength BindingStrength =
isWeak() ? GOFF::ESDBindingStrength::ESD_BST_Weak
: GOFF::ESDBindingStrength::ESD_BST_Strong;
+ return GOFF::LDAttr{false, CodeData, BindingStrength,
+ Linkage, GOFF::ESD_AMODE_64, BindingScope};
+}
+
+bool MCSymbolGOFF::hasERAttributes() const {
+ return !isTemporary() && !isDefined() && isExternal();
+}
+
+GOFF::ERAttr MCSymbolGOFF::getERAttributes() const {
+ assert(hasERAttributes() && "Symbol does not have ER attributes");
- if (isDefined()) {
- MCSectionGOFF &Section = static_cast<MCSectionGOFF &>(getSection());
- if (Section.isED()) {
- setLDAttributes(GOFF::LDAttr{false, CodeData, BindingStrength, Linkage,
- GOFF::ESD_AMODE_64, BindingScope});
- } else if (Section.isPR()) {
- // For data symbols, the attributes are already determind in TLOFI.
- // TODO Does it make sense to it to here?
- } else
- llvm_unreachable("Unexpected section type for label");
- } else {
- setERAttributes(GOFF::ERAttr{CodeData, BindingStrength, Linkage,
- GOFF::ESD_AMODE_64, BindingScope});
- }
+ GOFF::ESDBindingScope BindingScope =
+ isExternal()
+ ? (isExported() ? GOFF::ESD_BSC_ImportExport : GOFF::ESD_BSC_Library)
+ : GOFF::ESD_BSC_Section;
+ GOFF::ESDBindingStrength BindingStrength =
+ isWeak() ? GOFF::ESDBindingStrength::ESD_BST_Weak
+ : GOFF::ESDBindingStrength::ESD_BST_Strong;
+ return GOFF::ERAttr{CodeData, BindingStrength, Linkage, GOFF::ESD_AMODE_64,
+ BindingScope};
}
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.cpp
index fe2470e37435..b44cea33bd3b 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.cpp
@@ -236,13 +236,12 @@ void SystemZHLASMAsmStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
MCSymbolGOFF *Sym = static_cast<MCSymbolGOFF *>(Symbol);
MCStreamer::emitLabel(Sym, Loc);
- Sym->initAttributes();
// Emit ENTRY statement only if not implied by CSECT.
bool EmitEntry = !sameNameAsCSECT(Sym);
if (!Sym->isTemporary() && Sym->hasLDAttributes()) {
- GOFF::LDAttr &LD = Sym->getLDAttributes();
+ GOFF::LDAttr LD = Sym->getLDAttributes();
if (EmitEntry) {
OS << " ENTRY " << Sym->getName();
EmitEOL();
@@ -419,16 +418,18 @@ void SystemZHLASMAsmStreamer::emitExterns() {
continue;
if (Symbol.isRegistered()) {
auto &Sym = static_cast<MCSymbolGOFF &>(const_cast<MCSymbol &>(Symbol));
- Sym.initAttributes();
- GOFF::ERAttr &ER = Sym.getERAttributes();
- OS << " "
- << (ER.BindingStrength == GOFF::ESDBindingStrength::ESD_BST_Weak
- ? "WXTRN"
- : "EXTRN")
- << " " << Sym.getName();
- EmitEOL();
- emitXATTR(OS, Sym.getName(), ER.Linkage, ER.Executable, ER.BindingScope);
- EmitEOL();
+ if (Sym.hasERAttributes()) {
+ GOFF::ERAttr ER = Sym.getERAttributes();
+ OS << " "
+ << (ER.BindingStrength == GOFF::ESDBindingStrength::ESD_BST_Weak
+ ? "WXTRN"
+ : "EXTRN")
+ << " " << Sym.getName();
+ EmitEOL();
+ emitXATTR(OS, Sym.getName(), ER.Linkage, ER.Executable,
+ ER.BindingScope);
+ EmitEOL();
+ }
}
}
}