LLVM  4.0.0
MCContext.cpp
Go to the documentation of this file.
1 //===- lib/MC/MCContext.cpp - Machine Code Context ------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "llvm/MC/MCContext.h"
11 #include "llvm/ADT/SmallString.h"
12 #include "llvm/ADT/Twine.h"
13 #include "llvm/MC/MCAsmInfo.h"
14 #include "llvm/MC/MCAssembler.h"
15 #include "llvm/MC/MCCodeView.h"
16 #include "llvm/MC/MCDwarf.h"
17 #include "llvm/MC/MCLabel.h"
19 #include "llvm/MC/MCRegisterInfo.h"
20 #include "llvm/MC/MCSectionCOFF.h"
21 #include "llvm/MC/MCSectionELF.h"
22 #include "llvm/MC/MCSectionMachO.h"
23 #include "llvm/MC/MCStreamer.h"
24 #include "llvm/MC/MCSymbolCOFF.h"
25 #include "llvm/MC/MCSymbolELF.h"
26 #include "llvm/MC/MCSymbolMachO.h"
27 #include "llvm/Support/COFF.h"
29 #include "llvm/Support/ELF.h"
32 #include "llvm/Support/Signals.h"
33 #include "llvm/Support/SourceMgr.h"
34 
35 using namespace llvm;
36 
37 static cl::opt<char*>
38 AsSecureLogFileName("as-secure-log-file-name",
39  cl::desc("As secure log file name (initialized from "
40  "AS_SECURE_LOG_FILE env variable)"),
41  cl::init(getenv("AS_SECURE_LOG_FILE")), cl::Hidden);
42 
43 
44 MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri,
45  const MCObjectFileInfo *mofi, const SourceMgr *mgr,
46  bool DoAutoReset)
47  : SrcMgr(mgr), MAI(mai), MRI(mri), MOFI(mofi), Allocator(),
48  Symbols(Allocator), UsedNames(Allocator),
49  CurrentDwarfLoc(0, 0, 0, DWARF2_FLAG_IS_STMT, 0, 0), DwarfLocSeen(false),
50  GenDwarfForAssembly(false), GenDwarfFileNumber(0), DwarfVersion(4),
51  AllowTemporaryLabels(true), DwarfCompileUnitID(0),
52  AutoReset(DoAutoReset), HadError(false) {
53  SecureLogFile = AsSecureLogFileName;
54  SecureLog = nullptr;
55  SecureLogUsed = false;
56 
57  if (SrcMgr && SrcMgr->getNumBuffers())
58  MainFileName =
59  SrcMgr->getMemoryBuffer(SrcMgr->getMainFileID())->getBufferIdentifier();
60 }
61 
63  if (AutoReset)
64  reset();
65 
66  // NOTE: The symbols are all allocated out of a bump pointer allocator,
67  // we don't need to free them here.
68 }
69 
70 //===----------------------------------------------------------------------===//
71 // Module Lifetime Management
72 //===----------------------------------------------------------------------===//
73 
75  // Call the destructors so the fragments are freed
76  COFFAllocator.DestroyAll();
77  ELFAllocator.DestroyAll();
78  MachOAllocator.DestroyAll();
79 
80  MCSubtargetAllocator.DestroyAll();
81  UsedNames.clear();
82  Symbols.clear();
83  SectionSymbols.clear();
84  Allocator.Reset();
85  Instances.clear();
86  CompilationDir.clear();
87  MainFileName.clear();
88  MCDwarfLineTablesCUMap.clear();
89  SectionsForRanges.clear();
90  MCGenDwarfLabelEntries.clear();
91  DwarfDebugFlags = StringRef();
92  DwarfCompileUnitID = 0;
93  CurrentDwarfLoc = MCDwarfLoc(0, 0, 0, DWARF2_FLAG_IS_STMT, 0, 0);
94 
95  CVContext.reset();
96 
97  MachOUniquingMap.clear();
98  ELFUniquingMap.clear();
99  COFFUniquingMap.clear();
100 
101  NextID.clear();
102  AllowTemporaryLabels = true;
103  DwarfLocSeen = false;
104  GenDwarfForAssembly = false;
105  GenDwarfFileNumber = 0;
106 
107  HadError = false;
108 }
109 
110 //===----------------------------------------------------------------------===//
111 // Symbol Manipulation
112 //===----------------------------------------------------------------------===//
113 
115  SmallString<128> NameSV;
116  StringRef NameRef = Name.toStringRef(NameSV);
117 
118  assert(!NameRef.empty() && "Normal symbols cannot be unnamed!");
119 
120  MCSymbol *&Sym = Symbols[NameRef];
121  if (!Sym)
122  Sym = createSymbol(NameRef, false, false);
123 
124  return Sym;
125 }
126 
128  MCSymbol *&Sym = SectionSymbols[&Section];
129  if (Sym)
130  return cast<MCSymbolELF>(Sym);
131 
132  StringRef Name = Section.getSectionName();
133  auto NameIter = UsedNames.insert(std::make_pair(Name, false)).first;
134  Sym = new (&*NameIter, *this) MCSymbolELF(&*NameIter, /*isTemporary*/ false);
135 
136  return cast<MCSymbolELF>(Sym);
137 }
138 
140  unsigned Idx) {
141  return getOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + FuncName +
142  "$frame_escape_" + Twine(Idx));
143 }
144 
146  return getOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + FuncName +
147  "$parent_frame_offset");
148 }
149 
151  return getOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + "__ehtable$" +
152  FuncName);
153 }
154 
155 MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
156  bool IsTemporary) {
157  if (MOFI) {
158  switch (MOFI->getObjectFileType()) {
160  return new (Name, *this) MCSymbolCOFF(Name, IsTemporary);
162  return new (Name, *this) MCSymbolELF(Name, IsTemporary);
164  return new (Name, *this) MCSymbolMachO(Name, IsTemporary);
165  }
166  }
167  return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name,
168  IsTemporary);
169 }
170 
171 MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
172  bool CanBeUnnamed) {
173  if (CanBeUnnamed && !UseNamesOnTempLabels)
174  return createSymbolImpl(nullptr, true);
175 
176  // Determine whether this is a user written assembler temporary or normal
177  // label, if used.
178  bool IsTemporary = CanBeUnnamed;
179  if (AllowTemporaryLabels && !IsTemporary)
180  IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());
181 
182  SmallString<128> NewName = Name;
183  bool AddSuffix = AlwaysAddSuffix;
184  unsigned &NextUniqueID = NextID[Name];
185  for (;;) {
186  if (AddSuffix) {
187  NewName.resize(Name.size());
188  raw_svector_ostream(NewName) << NextUniqueID++;
189  }
190  auto NameEntry = UsedNames.insert(std::make_pair(NewName, true));
191  if (NameEntry.second || !NameEntry.first->second) {
192  // Ok, we found a name.
193  // Mark it as used for a non-section symbol.
194  NameEntry.first->second = true;
195  // Have the MCSymbol object itself refer to the copy of the string that is
196  // embedded in the UsedNames entry.
197  return createSymbolImpl(&*NameEntry.first, IsTemporary);
198  }
199  assert(IsTemporary && "Cannot rename non-temporary symbols");
200  AddSuffix = true;
201  }
202  llvm_unreachable("Infinite loop");
203 }
204 
205 MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix,
206  bool CanBeUnnamed) {
207  SmallString<128> NameSV;
208  raw_svector_ostream(NameSV) << MAI->getPrivateGlobalPrefix() << Name;
209  return createSymbol(NameSV, AlwaysAddSuffix, CanBeUnnamed);
210 }
211 
213  SmallString<128> NameSV;
214  raw_svector_ostream(NameSV) << MAI->getLinkerPrivateGlobalPrefix() << "tmp";
215  return createSymbol(NameSV, true, false);
216 }
217 
219  return createTempSymbol("tmp", true, CanBeUnnamed);
220 }
221 
222 unsigned MCContext::NextInstance(unsigned LocalLabelVal) {
223  MCLabel *&Label = Instances[LocalLabelVal];
224  if (!Label)
225  Label = new (*this) MCLabel(0);
226  return Label->incInstance();
227 }
228 
229 unsigned MCContext::GetInstance(unsigned LocalLabelVal) {
230  MCLabel *&Label = Instances[LocalLabelVal];
231  if (!Label)
232  Label = new (*this) MCLabel(0);
233  return Label->getInstance();
234 }
235 
236 MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
237  unsigned Instance) {
238  MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)];
239  if (!Sym)
240  Sym = createTempSymbol(false);
241  return Sym;
242 }
243 
245  unsigned Instance = NextInstance(LocalLabelVal);
246  return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
247 }
248 
250  bool Before) {
251  unsigned Instance = GetInstance(LocalLabelVal);
252  if (!Before)
253  ++Instance;
254  return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
255 }
256 
258  SmallString<128> NameSV;
259  StringRef NameRef = Name.toStringRef(NameSV);
260  return Symbols.lookup(NameRef);
261 }
262 
264  StringRef Sym,
265  uint64_t Val) {
266  auto Symbol = getOrCreateSymbol(Sym);
267  Streamer.EmitAssignment(Symbol, MCConstantExpr::create(Val, *this));
268 }
269 
270 //===----------------------------------------------------------------------===//
271 // Section Management
272 //===----------------------------------------------------------------------===//
273 
275  unsigned TypeAndAttributes,
276  unsigned Reserved2, SectionKind Kind,
277  const char *BeginSymName) {
278 
279  // We unique sections by their segment/section pair. The returned section
280  // may not have the same flags as the requested section, if so this should be
281  // diagnosed by the client as an error.
282 
283  // Form the name to look up.
285  Name += Segment;
286  Name.push_back(',');
287  Name += Section;
288 
289  // Do the lookup, if we have a hit, return it.
290  MCSectionMachO *&Entry = MachOUniquingMap[Name];
291  if (Entry)
292  return Entry;
293 
294  MCSymbol *Begin = nullptr;
295  if (BeginSymName)
296  Begin = createTempSymbol(BeginSymName, false);
297 
298  // Otherwise, return a new section.
299  return Entry = new (MachOAllocator.Allocate()) MCSectionMachO(
300  Segment, Section, TypeAndAttributes, Reserved2, Kind, Begin);
301 }
302 
304  StringRef GroupName;
305  if (const MCSymbol *Group = Section->getGroup())
306  GroupName = Group->getName();
307 
308  unsigned UniqueID = Section->getUniqueID();
309  ELFUniquingMap.erase(
310  ELFSectionKey{Section->getSectionName(), GroupName, UniqueID});
311  auto I = ELFUniquingMap.insert(std::make_pair(
312  ELFSectionKey{Name, GroupName, UniqueID},
313  Section))
314  .first;
315  StringRef CachedName = I->first.SectionName;
316  const_cast<MCSectionELF *>(Section)->setSectionName(CachedName);
317 }
318 
320  unsigned Flags, unsigned EntrySize,
321  const MCSymbolELF *Group,
322  const MCSectionELF *Associated) {
324  bool Inserted;
325  std::tie(I, Inserted) =
326  ELFRelSecNames.insert(std::make_pair(Name.str(), true));
327 
328  return new (ELFAllocator.Allocate())
330  EntrySize, Group, true, nullptr, Associated);
331 }
332 
334  const Twine &Suffix, unsigned Type,
335  unsigned Flags,
336  unsigned EntrySize) {
337  return getELFSection(Prefix + "." + Suffix, Type, Flags, EntrySize, Suffix);
338 }
339 
341  unsigned Flags, unsigned EntrySize,
342  const Twine &Group, unsigned UniqueID,
343  const char *BeginSymName) {
344  MCSymbolELF *GroupSym = nullptr;
345  if (!Group.isTriviallyEmpty() && !Group.str().empty())
346  GroupSym = cast<MCSymbolELF>(getOrCreateSymbol(Group));
347 
348  return getELFSection(Section, Type, Flags, EntrySize, GroupSym, UniqueID,
349  BeginSymName, nullptr);
350 }
351 
353  unsigned Flags, unsigned EntrySize,
354  const MCSymbolELF *GroupSym,
355  unsigned UniqueID,
356  const char *BeginSymName,
357  const MCSectionELF *Associated) {
358  StringRef Group = "";
359  if (GroupSym)
360  Group = GroupSym->getName();
361  // Do the lookup, if we have a hit, return it.
362  auto IterBool = ELFUniquingMap.insert(
363  std::make_pair(ELFSectionKey{Section.str(), Group, UniqueID}, nullptr));
364  auto &Entry = *IterBool.first;
365  if (!IterBool.second)
366  return Entry.second;
367 
368  StringRef CachedName = Entry.first.SectionName;
369 
371  if (Flags & ELF::SHF_ARM_PURECODE)
373  else if (Flags & ELF::SHF_EXECINSTR)
374  Kind = SectionKind::getText();
375  else
376  Kind = SectionKind::getReadOnly();
377 
378  MCSymbol *Begin = nullptr;
379  if (BeginSymName)
380  Begin = createTempSymbol(BeginSymName, false);
381 
382  MCSectionELF *Result = new (ELFAllocator.Allocate())
383  MCSectionELF(CachedName, Type, Flags, Kind, EntrySize, GroupSym, UniqueID,
384  Begin, Associated);
385  Entry.second = Result;
386  return Result;
387 }
388 
390  MCSectionELF *Result = new (ELFAllocator.Allocate())
392  Group, ~0, nullptr, nullptr);
393  return Result;
394 }
395 
397  unsigned Characteristics,
399  StringRef COMDATSymName, int Selection,
400  unsigned UniqueID,
401  const char *BeginSymName) {
402  MCSymbol *COMDATSymbol = nullptr;
403  if (!COMDATSymName.empty()) {
404  COMDATSymbol = getOrCreateSymbol(COMDATSymName);
405  COMDATSymName = COMDATSymbol->getName();
406  }
407 
408 
409  // Do the lookup, if we have a hit, return it.
410  COFFSectionKey T{Section, COMDATSymName, Selection, UniqueID};
411  auto IterBool = COFFUniquingMap.insert(std::make_pair(T, nullptr));
412  auto Iter = IterBool.first;
413  if (!IterBool.second)
414  return Iter->second;
415 
416  MCSymbol *Begin = nullptr;
417  if (BeginSymName)
418  Begin = createTempSymbol(BeginSymName, false);
419 
420  StringRef CachedName = Iter->first.SectionName;
421  MCSectionCOFF *Result = new (COFFAllocator.Allocate()) MCSectionCOFF(
422  CachedName, Characteristics, COMDATSymbol, Selection, Kind, Begin);
423 
424  Iter->second = Result;
425  return Result;
426 }
427 
429  unsigned Characteristics,
431  const char *BeginSymName) {
432  return getCOFFSection(Section, Characteristics, Kind, "", 0, GenericSectionID,
433  BeginSymName);
434 }
435 
437  COFFSectionKey T{Section, "", 0, GenericSectionID};
438  auto Iter = COFFUniquingMap.find(T);
439  if (Iter == COFFUniquingMap.end())
440  return nullptr;
441  return Iter->second;
442 }
443 
445  const MCSymbol *KeySym,
446  unsigned UniqueID) {
447  // Return the normal section if we don't have to be associative or unique.
448  if (!KeySym && UniqueID == GenericSectionID)
449  return Sec;
450 
451  // If we have a key symbol, make an associative section with the same name and
452  // kind as the normal section.
453  unsigned Characteristics = Sec->getCharacteristics();
454  if (KeySym) {
455  Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
457  Sec->getKind(), KeySym->getName(),
459  }
460 
461  return getCOFFSection(Sec->getSectionName(), Characteristics, Sec->getKind(),
462  "", 0, UniqueID);
463 }
464 
466  return *new (MCSubtargetAllocator.Allocate()) MCSubtargetInfo(STI);
467 }
468 
469 //===----------------------------------------------------------------------===//
470 // Dwarf Management
471 //===----------------------------------------------------------------------===//
472 
473 /// getDwarfFile - takes a file name an number to place in the dwarf file and
474 /// directory tables. If the file number has already been allocated it is an
475 /// error and zero is returned and the client reports the error, else the
476 /// allocated file number is returned. The file numbers may be in any order.
477 unsigned MCContext::getDwarfFile(StringRef Directory, StringRef FileName,
478  unsigned FileNumber, unsigned CUID) {
479  MCDwarfLineTable &Table = MCDwarfLineTablesCUMap[CUID];
480  return Table.getFile(Directory, FileName, FileNumber);
481 }
482 
483 /// isValidDwarfFileNumber - takes a dwarf file number and returns true if it
484 /// currently is assigned and false otherwise.
485 bool MCContext::isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID) {
486  const SmallVectorImpl<MCDwarfFile> &MCDwarfFiles = getMCDwarfFiles(CUID);
487  if (FileNumber == 0 || FileNumber >= MCDwarfFiles.size())
488  return false;
489 
490  return !MCDwarfFiles[FileNumber].Name.empty();
491 }
492 
493 /// Remove empty sections from SectionStartEndSyms, to avoid generating
494 /// useless debug info for them.
496  SectionsForRanges.remove_if(
497  [&](MCSection *Sec) { return !MCOS.mayHaveInstructions(*Sec); });
498 }
499 
501  if (!CVContext.get())
502  CVContext.reset(new CodeViewContext);
503  return *CVContext.get();
504 }
505 
506 //===----------------------------------------------------------------------===//
507 // Error Reporting
508 //===----------------------------------------------------------------------===//
509 
510 void MCContext::reportError(SMLoc Loc, const Twine &Msg) {
511  HadError = true;
512 
513  // If we have a source manager use it. Otherwise just use the generic
514  // report_fatal_error().
515  if (!SrcMgr)
516  report_fatal_error(Msg, false);
517 
518  // Use the source manager to print the message.
519  SrcMgr->PrintMessage(Loc, SourceMgr::DK_Error, Msg);
520 }
521 
522 void MCContext::reportFatalError(SMLoc Loc, const Twine &Msg) {
523  reportError(Loc, Msg);
524 
525  // If we reached here, we are failing ungracefully. Run the interrupt handlers
526  // to make sure any special cleanups get done, in particular that we remove
527  // files registered with RemoveFileOnSignal.
529  exit(1);
530 }
MCSymbolELF * getOrCreateSectionSymbol(const MCSectionELF &Section)
Definition: MCContext.cpp:127
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:40
void push_back(const T &Elt)
Definition: SmallVector.h:211
MCSymbol * getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before)
Create and return a directional local symbol for numbered label (used for "1b" or 1f" references)...
Definition: MCContext.cpp:249
StringRef getSectionName() const
Definition: MCSectionELF.h:74
This represents a section on a Mach-O system (used by Mac OS X).
MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *Associated)
Definition: MCContext.cpp:319
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
Definition: MCContext.h:463
MCSymbol * getOrCreateFrameAllocSymbol(StringRef FuncName, unsigned Idx)
Gets a symbol that will be defined to the final stack offset of a local variable after codegen...
Definition: MCContext.cpp:139
void reset()
reset - return object to right after construction state to prepare to process a new module ...
Definition: MCContext.cpp:74
SourceMgr SrcMgr
MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions)...
Definition: MCContext.cpp:244
unsigned getUniqueID() const
Definition: MCSectionELF.h:87
MCSymbol * getOrCreateParentFrameOffsetSymbol(StringRef FuncName)
Definition: MCContext.cpp:145
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:490
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
Definition: MCContext.cpp:257
unsigned getInstance() const
Get the current instance of this Directional Local Label.
Definition: MCLabel.h:39
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
Definition: MCContext.cpp:396
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...
Definition: MCContext.cpp:444
This represents a section on Windows.
Definition: MCSectionCOFF.h:24
unsigned getMainFileID() const
Definition: SourceMgr.h:106
std::string str() const
Return the twine contents as a std::string.
Definition: Twine.cpp:17
#define DWARF2_FLAG_IS_STMT
Definition: MCDwarf.h:66
MCSymbol * createLinkerPrivateTempSymbol()
Create and return a new linker temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:212
struct fuzzer::@269 Flags
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
void Reset()
Deallocate all but the current slab and reset the current pointer to the beginning of it...
Definition: Allocator.h:192
void renameELFSection(MCSectionELF *Section, StringRef Name)
Definition: MCContext.cpp:303
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:32
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionStartEndSyms, to avoid generating useless debug info for them...
Definition: MCContext.cpp:495
StringRef getPrivateGlobalPrefix() const
Definition: MCAsmInfo.h:476
virtual bool mayHaveInstructions(MCSection &Sec) const
Definition: MCStreamer.h:851
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:60
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Definition: MCStreamer.cpp:722
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:264
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.
Definition: MCContext.cpp:274
Environment getObjectFileType() const
Instances of this class represent the information from a dwarf .loc directive.
Definition: MCDwarf.h:54
Function Alias Analysis false
const MCSymbolELF * getGroup() const
Definition: MCSectionELF.h:79
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Definition: StringRef.h:135
LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:522
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...
Definition: MCAsmInfo.h:57
static cl::opt< char * > AsSecureLogFileName("as-secure-log-file-name", cl::desc("As secure log file name (initialized from ""AS_SECURE_LOG_FILE env variable)"), cl::init(getenv("AS_SECURE_LOG_FILE")), cl::Hidden)
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:395
Streaming machine code generation interface.
Definition: MCStreamer.h:161
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:218
unsigned const MachineRegisterInfo * MRI
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
unsigned getNumBuffers() const
Definition: SourceMgr.h:102
void RunInterruptHandlers()
This function runs all the registered interrupt handlers, including the removal of files registered b...
Greedy Register Allocator
cl::opt< int > DwarfVersion("dwarf-version", cl::desc("Dwarf version"), cl::init(0))
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:510
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:23
MCSectionELF * getELFNamedSection(const Twine &Prefix, const Twine &Suffix, unsigned Type, unsigned Flags, unsigned EntrySize=0)
Get a section with the provided group identifier.
Definition: MCContext.cpp:333
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Definition: SourceMgr.h:35
unsigned getCharacteristics() const
Definition: MCSectionCOFF.h:70
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID=0)
isValidDwarfFileNumber - takes a dwarf file number and returns true if it currently is assigned and f...
Definition: MCContext.cpp:485
unsigned incInstance()
Increment the current instance of this Directional Local Label.
Definition: MCLabel.h:42
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: StringMap.h:329
SectionKind getKind() const
Definition: MCSection.h:102
MCSymbol * getOrCreateLSDASymbol(StringRef FuncName)
Definition: MCContext.cpp:150
StringRef getSectionName() const
Definition: MCSectionCOFF.h:69
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
Definition: Twine.h:463
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:348
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:223
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
Definition: MCContext.h:324
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:130
void setSymbolValue(MCStreamer &Streamer, StringRef Sym, uint64_t Val)
Set value for a symbol.
Definition: MCContext.cpp:263
Basic Alias true
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:199
const MemoryBuffer * getMemoryBuffer(unsigned i) const
Definition: SourceMgr.h:97
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:114
#define I(x, y, z)
Definition: MD5.cpp:54
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Definition: SmallVector.h:135
COFFYAML::WeakExternalCharacteristics Characteristics
Definition: COFFYAML.cpp:270
MCSubtargetInfo - Generic base class for all target subtargets.
This represents a section on linux, lots of unix variants and some bare metal systems.
Definition: MCSectionELF.h:30
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group)
Definition: MCContext.cpp:389
CodeViewContext & getCVContext()
Definition: MCContext.cpp:500
const unsigned Kind
Instances of this class represent a label name in the MC file, and MCLabel are created and uniqued by...
Definition: MCLabel.h:26
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:341
unsigned getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
Definition: MCContext.cpp:477
StringRef getLinkerPrivateGlobalPrefix() const
Definition: MCAsmInfo.h:481
bool isTriviallyEmpty() const
Check if this twine is trivially empty; a false return value does not necessarily mean the twine is e...
Definition: Twine.h:408
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
Definition: SourceMgr.cpp:216
Represents a location in source code.
Definition: SMLoc.h:24
unsigned getFile(StringRef &Directory, StringRef &FileName, unsigned FileNumber=0)
Definition: MCDwarf.cpp:332
static SectionKind getReadOnly()
Definition: SectionKind.h:182
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
Definition: MCExpr.cpp:149
static SectionKind getExecuteOnly()
Definition: SectionKind.h:181
static SectionKind getText()
Definition: SectionKind.h:180
void resize(size_type N)
Definition: SmallVector.h:352
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Definition: MCContext.cpp:465
Holds state from .cv_file and .cv_loc directives for later emission.
Definition: MCCodeView.h:158