diff options
author | Sean Fertile <sfertile@ca.ibm.com> | 2019-07-09 19:21:01 +0000 |
---|---|---|
committer | Sean Fertile <sfertile@ca.ibm.com> | 2019-07-09 19:21:01 +0000 |
commit | f09d54ed2a75b62960b35258136435d7c8d418e1 (patch) | |
tree | 5f727b7c433f9026cf64e6ec03d25e11d306994d /llvm/lib/MC/MCContext.cpp | |
parent | 294f37561ab155e363be0fca5fa43528d8b29d18 (diff) | |
download | bcm5719-llvm-f09d54ed2a75b62960b35258136435d7c8d418e1.tar.gz bcm5719-llvm-f09d54ed2a75b62960b35258136435d7c8d418e1.zip |
Boilerplate for producing XCOFF object files from the PowerPC backend.
Stubs out a number of the classes needed to produce a new object file format
(XCOFF) for the powerpc-aix target. For testing input is an empty module which
produces an object file with just a file header.
Differential Revision: https://reviews.llvm.org/D61694
llvm-svn: 365541
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 5ec03ee0894..0dc2e2d37ca 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -26,6 +26,7 @@ #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionWasm.h" +#include "llvm/MC/MCSectionXCOFF.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbolCOFF.h" @@ -86,6 +87,7 @@ void MCContext::reset() { COFFAllocator.DestroyAll(); ELFAllocator.DestroyAll(); MachOAllocator.DestroyAll(); + XCOFFAllocator.DestroyAll(); MCSubtargetAllocator.DestroyAll(); UsedNames.clear(); @@ -107,6 +109,7 @@ void MCContext::reset() { ELFUniquingMap.clear(); COFFUniquingMap.clear(); WasmUniquingMap.clear(); + XCOFFUniquingMap.clear(); NextID.clear(); AllowTemporaryLabels = true; @@ -526,6 +529,38 @@ MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind Kind, return Result; } +MCSectionXCOFF *MCContext::getXCOFFSection(StringRef Section, + XCOFF::StorageMappingClass SMC, + SectionKind Kind, + 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)); + auto &Entry = *IterBool.first; + if (!IterBool.second) + return Entry.second; + + // Otherwise, return a new section. + StringRef CachedName = Entry.first.SectionName; + + MCSymbol *Begin = nullptr; + if (BeginSymName) + Begin = createTempSymbol(BeginSymName, false); + + MCSectionXCOFF *Result = new (XCOFFAllocator.Allocate()) + MCSectionXCOFF(CachedName, SMC, Kind, Begin); + Entry.second = Result; + + auto *F = new MCDataFragment(); + Result->getFragmentList().insert(Result->begin(), F); + F->setParent(Result); + + if (Begin) + Begin->setFragment(F); + + return Result; +} + MCSubtargetInfo &MCContext::getSubtargetCopy(const MCSubtargetInfo &STI) { return *new (MCSubtargetAllocator.Allocate()) MCSubtargetInfo(STI); } |