diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-26 01:24:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-26 01:24:18 +0000 |
commit | 32e4b063a9847876108d830e9ada6c9c7aa00d06 (patch) | |
tree | 272b43047ebbd69fc95910fdd7595621579187f1 /lib/Target/DarwinTargetAsmInfo.cpp | |
parent | ec1261ec5d7f972262b6741d0c83d749f0587a34 (diff) | |
download | external_llvm-32e4b063a9847876108d830e9ada6c9c7aa00d06.zip external_llvm-32e4b063a9847876108d830e9ada6c9c7aa00d06.tar.gz external_llvm-32e4b063a9847876108d830e9ada6c9c7aa00d06.tar.bz2 |
finish simplifying DarwinTargetAsmInfo::SelectSectionForGlobal
for now. Make the section switching directives more consistent
by not including \n and including \t for them all.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77107 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/DarwinTargetAsmInfo.cpp')
-rw-r--r-- | lib/Target/DarwinTargetAsmInfo.cpp | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/lib/Target/DarwinTargetAsmInfo.cpp b/lib/Target/DarwinTargetAsmInfo.cpp index 6be9aa0..1356f67 100644 --- a/lib/Target/DarwinTargetAsmInfo.cpp +++ b/lib/Target/DarwinTargetAsmInfo.cpp @@ -39,7 +39,7 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) // there, if needed. SixteenByteConstantSection = 0; - ReadOnlySection = getUnnamedSection("\t.const\n", SectionFlags::None); + ReadOnlySection = getUnnamedSection("\t.const", SectionFlags::None); TextCoalSection = getNamedSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions", @@ -48,7 +48,7 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) SectionFlags::None); ConstDataCoalSection = getNamedSection("\t__DATA,__const_coal,coalesced", SectionFlags::None); - ConstDataSection = getUnnamedSection(".const_data", SectionFlags::None); + ConstDataSection = getUnnamedSection("\t.const_data", SectionFlags::None); DataCoalSection = getNamedSection("\t__DATA,__datacoal_nt,coalesced", SectionFlags::Writable); @@ -75,7 +75,7 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) // Sections: CStringSection = "\t.cstring"; - JumpTableDataSection = "\t.const\n"; + JumpTableDataSection = "\t.const"; BSSSection = 0; if (TM.getRelocationModel() == Reloc::Static) { @@ -131,7 +131,6 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV, // FIXME: Use sectionflags:linkonce instead of isWeakForLinker() here. bool isWeak = GV->isWeakForLinker(); - bool isNonStatic = TM.getRelocationModel() != Reloc::Static; if (Kind.isCode()) return isWeak ? TextCoalSection : TextSection; @@ -148,30 +147,24 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV, if (Kind.isMergableString()) return MergeableStringSection(cast<GlobalVariable>(GV)); - switch (Kind.getKind()) { - case SectionKind::Data: - case SectionKind::DataRelLocal: - case SectionKind::DataRel: - case SectionKind::BSS: - if (cast<GlobalVariable>(GV)->isConstant()) - return ConstDataSection; - return DataSection; - - case SectionKind::ROData: - case SectionKind::DataRelRO: - case SectionKind::DataRelROLocal: - return isNonStatic ? ConstDataSection : getReadOnlySection(); - case SectionKind::RODataMergeConst: { + if (Kind.isMergableConstant()) { const Type *Ty = cast<GlobalVariable>(GV)->getInitializer()->getType(); const TargetData *TD = TM.getTargetData(); return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0); } - default: - llvm_unreachable("Unsuported section kind for global"); - } - // FIXME: Do we have any extra special weird cases? - return NULL; + // If this is marked const, put it into a const section. But if the dynamic + // linker needs to write to it, put it in the data segment. + if (Kind.isReadOnlyWithDynamicInit()) + return ConstDataSection; + + // FIXME: ROData -> const in -static mode that is relocatable but they happen + // by the static linker. Why not mergable? + if (Kind.isReadOnly()) + return getReadOnlySection(); + + // Otherwise, just drop the variable in the normal data section. + return DataSection; } const Section* |