mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-21 06:30:16 +00:00
Provide general hook for section name calculation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53304 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6d82942092
commit
265c5259ab
@ -481,11 +481,14 @@ namespace llvm {
|
|||||||
/// global with all necessary flags and marks.
|
/// global with all necessary flags and marks.
|
||||||
virtual std::string SectionForGlobal(const GlobalValue *GV) const;
|
virtual std::string SectionForGlobal(const GlobalValue *GV) const;
|
||||||
|
|
||||||
|
// Helper methods for SectionForGlobal
|
||||||
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
|
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
|
||||||
SectionKind::Kind kind) const;
|
SectionKind::Kind kind) const;
|
||||||
|
|
||||||
virtual std::string PrintSectionFlags(unsigned flags) const { return ""; }
|
virtual std::string PrintSectionFlags(unsigned flags) const { return ""; }
|
||||||
|
|
||||||
|
virtual std::string SelectSectionForGlobal(const GlobalValue *GV) const;
|
||||||
|
|
||||||
// Accessors.
|
// Accessors.
|
||||||
//
|
//
|
||||||
const char *getTextSection() const {
|
const char *getTextSection() const {
|
||||||
|
@ -257,12 +257,43 @@ TargetAsmInfo::SectionFlagsForGlobal(const GlobalValue *GV,
|
|||||||
|
|
||||||
std::string
|
std::string
|
||||||
TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
|
TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
|
||||||
|
unsigned flags = SectionFlagsForGlobal(GV, GV->getSection().c_str());
|
||||||
|
|
||||||
|
std::string Name;
|
||||||
|
|
||||||
|
// Select section name
|
||||||
|
if (GV->hasSection()) {
|
||||||
|
// Honour section already set, if any
|
||||||
|
Name = GV->getSection();
|
||||||
|
} else {
|
||||||
|
// Use default section depending on the 'type' of global
|
||||||
|
Name = SelectSectionForGlobal(GV);
|
||||||
|
}
|
||||||
|
|
||||||
|
Name += PrintSectionFlags(flags);
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lame default implementation. Calculate the section name for global.
|
||||||
|
std::string
|
||||||
|
TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
||||||
SectionKind::Kind kind = SectionKindForGlobal(GV);
|
SectionKind::Kind kind = SectionKindForGlobal(GV);
|
||||||
|
|
||||||
if (kind == SectionKind::Text)
|
if (GV->hasLinkOnceLinkage() ||
|
||||||
return getTextSection();
|
GV->hasWeakLinkage() ||
|
||||||
else if (kind == SectionKind::BSS && getBSSSection())
|
GV->hasCommonLinkage())
|
||||||
return getBSSSection();
|
return UniqueSectionForGlobal(GV, kind);
|
||||||
|
else {
|
||||||
|
if (kind == SectionKind::Text)
|
||||||
|
return getTextSection();
|
||||||
|
else if (kind == SectionKind::BSS && getBSSSection())
|
||||||
|
return getBSSSection();
|
||||||
|
else if (getReadOnlySection() &&
|
||||||
|
(kind == SectionKind::ROData ||
|
||||||
|
kind == SectionKind::RODataMergeConst ||
|
||||||
|
kind == SectionKind::RODataMergeStr))
|
||||||
|
return getReadOnlySection();
|
||||||
|
}
|
||||||
|
|
||||||
return getDataSection();
|
return getDataSection();
|
||||||
}
|
}
|
||||||
|
@ -494,7 +494,7 @@ std::string X86TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
|
|||||||
case Function::InternalLinkage:
|
case Function::InternalLinkage:
|
||||||
case Function::DLLExportLinkage:
|
case Function::DLLExportLinkage:
|
||||||
case Function::ExternalLinkage:
|
case Function::ExternalLinkage:
|
||||||
Name = TextSection;
|
Name = getTextSection();
|
||||||
break;
|
break;
|
||||||
case Function::WeakLinkage:
|
case Function::WeakLinkage:
|
||||||
case Function::LinkOnceLinkage:
|
case Function::LinkOnceLinkage:
|
||||||
@ -509,22 +509,22 @@ std::string X86TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
|
|||||||
else {
|
else {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case SectionKind::Data:
|
case SectionKind::Data:
|
||||||
Name = DataSection;
|
Name = getDataSection();
|
||||||
break;
|
break;
|
||||||
case SectionKind::BSS:
|
case SectionKind::BSS:
|
||||||
Name = (BSSSection ? BSSSection : DataSection);
|
Name = (getBSSSection() ? getBSSSection() : getDataSection());
|
||||||
break;
|
break;
|
||||||
case SectionKind::ROData:
|
case SectionKind::ROData:
|
||||||
case SectionKind::RODataMergeStr:
|
case SectionKind::RODataMergeStr:
|
||||||
case SectionKind::RODataMergeConst:
|
case SectionKind::RODataMergeConst:
|
||||||
// FIXME: Temporary
|
// FIXME: Temporary
|
||||||
Name = DataSection;
|
Name = getDataSection();
|
||||||
break;
|
break;
|
||||||
case SectionKind::ThreadData:
|
case SectionKind::ThreadData:
|
||||||
Name = (TLSDataSection ? TLSDataSection : DataSection);
|
Name = (getTLSDataSection() ? getTLSDataSection() : getDataSection());
|
||||||
break;
|
break;
|
||||||
case SectionKind::ThreadBSS:
|
case SectionKind::ThreadBSS:
|
||||||
Name = (TLSBSSSection ? TLSBSSSection : DataSection);
|
Name = (getTLSBSSSection() ? getTLSBSSSection() : getDataSection());
|
||||||
default:
|
default:
|
||||||
assert(0 && "Unsuported section kind for global");
|
assert(0 && "Unsuported section kind for global");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user