diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-26 05:44:20 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-26 05:44:20 +0000 |
commit | e346e180f339ad15322f0430aab8d812cf2fe4de (patch) | |
tree | 81dd3b4842c498cdd833bfa7bf4c6747f50b7455 /lib/Target/ELFTargetAsmInfo.cpp | |
parent | d6b06b1f3696b1bf4b334c14faebefad6be45015 (diff) | |
download | external_llvm-e346e180f339ad15322f0430aab8d812cf2fe4de.tar.gz external_llvm-e346e180f339ad15322f0430aab8d812cf2fe4de.tar.bz2 external_llvm-e346e180f339ad15322f0430aab8d812cf2fe4de.zip |
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
Diffstat (limited to 'lib/Target/ELFTargetAsmInfo.cpp')
-rw-r--r-- | lib/Target/ELFTargetAsmInfo.cpp | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp index 880dfbc0a9..c4011098b8 100644 --- a/lib/Target/ELFTargetAsmInfo.cpp +++ b/lib/Target/ELFTargetAsmInfo.cpp @@ -49,28 +49,30 @@ ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM) const Section* ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind) const { - switch (Kind.getKind()) { - default: llvm_unreachable("Unknown section kind"); - case SectionKind::Text: return TextSection; - case SectionKind::BSS: return getBSSSection_(); - case SectionKind::Data: return DataSection; - case SectionKind::DataRel: return DataRelSection; - case SectionKind::DataRelLocal: return DataRelLocalSection; - case SectionKind::DataRelRO: return DataRelROSection; - case SectionKind::DataRelROLocal: return DataRelROLocalSection; - case SectionKind::ROData: return getReadOnlySection(); - case SectionKind::RODataMergeStr: + if (Kind.isText()) return TextSection; + if (Kind.isMergableCString()) return MergeableStringSection(cast<GlobalVariable>(GV)); - case SectionKind::RODataMergeConst: { + if (Kind.isMergableConst()) { const Type *Ty = cast<GlobalVariable>(GV)->getInitializer()->getType(); const TargetData *TD = TM.getTargetData(); return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0); } - case SectionKind::ThreadData: - return TLSDataSection; - case SectionKind::ThreadBSS: - return TLSBSSSection; - } + if (Kind.isReadOnly()) return getReadOnlySection(); + + + if (Kind.isThreadData()) return TLSDataSection; + if (Kind.isThreadBSS()) return TLSBSSSection; + + if (Kind.isBSS()) return getBSSSection_(); + + + if (Kind.isDataNoRel()) return DataSection; + if (Kind.isDataRelLocal()) return DataRelLocalSection; + if (Kind.isDataRel()) return DataRelSection; + if (Kind.isReadOnlyWithRelLocal()) return DataRelROLocalSection; + + assert(Kind.isReadOnlyWithRel() && "Unknown section kind"); + return DataRelROSection; } /// getSectionForMergableConstant - Given a mergable constant with the @@ -129,21 +131,20 @@ unsigned ELFTargetAsmInfo::getFlagsForNamedSection(const char *Name) const { const char * ELFTargetAsmInfo::getSectionPrefixForUniqueGlobal(SectionKind Kind) const{ - switch (Kind.getKind()) { - default: llvm_unreachable("Unknown section kind"); - case SectionKind::Text: return ".gnu.linkonce.t."; - case SectionKind::Data: return ".gnu.linkonce.d."; - case SectionKind::DataRel: return ".gnu.linkonce.d.rel."; - case SectionKind::DataRelLocal: return ".gnu.linkonce.d.rel.local."; - case SectionKind::DataRelRO: return ".gnu.linkonce.d.rel.ro."; - case SectionKind::DataRelROLocal: return ".gnu.linkonce.d.rel.ro.local."; - case SectionKind::BSS: return ".gnu.linkonce.b."; - case SectionKind::ROData: - case SectionKind::RODataMergeConst: - case SectionKind::RODataMergeStr: return ".gnu.linkonce.r."; - case SectionKind::ThreadData: return ".gnu.linkonce.td."; - case SectionKind::ThreadBSS: return ".gnu.linkonce.tb."; - } + if (Kind.isText()) return ".gnu.linkonce.t."; + if (Kind.isReadOnly()) return ".gnu.linkonce.r."; + + if (Kind.isThreadData()) return ".gnu.linkonce.td."; + if (Kind.isThreadBSS()) return ".gnu.linkonce.tb."; + + if (Kind.isBSS()) return ".gnu.linkonce.b."; + if (Kind.isDataNoRel()) return ".gnu.linkonce.d."; + if (Kind.isDataRelLocal()) return ".gnu.linkonce.d.rel.local."; + if (Kind.isDataRel()) return ".gnu.linkonce.d.rel."; + if (Kind.isReadOnlyWithRelLocal()) return ".gnu.linkonce.d.rel.ro.local."; + + assert(Kind.isReadOnlyWithRel() && "Unknown section kind"); + return ".gnu.linkonce.d.rel.ro."; } |