aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2008-08-07 09:51:02 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2008-08-07 09:51:02 +0000
commit84e160e2656695a883ce54a2d630e502b49c7797 (patch)
tree038977429a1fe81f8be3d38d511dee5dcc50e8ff
parent93cacf131d64dccdfb04b215ca8a8909447f80cd (diff)
Add hook for constant pool section selection for darwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54449 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Target/DarwinTargetAsmInfo.h3
-rw-r--r--lib/Target/DarwinTargetAsmInfo.cpp22
-rw-r--r--lib/Target/ELFTargetAsmInfo.cpp4
3 files changed, 24 insertions, 5 deletions
diff --git a/include/llvm/Target/DarwinTargetAsmInfo.h b/include/llvm/Target/DarwinTargetAsmInfo.h
index afd0dd1b25..0ed9b38703 100644
--- a/include/llvm/Target/DarwinTargetAsmInfo.h
+++ b/include/llvm/Target/DarwinTargetAsmInfo.h
@@ -21,6 +21,7 @@
namespace llvm {
class GlobalValue;
class GlobalVariable;
+ class Type;
struct DarwinTargetAsmInfo: public virtual TargetAsmInfo {
const Section* TextCoalSection;
@@ -33,7 +34,9 @@ namespace llvm {
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind kind) const;
const Section* MergeableConstSection(const GlobalVariable *GV) const;
+ const Section* MergeableConstSection(const Type *Ty) const;
const Section* MergeableStringSection(const GlobalVariable *GV) const;
+ const Section* SelectSectionForMachineConst(const Type *Ty) const;
protected:
const TargetMachine* DTM;
};
diff --git a/lib/Target/DarwinTargetAsmInfo.cpp b/lib/Target/DarwinTargetAsmInfo.cpp
index 564d1a1835..749cb71794 100644
--- a/lib/Target/DarwinTargetAsmInfo.cpp
+++ b/lib/Target/DarwinTargetAsmInfo.cpp
@@ -107,10 +107,16 @@ DarwinTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
const Section*
DarwinTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
- const TargetData *TD = DTM->getTargetData();
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
- unsigned Size = TD->getABITypeSize(C->getType());
+ return MergeableConstSection(C->getType());
+}
+
+inline const Section*
+DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
+ const TargetData *TD = DTM->getTargetData();
+
+ unsigned Size = TD->getABITypeSize(Ty);
if (Size == 4)
return FourByteConstantSection_;
else if (Size == 8)
@@ -121,6 +127,18 @@ DarwinTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
return getReadOnlySection_();
}
+const Section*
+DarwinTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
+ const Section* S = MergeableConstSection(Ty);
+
+ // Handle weird special case, when compiling PIC stuff.
+ if (S == getReadOnlySection_() &&
+ DTM->getRelocationModel() != Reloc::Static)
+ return ConstDataSection;
+
+ return S;
+}
+
std::string
DarwinTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind kind) const {
diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp
index 3b89c3f1e2..e6a40e7cec 100644
--- a/lib/Target/ELFTargetAsmInfo.cpp
+++ b/lib/Target/ELFTargetAsmInfo.cpp
@@ -99,9 +99,7 @@ ELFTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
const Section*
ELFTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
- const Type *Ty = C->getType();
-
- return MergeableConstSection(Ty);
+ return MergeableConstSection(C->getType());
}
inline const Section*