Get rid of ReadOnlySection duplicate

llvm-svn: 56582
This commit is contained in:
Anton Korobeynikov 2008-09-24 22:20:27 +00:00
parent 91a6705839
commit 8e7b93938d
8 changed files with 17 additions and 29 deletions

View File

@ -146,8 +146,7 @@ namespace llvm {
/// ReadOnlySection - This is the directive that is emitted to switch to a /// ReadOnlySection - This is the directive that is emitted to switch to a
/// read-only section for constant data (e.g. data declared const, /// read-only section for constant data (e.g. data declared const,
/// jump tables). /// jump tables).
const char *ReadOnlySection; // Defaults to NULL const Section *ReadOnlySection; // Defaults to NULL
const Section *ReadOnlySection_;
/// SmallDataSection - This is the directive that is emitted to switch to a /// SmallDataSection - This is the directive that is emitted to switch to a
/// small data section. /// small data section.
@ -597,12 +596,9 @@ namespace llvm {
const Section *getBSSSection_() const { const Section *getBSSSection_() const {
return BSSSection_; return BSSSection_;
} }
const char *getReadOnlySection() const { const Section *getReadOnlySection() const {
return ReadOnlySection; return ReadOnlySection;
} }
const Section *getReadOnlySection_() const {
return ReadOnlySection_;
}
const Section *getSmallDataSection() const { const Section *getSmallDataSection() const {
return SmallDataSection; return SmallDataSection;
} }

View File

@ -72,7 +72,6 @@ ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM):
ProtectedDirective = NULL; ProtectedDirective = NULL;
JumpTableDataSection = ".const"; JumpTableDataSection = ".const";
CStringSection = "\t.cstring"; CStringSection = "\t.cstring";
ReadOnlySection = "\t.const\n";
HasDotTypeDotSizeDirective = false; HasDotTypeDotSizeDirective = false;
NeedsIndirectEncoding = true; NeedsIndirectEncoding = true;
if (TM.getRelocationModel() == Reloc::Static) { if (TM.getRelocationModel() == Reloc::Static) {
@ -112,7 +111,6 @@ ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMTargetMachine &TM):
HasLEB128 = true; HasLEB128 = true;
AbsoluteDebugSectionOffsets = true; AbsoluteDebugSectionOffsets = true;
CStringSection = ".rodata.str"; CStringSection = ".rodata.str";
ReadOnlySection = "\t.section\t.rodata\n";
PrivateGlobalPrefix = ".L"; PrivateGlobalPrefix = ".L";
WeakRefDirective = "\t.weak\t"; WeakRefDirective = "\t.weak\t";
SetDirective = "\t.set\t"; SetDirective = "\t.set\t";

View File

@ -38,12 +38,12 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) {
// there, if needed. // there, if needed.
SixteenByteConstantSection = 0; SixteenByteConstantSection = 0;
ReadOnlySection_ = getUnnamedSection("\t.const\n", SectionFlags::None); ReadOnlySection = getUnnamedSection("\t.const\n", SectionFlags::None);
TextCoalSection = TextCoalSection =
getNamedSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions", getNamedSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions",
SectionFlags::Code); SectionFlags::Code);
ConstDataCoalSection = getBamedSection("\t__DATA,__const_coal,coalesced", ConstDataCoalSection = getNamedSection("\t__DATA,__const_coal,coalesced",
SectionFlags::None); SectionFlags::None);
ConstDataSection = getUnnamedSection(".const_data", SectionFlags::None); ConstDataSection = getUnnamedSection(".const_data", SectionFlags::None);
DataCoalSection = getNamedSection("\t__DATA,__datacoal_nt,coalesced", DataCoalSection = getNamedSection("\t__DATA,__datacoal_nt,coalesced",
@ -92,7 +92,7 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
return (isWeak ? DataCoalSection : DataSection); return (isWeak ? DataCoalSection : DataSection);
case SectionKind::ROData: case SectionKind::ROData:
return (isWeak ? ConstDataCoalSection : return (isWeak ? ConstDataCoalSection :
(isNonStatic ? ConstDataSection : getReadOnlySection_())); (isNonStatic ? ConstDataSection : getReadOnlySection()));
case SectionKind::RODataMergeStr: case SectionKind::RODataMergeStr:
return (isWeak ? return (isWeak ?
ConstDataCoalSection : ConstDataCoalSection :
@ -122,7 +122,7 @@ DarwinTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
return getCStringSection_(); return getCStringSection_();
} }
return getReadOnlySection_(); return getReadOnlySection();
} }
const Section* const Section*
@ -144,7 +144,7 @@ DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
else if (Size == 16 && SixteenByteConstantSection) else if (Size == 16 && SixteenByteConstantSection)
return SixteenByteConstantSection; return SixteenByteConstantSection;
return getReadOnlySection_(); return getReadOnlySection();
} }
const Section* const Section*
@ -152,7 +152,7 @@ DarwinTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
const Section* S = MergeableConstSection(Ty); const Section* S = MergeableConstSection(Ty);
// Handle weird special case, when compiling PIC stuff. // Handle weird special case, when compiling PIC stuff.
if (S == getReadOnlySection_() && if (S == getReadOnlySection() &&
DTM->getRelocationModel() != Reloc::Static) DTM->getRelocationModel() != Reloc::Static)
return ConstDataSection; return ConstDataSection;

View File

@ -29,7 +29,7 @@ ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM) {
BSSSection_ = getUnnamedSection("\t.bss", BSSSection_ = getUnnamedSection("\t.bss",
SectionFlags::Writeable | SectionFlags::BSS); SectionFlags::Writeable | SectionFlags::BSS);
ReadOnlySection_ = getNamedSection("\t.rodata", SectionFlags::None); ReadOnlySection = getNamedSection("\t.rodata", SectionFlags::None);
TLSDataSection = getNamedSection("\t.tdata", TLSDataSection = getNamedSection("\t.tdata",
SectionFlags::Writeable | SectionFlags::TLS); SectionFlags::Writeable | SectionFlags::TLS);
TLSBSSSection = getNamedSection("\t.tbss", TLSBSSSection = getNamedSection("\t.tbss",
@ -70,7 +70,7 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
return getBSSSection_(); return getBSSSection_();
case SectionKind::ROData: case SectionKind::ROData:
case SectionKind::SmallROData: case SectionKind::SmallROData:
return getReadOnlySection_(); return getReadOnlySection();
case SectionKind::RODataMergeStr: case SectionKind::RODataMergeStr:
return MergeableStringSection(GVar); return MergeableStringSection(GVar);
case SectionKind::RODataMergeConst: case SectionKind::RODataMergeConst:
@ -116,7 +116,7 @@ ELFTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
Size)); Size));
} }
return getReadOnlySection_(); return getReadOnlySection();
} }
const Section* const Section*
@ -143,7 +143,7 @@ ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
return getNamedSection(Name.c_str(), Flags); return getNamedSection(Name.c_str(), Flags);
} }
return getReadOnlySection_(); return getReadOnlySection();
} }
std::string ELFTargetAsmInfo::printSectionFlags(unsigned flags) const { std::string ELFTargetAsmInfo::printSectionFlags(unsigned flags) const {

View File

@ -30,7 +30,6 @@ MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM):
PrivateGlobalPrefix = "$"; PrivateGlobalPrefix = "$";
JumpTableDataSection = "\t.rdata"; JumpTableDataSection = "\t.rdata";
CommentString = "#"; CommentString = "#";
ReadOnlySection = "\t.rdata";
ZeroDirective = "\t.space\t"; ZeroDirective = "\t.space\t";
BSSSection = "\t.section\t.bss"; BSSSection = "\t.section\t.bss";
CStringSection = ".rodata.str"; CStringSection = ".rodata.str";
@ -38,9 +37,10 @@ MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM):
if (!Subtarget->hasABICall()) { if (!Subtarget->hasABICall()) {
JumpTableDirective = "\t.word\t"; JumpTableDirective = "\t.word\t";
SmallDataSection = getNamedSection("\t.sdata", SectionFlags::Writeable); SmallDataSection = getNamedSection("\t.sdata", SectionFlags::Writeable);
SmallBSSSection = getNamedSection("\t.sbss", SectionFlags::Writeable | SmallBSSSection = getNamedSection("\t.sbss",
SectionFlags::Writeable |
SectionFlags::BSS); SectionFlags::BSS);
} else } else
JumpTableDirective = "\t.gpword\t"; JumpTableDirective = "\t.gpword\t";
} }

View File

@ -43,7 +43,6 @@ PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM):
ConstantPoolSection = "\t.const\t"; ConstantPoolSection = "\t.const\t";
JumpTableDataSection = ".const"; JumpTableDataSection = ".const";
CStringSection = "\t.cstring"; CStringSection = "\t.cstring";
ReadOnlySection = "\t.const\n";
if (TM.getRelocationModel() == Reloc::Static) { if (TM.getRelocationModel() == Reloc::Static) {
StaticCtorsSection = ".constructor"; StaticCtorsSection = ".constructor";
StaticDtorsSection = ".destructor"; StaticDtorsSection = ".destructor";
@ -137,7 +136,6 @@ PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits"; DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits"; DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
ReadOnlySection = "\t.section\t.rodata";
PCSymbol = "."; PCSymbol = ".";
// Set up DWARF directives // Set up DWARF directives

View File

@ -31,7 +31,6 @@ TargetAsmInfo::TargetAsmInfo() :
BSSSection("\t.bss"), BSSSection("\t.bss"),
BSSSection_(0), BSSSection_(0),
ReadOnlySection(0), ReadOnlySection(0),
ReadOnlySection_(0),
SmallDataSection(0), SmallDataSection(0),
SmallBSSSection(0), SmallBSSSection(0),
SmallRODataSection(0), SmallRODataSection(0),
@ -293,8 +292,8 @@ TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
return getTextSection(); return getTextSection();
else if (isBSS(Kind) && getBSSSection_()) else if (isBSS(Kind) && getBSSSection_())
return getBSSSection_(); return getBSSSection_();
else if (getReadOnlySection_() && SectionKind::isReadOnly(Kind)) else if (getReadOnlySection() && SectionKind::isReadOnly(Kind))
return getReadOnlySection_(); return getReadOnlySection();
} }
return getDataSection(); return getDataSection();

View File

@ -150,8 +150,6 @@ X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
SixteenByteConstantSection = getUnnamedSection("\t.literal16\n", SixteenByteConstantSection = getUnnamedSection("\t.literal16\n",
SectionFlags::Mergeable); SectionFlags::Mergeable);
} }
ReadOnlySection = "\t.const\n";
LCOMMDirective = "\t.lcomm\t"; LCOMMDirective = "\t.lcomm\t";
SwitchToSectionDirective = "\t.section "; SwitchToSectionDirective = "\t.section ";
StringConstantPrefix = "\1LC"; StringConstantPrefix = "\1LC";
@ -229,7 +227,6 @@ X86DarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM): X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
X86TargetAsmInfo(TM), ELFTargetAsmInfo(TM) { X86TargetAsmInfo(TM), ELFTargetAsmInfo(TM) {
ReadOnlySection = ".rodata";
CStringSection = ".rodata.str"; CStringSection = ".rodata.str";
PrivateGlobalPrefix = ".L"; PrivateGlobalPrefix = ".L";
WeakRefDirective = "\t.weak\t"; WeakRefDirective = "\t.weak\t";