9 #ifndef LLVM_MC_MCCONTEXT_H 10 #define LLVM_MC_MCCONTEXT_H 44 class CodeViewContext;
47 class MCObjectFileInfo;
85 std::unique_ptr<CodeViewContext> CVContext;
127 unsigned NextInstance(
unsigned LocalLabelVal);
130 unsigned GetInstance(
unsigned LocalLabelVal);
137 std::unique_ptr<raw_fd_ostream> SecureLog;
141 bool SecureLogUsed =
false;
147 std::map<const std::string, const std::string> DebugPrefixMap;
150 std::string MainFileName;
156 std::map<unsigned, MCDwarfLineTable> MCDwarfLineTablesCUMap;
160 bool DwarfLocSeen =
false;
163 bool GenDwarfForAssembly =
false;
167 unsigned GenDwarfFileNumber = 0;
174 std::vector<MCGenDwarfLabelEntry> MCGenDwarfLabelEntries;
190 bool AllowTemporaryLabels =
true;
191 bool UseNamesOnTempLabels =
true;
194 unsigned DwarfCompileUnitID = 0;
196 struct ELFSectionKey {
203 : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
207 if (SectionName != Other.SectionName)
208 return SectionName < Other.SectionName;
209 if (GroupName != Other.GroupName)
210 return GroupName < Other.GroupName;
211 return UniqueID < Other.UniqueID;
215 struct COFFSectionKey {
222 int SelectionKey,
unsigned UniqueID)
223 : SectionName(SectionName), GroupName(GroupName),
224 SelectionKey(SelectionKey), UniqueID(UniqueID) {}
226 bool operator<(
const COFFSectionKey &Other)
const {
227 if (SectionName != Other.SectionName)
228 return SectionName < Other.SectionName;
229 if (GroupName != Other.GroupName)
230 return GroupName < Other.GroupName;
231 if (SelectionKey != Other.SelectionKey)
232 return SelectionKey < Other.SelectionKey;
233 return UniqueID < Other.UniqueID;
237 struct WasmSectionKey {
244 : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
247 bool operator<(
const WasmSectionKey &Other)
const {
248 if (SectionName != Other.SectionName)
249 return SectionName < Other.SectionName;
250 if (GroupName != Other.GroupName)
251 return GroupName < Other.GroupName;
252 return UniqueID < Other.UniqueID;
256 struct XCOFFSectionKey {
262 : SectionName(SectionName), MappingClass(MappingClass) {}
264 bool operator<(
const XCOFFSectionKey &Other)
const {
265 return std::tie(SectionName, MappingClass) <
266 std::tie(Other.SectionName, Other.MappingClass);
271 std::map<ELFSectionKey, MCSectionELF *> ELFUniquingMap;
272 std::map<COFFSectionKey, MCSectionCOFF *> COFFUniquingMap;
273 std::map<WasmSectionKey, MCSectionWasm *> WasmUniquingMap;
274 std::map<XCOFFSectionKey, MCSectionXCOFF *> XCOFFUniquingMap;
284 bool HadError =
false;
291 MCSymbol *getOrCreateDirectionalLocalSymbol(
unsigned LocalLabelVal,
309 bool DoAutoReset =
true);
350 bool CanBeUnnamed =
true);
391 return InlineAsmUsedLabelNames.
lookup(Name);
413 unsigned TypeAndAttributes,
415 const char *BeginSymName =
nullptr);
419 const char *BeginSymName =
nullptr) {
430 unsigned Flags,
unsigned EntrySize,
431 const Twine &Group) {
432 return getELFSection(Section, Type, Flags, EntrySize, Group, ~0);
436 unsigned Flags,
unsigned EntrySize,
437 const Twine &Group,
unsigned UniqueID) {
438 return getELFSection(Section, Type, Flags, EntrySize, Group, UniqueID,
443 unsigned Flags,
unsigned EntrySize,
444 const Twine &Group,
unsigned UniqueID,
448 unsigned Flags,
unsigned EntrySize,
457 unsigned Type,
unsigned Flags,
458 unsigned EntrySize = 0);
461 unsigned Flags,
unsigned EntrySize,
473 const char *BeginSymName =
nullptr);
477 const char *BeginSymName =
nullptr);
492 const char *BeginSymName) {
497 const Twine &Group,
unsigned UniqueID) {
502 const Twine &Group,
unsigned UniqueID,
503 const char *BeginSymName);
507 const char *BeginSymName);
514 const char *BeginSymName =
nullptr);
555 return MCDwarfLineTablesCUMap;
559 return MCDwarfLineTablesCUMap[CUID];
563 auto I = MCDwarfLineTablesCUMap.find(CUID);
564 assert(
I != MCDwarfLineTablesCUMap.end());
579 DwarfCompileUnitID = CUIndex;
602 unsigned Flags,
unsigned Isa,
603 unsigned Discriminator) {
608 CurrentDwarfLoc.
setIsa(Isa);
623 GenDwarfFileNumber = FileNumber;
631 return SectionsForRanges;
635 return SectionsForRanges.
insert(Sec);
641 return MCGenDwarfLabelEntries;
645 MCGenDwarfLabelEntries.push_back(E);
668 SecureLog = std::move(Value);
691 return (I == MacroMap.
end()) ?
nullptr : &I->getValue();
695 MacroMap.
insert(std::make_pair(Name, std::move(Macro)));
728 size_t Alignment = 8) noexcept {
729 return C.allocate(Bytes, Alignment);
761 size_t Alignment = 8) noexcept {
762 return C.allocate(Bytes, Alignment);
775 #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)...
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.
This class represents lattice values for constants.
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 ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
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)
void setGenDwarfRootFile(StringRef FileName, StringRef Buffer)
Specifies information about the "root file" for assembler clients (e.g., llvm-mc).
uint16_t getDwarfVersion() const
void setDwarfVersion(uint16_t v)
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
COFF::SymbolStorageClass StorageClass
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 SectionsForRanges, to avoid generating useless debug info for them...
void setUseNamesOnTempLabels(bool Value)
void setRootFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
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.
Expected< unsigned > getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
void setCompilationDir(StringRef S)
Set the compilation directory for DW_AT_comp_dir.
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
MCSectionXCOFF * getXCOFFSection(StringRef Section, XCOFF::StorageMappingClass MappingClass, XCOFF::SymbolType CSectType, XCOFF::StorageClass StorageClass, SectionKind K, const char *BeginSymName=nullptr)
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.
unsigned getGenDwarfFileNumber()
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...
MCContext(const MCAsmInfo *MAI, const MCRegisterInfo *MRI, const MCObjectFileInfo *MOFI, const SourceMgr *Mgr=nullptr, MCTargetOptions const *TargetOpts=nullptr, bool DoAutoReset=true)
This class is intended to be used as a base class for asm properties and features specific to the tar...
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.
StorageMappingClass
Storage Mapping Class definitions.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This represents a section on wasm.
void setDwarfDebugFlags(StringRef S)
void undefineMacro(StringRef Name)
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.
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()
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
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...
This struct is a compact representation of a valid (non-zero power of two) alignment.
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)
void registerInlineAsmLabel(MCSymbol *Sym)
registerInlineAsmLabel - Records that the name is a label referenced in inline assembly.
BlockVerifier::State From
MCSymbol * getOrCreateLSDASymbol(StringRef FuncName)
void setDwarfDebugProducer(StringRef S)
MCSymbol * getInlineAsmLabel(StringRef Name) const
isInlineAsmLabel - Return true if the name is a label referenced in inline assembly.
#define LLVM_ATTRIBUTE_NORETURN
const MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID) const
void reportWarning(SMLoc L, const Twine &Msg)
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)
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
void setSymbolValue(MCStreamer &Streamer, StringRef Sym, uint64_t Val)
Set value for a symbol.
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 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.
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()
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
dwarf::DwarfFormat getDwarfFormat() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator<(int64_t V1, const APSInt &V2)
void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir, StringRef Filename, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
Specifies the "root" file and directory of the compilation unit.
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.
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.