9#ifndef LLVM_MC_MCCONTEXT_H 
   10#define LLVM_MC_MCCONTEXT_H 
   88                         std::vector<const MDNode *> &)>;
 
  114  std::unique_ptr<SourceMgr> InlineSrcMgr;
 
  115  std::vector<const MDNode *> LocInfos;
 
  131  std::unique_ptr<CodeViewContext> CVContext;
 
  172  unsigned NextInstance(
unsigned LocalLabelVal);
 
  175  unsigned GetInstance(
unsigned LocalLabelVal);
 
  183  std::string SecureLogFile;
 
  185  std::unique_ptr<raw_fd_ostream> SecureLog;
 
  189  bool SecureLogUsed = 
false;
 
  198  std::string MainFileName;
 
  204  std::map<unsigned, MCDwarfLineTable> MCDwarfLineTablesCUMap;
 
  208  bool DwarfLocSeen = 
false;
 
  211  bool GenDwarfForAssembly = 
false;
 
  215  unsigned GenDwarfFileNumber = 0;
 
  222  std::vector<MCGenDwarfLabelEntry> MCGenDwarfLabelEntries;
 
  241  bool SaveTempLabels = 
false;
 
  242  bool UseNamesOnTempLabels = 
false;
 
  245  unsigned DwarfCompileUnitID = 0;
 
  250  struct COFFSectionKey {
 
  262      return std::tie(SectionName, GroupName, SelectionKey, 
UniqueID) <
 
  268  struct WasmSectionKey {
 
  269    std::string SectionName;
 
  273    WasmSectionKey(StringRef SectionName, StringRef GroupName,
 
  275        : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {}
 
  277    bool operator<(
const WasmSectionKey &
Other)
 const {
 
  278      return std::tie(SectionName, GroupName, UniqueID) <
 
  283  struct XCOFFSectionKey {
 
  285    std::string SectionName;
 
  295    XCOFFSectionKey(StringRef SectionName,
 
  297        : SectionName(SectionName), MappingClass(MappingClass), IsCsect(
true) {}
 
  299    XCOFFSectionKey(StringRef SectionName,
 
  301        : SectionName(SectionName), DwarfSubtypeFlags(DwarfSubtypeFlags),
 
  304    bool operator<(
const XCOFFSectionKey &
Other)
 const {
 
  305      if (IsCsect && 
Other.IsCsect)
 
  306        return std::tie(SectionName, MappingClass) <
 
  307               std::tie(
Other.SectionName, 
Other.MappingClass);
 
  308      if (IsCsect != 
Other.IsCsect)
 
  310      return std::tie(SectionName, DwarfSubtypeFlags) <
 
  311             std::tie(
Other.SectionName, 
Other.DwarfSubtypeFlags);
 
  315  StringMap<MCSectionMachO *> MachOUniquingMap;
 
  316  std::map<COFFSectionKey, MCSectionCOFF *> COFFUniquingMap;
 
  317  StringMap<MCSectionELF *> ELFUniquingMap;
 
  318  std::map<std::string, MCSectionGOFF *> GOFFUniquingMap;
 
  319  std::map<WasmSectionKey, MCSectionWasm *> WasmUniquingMap;
 
  320  std::map<XCOFFSectionKey, MCSectionXCOFF *> XCOFFUniquingMap;
 
  321  StringMap<MCSectionDXContainer *> DXCUniquingMap;
 
  322  StringMap<bool> RelSecNames;
 
  324  SpecificBumpPtrAllocator<MCSubtargetInfo> MCSubtargetAllocator;
 
  329  MCTargetOptions 
const *TargetOptions;
 
  331  bool HadError = 
false;
 
  333  void reportCommon(SMLoc Loc,
 
  334                    std::function<
void(SMDiagnostic &, 
const SourceMgr *)>);
 
  339  MCSymbol *createRenamableSymbol(
const Twine &Name, 
bool AlwaysAddSuffix,
 
  342  MCSymbol *getOrCreateDirectionalLocalSymbol(
unsigned LocalLabelVal,
 
  345  template <
typename Symbol>
 
  346  Symbol *getOrCreateSectionSymbol(StringRef Section);
 
  348  MCSectionELF *createELFSectionImpl(StringRef Section, 
unsigned Type,
 
  349                                     unsigned Flags, 
unsigned EntrySize,
 
  350                                     const MCSymbolELF *Group, 
bool IsComdat,
 
  352                                     const MCSymbolELF *LinkedToSym);
 
  357  template <
typename TAttr>
 
  358  MCSectionGOFF *getGOFFSection(SectionKind Kind, StringRef Name,
 
  359                                TAttr SDAttributes, MCSection *Parent,
 
  363  StringMap<MCAsmMacro> MacroMap;
 
  371  DenseMap<std::tuple<StringRef, unsigned, unsigned>, 
unsigned> ELFEntrySizeMap;
 
  378  DenseSet<StringRef> ELFSeenGenericMergeableSections;
 
  382                              const MCRegisterInfo *MRI,
 
  383                              const MCSubtargetInfo *MSTI,
 
  384                              const SourceMgr *Mgr = 
nullptr,
 
  385                              MCTargetOptions 
const *TargetOpts = 
nullptr,
 
  386                              bool DoAutoReset = 
true,
 
  387                              StringRef Swift5ReflSegmentName = {});
 
  398    return Swift5ReflectionSegmentName;
 
 
  407    this->DiagHandler = DiagHandler;
 
 
  454                                      bool AlwaysAddSuffix = 
true);
 
  466                                       bool AlwaysEmit = 
false);
 
  523    return InlineAsmUsedLabelNames.lookup(Name);
 
 
  542                                           unsigned TypeAndAttributes,
 
  544                                           const char *BeginSymName = 
nullptr);
 
  548                                  const char *BeginSymName = 
nullptr) {
 
 
  559                              unsigned Flags, 
unsigned EntrySize) {
 
 
  565                              unsigned Flags, 
unsigned EntrySize,
 
  566                              const Twine &Group, 
bool IsComdat) {
 
 
  572                                       unsigned Flags, 
unsigned EntrySize,
 
  573                                       const Twine &Group, 
bool IsComdat,
 
  578                                       unsigned Flags, 
unsigned EntrySize,
 
  590                                            unsigned EntrySize = 0);
 
  629                                         unsigned Characteristics);
 
  642                                unsigned Flags = 0) {
 
 
  647                                         unsigned Flags, 
const Twine &Group,
 
  664      std::optional<XCOFF::CsectProperties> CsectProp = std::nullopt,
 
  665      bool MultiSymbolsAllowed = 
false,
 
  666      std::optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSubtypeFlags =
 
  689                                       const std::string &To);
 
  708               std::optional<MD5::MD5Result> Checksum,
 
  709               std::optional<StringRef> Source, 
unsigned CUID);
 
  714    return MCDwarfLineTablesCUMap;
 
 
  718    return MCDwarfLineTablesCUMap[CUID];
 
 
  722    auto I = MCDwarfLineTablesCUMap.find(CUID);
 
  723    assert(
I != MCDwarfLineTablesCUMap.end());
 
 
  743                              std::optional<MD5::MD5Result> Checksum,
 
  744                              std::optional<StringRef> Source) {
 
 
  759                          unsigned Flags, 
unsigned Isa,
 
  760                          unsigned Discriminator) {
 
  761    CurrentDwarfLoc.setFileNum(FileNum);
 
  762    CurrentDwarfLoc.setLine(Line);
 
  763    CurrentDwarfLoc.setColumn(Column);
 
  764    CurrentDwarfLoc.setFlags(Flags);
 
  765    CurrentDwarfLoc.setIsa(Isa);
 
  766    CurrentDwarfLoc.setDiscriminator(Discriminator);
 
 
  782    GenDwarfFileNumber = FileNumber;
 
 
  790    return SectionsForRanges;
 
 
  794    return SectionsForRanges.insert(Sec);
 
 
  800    return MCGenDwarfLabelEntries;
 
 
  804    MCGenDwarfLabelEntries.push_back(
E);
 
 
  825    SecureLog = std::move(
Value);
 
 
  850    return (
I == MacroMap.end()) ? nullptr : &
I->getValue();
 
 
  854    MacroMap.insert(std::make_pair(Name, std::move(
Macro)));
 
 
 
  889                          size_t Alignment = 8) 
noexcept {
 
  890  return C.allocate(Bytes, Alignment);
 
 
  922                            size_t Alignment = 8) 
noexcept {
 
  923  return C.allocate(Bytes, Alignment);
 
 
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
Function Alias Analysis false
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file contains constants used for implementing Dwarf debug support.
bool operator<(const DeltaInfo &LHS, int64_t Delta)
This file declares the MCSectionGOFF class, which contains all of the necessary machine code sections...
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallString class.
static void DiagHandler(const SMDiagnostic &Diag, void *Context)
Holds state from .cv_file and .cv_loc directives for later emission.
Tagged union holding either a T or a Error.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Context object for machine code objects.
MCPseudoProbeTable & getMCPseudoProbeTable()
const MCObjectFileInfo * getObjectFileInfo() const
LLVM_ABI void remapDebugPath(SmallVectorImpl< char > &Path)
Remap one path in-place as per the debug prefix map.
LLVM_ABI MCSymbol * createBlockSymbol(const Twine &Name, bool AlwaysEmit=false)
Get or create a symbol for a basic block.
LLVM_ABI MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
LLVM_ABI MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, const char *BeginSymName=nullptr)
Return the MCSection for the specified mach-o section.
void * allocate(unsigned Size, unsigned Align=8)
const SetVector< MCSection * > & getGenDwarfSectionSyms()
void deallocate(void *Ptr)
const SmallVectorImpl< std::string > & getMCDwarfDirs(unsigned CUID=0)
Environment getObjectFileType() const
bool isDwarfMD5UsageConsistent(unsigned CUID) const
Reports whether MD5 checksum usage is consistent (all-or-none).
void setObjectFileInfo(const MCObjectFileInfo *Mofi)
StringRef getDwarfDebugProducer()
LLVM_ABI void setSymbolValue(MCStreamer &Streamer, const Twine &Sym, uint64_t Val)
Set value for a symbol.
const std::string & getMainFileName() const
Get the main file name for use in error messages and debug info.
LLVM_ABI MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, StringRef COMDATSymName, int Selection, unsigned UniqueID=MCSection::NonUniqueID)
StringRef getDwarfDebugFlags()
LLVM_ABI void addDebugPrefixMapEntry(const std::string &From, const std::string &To)
Add an entry to the debug prefix map.
MCContext(const MCContext &)=delete
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir The compilation directory should be set with setComp...
bool getGenDwarfForAssembly()
LLVM_ABI void RemapDebugPaths()
LLVM_ABI MCInst * createMCInst()
Create and return a new MC instruction.
LLVM_ABI MCSymbol * getOrCreateFrameAllocSymbol(const Twine &FuncName, unsigned Idx)
Gets a symbol that will be defined to the final stack offset of a local variable after codegen.
LLVM_ABI MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *RelInfoSection)
void setSecureLogUsed(bool Value)
void defineMacro(StringRef Name, MCAsmMacro Macro)
LLVM_ABI MCSymbol * createLinkerPrivateTempSymbol()
Create a new linker temporary symbol with the specified prefix (Name) or "tmp".
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
LLVM_ABI void recordELFMergeableSectionInfo(StringRef SectionName, unsigned Flags, unsigned UniqueID, unsigned EntrySize)
MCSymbol * getInlineAsmLabel(StringRef Name) const
isInlineAsmLabel - Return true if the name is a label referenced in inline assembly.
LLVM_ABI Expected< unsigned > getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
LLVM_ABI wasm::WasmSignature * createWasmSignature()
Allocates and returns a new WasmSignature instance (with empty parameter and return type lists).
LLVM_ABI MCSectionELF * getELFNamedSection(const Twine &Prefix, const Twine &Suffix, unsigned Type, unsigned Flags, unsigned EntrySize=0)
Get a section with the provided group identifier.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize, const Twine &Group, bool IsComdat)
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize)
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
LLVM_ABI MCSectionXCOFF * getXCOFFSection(StringRef Section, SectionKind K, std::optional< XCOFF::CsectProperties > CsectProp=std::nullopt, bool MultiSymbolsAllowed=false, std::optional< XCOFF::DwarfSectionSubtypeFlags > DwarfSubtypeFlags=std::nullopt)
void setGenDwarfForAssembly(bool Value)
uint8_t getBBAddrMapVersion() const
LLVM_ABI void diagnose(const SMDiagnostic &SMD)
LLVM_ABI bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID=0)
isValidDwarfFileNumber - takes a dwarf file number and returns true if it currently is assigned and f...
void setDwarfVersion(uint16_t v)
const StringRef & getSwift5ReflectionSegmentName() const
LLVM_ABI void registerInlineAsmLabel(MCSymbol *Sym)
registerInlineAsmLabel - Records that the name is a label referenced in inline assembly.
LLVM_ABI MCSymbol * createLocalSymbol(StringRef Name)
Create a local, non-temporary symbol like an ELF mapping symbol.
bool addGenDwarfSection(MCSection *Sec)
StringRef allocateString(StringRef s)
Allocates a copy of the given string on the allocator managed by this context and returns the result.
MCAsmMacro * lookupMacro(StringRef Name)
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
raw_fd_ostream * getSecureLog()
LLVM_ABI void initInlineSourceManager()
void setDiagnosticHandler(DiagHandlerTy DiagHandler)
unsigned getDwarfCompileUnitID()
LLVM_ABI MCSymbol * getOrCreateParentFrameOffsetSymbol(const Twine &FuncName)
LLVM_ABI MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
LLVM_ABI bool emitCompactUnwindNonCanonical() const
void undefineMacro(StringRef Name)
LLVM_ABI CodeViewContext & getCVContext()
const MCRegisterInfo * getRegisterInfo() const
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
LLVM_ABI void reset()
reset - return object to right after construction state to prepare to process a new module
void setDwarfFormat(dwarf::DwarfFormat f)
void setCompilationDir(StringRef S)
Set the compilation directory for DW_AT_comp_dir.
const std::map< unsigned, MCDwarfLineTable > & getMCDwarfLineTables() const
LLVM_ABI bool isELFGenericMergeableSection(StringRef Name)
unsigned getGenDwarfFileNumber()
void setDwarfDebugFlags(StringRef S)
void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator)
Saves the information from the currently parsed dwarf .loc directive and sets DwarfLocSeen.
LLVM_ABI MCContext(const Triple &TheTriple, const MCAsmInfo *MAI, const MCRegisterInfo *MRI, const MCSubtargetInfo *MSTI, const SourceMgr *Mgr=nullptr, MCTargetOptions const *TargetOpts=nullptr, bool DoAutoReset=true, StringRef Swift5ReflSegmentName={})
void setDwarfDebugProducer(StringRef S)
LLVM_ABI std::optional< unsigned > getELFUniqueIDForEntsize(StringRef SectionName, unsigned Flags, unsigned EntrySize)
Return the unique ID of the section with the given name, flags and entry size, if it exists.
LLVM_ABI MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions).
LLVM_ABI void reportWarning(SMLoc L, const Twine &Msg)
uint16_t getDwarfVersion() const
std::function< void(const SMDiagnostic &, bool, const SourceMgr &, std::vector< const MDNode * > &)> DiagHandlerTy
const SourceMgr * getSourceManager() const
const SymbolTable & getSymbols() const
getSymbols - Get a reference for the symbol table for clients that want to, for example,...
const MCAsmInfo * getAsmInfo() const
StringMap< MCSymbolTableValue, BumpPtrAllocator & > SymbolTable
LLVM_ABI void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionsForRanges, to avoid generating useless debug info for them.
void setSecureLog(std::unique_ptr< raw_fd_ostream > Value)
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E)
LLVM_ABI MCSymbol * getOrCreateLSDASymbol(const Twine &FuncName)
LLVM_ABI MCSectionDXContainer * getDXContainerSection(StringRef Section, SectionKind K)
Get the section for the provided Section name.
MCContext & operator=(const MCContext &)=delete
LLVM_ABI bool hasXCOFFSection(StringRef Section, XCOFF::CsectProperties CsectProp) const
void setMainFileName(StringRef S)
Set the main file name and override the default.
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
SourceMgr * getInlineSourceManager()
LLVM_ABI MCSymbol * createLinkerPrivateSymbol(const Twine &Name)
void setGenDwarfFileNumber(unsigned FileNumber)
LLVM_ABI MCSectionSPIRV * getSPIRVSection()
LLVM_ABI MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=MCSection::NonUniqueID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym.
LLVM_ABI MCSymbol * cloneSymbol(MCSymbol &Sym)
Clone a symbol for the .set directive, replacing it in the symbol table.
const MCTargetOptions * getTargetOptions() const
void setDwarfCompileUnitID(unsigned CUIndex)
const MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID) const
LLVM_ABI MCSymbol * parseSymbol(const Twine &Name)
Variant of getOrCreateSymbol that handles backslash-escaped symbols.
LLVM_ABI EmitDwarfUnwindType emitDwarfUnwindInfo() const
LLVM_ABI bool isELFImplicitMergeableSectionNamePrefix(StringRef Name)
LLVM_ABI MCSectionELF * createELFGroupSection(const MCSymbolELF *Group, bool IsComdat)
void setUseNamesOnTempLabels(bool Value)
const MCDwarfLoc & getCurrentDwarfLoc()
LLVM_ABI void setGenDwarfRootFile(StringRef FileName, StringRef Buffer)
Specifies information about the "root file" for assembler clients (e.g., llvm-mc).
dwarf::DwarfFormat getDwarfFormat() const
const std::vector< MCGenDwarfLabelEntry > & getMCGenDwarfLabelEntries() const
StringRef getSecureLogFile()
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, SectionKind K, const char *BeginSymName=nullptr)
std::vector< const MDNode * > & getLocInfos()
void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir, StringRef Filename, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
Specifies the "root" file and directory of the compilation unit.
LLVM_ABI MCSymbol * getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before)
Create and return a directional local symbol for numbered label (used for "1b" or 1f" references).
const MCSubtargetInfo * getSubtargetInfo() const
LLVM_ABI MCSymbol * createNamedTempSymbol()
Create a temporary symbol with a unique name whose name cannot be omitted in the symbol table.
const Triple & getTargetTriple() const
bool isMD5UsageConsistent() const
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
void setRootFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Instances of this class represent the information from a dwarf .loc directive.
Instances of this class represent a single low-level machine instruction.
Instances of this class represent a label name in the MC file, and MCLabel are created and uniqued by...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This represents a section on Windows.
This represents a section on linux, lots of unix variants and some bare metal systems.
This represents a section on a Mach-O system (used by Mac OS X).
This represents a section on wasm.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
static constexpr unsigned NonUniqueID
Streaming machine code generation interface.
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Represents a location in source code.
SectionKind - This is a simple POD value that classifies the properties of a section.
A vector that has set insertion semantics.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringMapIterBase< ValueTy, false > iterator
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
StringRef save(const char *S)
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
A raw_ostream that writes to a file descriptor.
DwarfSectionSubtypeFlags
Values for defining the section subtype of sections of type STYP_DWARF as they would appear in the (s...
StorageMappingClass
Storage Mapping Class definitions.
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
This is an optimization pass for GlobalISel generic memory operations.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
StringMapEntry< MCSymbolTableValue > MCSymbolTableEntry
MCContext stores MCSymbolTableValue in a string map (see MCSymbol::operator new).
This struct is a compact representation of a valid (non-zero power of two) alignment.