StringRef getNameForTracebackTableLanguageId(TracebackTable::LanguageID LangId);
SmallString<32> getExtendedTBTableFlagString(uint8_t Flag);
+struct CsectProperties {
+ CsectProperties(StorageMappingClass SMC, SymbolType ST)
+ : MappingClass(SMC), Type(ST) {}
+ StorageMappingClass MappingClass;
+ SymbolType Type;
+};
+
} // end namespace XCOFF
} // end namespace llvm
const MCSymbolWasm *Group, unsigned UniqueID,
const char *BeginSymName);
- MCSectionXCOFF *getXCOFFSection(StringRef Section,
- XCOFF::StorageMappingClass MappingClass,
- XCOFF::SymbolType CSectType, SectionKind K,
- bool MultiSymbolsAllowed = false,
- const char *BeginSymName = nullptr);
+ MCSectionXCOFF *
+ getXCOFFSection(StringRef Section, SectionKind K,
+ Optional<XCOFF::CsectProperties> CsectProp = None,
+ bool MultiSymbolsAllowed = false,
+ const char *BeginSymName = nullptr);
// Create and save a copy of STI and return a reference to the copy.
MCSubtargetInfo &getSubtargetCopy(const MCSubtargetInfo &STI);
else
report_fatal_error("XCOFF other section types not yet implemented.");
- return getContext().getXCOFFSection(SectionName, MappingClass, XCOFF::XTY_SD,
- Kind, /* MultiSymbolsAllowed*/ true);
+ return getContext().getXCOFFSection(
+ SectionName, Kind, XCOFF::CsectProperties(MappingClass, XCOFF::XTY_SD),
+ /* MultiSymbolsAllowed*/ true);
}
MCSection *TargetLoweringObjectFileXCOFF::getSectionForExternalReference(
// Externals go into a csect of type ER.
return getContext().getXCOFFSection(
- Name, isa<Function>(GO) ? XCOFF::XMC_DS : XCOFF::XMC_UA, XCOFF::XTY_ER,
- SectionKind::getMetadata());
+ Name, SectionKind::getMetadata(),
+ XCOFF::CsectProperties(isa<Function>(GO) ? XCOFF::XMC_DS : XCOFF::XMC_UA,
+ XCOFF::XTY_ER));
}
MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal(
SmallString<128> Name;
getNameWithPrefix(Name, GO, TM);
return getContext().getXCOFFSection(
- Name, Kind.isBSSLocal() ? XCOFF::XMC_BS : XCOFF::XMC_RW, XCOFF::XTY_CM,
- Kind);
+ Name, Kind,
+ XCOFF::CsectProperties(
+ Kind.isBSSLocal() ? XCOFF::XMC_BS : XCOFF::XMC_RW, XCOFF::XTY_CM));
}
if (Kind.isMergeableCString()) {
getNameWithPrefix(Name, GO, TM);
return getContext().getXCOFFSection(
- Name, XCOFF::XMC_RO, XCOFF::XTY_SD, Kind,
+ Name, Kind, XCOFF::CsectProperties(XCOFF::XMC_RO, XCOFF::XTY_SD),
/* MultiSymbolsAllowed*/ !TM.getDataSections());
}
if (TM.getDataSections()) {
SmallString<128> Name;
getNameWithPrefix(Name, GO, TM);
- return getContext().getXCOFFSection(Name, XCOFF::XMC_RW, XCOFF::XTY_SD,
- SectionKind::getData());
+ return getContext().getXCOFFSection(
+ Name, SectionKind::getData(),
+ XCOFF::CsectProperties(XCOFF::XMC_RW, XCOFF::XTY_SD));
}
return DataSection;
}
if (TM.getDataSections()) {
SmallString<128> Name;
getNameWithPrefix(Name, GO, TM);
- return getContext().getXCOFFSection(Name, XCOFF::XMC_RO, XCOFF::XTY_SD,
- SectionKind::getReadOnly());
+ return getContext().getXCOFFSection(
+ Name, SectionKind::getReadOnly(),
+ XCOFF::CsectProperties(XCOFF::XMC_RO, XCOFF::XTY_SD));
}
return ReadOnlySection;
}
// the table doesn't prevent the removal.
SmallString<128> NameStr(".rodata.jmp..");
getNameWithPrefix(NameStr, &F, TM);
- return getContext().getXCOFFSection(NameStr, XCOFF::XMC_RO, XCOFF::XTY_SD,
- SectionKind::getReadOnly());
+ return getContext().getXCOFFSection(
+ NameStr, SectionKind::getReadOnly(),
+ XCOFF::CsectProperties(XCOFF::XMC_RO, XCOFF::XTY_SD));
}
bool TargetLoweringObjectFileXCOFF::shouldPutJumpTableInFunctionSection(
Func->isDeclaration()) &&
isa<Function>(Func)) {
return getContext()
- .getXCOFFSection(NameStr, XCOFF::XMC_PR,
- Func->isDeclaration() ? XCOFF::XTY_ER : XCOFF::XTY_SD,
- SectionKind::getText())
+ .getXCOFFSection(
+ NameStr, SectionKind::getText(),
+ XCOFF::CsectProperties(XCOFF::XMC_PR, Func->isDeclaration()
+ ? XCOFF::XTY_ER
+ : XCOFF::XTY_SD))
->getQualNameSymbol();
}
const Function *F, const TargetMachine &TM) const {
SmallString<128> NameStr;
getNameWithPrefix(NameStr, F, TM);
- return getContext().getXCOFFSection(NameStr, XCOFF::XMC_DS, XCOFF::XTY_SD,
- SectionKind::getData());
+ return getContext().getXCOFFSection(
+ NameStr, SectionKind::getData(),
+ XCOFF::CsectProperties(XCOFF::XMC_DS, XCOFF::XTY_SD));
}
MCSection *TargetLoweringObjectFileXCOFF::getSectionForTOCEntry(
// Use TE storage-mapping class when large code model is enabled so that
// the chance of needing -bbigtoc is decreased.
return getContext().getXCOFFSection(
- cast<MCSymbolXCOFF>(Sym)->getSymbolTableName(),
- TM.getCodeModel() == CodeModel::Large ? XCOFF::XMC_TE : XCOFF::XMC_TC,
- XCOFF::XTY_SD, SectionKind::getData());
+ cast<MCSymbolXCOFF>(Sym)->getSymbolTableName(), SectionKind::getData(),
+ XCOFF::CsectProperties(
+ TM.getCodeModel() == CodeModel::Large ? XCOFF::XMC_TE : XCOFF::XMC_TC,
+ XCOFF::XTY_SD));
}
}
MCSectionXCOFF *
-MCContext::getXCOFFSection(StringRef Section, XCOFF::StorageMappingClass SMC,
- XCOFF::SymbolType Type, SectionKind Kind,
+MCContext::getXCOFFSection(StringRef Section, SectionKind Kind,
+ Optional<XCOFF::CsectProperties> CsectProp,
bool MultiSymbolsAllowed, const char *BeginSymName) {
// Do the lookup. If we have a hit, return it.
- auto IterBool = XCOFFUniquingMap.insert(
- std::make_pair(XCOFFSectionKey{Section.str(), SMC}, nullptr));
+ // FIXME: handle the case for non-csect sections. Non-csect section has None
+ // CsectProp.
+ auto IterBool = XCOFFUniquingMap.insert(std::make_pair(
+ XCOFFSectionKey{Section.str(), CsectProp->MappingClass}, nullptr));
auto &Entry = *IterBool.first;
if (!IterBool.second) {
MCSectionXCOFF *ExistedEntry = Entry.second;
// Otherwise, return a new section.
StringRef CachedName = Entry.first.SectionName;
MCSymbolXCOFF *QualName = cast<MCSymbolXCOFF>(getOrCreateSymbol(
- CachedName + "[" + XCOFF::getMappingClassString(SMC) + "]"));
+ CachedName + "[" + XCOFF::getMappingClassString(CsectProp->MappingClass) +
+ "]"));
MCSymbol *Begin = nullptr;
if (BeginSymName)
// QualName->getUnqualifiedName() and CachedName are the same except when
// CachedName contains invalid character(s) such as '$' for an XCOFF symbol.
- MCSectionXCOFF *Result = new (XCOFFAllocator.Allocate())
- MCSectionXCOFF(QualName->getUnqualifiedName(), SMC, Type, Kind, QualName,
- Begin, CachedName, MultiSymbolsAllowed);
+ MCSectionXCOFF *Result = new (XCOFFAllocator.Allocate()) MCSectionXCOFF(
+ QualName->getUnqualifiedName(), CsectProp->MappingClass, CsectProp->Type,
+ Kind, QualName, Begin, CachedName, MultiSymbolsAllowed);
Entry.second = Result;
auto *F = new MCDataFragment();
// the ABI or object file format. For example, the XL compiler uses an unnamed
// csect for program code.
TextSection = Ctx->getXCOFFSection(
- ".text", XCOFF::StorageMappingClass::XMC_PR, XCOFF::XTY_SD,
- SectionKind::getText(), /* MultiSymbolsAllowed*/ true);
+ ".text", SectionKind::getText(),
+ XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_PR, XCOFF::XTY_SD),
+ /* MultiSymbolsAllowed*/ true);
DataSection = Ctx->getXCOFFSection(
- ".data", XCOFF::StorageMappingClass::XMC_RW, XCOFF::XTY_SD,
- SectionKind::getData(), /* MultiSymbolsAllowed*/ true);
+ ".data", SectionKind::getData(),
+ XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_RW, XCOFF::XTY_SD),
+ /* MultiSymbolsAllowed*/ true);
ReadOnlySection = Ctx->getXCOFFSection(
- ".rodata", XCOFF::StorageMappingClass::XMC_RO, XCOFF::XTY_SD,
- SectionKind::getReadOnly(), /* MultiSymbolsAllowed*/ true);
+ ".rodata", SectionKind::getReadOnly(),
+ XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_RO, XCOFF::XTY_SD),
+ /* MultiSymbolsAllowed*/ true);
- TOCBaseSection =
- Ctx->getXCOFFSection("TOC", XCOFF::StorageMappingClass::XMC_TC0,
- XCOFF::XTY_SD, SectionKind::getData());
+ TOCBaseSection = Ctx->getXCOFFSection(
+ "TOC", SectionKind::getData(),
+ XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_TC0,
+ XCOFF::XTY_SD));
// The TOC-base always has 0 size, but 4 byte alignment.
TOCBaseSection->setAlignment(Align(4));
- LSDASection = Ctx->getXCOFFSection(".gcc_except_table",
- XCOFF::StorageMappingClass::XMC_RO,
- XCOFF::XTY_SD, SectionKind::getReadOnly());
+ LSDASection = Ctx->getXCOFFSection(
+ ".gcc_except_table", SectionKind::getReadOnly(),
+ XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_RO,
+ XCOFF::XTY_SD));
- CompactUnwindSection =
- Ctx->getXCOFFSection(".eh_info_table", XCOFF::StorageMappingClass::XMC_RW,
- XCOFF::XTY_SD, SectionKind::getData());
+ CompactUnwindSection = Ctx->getXCOFFSection(
+ ".eh_info_table", SectionKind::getData(),
+ XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_RW,
+ XCOFF::XTY_SD));
// DWARF sections for XCOFF are not csects. They are special STYP_DWARF
// sections, and the individual DWARF sections are distinguished by their
const auto getExternalFunctionEntryPointSymbol = [&](StringRef SymName) {
auto &Context = DAG.getMachineFunction().getMMI().getContext();
MCSectionXCOFF *Sec = Context.getXCOFFSection(
- (Twine(".") + Twine(SymName)).str(), XCOFF::XMC_PR, XCOFF::XTY_ER,
- SectionKind::getMetadata());
+ (Twine(".") + Twine(SymName)).str(), SectionKind::getMetadata(),
+ XCOFF::CsectProperties(XCOFF::XMC_PR, XCOFF::XTY_ER));
return Sec->getQualNameSymbol();
};