10 #ifndef LLVM_MC_MCCONTEXT_H 11 #define LLVM_MC_MCCONTEXT_H 43 class CodeViewContext;
46 class MCObjectFileInfo;
83 std::unique_ptr<CodeViewContext> CVContext;
121 unsigned NextInstance(
unsigned LocalLabelVal);
124 unsigned GetInstance(
unsigned LocalLabelVal);
131 std::unique_ptr<raw_fd_ostream> SecureLog;
135 bool SecureLogUsed =
false;
141 std::map<const std::string, const std::string> DebugPrefixMap;
144 std::string MainFileName;
150 std::map<unsigned, MCDwarfLineTable> MCDwarfLineTablesCUMap;
154 bool DwarfLocSeen =
false;
157 bool GenDwarfForAssembly =
false;
161 unsigned GenDwarfFileNumber = 0;
168 std::vector<MCGenDwarfLabelEntry> MCGenDwarfLabelEntries;
179 uint16_t DwarfVersion = 4;
184 bool AllowTemporaryLabels =
true;
185 bool UseNamesOnTempLabels =
true;
188 unsigned DwarfCompileUnitID = 0;
190 struct ELFSectionKey {
197 : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
200 bool operator<(
const ELFSectionKey &Other)
const {
201 if (SectionName != Other.SectionName)
202 return SectionName < Other.SectionName;
203 if (GroupName != Other.GroupName)
204 return GroupName < Other.GroupName;
205 return UniqueID < Other.UniqueID;
209 struct COFFSectionKey {
216 int SelectionKey,
unsigned UniqueID)
217 : SectionName(SectionName), GroupName(GroupName),
218 SelectionKey(SelectionKey), UniqueID(UniqueID) {}
220 bool operator<(
const COFFSectionKey &Other)
const {
221 if (SectionName != Other.SectionName)
222 return SectionName < Other.SectionName;
223 if (GroupName != Other.GroupName)
224 return GroupName < Other.GroupName;
225 if (SelectionKey != Other.SelectionKey)
226 return SelectionKey < Other.SelectionKey;
227 return UniqueID < Other.UniqueID;
231 struct WasmSectionKey {
238 : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
241 bool operator<(
const WasmSectionKey &Other)
const {
242 if (SectionName != Other.SectionName)
243 return SectionName < Other.SectionName;
244 if (GroupName != Other.GroupName)
245 return GroupName < Other.GroupName;
246 return UniqueID < Other.UniqueID;
251 std::map<ELFSectionKey, MCSectionELF *> ELFUniquingMap;
252 std::map<COFFSectionKey, MCSectionCOFF *> COFFUniquingMap;
253 std::map<WasmSectionKey, MCSectionWasm *> WasmUniquingMap;
261 bool HadError =
false;
268 MCSymbol *getOrCreateDirectionalLocalSymbol(
unsigned LocalLabelVal,
284 const SourceMgr *Mgr =
nullptr,
bool DoAutoReset =
true);
329 bool CanBeUnnamed =
true);
382 unsigned TypeAndAttributes,
384 const char *BeginSymName =
nullptr);
388 const char *BeginSymName =
nullptr) {
399 unsigned Flags,
unsigned EntrySize,
400 const Twine &Group) {
401 return getELFSection(Section, Type, Flags, EntrySize, Group, ~0);
405 unsigned Flags,
unsigned EntrySize,
406 const Twine &Group,
unsigned UniqueID) {
407 return getELFSection(Section, Type, Flags, EntrySize, Group, UniqueID,
412 unsigned Flags,
unsigned EntrySize,
413 const Twine &Group,
unsigned UniqueID,
417 unsigned Flags,
unsigned EntrySize,
426 unsigned Type,
unsigned Flags,
427 unsigned EntrySize = 0);
430 unsigned Flags,
unsigned EntrySize,
442 const char *BeginSymName =
nullptr);
446 const char *BeginSymName =
nullptr);
463 const char *BeginSymName) {
468 const Twine &Group,
unsigned UniqueID) {
473 const Twine &Group,
unsigned UniqueID,
474 const char *BeginSymName);
478 const char *BeginSymName);
497 const std::map<const std::string, const std::string> &
499 return DebugPrefixMap;
525 return MCDwarfLineTablesCUMap;
529 return MCDwarfLineTablesCUMap[CUID];
533 auto I = MCDwarfLineTablesCUMap.find(CUID);
534 assert(
I != MCDwarfLineTablesCUMap.end());
547 for (
const auto &Table : MCDwarfLineTablesCUMap)
548 if (!Table.second.getMCDwarfFiles().empty() || Table.second.getLabel())
556 DwarfCompileUnitID = CUIndex;
578 unsigned Flags,
unsigned Isa,
579 unsigned Discriminator) {
584 CurrentDwarfLoc.
setIsa(Isa);
599 GenDwarfFileNumber = FileNumber;
603 return SectionsForRanges;
607 return SectionsForRanges.
insert(Sec);
613 return MCGenDwarfLabelEntries;
617 MCGenDwarfLabelEntries.push_back(E);
640 SecureLog = std::move(Value);
662 return (I == MacroMap.
end()) ?
nullptr : &I->getValue();
666 MacroMap.
insert(std::make_pair(Name, std::move(Macro)));
699 size_t Alignment = 8) noexcept {
700 return C.allocate(Bytes, Alignment);
732 size_t Alignment = 8) noexcept {
733 return C.allocate(Bytes, Alignment);
746 #endif // LLVM_MC_MCCONTEXT_H const MCAsmInfo * getAsmInfo() const
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E)
Instances of this class represent a uniqued identifier for a section in the current translation unit...
MCSymbol * getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before)
Create and return a directional local symbol for numbered label (used for "1b" or 1f" references)...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
void setGenDwarfForAssembly(bool Value)
This represents a section on a Mach-O system (used by Mac OS X).
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
Compute iterated dominance frontiers using a linear time algorithm.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
MCSymbol * getOrCreateFrameAllocSymbol(StringRef FuncName, unsigned Idx)
Gets a symbol that will be defined to the final stack offset of a local variable after codegen...
void reset()
reset - return object to right after construction state to prepare to process a new module ...
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, const char *BeginSymName)
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, const Twine &Group, unsigned UniqueID)
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K)
MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions)...
iterator find(StringRef Key)
MCSymbol * getOrCreateParentFrameOffsetSymbol(StringRef FuncName)
uint16_t getDwarfVersion() const
void setDwarfVersion(uint16_t v)
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
MCContext(const MCAsmInfo *MAI, const MCRegisterInfo *MRI, const MCObjectFileInfo *MOFI, const SourceMgr *Mgr=nullptr, bool DoAutoReset=true)
StringRef getDwarfDebugFlags()
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=GenericSectionID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym...
This represents a section on Windows.
const std::vector< MCGenDwarfLabelEntry > & getMCGenDwarfLabelEntries() const
StringRef getDwarfDebugProducer()
MCSymbol * createLinkerPrivateTempSymbol()
Create and return a new linker temporary symbol with a unique but unspecified name.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
void renameELFSection(MCSectionELF *Section, StringRef Name)
bool isMD5UsageConsistent() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionStartEndSyms, to avoid generating useless debug info for them...
void setUseNamesOnTempLabels(bool Value)
Tagged union holding either a T or a Error.
void * allocate(unsigned Size, unsigned Align=8)
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
const SmallVectorImpl< std::string > & getMCDwarfDirs(unsigned CUID=0)
Context object for machine code objects.
void setCompilationDir(StringRef S)
Set the compilation directory for DW_AT_comp_dir.
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
bool insert(const value_type &X)
Insert a new element into the SetVector.
void setDwarfCompileUnitID(unsigned CUIndex)
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.
unsigned getDwarfCompileUnitID()
const std::map< unsigned, MCDwarfLineTable > & getMCDwarfLineTables() const
Instances of this class represent the information from a dwarf .loc directive.
void clearCVLocSeen()
Clear the current cv_loc, if there is one.
unsigned getGenDwarfFileNumber()
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
const SymbolTable & getSymbols() const
getSymbols - Get a reference for the symbol table for clients that want to, for example, iterate over all symbols.
bool isDwarfMD5UsageConsistent(unsigned CUID) const
Reports whether MD5 checksum usage is consistent (all-or-none).
LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L, const Twine &Msg)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
bool hasMCLineSections() const
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
void setInlineSourceManager(SourceMgr *SM)
Streaming machine code generation interface.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
void setAllowTemporaryLabels(bool Value)
The instances of the Type class are immutable: once they are created, they are never changed...
Allocate memory in an ever growing pool, as if by bump-pointer.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This represents a section on wasm.
void setDwarfDebugFlags(StringRef S)
void undefineMacro(StringRef Name)
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
const MCObjectFileInfo * getObjectFileInfo() const
void reportError(SMLoc L, const Twine &Msg)
SectionKind - This is a simple POD value that classifies the properties of a section.
#define LLVM_ATTRIBUTE_NORETURN
AMDGPU DAG DAG Pattern Instruction Selection
MCSectionELF * getELFNamedSection(const Twine &Prefix, const Twine &Suffix, unsigned Type, unsigned Flags, unsigned EntrySize=0)
Get a section with the provided group identifier.
const MCDwarfLoc & getCurrentDwarfLoc()
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
const SourceMgr * getSourceManager() const
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize, const Twine &Group, unsigned UniqueID)
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, SectionKind K, const char *BeginSymName=nullptr)
const MCAsmMacro * lookupMacro(StringRef Name)
bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID=0)
isValidDwarfFileNumber - takes a dwarf file number and returns true if it currently is assigned and f...
bool getGenDwarfForAssembly()
void setMainFileName(StringRef S)
Set the main file name and override the default.
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir The compilation directory should be set with setComp...
const SetVector< MCSection * > & getGenDwarfSectionSyms()
MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *RelInfoSection)
MCSymbol * getOrCreateLSDASymbol(StringRef FuncName)
void setDwarfDebugProducer(StringRef S)
const MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID) const
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize, const Twine &Group)
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
This file contains constants used for implementing Dwarf debug support.
bool addGenDwarfSection(MCSection *Sec)
void setSymbolValue(MCStreamer &Streamer, StringRef Sym, uint64_t Val)
Set value for a symbol.
const std::map< const std::string, const std::string > & getDebugPrefixMap() const
Get the debug prefix map.
char * getSecureLogFile()
A raw_ostream that writes to a file descriptor.
void setGenDwarfFileNumber(unsigned FileNumber)
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
void deallocate(void *Ptr)
void setRootFile(StringRef Directory, StringRef FileName, MD5::MD5Result *Checksum, Optional< StringRef > Source)
void addDebugPrefixMapEntry(const std::string &From, const std::string &To)
Add an entry to the debug prefix map.
COFFYAML::WeakExternalCharacteristics Characteristics
Generic base class for all target subtargets.
This represents a section on linux, lots of unix variants and some bare metal systems.
void setFileNum(unsigned fileNum)
Set the FileNum of this MCDwarfLoc.
void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir, StringRef Filename, MD5::MD5Result *Checksum, Optional< StringRef > Source)
Specifies the "root" file and directory of the compilation unit.
const std::string & getMainFileName() const
Get the main file name for use in error messages and debug info.
void setFlags(unsigned flags)
Set the Flags of this MCDwarfLoc.
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group)
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.
CodeViewContext & getCVContext()
Expected< unsigned > getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, MD5::MD5Result *Checksum, Optional< StringRef > Source, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
dwarf::DwarfFormat getDwarfFormat() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator<(int64_t V1, const APSInt &V2)
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
raw_fd_ostream * getSecureLog()
const MCRegisterInfo * getRegisterInfo() const
LLVM Value Representation.
A vector that has set insertion semantics.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
void setColumn(unsigned column)
Set the Column of this MCDwarfLoc.
StringRef - Represent a constant reference to a string, i.e.
MCContext & operator=(const MCContext &)=delete
Represents a location in source code.
void setSecureLog(std::unique_ptr< raw_fd_ostream > Value)
void setDiscriminator(unsigned discriminator)
Set the Discriminator of this MCDwarfLoc.
void setSecureLogUsed(bool Value)
void defineMacro(StringRef Name, MCAsmMacro Macro)
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Holds state from .cv_file and .cv_loc directives for later emission.