aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-25 23:21:55 +0000
committerChris Lattner <sabre@nondot.org>2009-07-25 23:21:55 +0000
commit460d51e0c029814cd901a2642bcaa7d776ff5929 (patch)
tree58e9d81acef6ea84bc90dcdc50ea4f6835c566f6 /include/llvm
parent7d509134dcec17f6094032196b21af5c67943f0f (diff)
downloadexternal_llvm-460d51e0c029814cd901a2642bcaa7d776ff5929.tar.gz
external_llvm-460d51e0c029814cd901a2642bcaa7d776ff5929.tar.bz2
external_llvm-460d51e0c029814cd901a2642bcaa7d776ff5929.zip
make SectionKind be a first-class pod struct instead of just
an enum. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77096 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/Target/DarwinTargetAsmInfo.h2
-rw-r--r--include/llvm/Target/ELFTargetAsmInfo.h4
-rw-r--r--include/llvm/Target/TargetAsmInfo.h49
3 files changed, 39 insertions, 16 deletions
diff --git a/include/llvm/Target/DarwinTargetAsmInfo.h b/include/llvm/Target/DarwinTargetAsmInfo.h
index 10faacca7e..3b3b7329f8 100644
--- a/include/llvm/Target/DarwinTargetAsmInfo.h
+++ b/include/llvm/Target/DarwinTargetAsmInfo.h
@@ -35,7 +35,7 @@ namespace llvm {
explicit DarwinTargetAsmInfo(const TargetMachine &TM);
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV,
- SectionKind::Kind Kind) const;
+ SectionKind Kind) const;
virtual bool emitUsedDirectiveFor(const GlobalValue *GV,
Mangler *Mang) const;
diff --git a/include/llvm/Target/ELFTargetAsmInfo.h b/include/llvm/Target/ELFTargetAsmInfo.h
index 5bd9938d97..c5d94baf9e 100644
--- a/include/llvm/Target/ELFTargetAsmInfo.h
+++ b/include/llvm/Target/ELFTargetAsmInfo.h
@@ -37,10 +37,10 @@ namespace llvm {
/// ".tbss" gets the TLS bit set etc.
virtual unsigned getFlagsForNamedSection(const char *Section) const;
- const char *getSectionPrefixForUniqueGlobal(SectionKind::Kind Kind) const;
+ const char *getSectionPrefixForUniqueGlobal(SectionKind Kind) const;
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV,
- SectionKind::Kind Kind) const;
+ SectionKind Kind) const;
virtual std::string printSectionFlags(unsigned flags) const;
const Section* DataRelSection;
diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h
index b8851a6eee..15f17ba059 100644
--- a/include/llvm/Target/TargetAsmInfo.h
+++ b/include/llvm/Target/TargetAsmInfo.h
@@ -31,7 +31,9 @@ namespace llvm {
};
}
- namespace SectionKind {
+ /// SectionKind - This is a simple POD value that classifies the properties of
+ /// a section.
+ struct SectionKind {
enum Kind {
Unknown = 0, ///< Custom section.
Text, ///< Text section.
@@ -53,9 +55,12 @@ namespace llvm {
/// Thread local data.
ThreadData, ///< Initialized TLS data objects
ThreadBSS ///< Uninitialized TLS data objects
- };
+ } K; // This is private.
+
+ // FIXME: Eliminate.
+ Kind getKind() const { return K; }
- static inline bool isReadOnly(Kind K) {
+ bool isReadOnly() const {
return (K == SectionKind::ROData ||
K == SectionKind::DataRelRO ||
K == SectionKind::DataRelROLocal ||
@@ -63,20 +68,20 @@ namespace llvm {
K == SectionKind::RODataMergeStr);
}
- static inline bool isBSS(Kind K) {
+ bool isBSS() const {
return K == BSS || K == ThreadBSS;
}
- static inline bool isTLS(Kind K) {
+ bool isTLS() const {
return K == ThreadData || K == ThreadBSS;
}
- static inline bool isCode(Kind K) {
+ bool isCode() const {
return K == Text;
}
- static inline bool isWritable(Kind K) {
- return isTLS(K) ||
+ bool isWritable() const {
+ return isTLS() ||
K == SectionKind::Data ||
K == SectionKind::DataRel ||
K == SectionKind::DataRelLocal ||
@@ -84,7 +89,24 @@ namespace llvm {
K == SectionKind::DataRelROLocal ||
K == SectionKind::BSS;
}
- }
+
+ static SectionKind get(Kind K) {
+ SectionKind Res = { K };
+ return Res;
+ }
+ static SectionKind getText() { return get(Text); }
+ 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); }
+};
namespace SectionFlags {
const unsigned Invalid = -1U;
@@ -109,8 +131,9 @@ namespace llvm {
return (Flags >> 24) & 0xFF;
}
+ // FIXME: Why does this return a value?
static inline unsigned setEntitySize(unsigned Flags, unsigned Size) {
- return ((Flags & ~EntitySize) | ((Size & 0xFF) << 24));
+ return (Flags & ~EntitySize) | ((Size & 0xFF) << 24);
}
struct KeyInfo {
@@ -604,7 +627,7 @@ namespace llvm {
/// global. This is important for globals that need to be merged across
/// translation units.
virtual const char *
- getSectionPrefixForUniqueGlobal(SectionKind::Kind Kind) const {
+ getSectionPrefixForUniqueGlobal(SectionKind Kind) const {
return 0;
}
@@ -628,7 +651,7 @@ namespace llvm {
/// getFlagsForNamedSection.
virtual const Section *
getSpecialCasedSectionGlobals(const GlobalValue *GV,
- SectionKind::Kind Kind) const{
+ SectionKind Kind) const {
return 0;
}
@@ -637,7 +660,7 @@ namespace llvm {
// FIXME: Eliminate this.
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV,
- SectionKind::Kind Kind) const;
+ SectionKind Kind) const;
/// getSLEB128Size - Compute the number of bytes required for a signed
/// leb128 value.