#include "llvm/MC/MCContext.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/BinaryFormat/Wasm.h"
#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCCodeView.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFragment.h"
#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"
#include "llvm/MC/MCSectionSPIRV.h"
#include "llvm/MC/MCSectionWasm.h"
#include "llvm/MC/MCSectionXCOFF.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolCOFF.h"
#include "llvm/MC/MCSymbolELF.h"
#include "llvm/MC/MCSymbolGOFF.h"
#include "llvm/MC/MCSymbolMachO.h"
#include "llvm/MC/MCSymbolWasm.h"
#include "llvm/MC/MCSymbolXCOFF.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/SectionKind.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SMLoc.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdlib>
#include <optional>
#include <tuple>
#include <utility>
usingnamespacellvm;
static void defaultDiagHandler(const SMDiagnostic &SMD, bool, const SourceMgr &,
std::vector<const MDNode *> &) { … }
MCContext::MCContext(const Triple &TheTriple, const MCAsmInfo *mai,
const MCRegisterInfo *mri, const MCSubtargetInfo *msti,
const SourceMgr *mgr, MCTargetOptions const *TargetOpts,
bool DoAutoReset, StringRef Swift5ReflSegmentName)
: … { … }
MCContext::~MCContext() { … }
void MCContext::initInlineSourceManager() { … }
void MCContext::reset() { … }
MCInst *MCContext::createMCInst() { … }
MCDataFragment *MCContext::allocInitialFragment(MCSection &Sec) { … }
MCSymbol *MCContext::getOrCreateSymbol(const Twine &Name) { … }
MCSymbol *MCContext::getOrCreateFrameAllocSymbol(const Twine &FuncName,
unsigned Idx) { … }
MCSymbol *MCContext::getOrCreateParentFrameOffsetSymbol(const Twine &FuncName) { … }
MCSymbol *MCContext::getOrCreateLSDASymbol(const Twine &FuncName) { … }
MCSymbolTableEntry &MCContext::getSymbolTableEntry(StringRef Name) { … }
MCSymbol *MCContext::createSymbolImpl(const MCSymbolTableEntry *Name,
bool IsTemporary) { … }
MCSymbol *MCContext::createRenamableSymbol(const Twine &Name,
bool AlwaysAddSuffix,
bool IsTemporary) { … }
MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix) { … }
MCSymbol *MCContext::createNamedTempSymbol(const Twine &Name) { … }
MCSymbol *MCContext::createBlockSymbol(const Twine &Name, bool AlwaysEmit) { … }
MCSymbol *MCContext::createLinkerPrivateTempSymbol() { … }
MCSymbol *MCContext::createLinkerPrivateSymbol(const Twine &Name) { … }
MCSymbol *MCContext::createTempSymbol() { … }
MCSymbol *MCContext::createNamedTempSymbol() { … }
MCSymbol *MCContext::createLocalSymbol(StringRef Name) { … }
unsigned MCContext::NextInstance(unsigned LocalLabelVal) { … }
unsigned MCContext::GetInstance(unsigned LocalLabelVal) { … }
MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
unsigned Instance) { … }
MCSymbol *MCContext::createDirectionalLocalSymbol(unsigned LocalLabelVal) { … }
MCSymbol *MCContext::getDirectionalLocalSymbol(unsigned LocalLabelVal,
bool Before) { … }
template <typename Symbol>
Symbol *MCContext::getOrCreateSectionSymbol(StringRef Section) { … }
MCSymbol *MCContext::lookupSymbol(const Twine &Name) const { … }
void MCContext::setSymbolValue(MCStreamer &Streamer, const Twine &Sym,
uint64_t Val) { … }
void MCContext::registerInlineAsmLabel(MCSymbol *Sym) { … }
wasm::WasmSignature *MCContext::createWasmSignature() { … }
MCSymbolXCOFF *MCContext::createXCOFFSymbolImpl(const MCSymbolTableEntry *Name,
bool IsTemporary) { … }
MCSectionMachO *MCContext::getMachOSection(StringRef Segment, StringRef Section,
unsigned TypeAndAttributes,
unsigned Reserved2, SectionKind Kind,
const char *BeginSymName) { … }
MCSectionELF *MCContext::createELFSectionImpl(StringRef Section, unsigned Type,
unsigned Flags,
unsigned EntrySize,
const MCSymbolELF *Group,
bool Comdat, unsigned UniqueID,
const MCSymbolELF *LinkedToSym) { … }
MCSectionELF *
MCContext::createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags,
unsigned EntrySize, const MCSymbolELF *Group,
const MCSectionELF *RelInfoSection) { … }
MCSectionELF *MCContext::getELFNamedSection(const Twine &Prefix,
const Twine &Suffix, unsigned Type,
unsigned Flags,
unsigned EntrySize) { … }
MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
const Twine &Group, bool IsComdat,
unsigned UniqueID,
const MCSymbolELF *LinkedToSym) { … }
MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
const MCSymbolELF *GroupSym,
bool IsComdat, unsigned UniqueID,
const MCSymbolELF *LinkedToSym) { … }
MCSectionELF *MCContext::createELFGroupSection(const MCSymbolELF *Group,
bool IsComdat) { … }
void MCContext::recordELFMergeableSectionInfo(StringRef SectionName,
unsigned Flags, unsigned UniqueID,
unsigned EntrySize) { … }
bool MCContext::isELFImplicitMergeableSectionNamePrefix(StringRef SectionName) { … }
bool MCContext::isELFGenericMergeableSection(StringRef SectionName) { … }
std::optional<unsigned>
MCContext::getELFUniqueIDForEntsize(StringRef SectionName, unsigned Flags,
unsigned EntrySize) { … }
MCSectionGOFF *MCContext::getGOFFSection(StringRef Section, SectionKind Kind,
MCSection *Parent,
uint32_t Subsection) { … }
MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
unsigned Characteristics,
StringRef COMDATSymName, int Selection,
unsigned UniqueID) { … }
MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
unsigned Characteristics) { … }
MCSectionCOFF *MCContext::getAssociativeCOFFSection(MCSectionCOFF *Sec,
const MCSymbol *KeySym,
unsigned UniqueID) { … }
MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind K,
unsigned Flags, const Twine &Group,
unsigned UniqueID) { … }
MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind Kind,
unsigned Flags,
const MCSymbolWasm *GroupSym,
unsigned UniqueID) { … }
bool MCContext::hasXCOFFSection(StringRef Section,
XCOFF::CsectProperties CsectProp) const { … }
MCSectionXCOFF *MCContext::getXCOFFSection(
StringRef Section, SectionKind Kind,
std::optional<XCOFF::CsectProperties> CsectProp, bool MultiSymbolsAllowed,
std::optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSectionSubtypeFlags) { … }
MCSectionSPIRV *MCContext::getSPIRVSection() { … }
MCSectionDXContainer *MCContext::getDXContainerSection(StringRef Section,
SectionKind K) { … }
MCSubtargetInfo &MCContext::getSubtargetCopy(const MCSubtargetInfo &STI) { … }
void MCContext::addDebugPrefixMapEntry(const std::string &From,
const std::string &To) { … }
void MCContext::remapDebugPath(SmallVectorImpl<char> &Path) { … }
void MCContext::RemapDebugPaths() { … }
EmitDwarfUnwindType MCContext::emitDwarfUnwindInfo() const { … }
bool MCContext::emitCompactUnwindNonCanonical() const { … }
void MCContext::setGenDwarfRootFile(StringRef InputFileName, StringRef Buffer) { … }
Expected<unsigned>
MCContext::getDwarfFile(StringRef Directory, StringRef FileName,
unsigned FileNumber,
std::optional<MD5::MD5Result> Checksum,
std::optional<StringRef> Source, unsigned CUID) { … }
bool MCContext::isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID) { … }
void MCContext::finalizeDwarfSections(MCStreamer &MCOS) { … }
CodeViewContext &MCContext::getCVContext() { … }
void MCContext::diagnose(const SMDiagnostic &SMD) { … }
void MCContext::reportCommon(
SMLoc Loc,
std::function<void(SMDiagnostic &, const SourceMgr *)> GetMessage) { … }
void MCContext::reportError(SMLoc Loc, const Twine &Msg) { … }
void MCContext::reportWarning(SMLoc Loc, const Twine &Msg) { … }