10 #ifndef LLVM_MC_MCCONTEXT_H
11 #define LLVM_MC_MCCONTEXT_H
37 class MCObjectFileInfo;
101 unsigned NextInstance(
unsigned LocalLabelVal);
104 unsigned GetInstance(
unsigned LocalLabelVal);
121 std::string MainFileName;
127 std::map<unsigned, MCDwarfLineTable> MCDwarfLineTablesCUMap;
134 bool GenDwarfForAssembly;
138 unsigned GenDwarfFileNumber;
145 std::vector<MCGenDwarfLabelEntry> MCGenDwarfLabelEntries;
156 uint16_t DwarfVersion;
161 bool AllowTemporaryLabels;
162 bool UseNamesOnTempLabels =
true;
165 unsigned DwarfCompileUnitID;
167 struct ELFSectionKey {
168 std::string SectionName;
173 : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
176 if (SectionName != Other.SectionName)
177 return SectionName < Other.SectionName;
178 if (GroupName != Other.GroupName)
179 return GroupName < Other.GroupName;
180 return UniqueID < Other.UniqueID;
184 struct COFFSectionKey {
185 std::string SectionName;
188 COFFSectionKey(StringRef SectionName, StringRef GroupName,
190 : SectionName(SectionName), GroupName(GroupName),
191 SelectionKey(SelectionKey) {}
192 bool operator<(
const COFFSectionKey &Other)
const {
193 if (SectionName != Other.SectionName)
194 return SectionName < Other.SectionName;
195 if (GroupName != Other.GroupName)
196 return GroupName < Other.GroupName;
197 return SelectionKey < Other.SelectionKey;
201 StringMap<MCSectionMachO *> MachOUniquingMap;
202 std::map<ELFSectionKey, MCSectionELF *> ELFUniquingMap;
203 std::map<COFFSectionKey, MCSectionCOFF *> COFFUniquingMap;
204 StringMap<bool> ELFRelSecNames;
209 MCSymbol *createSymbolImpl(
const StringMapEntry<bool> *
Name,
211 MCSymbol *createSymbol(StringRef
Name,
bool AlwaysAddSuffix,
214 MCSymbol *getOrCreateDirectionalLocalSymbol(
unsigned LocalLabelVal,
218 explicit MCContext(
const MCAsmInfo *MAI,
const MCRegisterInfo *MRI,
219 const MCObjectFileInfo *MOFI,
220 const SourceMgr *Mgr =
nullptr,
bool DoAutoReset =
true);
255 bool CanBeUnnamed =
true);
300 unsigned TypeAndAttributes,
302 const char *BeginSymName =
nullptr);
306 const char *BeginSymName =
nullptr) {
317 unsigned Flags,
const char *BeginSymName) {
318 return getELFSection(Section, Type, Flags, 0,
"", BeginSymName);
322 unsigned Flags,
unsigned EntrySize,
324 return getELFSection(Section, Type, Flags, EntrySize, Group,
nullptr);
328 unsigned Flags,
unsigned EntrySize,
329 StringRef Group,
const char *BeginSymName) {
330 return getELFSection(Section, Type, Flags, EntrySize, Group, ~0,
335 unsigned Flags,
unsigned EntrySize,
337 return getELFSection(Section, Type, Flags, EntrySize, Group, UniqueID,
342 unsigned Flags,
unsigned EntrySize,
344 const char *BeginSymName);
347 unsigned Flags,
unsigned EntrySize,
349 const char *BeginSymName,
353 unsigned Flags,
unsigned EntrySize,
364 const char *BeginSymName =
nullptr);
368 const char *BeginSymName =
nullptr);
405 unsigned FileNumber,
unsigned CUID);
410 return MCDwarfLineTablesCUMap;
414 return MCDwarfLineTablesCUMap[CUID];
418 auto I = MCDwarfLineTablesCUMap.find(CUID);
419 assert(
I != MCDwarfLineTablesCUMap.end());
431 for (
const auto &Table : MCDwarfLineTablesCUMap)
432 if (!Table.second.getMCDwarfFiles().empty() || Table.second.getLabel())
438 DwarfCompileUnitID = CUIndex;
449 unsigned Flags,
unsigned Isa,
450 unsigned Discriminator) {
455 CurrentDwarfLoc.
setIsa(Isa);
468 GenDwarfFileNumber = FileNumber;
471 return SectionsForRanges;
474 return SectionsForRanges.insert(Sec);
479 return MCGenDwarfLabelEntries;
482 MCGenDwarfLabelEntries.push_back(E);
511 const Twine &Msg)
const;
541 size_t Alignment = 8)
throw() {
542 return C.allocate(Bytes, Alignment);
575 size_t Alignment = 8)
throw() {
576 return C.allocate(Bytes, Alignment);
void setCompilationDir(StringRef CompilationDir)
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E)
MCSymbolELF * getOrCreateSectionSymbol(const MCSectionELF &Section)
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)...
const MCAsmInfo * getAsmInfo() const
void setGenDwarfForAssembly(bool Value)
const MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID) const
MCSectionMachO - This represents a section on a Mach-O system (used by Mac OS X). ...
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags)
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 ...
MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions)...
LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L, const Twine &Msg) const
MCSymbol * getOrCreateParentFrameOffsetSymbol(StringRef FuncName)
std::string str() const
str - Get the contents as an std::string.
void setDwarfVersion(uint16_t v)
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
StringMap< MCSymbol *, BumpPtrAllocator & > SymbolTable
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags, unsigned EntrySize, StringRef Group)
uint16_t getDwarfVersion() const
StringRef getDwarfDebugFlags()
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags, unsigned EntrySize, StringRef Group, unsigned UniqueID)
MCSectionCOFF - This represents a section on Windows.
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...
void renameELFSection(MCSectionELF *Section, StringRef Name)
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)
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags, const char *BeginSymName)
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 Override the default (CWD) compilation directory...
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
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.
const std::string & getMainFileName() const
Get the main file name for use in error messages and debug info.
unsigned getDwarfCompileUnitID()
Instances of this class represent the information from a dwarf .loc directive.
static cl::opt< std::string > FuncName("cppfname", cl::desc("Specify the name of the generated function"), cl::value_desc("function name"))
unsigned getGenDwarfFileNumber()
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...
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...
const SymbolTable & getSymbols() const
getSymbols - Get a reference for the symbol table for clients that want to, for example, iterate over all symbols.
Allocate memory in an ever growing pool, as if by bump-pointer.
void setDwarfDebugFlags(StringRef S)
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
SectionKind - This is a simple POD value that classifies the properties of a section.
const MCDwarfLoc & getCurrentDwarfLoc()
MCSectionELF * createELFRelSection(StringRef Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *Associated)
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
const SourceMgr * getSourceManager() const
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, SectionKind K, const char *BeginSymName=nullptr)
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.
const SetVector< MCSection * > & getGenDwarfSectionSyms()
MCSymbol * getOrCreateLSDASymbol(StringRef FuncName)
bool hasMCLineSections() const
void setDwarfDebugProducer(StringRef S)
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags, unsigned EntrySize, StringRef Group, const char *BeginSymName)
#define LLVM_ATTRIBUTE_NORETURN
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(NoStrictAlign), cl::values(clEnumValN(StrictAlign,"aarch64-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"aarch64-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
const std::vector< MCGenDwarfLabelEntry > & getMCGenDwarfLabelEntries() const
bool addGenDwarfSection(MCSection *Sec)
void setSecureLog(raw_ostream *Value)
const MCRegisterInfo * getRegisterInfo() const
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir This can be overridden by clients which want to cont...
raw_ostream * getSecureLog()
char * getSecureLogFile()
void setGenDwarfFileNumber(unsigned FileNumber)
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym...
const std::map< unsigned, MCDwarfLineTable > & getMCDwarfLineTables() const
void deallocate(void *Ptr)
COFFYAML::WeakExternalCharacteristics Characteristics
MCSectionELF - 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 setFlags(unsigned flags)
Set the Flags of this MCDwarfLoc.
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group)
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, const char *BeginSymName=nullptr)
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.
const ARM::ArchExtKind Kind
bool operator<(int64_t V1, const APSInt &V2)
LLVM Value Representation.
const MCObjectFileInfo * getObjectFileInfo() const
unsigned getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
A vector that has set insertion semantics.
This class implements an extremely fast bulk output stream that can only output to a stream...
void setColumn(unsigned column)
Set the Column of this MCDwarfLoc.
C - The default llvm calling convention, compatible with C.
StringRef - Represent a constant reference to a string, i.e.
Represents a location in source code.
void setMCLineTableCompilationDir(unsigned CUID, StringRef CompilationDir)
void setDiscriminator(unsigned discriminator)
Set the Discriminator of this MCDwarfLoc.
void setSecureLogUsed(bool Value)