LLVM  6.0.0svn
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/SmallVector.h"
13 #include "llvm/ADT/StringMap.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/ADT/Twine.h"
16 #include "llvm/BinaryFormat/COFF.h"
17 #include "llvm/BinaryFormat/ELF.h"
18 #include "llvm/MC/MCAsmInfo.h"
19 #include "llvm/MC/MCCodeView.h"
20 #include "llvm/MC/MCDwarf.h"
21 #include "llvm/MC/MCExpr.h"
22 #include "llvm/MC/MCFragment.h"
23 #include "llvm/MC/MCLabel.h"
25 #include "llvm/MC/MCSectionCOFF.h"
26 #include "llvm/MC/MCSectionELF.h"
27 #include "llvm/MC/MCSectionMachO.h"
28 #include "llvm/MC/MCSectionWasm.h"
29 #include "llvm/MC/MCStreamer.h"
30 #include "llvm/MC/MCSymbol.h"
31 #include "llvm/MC/MCSymbolCOFF.h"
32 #include "llvm/MC/MCSymbolELF.h"
33 #include "llvm/MC/MCSymbolMachO.h"
34 #include "llvm/MC/MCSymbolWasm.h"
35 #include "llvm/MC/SectionKind.h"
36 #include "llvm/Support/Casting.h"
40 #include "llvm/Support/Signals.h"
41 #include "llvm/Support/SourceMgr.h"
43 #include <cassert>
44 #include <cstdlib>
45 #include <tuple>
46 #include <utility>
47 
48 using namespace llvm;
49 
50 static cl::opt<char*>
51 AsSecureLogFileName("as-secure-log-file-name",
52  cl::desc("As secure log file name (initialized from "
53  "AS_SECURE_LOG_FILE env variable)"),
54  cl::init(getenv("AS_SECURE_LOG_FILE")), cl::Hidden);
55 
57  const MCObjectFileInfo *mofi, const SourceMgr *mgr,
58  bool DoAutoReset)
59  : SrcMgr(mgr), InlineSrcMgr(nullptr), MAI(mai), MRI(mri), MOFI(mofi),
60  Symbols(Allocator), UsedNames(Allocator),
61  CurrentDwarfLoc(0, 0, 0, DWARF2_FLAG_IS_STMT, 0, 0),
62  AutoReset(DoAutoReset) {
63  SecureLogFile = AsSecureLogFileName;
64 
65  if (SrcMgr && SrcMgr->getNumBuffers())
66  MainFileName =
67  SrcMgr->getMemoryBuffer(SrcMgr->getMainFileID())->getBufferIdentifier();
68 }
69 
71  if (AutoReset)
72  reset();
73 
74  // NOTE: The symbols are all allocated out of a bump pointer allocator,
75  // we don't need to free them here.
76 }
77 
78 //===----------------------------------------------------------------------===//
79 // Module Lifetime Management
80 //===----------------------------------------------------------------------===//
81 
83  // Call the destructors so the fragments are freed
84  COFFAllocator.DestroyAll();
85  ELFAllocator.DestroyAll();
86  MachOAllocator.DestroyAll();
87 
88  MCSubtargetAllocator.DestroyAll();
89  UsedNames.clear();
90  Symbols.clear();
91  Allocator.Reset();
92  Instances.clear();
93  CompilationDir.clear();
94  MainFileName.clear();
95  MCDwarfLineTablesCUMap.clear();
96  SectionsForRanges.clear();
97  MCGenDwarfLabelEntries.clear();
98  DwarfDebugFlags = StringRef();
99  DwarfCompileUnitID = 0;
100  CurrentDwarfLoc = MCDwarfLoc(0, 0, 0, DWARF2_FLAG_IS_STMT, 0, 0);
101 
102  CVContext.reset();
103 
104  MachOUniquingMap.clear();
105  ELFUniquingMap.clear();
106  COFFUniquingMap.clear();
107 
108  NextID.clear();
109  AllowTemporaryLabels = true;
110  DwarfLocSeen = false;
111  GenDwarfForAssembly = false;
112  GenDwarfFileNumber = 0;
113 
114  HadError = false;
115 }
116 
117 //===----------------------------------------------------------------------===//
118 // Symbol Manipulation
119 //===----------------------------------------------------------------------===//
120 
122  SmallString<128> NameSV;
123  StringRef NameRef = Name.toStringRef(NameSV);
124 
125  assert(!NameRef.empty() && "Normal symbols cannot be unnamed!");
126 
127  MCSymbol *&Sym = Symbols[NameRef];
128  if (!Sym)
129  Sym = createSymbol(NameRef, false, false);
130 
131  return Sym;
132 }
133 
135  unsigned Idx) {
136  return getOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + FuncName +
137  "$frame_escape_" + Twine(Idx));
138 }
139 
141  return getOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + FuncName +
142  "$parent_frame_offset");
143 }
144 
146  return getOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + "__ehtable$" +
147  FuncName);
148 }
149 
150 MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
151  bool IsTemporary) {
152  if (MOFI) {
153  switch (MOFI->getObjectFileType()) {
155  return new (Name, *this) MCSymbolCOFF(Name, IsTemporary);
157  return new (Name, *this) MCSymbolELF(Name, IsTemporary);
159  return new (Name, *this) MCSymbolMachO(Name, IsTemporary);
161  return new (Name, *this) MCSymbolWasm(Name, IsTemporary);
162  }
163  }
164  return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name,
165  IsTemporary);
166 }
167 
168 MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
169  bool CanBeUnnamed) {
170  if (CanBeUnnamed && !UseNamesOnTempLabels)
171  return createSymbolImpl(nullptr, true);
172 
173  // Determine whether this is a user written assembler temporary or normal
174  // label, if used.
175  bool IsTemporary = CanBeUnnamed;
176  if (AllowTemporaryLabels && !IsTemporary)
177  IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());
178 
179  SmallString<128> NewName = Name;
180  bool AddSuffix = AlwaysAddSuffix;
181  unsigned &NextUniqueID = NextID[Name];
182  while (true) {
183  if (AddSuffix) {
184  NewName.resize(Name.size());
185  raw_svector_ostream(NewName) << NextUniqueID++;
186  }
187  auto NameEntry = UsedNames.insert(std::make_pair(NewName, true));
188  if (NameEntry.second || !NameEntry.first->second) {
189  // Ok, we found a name.
190  // Mark it as used for a non-section symbol.
191  NameEntry.first->second = true;
192  // Have the MCSymbol object itself refer to the copy of the string that is
193  // embedded in the UsedNames entry.
194  return createSymbolImpl(&*NameEntry.first, IsTemporary);
195  }
196  assert(IsTemporary && "Cannot rename non-temporary symbols");
197  AddSuffix = true;
198  }
199  llvm_unreachable("Infinite loop");
200 }
201 
202 MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix,
203  bool CanBeUnnamed) {
204  SmallString<128> NameSV;
205  raw_svector_ostream(NameSV) << MAI->getPrivateGlobalPrefix() << Name;
206  return createSymbol(NameSV, AlwaysAddSuffix, CanBeUnnamed);
207 }
208 
210  SmallString<128> NameSV;
211  raw_svector_ostream(NameSV) << MAI->getLinkerPrivateGlobalPrefix() << "tmp";
212  return createSymbol(NameSV, true, false);
213 }
214 
216  return createTempSymbol("tmp", true, CanBeUnnamed);
217 }
218 
219 unsigned MCContext::NextInstance(unsigned LocalLabelVal) {
220  MCLabel *&Label = Instances[LocalLabelVal];
221  if (!Label)
222  Label = new (*this) MCLabel(0);
223  return Label->incInstance();
224 }
225 
226 unsigned MCContext::GetInstance(unsigned LocalLabelVal) {
227  MCLabel *&Label = Instances[LocalLabelVal];
228  if (!Label)
229  Label = new (*this) MCLabel(0);
230  return Label->getInstance();
231 }
232 
233 MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
234  unsigned Instance) {
235  MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)];
236  if (!Sym)
237  Sym = createTempSymbol(false);
238  return Sym;
239 }
240 
242  unsigned Instance = NextInstance(LocalLabelVal);
243  return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
244 }
245 
247  bool Before) {
248  unsigned Instance = GetInstance(LocalLabelVal);
249  if (!Before)
250  ++Instance;
251  return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
252 }
253 
255  SmallString<128> NameSV;
256  StringRef NameRef = Name.toStringRef(NameSV);
257  return Symbols.lookup(NameRef);
258 }
259 
261  StringRef Sym,
262  uint64_t Val) {
263  auto Symbol = getOrCreateSymbol(Sym);
264  Streamer.EmitAssignment(Symbol, MCConstantExpr::create(Val, *this));
265 }
266 
267 //===----------------------------------------------------------------------===//
268 // Section Management
269 //===----------------------------------------------------------------------===//
270 
272  unsigned TypeAndAttributes,
273  unsigned Reserved2, SectionKind Kind,
274  const char *BeginSymName) {
275  // We unique sections by their segment/section pair. The returned section
276  // may not have the same flags as the requested section, if so this should be
277  // diagnosed by the client as an error.
278 
279  // Form the name to look up.
281  Name += Segment;
282  Name.push_back(',');
283  Name += Section;
284 
285  // Do the lookup, if we have a hit, return it.
286  MCSectionMachO *&Entry = MachOUniquingMap[Name];
287  if (Entry)
288  return Entry;
289 
290  MCSymbol *Begin = nullptr;
291  if (BeginSymName)
292  Begin = createTempSymbol(BeginSymName, false);
293 
294  // Otherwise, return a new section.
295  return Entry = new (MachOAllocator.Allocate()) MCSectionMachO(
296  Segment, Section, TypeAndAttributes, Reserved2, Kind, Begin);
297 }
298 
300  StringRef GroupName;
301  if (const MCSymbol *Group = Section->getGroup())
302  GroupName = Group->getName();
303 
304  unsigned UniqueID = Section->getUniqueID();
305  ELFUniquingMap.erase(
306  ELFSectionKey{Section->getSectionName(), GroupName, UniqueID});
307  auto I = ELFUniquingMap.insert(std::make_pair(
308  ELFSectionKey{Name, GroupName, UniqueID},
309  Section))
310  .first;
311  StringRef CachedName = I->first.SectionName;
312  const_cast<MCSectionELF *>(Section)->setSectionName(CachedName);
313 }
314 
315 MCSectionELF *MCContext::createELFSectionImpl(StringRef Section, unsigned Type,
316  unsigned Flags, SectionKind K,
317  unsigned EntrySize,
318  const MCSymbolELF *Group,
319  unsigned UniqueID,
320  const MCSymbolELF *Associated) {
321  MCSymbolELF *R;
322  MCSymbol *&Sym = Symbols[Section];
323  // A section symbol can not redefine regular symbols. There may be multiple
324  // sections with the same name, in which case the first such section wins.
325  if (Sym && Sym->isDefined() &&
326  (!Sym->isInSection() || Sym->getSection().getBeginSymbol() != Sym))
327  reportError(SMLoc(), "invalid symbol redefinition");
328  if (Sym && Sym->isUndefined()) {
329  R = cast<MCSymbolELF>(Sym);
330  } else {
331  auto NameIter = UsedNames.insert(std::make_pair(Section, false)).first;
332  R = new (&*NameIter, *this) MCSymbolELF(&*NameIter, /*isTemporary*/ false);
333  if (!Sym)
334  Sym = R;
335  }
338 
339  auto *Ret = new (ELFAllocator.Allocate()) MCSectionELF(
340  Section, Type, Flags, K, EntrySize, Group, UniqueID, R, Associated);
341 
342  auto *F = new MCDataFragment();
343  Ret->getFragmentList().insert(Ret->begin(), F);
344  F->setParent(Ret);
345  R->setFragment(F);
346 
347  return Ret;
348 }
349 
351  unsigned Flags, unsigned EntrySize,
352  const MCSymbolELF *Group,
353  const MCSectionELF *RelInfoSection) {
355  bool Inserted;
356  std::tie(I, Inserted) =
357  RelSecNames.insert(std::make_pair(Name.str(), true));
358 
359  return createELFSectionImpl(
360  I->getKey(), Type, Flags, SectionKind::getReadOnly(), EntrySize, Group,
361  true, cast<MCSymbolELF>(RelInfoSection->getBeginSymbol()));
362 }
363 
365  const Twine &Suffix, unsigned Type,
366  unsigned Flags,
367  unsigned EntrySize) {
368  return getELFSection(Prefix + "." + Suffix, Type, Flags, EntrySize, Suffix);
369 }
370 
371 MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type,
372  unsigned Flags, unsigned EntrySize,
373  const Twine &Group, unsigned UniqueID,
374  const MCSymbolELF *Associated) {
375  MCSymbolELF *GroupSym = nullptr;
376  if (!Group.isTriviallyEmpty() && !Group.str().empty())
377  GroupSym = cast<MCSymbolELF>(getOrCreateSymbol(Group));
378 
379  return getELFSection(Section, Type, Flags, EntrySize, GroupSym, UniqueID,
380  Associated);
381 }
382 
383 MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type,
384  unsigned Flags, unsigned EntrySize,
385  const MCSymbolELF *GroupSym,
386  unsigned UniqueID,
387  const MCSymbolELF *Associated) {
388  StringRef Group = "";
389  if (GroupSym)
390  Group = GroupSym->getName();
391  // Do the lookup, if we have a hit, return it.
392  auto IterBool = ELFUniquingMap.insert(
393  std::make_pair(ELFSectionKey{Section.str(), Group, UniqueID}, nullptr));
394  auto &Entry = *IterBool.first;
395  if (!IterBool.second)
396  return Entry.second;
397 
398  StringRef CachedName = Entry.first.SectionName;
399 
401  if (Flags & ELF::SHF_ARM_PURECODE)
403  else if (Flags & ELF::SHF_EXECINSTR)
404  Kind = SectionKind::getText();
405  else
406  Kind = SectionKind::getReadOnly();
407 
408  MCSectionELF *Result = createELFSectionImpl(
409  CachedName, Type, Flags, Kind, EntrySize, GroupSym, UniqueID, Associated);
410  Entry.second = Result;
411  return Result;
412 }
413 
415  return createELFSectionImpl(".group", ELF::SHT_GROUP, 0,
416  SectionKind::getReadOnly(), 4, Group, ~0,
417  nullptr);
418 }
419 
421  unsigned Characteristics,
423  StringRef COMDATSymName, int Selection,
424  unsigned UniqueID,
425  const char *BeginSymName) {
426  MCSymbol *COMDATSymbol = nullptr;
427  if (!COMDATSymName.empty()) {
428  COMDATSymbol = getOrCreateSymbol(COMDATSymName);
429  COMDATSymName = COMDATSymbol->getName();
430  }
431 
432 
433  // Do the lookup, if we have a hit, return it.
434  COFFSectionKey T{Section, COMDATSymName, Selection, UniqueID};
435  auto IterBool = COFFUniquingMap.insert(std::make_pair(T, nullptr));
436  auto Iter = IterBool.first;
437  if (!IterBool.second)
438  return Iter->second;
439 
440  MCSymbol *Begin = nullptr;
441  if (BeginSymName)
442  Begin = createTempSymbol(BeginSymName, false);
443 
444  StringRef CachedName = Iter->first.SectionName;
445  MCSectionCOFF *Result = new (COFFAllocator.Allocate()) MCSectionCOFF(
446  CachedName, Characteristics, COMDATSymbol, Selection, Kind, Begin);
447 
448  Iter->second = Result;
449  return Result;
450 }
451 
453  unsigned Characteristics,
455  const char *BeginSymName) {
456  return getCOFFSection(Section, Characteristics, Kind, "", 0, GenericSectionID,
457  BeginSymName);
458 }
459 
461  COFFSectionKey T{Section, "", 0, GenericSectionID};
462  auto Iter = COFFUniquingMap.find(T);
463  if (Iter == COFFUniquingMap.end())
464  return nullptr;
465  return Iter->second;
466 }
467 
469  const MCSymbol *KeySym,
470  unsigned UniqueID) {
471  // Return the normal section if we don't have to be associative or unique.
472  if (!KeySym && UniqueID == GenericSectionID)
473  return Sec;
474 
475  // If we have a key symbol, make an associative section with the same name and
476  // kind as the normal section.
477  unsigned Characteristics = Sec->getCharacteristics();
478  if (KeySym) {
479  Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
481  Sec->getKind(), KeySym->getName(),
483  }
484 
485  return getCOFFSection(Sec->getSectionName(), Characteristics, Sec->getKind(),
486  "", 0, UniqueID);
487 }
488 
490  const Twine &Group, unsigned UniqueID,
491  const char *BeginSymName) {
492  MCSymbolWasm *GroupSym = nullptr;
493  if (!Group.isTriviallyEmpty() && !Group.str().empty())
494  GroupSym = cast<MCSymbolWasm>(getOrCreateSymbol(Group));
495 
496  return getWasmSection(Section, K, GroupSym, UniqueID, BeginSymName);
497 }
498 
500  const MCSymbolWasm *GroupSym,
501  unsigned UniqueID,
502  const char *BeginSymName) {
503  StringRef Group = "";
504  if (GroupSym)
505  Group = GroupSym->getName();
506  // Do the lookup, if we have a hit, return it.
507  auto IterBool = WasmUniquingMap.insert(
508  std::make_pair(WasmSectionKey{Section.str(), Group, UniqueID}, nullptr));
509  auto &Entry = *IterBool.first;
510  if (!IterBool.second)
511  return Entry.second;
512 
513  StringRef CachedName = Entry.first.SectionName;
514 
515  MCSymbol *Begin = nullptr;
516  if (BeginSymName)
517  Begin = createTempSymbol(BeginSymName, false);
518 
519  MCSectionWasm *Result = new (WasmAllocator.Allocate())
520  MCSectionWasm(CachedName, Kind, GroupSym, UniqueID, Begin);
521  Entry.second = Result;
522  return Result;
523 }
524 
526  return *new (MCSubtargetAllocator.Allocate()) MCSubtargetInfo(STI);
527 }
528 
529 //===----------------------------------------------------------------------===//
530 // Dwarf Management
531 //===----------------------------------------------------------------------===//
532 
533 /// getDwarfFile - takes a file name an number to place in the dwarf file and
534 /// directory tables. If the file number has already been allocated it is an
535 /// error and zero is returned and the client reports the error, else the
536 /// allocated file number is returned. The file numbers may be in any order.
537 unsigned MCContext::getDwarfFile(StringRef Directory, StringRef FileName,
538  unsigned FileNumber, unsigned CUID) {
539  MCDwarfLineTable &Table = MCDwarfLineTablesCUMap[CUID];
540  return Table.getFile(Directory, FileName, FileNumber);
541 }
542 
543 /// isValidDwarfFileNumber - takes a dwarf file number and returns true if it
544 /// currently is assigned and false otherwise.
545 bool MCContext::isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID) {
546  const SmallVectorImpl<MCDwarfFile> &MCDwarfFiles = getMCDwarfFiles(CUID);
547  if (FileNumber == 0 || FileNumber >= MCDwarfFiles.size())
548  return false;
549 
550  return !MCDwarfFiles[FileNumber].Name.empty();
551 }
552 
553 /// Remove empty sections from SectionStartEndSyms, to avoid generating
554 /// useless debug info for them.
556  SectionsForRanges.remove_if(
557  [&](MCSection *Sec) { return !MCOS.mayHaveInstructions(*Sec); });
558 }
559 
561  if (!CVContext.get())
562  CVContext.reset(new CodeViewContext);
563  return *CVContext.get();
564 }
565 
566 //===----------------------------------------------------------------------===//
567 // Error Reporting
568 //===----------------------------------------------------------------------===//
569 
570 void MCContext::reportError(SMLoc Loc, const Twine &Msg) {
571  HadError = true;
572 
573  // If we have a source manager use it. Otherwise, try using the inline source
574  // manager.
575  // If that fails, use the generic report_fatal_error().
576  if (SrcMgr)
577  SrcMgr->PrintMessage(Loc, SourceMgr::DK_Error, Msg);
578  else if (InlineSrcMgr)
579  InlineSrcMgr->PrintMessage(Loc, SourceMgr::DK_Error, Msg);
580  else
581  report_fatal_error(Msg, false);
582 }
583 
584 void MCContext::reportFatalError(SMLoc Loc, const Twine &Msg) {
585  reportError(Loc, Msg);
586 
587  // If we reached here, we are failing ungracefully. Run the interrupt handlers
588  // to make sure any special cleanups get done, in particular that we remove
589  // files registered with RemoveFileOnSignal.
591  exit(1);
592 }
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
void push_back(const T &Elt)
Definition: SmallVector.h:212
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:246
SectionKind getKind() const
Definition: MCSection.h:102
This represents a section on a Mach-O system (used by Mac OS X).
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
Definition: MCContext.cpp:254
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:115
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMap.h:126
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
MCSection & getSection(bool SetUsed=true) const
Get the section associated with a defined, non-absolute symbol.
Definition: MCSymbol.h:268
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Definition: SmallVector.h:136
unsigned getNumBuffers() const
Definition: SourceMgr.h:109
StringRef getLinkerPrivateGlobalPrefix() const
Definition: MCAsmInfo.h:482
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
Definition: MCContext.h:510
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:134
void reset()
reset - return object to right after construction state to prepare to process a new module ...
Definition: MCContext.cpp:82
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Definition: StringRef.h:138
SourceMgr SrcMgr
Definition: Error.cpp:23
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:398
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
Definition: Twine.h:453
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K)
Definition: MCContext.h:444
MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions)...
Definition: MCContext.cpp:241
MCSymbol * getOrCreateParentFrameOffsetSymbol(StringRef FuncName)
Definition: MCContext.cpp:140
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:489
F(f)
StringRef getPrivateGlobalPrefix() const
Definition: MCAsmInfo.h:475
MCContext(const MCAsmInfo *MAI, const MCRegisterInfo *MRI, const MCObjectFileInfo *MOFI, const SourceMgr *Mgr=nullptr, bool DoAutoReset=true)
Definition: MCContext.cpp:56
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
Definition: MCContext.cpp:420
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:468
This represents a section on Windows.
Definition: MCSectionCOFF.h:27
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:225
#define DWARF2_FLAG_IS_STMT
Definition: MCDwarf.h:69
MCSymbol * createLinkerPrivateTempSymbol()
Create and return a new linker temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:209
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:299
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionStartEndSyms, to avoid generating useless debug info for them...
Definition: MCContext.cpp:555
void setFragment(MCFragment *F) const
Mark the symbol as defined in the fragment F.
Definition: MCSymbol.h:274
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Definition: MCStreamer.cpp:820
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)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:267
const MemoryBuffer * getMemoryBuffer(unsigned i) const
Definition: SourceMgr.h:104
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:271
Instances of this class represent the information from a dwarf .loc directive.
Definition: MCDwarf.h:57
unsigned getCharacteristics() const
Definition: MCSectionCOFF.h:73
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
Definition: MCContext.h:362
LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:584
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
unsigned getMainFileID() const
Definition: SourceMgr.h:113
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
unsigned getUniqueID() const
Definition: MCSectionELF.h:87
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:406
Streaming machine code generation interface.
Definition: MCStreamer.h:169
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:215
unsigned const MachineRegisterInfo * MRI
const MCSymbolELF * getGroup() const
Definition: MCSectionELF.h:78
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This represents a section on wasm.
Definition: MCSectionWasm.h:28
void RunInterruptHandlers()
This function runs all the registered interrupt handlers, including the removal of files registered b...
virtual bool mayHaveInstructions(MCSection &Sec) const
Definition: MCStreamer.h:898
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:570
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:23
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.
Definition: MCContext.cpp:364
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:351
Environment getObjectFileType() const
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Definition: SourceMgr.h:41
StringRef getSectionName() const
Definition: MCSectionCOFF.h:72
#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:545
void setType(unsigned Type) const
Definition: MCSymbolELF.cpp:96
MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *RelInfoSection)
Definition: MCContext.cpp:350
unsigned incInstance()
Increment the current instance of this Directional Local Label.
Definition: MCLabel.h:41
Basic Register Allocator
bool isInSection(bool SetUsed=true) const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
Definition: MCSymbol.h:255
MCSymbol * getOrCreateLSDASymbol(StringRef FuncName)
Definition: MCContext.cpp:145
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
Definition: MCSymbol.h:260
void setBinding(unsigned Binding) const
Definition: MCSymbolELF.cpp:43
MCSymbol * getBeginSymbol()
Definition: MCSection.h:106
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:370
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:224
void setSymbolValue(MCStreamer &Streamer, StringRef Sym, uint64_t Val)
Set value for a symbol.
Definition: MCContext.cpp:260
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:121
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:61
unsigned getInstance() const
Get the current instance of this Directional Local Label.
Definition: MCLabel.h:38
#define I(x, y, z)
Definition: MD5.cpp:58
bool isDefined(bool SetUsed=true) const
isDefined - Check if this symbol is defined (i.e., it has an address).
Definition: MCSymbol.h:249
COFFYAML::WeakExternalCharacteristics Characteristics
Definition: COFFYAML.cpp:323
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:28
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group)
Definition: MCContext.cpp:414
std::string str() const
Return the twine contents as a std::string.
Definition: Twine.cpp:17
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:203
CodeViewContext & getCVContext()
Definition: MCContext.cpp:560
const unsigned Kind
Fragment for data and encoded instructions.
Definition: MCFragment.h:226
Instances of this class represent a label name in the MC file, and MCLabel are created and uniqued by...
Definition: MCLabel.h:24
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:379
unsigned getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
Definition: MCContext.cpp:537
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Represents a location in source code.
Definition: SMLoc.h:24
unsigned getFile(StringRef &Directory, StringRef &FileName, unsigned FileNumber=0)
Definition: MCDwarf.cpp:346
static SectionKind getReadOnly()
Definition: SectionKind.h:182
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
Definition: MCExpr.cpp:159
StringRef getSectionName() const
Definition: MCSectionELF.h:73
static SectionKind getExecuteOnly()
Definition: SectionKind.h:181
static SectionKind getText()
Definition: SectionKind.h:180
void resize(size_type N)
Definition: SmallVector.h:355
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Definition: MCContext.cpp:525
Holds state from .cv_file and .cv_loc directives for later emission.
Definition: MCCodeView.h:158