43 SrcMgr(mgr), MAI(mai),
MRI(mri), MOFI(mofi),
44 Allocator(), Symbols(Allocator), UsedNames(Allocator),
47 DwarfLocSeen(
false), GenDwarfForAssembly(
false), GenDwarfFileNumber(0),
48 AllowTemporaryLabels(
true), DwarfCompileUnitID(0), AutoReset(DoAutoReset) {
51 assert(!EC &&
"Could not determine the current directory");
58 SecureLogFile =
getenv(
"AS_SECURE_LOG_FILE");
60 SecureLogUsed =
false;
89 MCDwarfFilesCUMap.clear();
90 MCDwarfDirsCUMap.clear();
91 MCGenDwarfLabelEntries.clear();
93 MCLineSections.clear();
94 MCLineSectionOrder.clear();
95 DwarfCompileUnitID = 0;
96 MCLineTableSymbols.clear();
103 MachOUniquingMap = 0;
108 AllowTemporaryLabels =
true;
109 DwarfLocSeen =
false;
110 GenDwarfForAssembly =
false;
111 GenDwarfFileNumber = 0;
119 assert(!Name.
empty() &&
"Normal symbols cannot be unnamed!");
129 Sym = CreateSymbol(Name);
136 bool isTemporary =
false;
137 if (AllowTemporaryLabels)
142 assert(isTemporary &&
"Cannot rename non temporary symbols");
147 NameEntry = &UsedNames.GetOrCreateValue(NewName);
169 return CreateSymbol(NameSV);
172 unsigned MCContext::NextInstance(int64_t LocalLabelVal) {
173 MCLabel *&Label = Instances[LocalLabelVal];
175 Label =
new (*this)
MCLabel(0);
179 unsigned MCContext::GetInstance(int64_t LocalLabelVal) {
180 MCLabel *&Label = Instances[LocalLabelVal];
182 Label =
new (*this)
MCLabel(0);
188 Twine(LocalLabelVal) +
190 Twine(NextInstance(LocalLabelVal)));
195 Twine(LocalLabelVal) +
197 Twine(GetInstance(LocalLabelVal) + bORf));
201 return Symbols.
lookup(Name);
216 unsigned TypeAndAttributes,
224 if (MachOUniquingMap == 0)
236 if (Entry)
return Entry;
239 return Entry =
new (*this)
MCSectionMachO(Segment, Section, TypeAndAttributes,
252 if (ELFUniquingMap == 0)
257 std::pair<ELFUniqueMapTy::iterator, bool> Entry = Map.insert(
259 if (!Entry.second)
return Entry.first->second;
271 Entry.first->first.first, Type, Flags, Kind, EntrySize, GroupSym);
272 Entry.first->second = Result;
287 if (COFFUniquingMap == 0)
297 Selection, Assoc,
Kind);
304 if (COFFUniquingMap == 0)
308 return Map.
lookup(Section);
320 unsigned FileNumber,
unsigned CUID) {
328 if (FileNumber >= MCDwarfFiles.
size()) {
329 MCDwarfFiles.
resize(FileNumber + 1);
331 MCDwarfFile *&ExistingFile = MCDwarfFiles[FileNumber];
340 if (Directory.
empty()) {
343 if (!tFileName.
empty()) {
345 if (!Directory.
empty())
346 FileName = tFileName;
353 if (Directory.
empty()) {
358 for (
unsigned End = MCDwarfDirs.
size(); DirIndex < End; DirIndex++) {
359 if (Directory == MCDwarfDirs[DirIndex])
362 if (DirIndex >= MCDwarfDirs.
size()) {
363 char *Buf =
static_cast<char *
>(
Allocate(Directory.
size()));
376 char *Buf =
static_cast<char *
>(
Allocate(FileName.
size()));
388 if(FileNumber == 0 || FileNumber >= MCDwarfFiles.
size())
391 return MCDwarfFiles[FileNumber] != 0;
397 if (!SrcMgr || Loc ==
SMLoc())
void toVector(SmallVectorImpl< char > &Out) const
const MCSectionELF * CreateELFGroupSection()
void push_back(const T &Elt)
std::map< SectionGroupPair, const MCSectionELF * > ELFUniqueMapTy
unsigned GetDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, unsigned CUID)
GetDwarfFile - creates an entry in the dwarf file and directory tables.
const ValueTy & getValue() const
size_t size() const
size - Get the string size.
void setValue(const ValueTy &V)
const MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags, SectionKind Kind)
const StringRef parent_path(StringRef path)
Get parent path.
const char * getPrivateGlobalPrefix() const
error_code current_path(SmallVectorImpl< char > &result)
Get the current path.
unsigned getInstance() const
getInstance - Get the current instance of this Directional Local Label.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
MCSectionCOFF - This represents a section on Windows.
virtual const char * getBufferIdentifier() const
MCSymbol * GetOrCreateSymbol(StringRef Name)
#define DWARF2_FLAG_IS_STMT
MCSymbol * CreateTempSymbol()
StringMap< const MCSectionMachO * > MachOUniqueMapTy
std::pair< std::string, std::string > SectionGroupPair
const char * data() const
void RunInterruptHandlers()
MCSymbol * GetDirectionalLocalSymbol(int64_t LocalLabelVal, int bORf)
const MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, int Selection=0, const MCSectionCOFF *Assoc=0)
bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID=0)
LLVM_ATTRIBUTE_NORETURN void FatalError(SMLoc L, const Twine &Msg)
bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
ValueTy lookup(StringRef Key) const
StringRef str() const
Explicit conversion to StringRef.
void * Allocate(unsigned Size, unsigned Align=8)
MapEntryTy & GetOrCreateValue(StringRef Key, InitTy Val)
const MemoryBuffer * getMemoryBuffer(unsigned i) const
StringMap< const MCSectionCOFF * > COFFUniqueMapTy
MCSymbol * LookupSymbol(StringRef Name) const
LookupSymbol - Get the symbol for Name, or null.
size_t getNumBuffers() const
const MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K)
const MCRegisterInfo & MRI
const StringRef filename(StringRef path)
Get filename.
COFF::SectionCharacteristics Characteristics
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None, bool ShowColors=true) const
Represents a location in source code.
char *getenv(const char *name);
static SectionKind getReadOnly()
static unsigned DetermineEntrySize(SectionKind Kind)
MCSymbol * CreateDirectionalLocalSymbol(int64_t LocalLabelVal)
bool empty() const
empty - Check if the string is empty.