Get rid of duplicate char*/Section* DataSection

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56575 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov 2008-09-24 22:16:16 +00:00
parent d7ca416d6c
commit 315690ec2a
9 changed files with 17 additions and 23 deletions

View File

@ -131,12 +131,11 @@ namespace llvm {
/// TextSection - Section directive for standard text. /// TextSection - Section directive for standard text.
/// ///
const Section *TextSection; // Defaults to ".text". const Section *TextSection; // Defaults to ".text".
/// DataSection - Section directive for standard data. /// DataSection - Section directive for standard data.
/// ///
const char *DataSection; // Defaults to ".data". const Section *DataSection; // Defaults to ".data".
const Section *DataSection_;
/// BSSSection - Section directive for uninitialized data. Null if this /// BSSSection - Section directive for uninitialized data. Null if this
/// target doesn't support a BSS section. /// target doesn't support a BSS section.
@ -601,12 +600,9 @@ namespace llvm {
const Section *getTextSection() const { const Section *getTextSection() const {
return TextSection; return TextSection;
} }
const char *getDataSection() const { const Section *getDataSection() const {
return DataSection; return DataSection;
} }
const Section *getDataSection_() const {
return DataSection_;
}
const char *getBSSSection() const { const char *getBSSSection() const {
return BSSSection; return BSSSection;
} }

View File

@ -2064,7 +2064,7 @@ private:
Asm->SwitchToSection(TAI->getTextSection()); Asm->SwitchToSection(TAI->getTextSection());
EmitLabel("text_begin", 0); EmitLabel("text_begin", 0);
Asm->SwitchToDataSection(TAI->getDataSection()); Asm->SwitchToSection(TAI->getDataSection());
EmitLabel("data_begin", 0); EmitLabel("data_begin", 0);
} }
@ -2750,7 +2750,7 @@ public:
// Standard sections final addresses. // Standard sections final addresses.
Asm->SwitchToSection(TAI->getTextSection()); Asm->SwitchToSection(TAI->getTextSection());
EmitLabel("text_end", 0); EmitLabel("text_end", 0);
Asm->SwitchToDataSection(TAI->getDataSection()); Asm->SwitchToSection(TAI->getDataSection());
EmitLabel("data_end", 0); EmitLabel("data_end", 0);
// End text sections. // End text sections.

View File

@ -65,7 +65,7 @@ void OcamlGCMetadataPrinter::beginAssembly(raw_ostream &OS, AsmPrinter &AP,
AP.SwitchToSection(TAI.getTextSection()); AP.SwitchToSection(TAI.getTextSection());
EmitCamlGlobal(getModule(), OS, AP, TAI, "code_begin"); EmitCamlGlobal(getModule(), OS, AP, TAI, "code_begin");
AP.SwitchToDataSection(TAI.getDataSection()); AP.SwitchToSection(TAI.getDataSection());
EmitCamlGlobal(getModule(), OS, AP, TAI, "data_begin"); EmitCamlGlobal(getModule(), OS, AP, TAI, "data_begin");
} }
@ -100,13 +100,13 @@ void OcamlGCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP,
AP.SwitchToSection(TAI.getTextSection()); AP.SwitchToSection(TAI.getTextSection());
EmitCamlGlobal(getModule(), OS, AP, TAI, "code_end"); EmitCamlGlobal(getModule(), OS, AP, TAI, "code_end");
AP.SwitchToDataSection(TAI.getDataSection()); AP.SwitchToSection(TAI.getDataSection());
EmitCamlGlobal(getModule(), OS, AP, TAI, "data_end"); EmitCamlGlobal(getModule(), OS, AP, TAI, "data_end");
OS << AddressDirective << 0; // FIXME: Why does ocaml emit this?? OS << AddressDirective << 0; // FIXME: Why does ocaml emit this??
AP.EOL(); AP.EOL();
AP.SwitchToDataSection(TAI.getDataSection()); AP.SwitchToSection(TAI.getDataSection());
EmitCamlGlobal(getModule(), OS, AP, TAI, "frametable"); EmitCamlGlobal(getModule(), OS, AP, TAI, "frametable");
for (iterator I = begin(), IE = end(); I != IE; ++I) { for (iterator I = begin(), IE = end(); I != IE; ++I) {

View File

@ -48,7 +48,6 @@ ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) {
AlignmentIsInBytes = false; AlignmentIsInBytes = false;
Data64bitsDirective = 0; Data64bitsDirective = 0;
CommentString = "@"; CommentString = "@";
DataSection = "\t.data";
ConstantPoolSection = "\t.text\n"; ConstantPoolSection = "\t.text\n";
COMMDirectiveTakesAlignment = false; COMMDirectiveTakesAlignment = false;
InlineAsmStart = "@ InlineAsm Start"; InlineAsmStart = "@ InlineAsm Start";

View File

@ -90,7 +90,7 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
if (cast<GlobalVariable>(GV)->isConstant()) if (cast<GlobalVariable>(GV)->isConstant())
return (isWeak ? ConstDataCoalSection : ConstDataSection); return (isWeak ? ConstDataCoalSection : ConstDataSection);
else else
return (isWeak ? DataCoalSection : getDataSection_()); return (isWeak ? DataCoalSection : getDataSection());
case SectionKind::ROData: case SectionKind::ROData:
return (isWeak ? ConstDataCoalSection : return (isWeak ? ConstDataCoalSection :
(isNonStatic ? ConstDataSection : getReadOnlySection_())); (isNonStatic ? ConstDataSection : getReadOnlySection_()));

View File

@ -27,7 +27,6 @@ using namespace llvm;
ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM) { ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM) {
ETM = &TM; ETM = &TM;
DataSection_ = getUnnamedSection("\t.data", SectionFlags::Writeable);
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);
@ -64,7 +63,7 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
switch (Kind) { switch (Kind) {
case SectionKind::Data: case SectionKind::Data:
case SectionKind::SmallData: case SectionKind::SmallData:
return getDataSection_(); return getDataSection();
case SectionKind::BSS: case SectionKind::BSS:
case SectionKind::SmallBSS: case SectionKind::SmallBSS:
// ELF targets usually have BSS sections // ELF targets usually have BSS sections

View File

@ -27,8 +27,7 @@ using namespace llvm;
TargetAsmInfo::TargetAsmInfo() : TargetAsmInfo::TargetAsmInfo() :
TextSection(0), TextSection(0),
DataSection("\t.data"), DataSection(0),
DataSection_(0),
BSSSection("\t.bss"), BSSSection("\t.bss"),
BSSSection_(0), BSSSection_(0),
ReadOnlySection(0), ReadOnlySection(0),
@ -126,7 +125,7 @@ TargetAsmInfo::TargetAsmInfo() :
DwarfExceptionSection(".gcc_except_table"), DwarfExceptionSection(".gcc_except_table"),
AsmTransCBE(0) { AsmTransCBE(0) {
TextSection = getUnnamedSection("\t.text", SectionFlags::Code); TextSection = getUnnamedSection("\t.text", SectionFlags::Code);
DataSection_ = getUnnamedSection(DataSection); DataSection = getUnnamedSection("\t.data", SectionFlags::Writeable);
} }
TargetAsmInfo::~TargetAsmInfo() { TargetAsmInfo::~TargetAsmInfo() {
@ -306,14 +305,14 @@ TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
return getReadOnlySection_(); return getReadOnlySection_();
} }
return getDataSection_(); return getDataSection();
} }
// Lame default implementation. Calculate the section name for machine const. // Lame default implementation. Calculate the section name for machine const.
const Section* const Section*
TargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const { TargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
// FIXME: Support data.rel stuff someday // FIXME: Support data.rel stuff someday
return getDataSection_(); return getDataSection();
} }
std::string std::string

View File

@ -481,7 +481,7 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) {
O << "\tpublic " << name << "\n"; O << "\tpublic " << name << "\n";
// FALL THROUGH // FALL THROUGH
case GlobalValue::InternalLinkage: case GlobalValue::InternalLinkage:
SwitchToDataSection(TAI->getDataSection(), I); SwitchToSection(TAI->getDataSection());
break; break;
default: default:
assert(0 && "Unknown linkage type!"); assert(0 && "Unknown linkage type!");

View File

@ -434,7 +434,8 @@ X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
HasDotTypeDotSizeDirective = false; HasDotTypeDotSizeDirective = false;
TextSection = getUnnamedSection("_text", SectionFlags::Code); TextSection = getUnnamedSection("_text", SectionFlags::Code);
DataSection = "_data"; DataSection = getUnnamedSection("_data", SectionFlags::Writeable);
JumpTableDataSection = NULL; JumpTableDataSection = NULL;
SwitchToSectionDirective = ""; SwitchToSectionDirective = "";
TextSectionStartSuffix = "\tsegment 'CODE'"; TextSectionStartSuffix = "\tsegment 'CODE'";