Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/MC/MCContext.cpp
Show First 20 Lines • Show All 656 Lines • ▼ Show 20 Lines | MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind Kind, | ||||
Begin->setFragment(F); | Begin->setFragment(F); | ||||
return Result; | return Result; | ||||
} | } | ||||
MCSectionXCOFF *MCContext::getXCOFFSection(StringRef Section, | MCSectionXCOFF *MCContext::getXCOFFSection(StringRef Section, | ||||
XCOFF::StorageMappingClass SMC, | XCOFF::StorageMappingClass SMC, | ||||
XCOFF::SymbolType Type, | XCOFF::SymbolType Type, | ||||
XCOFF::StorageClass SC, | |||||
SectionKind Kind, | SectionKind Kind, | ||||
const char *BeginSymName) { | const char *BeginSymName) { | ||||
// Do the lookup. If we have a hit, return it. | // Do the lookup. If we have a hit, return it. | ||||
auto IterBool = XCOFFUniquingMap.insert( | auto IterBool = XCOFFUniquingMap.insert( | ||||
std::make_pair(XCOFFSectionKey{Section.str(), SMC}, nullptr)); | std::make_pair(XCOFFSectionKey{Section.str(), SMC}, nullptr)); | ||||
auto &Entry = *IterBool.first; | auto &Entry = *IterBool.first; | ||||
if (!IterBool.second) | if (!IterBool.second) | ||||
return Entry.second; | return Entry.second; | ||||
// Otherwise, return a new section. | // Otherwise, return a new section. | ||||
StringRef CachedName = Entry.first.SectionName; | StringRef CachedName = Entry.first.SectionName; | ||||
MCSymbolXCOFF *QualName = cast<MCSymbolXCOFF>(getOrCreateSymbol( | MCSymbolXCOFF *QualName = cast<MCSymbolXCOFF>(getOrCreateSymbol( | ||||
CachedName + "[" + XCOFF::getMappingClassString(SMC) + "]")); | CachedName + "[" + XCOFF::getMappingClassString(SMC) + "]")); | ||||
MCSymbol *Begin = nullptr; | MCSymbol *Begin = nullptr; | ||||
if (BeginSymName) | if (BeginSymName) | ||||
Begin = createTempSymbol(BeginSymName, false); | Begin = createTempSymbol(BeginSymName, false); | ||||
// QualName->getUnqualifiedName() and CachedName are the same except when | // QualName->getUnqualifiedName() and CachedName are the same except when | ||||
// CachedName contains invalid character(s) such as '$' for an XCOFF symbol. | // CachedName contains invalid character(s) such as '$' for an XCOFF symbol. | ||||
MCSectionXCOFF *Result = new (XCOFFAllocator.Allocate()) | MCSectionXCOFF *Result = new (XCOFFAllocator.Allocate()) | ||||
MCSectionXCOFF(QualName->getUnqualifiedName(), SMC, Type, SC, Kind, | MCSectionXCOFF(QualName->getUnqualifiedName(), SMC, Type, Kind, QualName, | ||||
QualName, Begin, CachedName); | Begin, CachedName); | ||||
Entry.second = Result; | Entry.second = Result; | ||||
auto *F = new MCDataFragment(); | auto *F = new MCDataFragment(); | ||||
Result->getFragmentList().insert(Result->begin(), F); | Result->getFragmentList().insert(Result->begin(), F); | ||||
F->setParent(Result); | F->setParent(Result); | ||||
if (Begin) | if (Begin) | ||||
Begin->setFragment(F); | Begin->setFragment(F); | ||||
▲ Show 20 Lines • Show All 161 Lines • Show Last 20 Lines |