aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-26 05:44:20 +0000
committerChris Lattner <sabre@nondot.org>2009-07-26 05:44:20 +0000
commite346e180f339ad15322f0430aab8d812cf2fe4de (patch)
tree81dd3b4842c498cdd833bfa7bf4c6747f50b7455 /include
parentd6b06b1f3696b1bf4b334c14faebefad6be45015 (diff)
downloadexternal_llvm-e346e180f339ad15322f0430aab8d812cf2fe4de.zip
external_llvm-e346e180f339ad15322f0430aab8d812cf2fe4de.tar.gz
external_llvm-e346e180f339ad15322f0430aab8d812cf2fe4de.tar.bz2
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 'include')
-rw-r--r--include/llvm/Target/TargetAsmInfo.h165
1 files changed, 116 insertions, 49 deletions
diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h
index 59fb8c9..f9105dd 100644
--- a/include/llvm/Target/TargetAsmInfo.h
+++ b/include/llvm/Target/TargetAsmInfo.h
@@ -32,66 +32,131 @@ namespace llvm {
}
/// SectionKind - This is a simple POD value that classifies the properties of
- /// a section.
+ /// a section. A global variable is classified into the deepest possible
+ /// classification, and then the target maps them onto their sections based on
+ /// what capabilities they have.
+ ///
+ /// The comments below describe these as if they were an inheritance hierarchy
+ /// in order to explain the predicates below.
struct SectionKind {
enum Kind {
- Text, ///< Text section.
- BSS, ///< BSS section.
-
- Data, ///< Data section.
- DataRel, ///< Data that has relocations.
- DataRelLocal, ///< Data that only has local relocations.
-
- // Readonly data.
- ROData, ///< Readonly data section.
- DataRelRO, ///< Readonly data with non-local relocations.
- DataRelROLocal, ///< Readonly data with local relocations only.
+ /// Text - Text section, used for functions and other executable code.
+ Text,
+
+ /// ReadOnly - Data that is never written to at program runtime by the
+ /// program or the dynamic linker. Things in the top-level readonly
+ /// SectionKind are not mergable.
+ ReadOnly,
+
+ /// MergableCString - This is a special section for nul-terminated
+ /// strings. The linker can unique the C strings, knowing their
+ /// semantics. Because it uniques based on the nul terminators, the
+ /// compiler can't put strings in this section that have embeded nuls
+ /// in them.
+ MergableCString,
+
+ /// MergableConst - These are sections for merging fixed-length
+ /// constants together. For example, this can be used to unique
+ /// constant pool entries etc.
+ MergableConst,
+
+
+ /// Writable - This is the base of all segments that need to be written
+ /// to during program runtime.
+
+ /// ThreadLocal - This is the base of all TLS segments. All TLS
+ /// objects must be writable, otherwise there is no reason for them to
+ /// be thread local!
+
+ /// ThreadBSS - Zero-initialized TLS data objects.
+ ThreadBSS,
- /// Mergable sections.
- RODataMergeStr, ///< Readonly data section: nul-terminated strings.
- RODataMergeConst, ///< Readonly data section: fixed-length constants.
+ /// ThreadData - Initialized TLS data objects.
+ ThreadData,
+
+ /// GlobalWritableData - Writable data that is global (not thread
+ /// local).
+
+ /// BSS - Zero initialized writable data.
+ BSS,
+
+ /// DataRel - This is the most general form of data that is written
+ /// to by the program, it can have random relocations to arbitrary
+ /// globals.
+ DataRel,
+
+ /// DataRelLocal - This is writable data that has a non-zero
+ /// initializer and has relocations in it, but all of the
+ /// relocations are known to be within the final linked image
+ /// the global is linked into.
+ DataRelLocal,
+
+ /// DataNoRel - This is writable data that has a non-zero
+ /// initializer, but whose initializer is known to have no
+ /// relocations.
+ DataNoRel,
+
+ /// ReadOnlyWithRel - These are global variables that are never
+ /// written to by the program, but that have relocations, so they
+ /// must be stuck in a writable section so that the dynamic linker
+ /// can write to them. If it chooses to, the dynamic linker can
+ /// mark the pages these globals end up on as read-only after it is
+ /// done with its relocation phase.
+ ReadOnlyWithRel,
+
+ /// ReadOnlyWithRelLocal - This is data that is readonly by the
+ /// program, but must be writable so that the dynamic linker
+ /// can perform relocations in it. This is used when we know
+ /// that all the relocations are to globals in this final
+ /// linked image.
+ ReadOnlyWithRelLocal
- /// Thread local data.
- ThreadData, ///< Initialized TLS data objects
- ThreadBSS ///< Uninitialized TLS data objects
} K : 8; // This is private.
- // FIXME: Eliminate.
- Kind getKind() const { return K; }
-
- bool isReadOnly() const {
- return K == ROData || K == RODataMergeConst || K == RODataMergeStr;
+ bool isText() const {
+ return K == Text;
}
- /// isReadOnlyWithDynamicInit - Return true if this data is readonly, but
- /// the dynamic linker has to write to it to apply relocations.
- bool isReadOnlyWithDynamicInit() const {
- return K == DataRelRO || K == DataRelROLocal;
+ bool isReadOnly() const {
+ return K == ReadOnly || K == MergableCString || K == MergableConst;
}
- bool isBSS() const {
- return K == BSS || K == ThreadBSS;
+ bool isMergableCString() const { return K == MergableCString; }
+ bool isMergableConst() const { return K == MergableConst; }
+
+ bool isWritable() const {
+ return isThreadLocal() || isGlobalWritableData();
}
- bool isTLS() const {
+ bool isThreadLocal() const {
return K == ThreadData || K == ThreadBSS;
}
- bool isCode() const {
- return K == Text;
+ bool isThreadBSS() const { return K == ThreadBSS; }
+ bool isThreadData() const { return K == ThreadData; }
+
+ bool isGlobalWritableData() const {
+ return isBSS() || isDataRel() || isReadOnlyWithRel();
}
- bool isWritable() const {
- return isTLS() ||
- K == Data ||
- K == DataRel || K == DataRelLocal ||
- K == DataRelRO || K == DataRelROLocal ||
- K == BSS;
+ bool isBSS() const { return K == BSS; }
+
+ bool isDataRel() const {
+ return K == DataRel || K == DataRelLocal || K == DataNoRel;
}
- bool isMergableString() const { return K == RODataMergeStr; }
- bool isMergableConstant() const {
- return K == RODataMergeStr || K == RODataMergeConst;
+ bool isDataRelLocal() const {
+ return K == DataRelLocal || K == DataNoRel;
+ }
+
+ bool isDataNoRel() const { return K == DataNoRel; }
+
+ bool isReadOnlyWithRel() const {
+ return K == ReadOnlyWithRel || K == ReadOnlyWithRelLocal;
+ }
+
+ bool isReadOnlyWithRelLocal() const {
+ return K == ReadOnlyWithRelLocal;
}
static SectionKind get(Kind K) {
@@ -99,17 +164,19 @@ namespace llvm {
return Res;
}
static SectionKind getText() { return get(Text); }
+ static SectionKind getReadOnly() { return get(ReadOnly); }
+ static SectionKind getMergableCString() { return get(MergableCString); }
+ static SectionKind getMergableConst() { return get(MergableConst); }
+ static SectionKind getThreadBSS() { return get(ThreadBSS); }
+ static SectionKind getThreadData() { return get(ThreadData); }
static SectionKind getBSS() { return get(BSS); }
- static SectionKind getData() { return get(Data); }
static SectionKind getDataRel() { return get(DataRel); }
static SectionKind getDataRelLocal() { return get(DataRelLocal); }
- static SectionKind getROData() { return get(ROData); }
- static SectionKind getDataRelRO() { return get(DataRelRO); }
- static SectionKind getDataRelROLocal() { return get(DataRelROLocal); }
- static SectionKind getRODataMergeStr() { return get(RODataMergeStr); }
- static SectionKind getRODataMergeConst() { return get(RODataMergeConst); }
- static SectionKind getThreadData() { return get(ThreadData); }
- static SectionKind getThreadBSS() { return get(ThreadBSS); }
+ static SectionKind getDataNoRel() { return get(DataNoRel); }
+ static SectionKind getReadOnlyWithRel() { return get(ReadOnlyWithRel); }
+ static SectionKind getReadOnlyWithRelLocal() {
+ return get(ReadOnlyWithRelLocal);
+ }
};
namespace SectionFlags {