aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-26 06:16:11 +0000
committerChris Lattner <sabre@nondot.org>2009-07-26 06:16:11 +0000
commitf15327290e624472a7565ac5d022767a78912ab6 (patch)
tree56a8e2cc179052945e1852718a69032669dec618
parent8ca520944e1924f487561be5cd8369da0a53d8ae (diff)
downloadexternal_llvm-f15327290e624472a7565ac5d022767a78912ab6.zip
external_llvm-f15327290e624472a7565ac5d022767a78912ab6.tar.gz
external_llvm-f15327290e624472a7565ac5d022767a78912ab6.tar.bz2
precreate 4/8/16 byte mergable sections to simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77133 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Target/ELFTargetAsmInfo.h16
-rw-r--r--lib/Target/ELFTargetAsmInfo.cpp35
2 files changed, 29 insertions, 22 deletions
diff --git a/include/llvm/Target/ELFTargetAsmInfo.h b/include/llvm/Target/ELFTargetAsmInfo.h
index c5d94ba..9d31faa 100644
--- a/include/llvm/Target/ELFTargetAsmInfo.h
+++ b/include/llvm/Target/ELFTargetAsmInfo.h
@@ -43,13 +43,17 @@ namespace llvm {
SectionKind Kind) const;
virtual std::string printSectionFlags(unsigned flags) const;
- const Section* DataRelSection;
- const Section* DataRelLocalSection;
- const Section* DataRelROSection;
- const Section* DataRelROLocalSection;
-
+ const Section *DataRelSection;
+ const Section *DataRelLocalSection;
+ const Section *DataRelROSection;
+ const Section *DataRelROLocalSection;
+
+ const Section *MergableConst4Section;
+ const Section *MergableConst8Section;
+ const Section *MergableConst16Section;
+
private:
- const Section* MergeableStringSection(const GlobalVariable *GV) const;
+ const Section *MergeableStringSection(const GlobalVariable *GV) const;
};
}
diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp
index 4631cda..82c993b 100644
--- a/lib/Target/ELFTargetAsmInfo.cpp
+++ b/lib/Target/ELFTargetAsmInfo.cpp
@@ -43,6 +43,13 @@ ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
SectionFlags::Writable);
DataRelROLocalSection = getNamedSection("\t.data.rel.ro.local",
SectionFlags::Writable);
+
+ MergableConst4Section = getNamedSection(".rodata.cst4",
+ SectionFlags::setEntitySize(SectionFlags::Mergeable, 4));
+ MergableConst8Section = getNamedSection(".rodata.cst8",
+ SectionFlags::setEntitySize(SectionFlags::Mergeable, 8));
+ MergableConst16Section = getNamedSection(".rodata.cst16",
+ SectionFlags::setEntitySize(SectionFlags::Mergeable, 16));
}
@@ -54,10 +61,15 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
return MergeableStringSection(cast<GlobalVariable>(GV));
if (Kind.isMergableConst()) {
- const Type *Ty = cast<GlobalVariable>(GV)->getInitializer()->getType();
- const TargetData *TD = TM.getTargetData();
- return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
+ if (Kind.isMergableConst4())
+ return MergableConst4Section;
+ if (Kind.isMergableConst8())
+ return MergableConst8Section;
+ if (Kind.isMergableConst16())
+ return MergableConst16Section;
+ return ReadOnlySection; // .const
}
+
if (Kind.isReadOnly()) return getReadOnlySection();
@@ -89,21 +101,12 @@ ELFTargetAsmInfo::getSectionForMergableConstant(uint64_t Size,
if (ReloInfo == 1)
return DataRelROLocalSection;
-
- const char *SecName = 0;
switch (Size) {
- default: break;
- case 4: SecName = ".rodata.cst4"; break;
- case 8: SecName = ".rodata.cst8"; break;
- case 16: SecName = ".rodata.cst16"; break;
+ default: return ReadOnlySection; // .rodata
+ case 4: return MergableConst4Section;
+ case 8: return MergableConst8Section;
+ case 16: return MergableConst16Section;
}
-
- if (SecName)
- return getNamedSection(SecName,
- SectionFlags::setEntitySize(SectionFlags::Mergeable,
- Size));
-
- return getReadOnlySection(); // .rodata
}
/// getFlagsForNamedSection - If this target wants to be able to infer