explicit TargetAsmInfo(const TargetMachine &TM);
virtual ~TargetAsmInfo();
- const Section* getNamedSection(const char *Name,
- SectionKind::Kind K) const;
- const Section* getUnnamedSection(const char *Directive,
- SectionKind::Kind K) const;
+ const Section *getOrCreateSection(const char *Name,
+ bool isDirective,
+ SectionKind::Kind K) const;
/// Measure the specified inline asm to determine an approximation of its
/// length.
ARMTargetAsmInfo<ELFTargetAsmInfo>(TM) {
Subtarget = &TM.getSubtarget<ARMSubtarget>();
- BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
+ BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
NeedsSet = false;
HasLEB128 = true;
// BSS section needs to be emitted as ".section"
BSSSection = "\t.section\t.bss";
- BSSSection_ = getUnnamedSection("\t.section\t.bss", SectionKind::BSS);
+ BSSSection_ = getOrCreateSection("\t.bss", false, SectionKind::BSS);
SupportsDebugInformation = true;
NeedsSet = true;
DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM)
: TargetAsmInfo(TM) {
- CStringSection_ = getUnnamedSection("\t.cstring",
- SectionKind::MergeableCString);
- FourByteConstantSection = getUnnamedSection("\t.literal4\n",
- SectionKind::MergeableConst4);
- EightByteConstantSection = getUnnamedSection("\t.literal8\n",
- SectionKind::MergeableConst8);
+ CStringSection_ = getOrCreateSection("\t.cstring", true,
+ SectionKind::MergeableCString);
+ FourByteConstantSection = getOrCreateSection("\t.literal4\n", true,
+ SectionKind::MergeableConst4);
+ EightByteConstantSection = getOrCreateSection("\t.literal8\n", true,
+ SectionKind::MergeableConst8);
// Note: 16-byte constant section is subtarget specific and should be provided
// there, if needed.
SixteenByteConstantSection = 0;
- ReadOnlySection = getUnnamedSection("\t.const", SectionKind::ReadOnly);
+ ReadOnlySection = getOrCreateSection("\t.const", true, SectionKind::ReadOnly);
TextCoalSection =
- getNamedSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions",
- SectionKind::Text);
- ConstTextCoalSection = getNamedSection("\t__TEXT,__const_coal,coalesced",
- SectionKind::Text);
- ConstDataCoalSection = getNamedSection("\t__DATA,__const_coal,coalesced",
- SectionKind::Text);
- ConstDataSection = getUnnamedSection("\t.const_data",
- SectionKind::ReadOnlyWithRel);
- DataCoalSection = getNamedSection("\t__DATA,__datacoal_nt,coalesced",
- SectionKind::DataRel);
+ getOrCreateSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions",
+ false, SectionKind::Text);
+ ConstTextCoalSection = getOrCreateSection("\t__TEXT,__const_coal,coalesced",
+ false, SectionKind::Text);
+ ConstDataCoalSection = getOrCreateSection("\t__DATA,__const_coal,coalesced",
+ false, SectionKind::Text);
+ ConstDataSection = getOrCreateSection("\t.const_data", true,
+ SectionKind::ReadOnlyWithRel);
+ DataCoalSection = getOrCreateSection("\t__DATA,__datacoal_nt,coalesced",
+ false, SectionKind::DataRel);
// Common settings for all Darwin targets.
ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
: TargetAsmInfo(TM) {
-
- ReadOnlySection = getNamedSection("\t.rodata", SectionKind::ReadOnly);
- TLSDataSection = getNamedSection("\t.tdata", SectionKind::ThreadData);
- TLSBSSSection = getNamedSection("\t.tbss", SectionKind::ThreadBSS);
-
- DataRelSection = getNamedSection("\t.data.rel", SectionKind::DataRel);
- DataRelLocalSection = getNamedSection("\t.data.rel.local",
- SectionKind::DataRelLocal);
- DataRelROSection = getNamedSection("\t.data.rel.ro",
- SectionKind::ReadOnlyWithRel);
- DataRelROLocalSection = getNamedSection("\t.data.rel.ro.local",
- SectionKind::ReadOnlyWithRelLocal);
+ ReadOnlySection =
+ getOrCreateSection("\t.rodata", false, SectionKind::ReadOnly);
+ TLSDataSection =
+ getOrCreateSection("\t.tdata", false, SectionKind::ThreadData);
+ TLSBSSSection = getOrCreateSection("\t.tbss", false, SectionKind::ThreadBSS);
+
+ DataRelSection = getOrCreateSection("\t.data.rel", false,
+ SectionKind::DataRel);
+ DataRelLocalSection = getOrCreateSection("\t.data.rel.local", false,
+ SectionKind::DataRelLocal);
+ DataRelROSection = getOrCreateSection("\t.data.rel.ro", false,
+ SectionKind::ReadOnlyWithRel);
+ DataRelROLocalSection =
+ getOrCreateSection("\t.data.rel.ro.local", false,
+ SectionKind::ReadOnlyWithRelLocal);
- MergeableConst4Section = getNamedSection(".rodata.cst4",
- SectionKind::MergeableConst4);
- MergeableConst8Section = getNamedSection(".rodata.cst8",
- SectionKind::MergeableConst8);
- MergeableConst16Section = getNamedSection(".rodata.cst16",
- SectionKind::MergeableConst16);
+ MergeableConst4Section = getOrCreateSection(".rodata.cst4", false,
+ SectionKind::MergeableConst4);
+ MergeableConst8Section = getOrCreateSection(".rodata.cst8", false,
+ SectionKind::MergeableConst8);
+ MergeableConst16Section = getOrCreateSection(".rodata.cst16", false,
+ SectionKind::MergeableConst16);
}
Align = Size;
std::string Name = getCStringSection() + utostr(Size) + '.' + utostr(Align);
- return getNamedSection(Name.c_str(), SectionKind::MergeableCString);
+ return getOrCreateSection(Name.c_str(), false,
+ SectionKind::MergeableCString);
}
return getReadOnlySection();
: ELFTargetAsmInfo(TM) {
AlignmentIsInBytes = false;
- BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
+ BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
}
BSSSection = "\t.section\t.bss";
CStringSection = ".rodata.str";
- BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
+ BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
if (!TM.getSubtarget<MipsSubtarget>().hasABICall())
JumpTableDirective = "\t.word\t";
const char *codeSection = PAN::getCodeSectionName(CurrentFnName).c_str();
const Section *fCodeSection =
- TAI->getNamedSection(codeSection, SectionKind::Text);
+ TAI->getOrCreateSection(codeSection, false, SectionKind::Text);
// Start the Code Section.
O << "\n";
SwitchToSection(fCodeSection);
const char *SectionName = PAN::getFrameSectionName(CurrentFnName).c_str();
const Section *fPDataSection =
- TAI->getNamedSection(SectionName, SectionKind::DataRel);
+ TAI->getOrCreateSection(SectionName, false, SectionKind::DataRel);
SwitchToSection(fPDataSection);
// Emit function frame label
ZeroDirective = NULL;
AsciiDirective = " dt ";
AscizDirective = NULL;
- BSSSection_ = getNamedSection("udata.# UDATA", SectionKind::BSS);
- ReadOnlySection = getNamedSection("romdata.# ROMDATA", SectionKind::ReadOnly);
- DataSection = getNamedSection("idata.# IDATA", SectionKind::DataRel);
+ BSSSection_ = getOrCreateSection("udata.# UDATA", false, SectionKind::BSS);
+ ReadOnlySection = getOrCreateSection("romdata.# ROMDATA", false,
+ SectionKind::ReadOnly);
+ DataSection = getOrCreateSection("idata.# IDATA", false,SectionKind::DataRel);
SwitchToSectionDirective = "";
// Need because otherwise a .text symbol is emitted by DwarfWriter
// in BeginModule, and gpasm cribbs for that .text symbol.
- TextSection = getUnnamedSection("", SectionKind::Text);
+ TextSection = getOrCreateSection("", true, SectionKind::Text);
PIC16Section *ROSection = new PIC16Section(getReadOnlySection());
ROSections.push_back(ROSection);
// FIXME: I don't know what the classification of these sections really is.
- ExternalVarDecls = new PIC16Section(getNamedSection("ExternalVarDecls",
- SectionKind::Metadata));
- ExternalVarDefs = new PIC16Section(getNamedSection("ExternalVarDefs",
- SectionKind::Metadata));
+ ExternalVarDecls = new PIC16Section(getOrCreateSection("ExternalVarDecls",
+ false,
+ SectionKind::Metadata));
+ ExternalVarDefs = new PIC16Section(getOrCreateSection("ExternalVarDefs",
+ false,
+ SectionKind::Metadata));
// Set it to false because we weed to generate c file name and not bc file
// name.
HasSingleParameterDotFile = false;
// No BSS section spacious enough was found. Crate a new one.
if (!FoundBSS) {
std::string name = PAN::getUdataSectionName(BSSSections.size());
- const Section *NewSection = getNamedSection(name.c_str(),
- // FIXME.
- SectionKind::Metadata);
+ const Section *NewSection = getOrCreateSection(name.c_str(), false,
+ // FIXME.
+ SectionKind::Metadata);
FoundBSS = new PIC16Section(NewSection);
// No IDATA section spacious enough was found. Crate a new one.
if (!FoundIDATA) {
std::string name = PAN::getIdataSectionName(IDATASections.size());
- const Section *NewSection = getNamedSection(name.c_str(),
- // FIXME.
- SectionKind::Metadata);
+ const Section *NewSection = getOrCreateSection(name.c_str(),
+ false,
+ // FIXME.
+ SectionKind::Metadata);
FoundIDATA = new PIC16Section(NewSection);
// No Auto section was found. Crate a new one.
if (!FoundAutoSec) {
- const Section *NewSection = getNamedSection(name.c_str(),
- // FIXME.
- SectionKind::Metadata);
+ const Section *NewSection = getOrCreateSection(name.c_str(),
+ // FIXME.
+ false,
+ SectionKind::Metadata);
FoundAutoSec = new PIC16Section(NewSection);
PIC16Section *NewBSS = FoundBSS;
if (NewBSS == NULL) {
- const Section *NewSection = getNamedSection(Name.c_str(), SectionKind::BSS);
+ const Section *NewSection = getOrCreateSection(Name.c_str(),
+ false, SectionKind::BSS);
NewBSS = new PIC16Section(NewSection);
BSSSections.push_back(NewBSS);
}
PIC16Section *NewIDATASec = FoundIDATASec;
if (NewIDATASec == NULL) {
- const Section *NewSection = getNamedSection(Name.c_str(),
- // FIXME:
- SectionKind::Metadata);
+ const Section *NewSection = getOrCreateSection(Name.c_str(),
+ false,
+ // FIXME:
+ SectionKind::Metadata);
NewIDATASec = new PIC16Section(NewSection);
IDATASections.push_back(NewIDATASec);
}
PIC16Section *NewRomSec = FoundROSec;
if (NewRomSec == NULL) {
- const Section *NewSection = getNamedSection(Name.c_str(),
- SectionKind::ReadOnly);
+ const Section *NewSection = getOrCreateSection(Name.c_str(),
+ false,
+ SectionKind::ReadOnly);
NewRomSec = new PIC16Section(NewSection);
ROSections.push_back(NewRomSec);
}
BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
// PPC/Linux normally uses named section for BSS.
- BSSSection_ = getNamedSection("\t.bss", SectionKind::BSS);
+ BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
// Debug Information
AbsoluteDebugSectionOffsets = true;
CStringSection=".rodata.str";
// Sparc normally uses named section for BSS.
- BSSSection_ = getNamedSection("\t.bss", SectionKind::BSS);
+ BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
}
NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
- BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
+ BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
}
DwarfEHFrameSection = ".eh_frame";
DwarfExceptionSection = ".gcc_except_table";
AsmTransCBE = 0;
- TextSection = getUnnamedSection("\t.text", SectionKind::Text);
- DataSection = getUnnamedSection("\t.data", SectionKind::DataRel);
+ TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
+ DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel);
}
TargetAsmInfo::~TargetAsmInfo() {
// section and still get the appropriate section flags printed.
GVKind = getKindForNamedSection(GV->getSection().c_str(), GVKind);
- return getNamedSection(GV->getSection().c_str(), GVKind);
+ return getOrCreateSection(GV->getSection().c_str(), false, GVKind);
}
// If this global is linkonce/weak and the target handles this by emitting it
if (const char *Prefix = getSectionPrefixForUniqueGlobal(Kind)) {
// FIXME: Use mangler interface (PR4584).
std::string Name = Prefix+GV->getNameStr();
- return getNamedSection(Name.c_str(), GVKind);
+ return getOrCreateSection(Name.c_str(), false, GVKind);
}
}
}
-const Section *TargetAsmInfo::getNamedSection(const char *Name,
- SectionKind::Kind Kind) const {
+const Section *TargetAsmInfo::getOrCreateSection(const char *Name,
+ bool isDirective,
+ SectionKind::Kind Kind) const {
Section &S = Sections[Name];
// This is newly-created section, set it up properly.
if (S.Name.empty()) {
- S.Kind = SectionKind::get(Kind, false /*weak*/, true /*Named*/);
+ S.Kind = SectionKind::get(Kind, false /*weak*/, !isDirective);
S.Name = Name;
}
return &S;
}
-const Section*
-TargetAsmInfo::getUnnamedSection(const char *Directive,
- SectionKind::Kind Kind) const {
- Section& S = Sections[Directive];
-
- // This is newly-created section, set it up properly.
- if (S.Name.empty()) {
- S.Kind = SectionKind::get(Kind, false /*weak*/, false /*Named*/);
- S.Name = Directive;
- }
-
- return &S;
-}
-
unsigned TargetAsmInfo::getULEB128Size(unsigned Value) {
unsigned Size = 0;
do {
ConstantPoolSection = "\t.const\n";
// FIXME: Why don't we always use this section?
if (is64Bit)
- SixteenByteConstantSection = getUnnamedSection("\t.literal16\n",
- SectionKind::MergeableConst16);
+ SixteenByteConstantSection =
+ getOrCreateSection("\t.literal16\n", true, SectionKind::MergeableConst16);
LCOMMDirective = "\t.lcomm\t";
// Leopard and above support aligned common symbols.
bool Global) const {
if (Reason == DwarfEncoding::Functions && Global)
return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
- else if (Reason == DwarfEncoding::CodeLabels || !Global)
+ if (Reason == DwarfEncoding::CodeLabels || !Global)
return DW_EH_PE_pcrel;
- else
- return DW_EH_PE_absptr;
+ return DW_EH_PE_absptr;
}
const char *
-X86DarwinTargetAsmInfo::getEHGlobalPrefix() const
-{
+X86DarwinTargetAsmInfo::getEHGlobalPrefix() const {
const X86Subtarget* Subtarget = &TM.getSubtarget<X86Subtarget>();
if (Subtarget->getDarwinVers() > 9)
return PrivateGlobalPrefix;
- else
- return "";
+ return "";
}
-X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
+X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) :
X86TargetAsmInfo<ELFTargetAsmInfo>(TM) {
CStringSection = ".rodata.str";
// Set up DWARF directives
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
- BSSSection_ = getUnnamedSection("\t.bss", SectionKind::BSS);
+ BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
// Debug Information
AbsoluteDebugSectionOffsets = true;
AlignmentIsInBytes = true;
- TextSection = getUnnamedSection("_text", SectionKind::Text);
- DataSection = getUnnamedSection("_data", SectionKind::DataRel);
+ TextSection = getOrCreateSection("_text", true, SectionKind::Text);
+ DataSection = getOrCreateSection("_data", true, SectionKind::DataRel);
JumpTableDataSection = NULL;
SwitchToSectionDirective = "";
XCoreTargetAsmInfo::XCoreTargetAsmInfo(const XCoreTargetMachine &TM)
: ELFTargetAsmInfo(TM) {
SupportsDebugInformation = true;
- TextSection = getUnnamedSection("\t.text", SectionKind::Text);
- DataSection = getNamedSection("\t.dp.data", SectionKind::DataRel);
- BSSSection_ = getNamedSection("\t.dp.bss", SectionKind::BSS);
+ TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
+ DataSection = getOrCreateSection("\t.dp.data", false, SectionKind::DataRel);
+ BSSSection_ = getOrCreateSection("\t.dp.bss", false, SectionKind::BSS);
// TLS globals are lowered in the backend to arrays indexed by the current
// thread id. After lowering they require no special handling by the linker
if (TM.getSubtargetImpl()->isXS1A())
// FIXME: Why is this writable???
- ReadOnlySection = getNamedSection("\t.dp.rodata", SectionKind::DataRel);
+ ReadOnlySection = getOrCreateSection("\t.dp.rodata", false,
+ SectionKind::DataRel);
else
- ReadOnlySection = getNamedSection("\t.cp.rodata", SectionKind::ReadOnly);
+ ReadOnlySection = getOrCreateSection("\t.cp.rodata", false,
+ SectionKind::ReadOnly);
Data16bitsDirective = "\t.short\t";
Data32bitsDirective = "\t.long\t";
Data64bitsDirective = 0;