diff options
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 52bf48b..1c0c711 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -26,6 +26,7 @@ #include "llvm/MC/MCInst.h" #include "llvm/MC/MCLabel.h" #include "llvm/MC/MCSectionCOFF.h" +#include "llvm/MC/MCSectionDXContainer.h" #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionGOFF.h" #include "llvm/MC/MCSectionMachO.h" @@ -145,6 +146,7 @@ void MCContext::reset() { // Call the destructors so the fragments are freed COFFAllocator.DestroyAll(); + DXCAllocator.DestroyAll(); ELFAllocator.DestroyAll(); GOFFAllocator.DestroyAll(); MachOAllocator.DestroyAll(); @@ -176,6 +178,7 @@ void MCContext::reset() { COFFUniquingMap.clear(); WasmUniquingMap.clear(); XCOFFUniquingMap.clear(); + DXCUniquingMap.clear(); ELFEntrySizeMap.clear(); ELFSeenGenericMergeableSections.clear(); @@ -838,6 +841,29 @@ MCSectionSPIRV *MCContext::getSPIRVSection() { return Result; } +MCSectionDXContainer *MCContext::getDXContainerSection(StringRef Section, + SectionKind K) { + // Do the lookup, if we have a hit, return it. + auto ItInsertedPair = DXCUniquingMap.try_emplace(Section); + if (!ItInsertedPair.second) + return ItInsertedPair.first->second; + + auto MapIt = ItInsertedPair.first; + // Grab the name from the StringMap. Since the Section is going to keep a + // copy of this StringRef we need to make sure the underlying string stays + // alive as long as we need it. + StringRef Name = MapIt->first(); + MapIt->second = + new (DXCAllocator.Allocate()) MCSectionDXContainer(Name, K, nullptr); + + // The first fragment will store the header + auto *F = new MCDataFragment(); + MapIt->second->getFragmentList().insert(MapIt->second->begin(), F); + F->setParent(MapIt->second); + + return MapIt->second; +} + MCSubtargetInfo &MCContext::getSubtargetCopy(const MCSubtargetInfo &STI) { return *new (MCSubtargetAllocator.Allocate()) MCSubtargetInfo(STI); } |