mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-27 14:34:58 +00:00
the 'isWeakForLinker' code is common between functions and globals, hoist it
and simplify some other code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76949 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
55acc6807f
commit
f76280de82
@ -77,65 +77,54 @@ const Section*
|
||||
ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
||||
SectionKind::Kind Kind = SectionKindForGlobal(GV);
|
||||
|
||||
if (GV->isWeakForLinker()) {
|
||||
// FIXME: Use mangler interface (PR4584).
|
||||
std::string Name = getSectionPrefixForUniqueGlobal(Kind)+GV->getName();
|
||||
unsigned Flags = SectionFlagsForGlobal(GV, Name.c_str());
|
||||
return getNamedSection(Name.c_str(), Flags);
|
||||
}
|
||||
|
||||
if (const Function *F = dyn_cast<Function>(GV)) {
|
||||
switch (F->getLinkage()) {
|
||||
default: llvm_unreachable("Unknown linkage type!");
|
||||
case Function::PrivateLinkage:
|
||||
case Function::LinkerPrivateLinkage:
|
||||
case Function::InternalLinkage:
|
||||
case Function::DLLExportLinkage:
|
||||
case Function::ExternalLinkage:
|
||||
return TextSection;
|
||||
case Function::WeakAnyLinkage:
|
||||
case Function::WeakODRLinkage:
|
||||
case Function::LinkOnceAnyLinkage:
|
||||
case Function::LinkOnceODRLinkage:
|
||||
// FIXME: Use mangler interface (PR4584).
|
||||
std::string Name = getSectionPrefixForUniqueGlobal(Kind)+GV->getName();
|
||||
unsigned Flags = SectionFlagsForGlobal(GV, Name.c_str());
|
||||
return getNamedSection(Name.c_str(), Flags);
|
||||
default: llvm_unreachable("Unknown linkage type!");
|
||||
case Function::PrivateLinkage:
|
||||
case Function::LinkerPrivateLinkage:
|
||||
case Function::InternalLinkage:
|
||||
case Function::DLLExportLinkage:
|
||||
case Function::ExternalLinkage:
|
||||
return TextSection;
|
||||
}
|
||||
} else if (const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV)) {
|
||||
if (GVar->isWeakForLinker()) {
|
||||
// FIXME: Use mangler interface (PR4584).
|
||||
std::string Name = getSectionPrefixForUniqueGlobal(Kind)+GV->getName();
|
||||
unsigned Flags = SectionFlagsForGlobal(GVar, Name.c_str());
|
||||
return getNamedSection(Name.c_str(), Flags);
|
||||
} else {
|
||||
switch (Kind) {
|
||||
case SectionKind::Data:
|
||||
case SectionKind::DataRel:
|
||||
return DataRelSection;
|
||||
case SectionKind::DataRelLocal:
|
||||
return DataRelLocalSection;
|
||||
case SectionKind::DataRelRO:
|
||||
return DataRelROSection;
|
||||
case SectionKind::DataRelROLocal:
|
||||
return DataRelROLocalSection;
|
||||
case SectionKind::BSS:
|
||||
return getBSSSection_();
|
||||
case SectionKind::ROData:
|
||||
return getReadOnlySection();
|
||||
case SectionKind::RODataMergeStr:
|
||||
return MergeableStringSection(GVar);
|
||||
case SectionKind::RODataMergeConst: {
|
||||
const Type *Ty = GVar->getInitializer()->getType();
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
|
||||
}
|
||||
case SectionKind::ThreadData:
|
||||
// ELF targets usually support TLS stuff
|
||||
return TLSDataSection;
|
||||
case SectionKind::ThreadBSS:
|
||||
return TLSBSSSection;
|
||||
default:
|
||||
llvm_unreachable("Unsuported section kind for global");
|
||||
}
|
||||
} else {
|
||||
const GlobalVariable *GVar = cast<GlobalVariable>(GV);
|
||||
switch (Kind) {
|
||||
default: llvm_unreachable("Unsuported section kind for global");
|
||||
case SectionKind::Data:
|
||||
case SectionKind::DataRel:
|
||||
return DataRelSection;
|
||||
case SectionKind::DataRelLocal:
|
||||
return DataRelLocalSection;
|
||||
case SectionKind::DataRelRO:
|
||||
return DataRelROSection;
|
||||
case SectionKind::DataRelROLocal:
|
||||
return DataRelROLocalSection;
|
||||
case SectionKind::BSS:
|
||||
return getBSSSection_();
|
||||
case SectionKind::ROData:
|
||||
return getReadOnlySection();
|
||||
case SectionKind::RODataMergeStr:
|
||||
return MergeableStringSection(GVar);
|
||||
case SectionKind::RODataMergeConst: {
|
||||
const Type *Ty = GVar->getInitializer()->getType();
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
|
||||
}
|
||||
} else
|
||||
llvm_unreachable("Unsupported global");
|
||||
|
||||
return NULL;
|
||||
case SectionKind::ThreadData:
|
||||
// ELF targets usually support TLS stuff
|
||||
return TLSDataSection;
|
||||
case SectionKind::ThreadBSS:
|
||||
return TLSBSSSection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// getSectionForMergableConstant - Given a mergable constant with the
|
||||
|
Loading…
x
Reference in New Issue
Block a user