forked from OSchip/llvm-project
Add hook for constant pool section selection for darwin.
llvm-svn: 54449
This commit is contained in:
parent
ef643a4850
commit
6c7b43cccd
|
@ -21,6 +21,7 @@
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class GlobalValue;
|
class GlobalValue;
|
||||||
class GlobalVariable;
|
class GlobalVariable;
|
||||||
|
class Type;
|
||||||
|
|
||||||
struct DarwinTargetAsmInfo: public virtual TargetAsmInfo {
|
struct DarwinTargetAsmInfo: public virtual TargetAsmInfo {
|
||||||
const Section* TextCoalSection;
|
const Section* TextCoalSection;
|
||||||
|
@ -33,7 +34,9 @@ namespace llvm {
|
||||||
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
|
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
|
||||||
SectionKind::Kind kind) const;
|
SectionKind::Kind kind) const;
|
||||||
const Section* MergeableConstSection(const GlobalVariable *GV) const;
|
const Section* MergeableConstSection(const GlobalVariable *GV) const;
|
||||||
|
const Section* MergeableConstSection(const Type *Ty) const;
|
||||||
const Section* MergeableStringSection(const GlobalVariable *GV) const;
|
const Section* MergeableStringSection(const GlobalVariable *GV) const;
|
||||||
|
const Section* SelectSectionForMachineConst(const Type *Ty) const;
|
||||||
protected:
|
protected:
|
||||||
const TargetMachine* DTM;
|
const TargetMachine* DTM;
|
||||||
};
|
};
|
||||||
|
|
|
@ -107,10 +107,16 @@ DarwinTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
|
||||||
|
|
||||||
const Section*
|
const Section*
|
||||||
DarwinTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
|
DarwinTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
|
||||||
const TargetData *TD = DTM->getTargetData();
|
|
||||||
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
|
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)
|
if (Size == 4)
|
||||||
return FourByteConstantSection_;
|
return FourByteConstantSection_;
|
||||||
else if (Size == 8)
|
else if (Size == 8)
|
||||||
|
@ -121,6 +127,18 @@ DarwinTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
|
||||||
return getReadOnlySection_();
|
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
|
std::string
|
||||||
DarwinTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
|
DarwinTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
|
||||||
SectionKind::Kind kind) const {
|
SectionKind::Kind kind) const {
|
||||||
|
|
|
@ -99,9 +99,7 @@ ELFTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
|
||||||
const Section*
|
const Section*
|
||||||
ELFTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
|
ELFTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
|
||||||
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
|
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
|
||||||
const Type *Ty = C->getType();
|
return MergeableConstSection(C->getType());
|
||||||
|
|
||||||
return MergeableConstSection(Ty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Section*
|
inline const Section*
|
||||||
|
|
Loading…
Reference in New Issue