Rearrange all the SectionKinds and structure them into a hierarchical
group instead of a bunch of random unrelated ideas. Provide predicates
to categorize a SectionKind into a group, and use them instead of
getKind() throughout the code.
This also renames a ton of SectionKinds to be more consistent and
evocative, and adds a huge number of comments on the enums so that
I will hopefully be able to remember how this stuff works long from
now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77129 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp
index c3fb942..02e01be 100644
--- a/lib/Target/TargetAsmInfo.cpp
+++ b/lib/Target/TargetAsmInfo.cpp
@@ -204,11 +204,11 @@
unsigned Flags = SectionFlags::None;
if (GV->isWeakForLinker())
Flags |= SectionFlags::Linkonce;
- if (Kind.isBSS())
+ if (Kind.isBSS() || Kind.isThreadBSS())
Flags |= SectionFlags::BSS;
- if (Kind.isTLS())
+ if (Kind.isThreadLocal())
Flags |= SectionFlags::TLS;
- if (Kind.isCode())
+ if (Kind.isText())
Flags |= SectionFlags::Code;
if (Kind.isWritable())
Flags |= SectionFlags::Writable;
@@ -247,32 +247,32 @@
// If initializer is a null-terminated string, put it in a "cstring"
// section if the target has it.
if (isConstantString(C))
- return SectionKind::getRODataMergeStr();
+ return SectionKind::getMergableCString();
// Otherwise, just drop it into a mergable constant section.
- return SectionKind::getRODataMergeConst();
+ return SectionKind::getMergableConst();
case Constant::LocalRelocation:
// In static relocation model, the linker will resolve all addresses, so
// the relocation entries will actually be constants by the time the app
// starts up.
if (ReloModel == Reloc::Static)
- return SectionKind::getROData();
+ return SectionKind::getReadOnly();
// Otherwise, the dynamic linker needs to fix it up, put it in the
// writable data.rel.local section.
- return SectionKind::getDataRelROLocal();
+ return SectionKind::getReadOnlyWithRelLocal();
case Constant::GlobalRelocations:
// In static relocation model, the linker will resolve all addresses, so
// the relocation entries will actually be constants by the time the app
// starts up.
if (ReloModel == Reloc::Static)
- return SectionKind::getROData();
+ return SectionKind::getReadOnly();
// Otherwise, the dynamic linker needs to fix it up, put it in the
// writable data.rel section.
- return SectionKind::getDataRelRO();
+ return SectionKind::getReadOnlyWithRel();
}
}
@@ -282,11 +282,11 @@
// globals together onto fewer pages, improving the locality of the dynamic
// linker.
if (ReloModel == Reloc::Static)
- return SectionKind::getData();
+ return SectionKind::getDataNoRel();
switch (C->getRelocationInfo()) {
default: llvm_unreachable("unknown relocation info kind");
- case Constant::NoRelocation: return SectionKind::getData();
+ case Constant::NoRelocation: return SectionKind::getDataNoRel();
case Constant::LocalRelocation: return SectionKind::getDataRelLocal();
case Constant::GlobalRelocations: return SectionKind::getDataRel();
}
@@ -342,7 +342,9 @@
const Section*
TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
SectionKind Kind) const {
- if (Kind.isCode())
+ assert(!Kind.isThreadLocal() && "Doesn't support TLS");
+
+ if (Kind.isText())
return getTextSection();
if (Kind.isBSS())