LLVM  3.7.0
MCContext.h
Go to the documentation of this file.
1 //===- MCContext.h - Machine Code Context -----------------------*- C++ -*-===//
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 #ifndef LLVM_MC_MCCONTEXT_H
11 #define LLVM_MC_MCCONTEXT_H
12 
13 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/ADT/SetVector.h"
15 #include "llvm/ADT/SmallString.h"
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/ADT/StringMap.h"
18 #include "llvm/ADT/Twine.h"
19 #include "llvm/MC/MCDwarf.h"
20 #include "llvm/MC/SectionKind.h"
21 #include "llvm/Support/Allocator.h"
22 #include "llvm/Support/Compiler.h"
24 #include <map>
25 #include <tuple>
26 #include <vector> // FIXME: Shouldn't be needed.
27 
28 namespace llvm {
29  class MCAsmInfo;
30  class MCExpr;
31  class MCSection;
32  class MCSymbol;
33  class MCSymbolELF;
34  class MCLabel;
35  struct MCDwarfFile;
36  class MCDwarfLoc;
37  class MCObjectFileInfo;
38  class MCRegisterInfo;
39  class MCLineSection;
40  class SMLoc;
41  class MCSectionMachO;
42  class MCSectionELF;
43  class MCSectionCOFF;
44 
45  /// Context object for machine code objects. This class owns all of the
46  /// sections that it creates.
47  ///
48  class MCContext {
49  MCContext(const MCContext &) = delete;
50  MCContext &operator=(const MCContext &) = delete;
51 
52  public:
54 
55  private:
56  /// The SourceMgr for this object, if any.
57  const SourceMgr *SrcMgr;
58 
59  /// The MCAsmInfo for this target.
60  const MCAsmInfo *MAI;
61 
62  /// The MCRegisterInfo for this target.
63  const MCRegisterInfo *MRI;
64 
65  /// The MCObjectFileInfo for this target.
66  const MCObjectFileInfo *MOFI;
67 
68  /// Allocator object used for creating machine code objects.
69  ///
70  /// We use a bump pointer allocator to avoid the need to track all allocated
71  /// objects.
72  BumpPtrAllocator Allocator;
73 
74  /// Bindings of names to symbols.
75  SymbolTable Symbols;
76 
77  /// ELF sections can have a corresponding symbol. This maps one to the
78  /// other.
80 
81  /// A mapping from a local label number and an instance count to a symbol.
82  /// For example, in the assembly
83  /// 1:
84  /// 2:
85  /// 1:
86  /// We have three labels represented by the pairs (1, 0), (2, 0) and (1, 1)
88 
89  /// Keeps tracks of names that were used both for used declared and
90  /// artificial symbols.
92 
93  /// The next ID to dole out to an unnamed assembler temporary symbol with
94  /// a given prefix.
95  StringMap<unsigned> NextID;
96 
97  /// Instances of directional local labels.
99  /// NextInstance() creates the next instance of the directional local label
100  /// for the LocalLabelVal and adds it to the map if needed.
101  unsigned NextInstance(unsigned LocalLabelVal);
102  /// GetInstance() gets the current instance of the directional local label
103  /// for the LocalLabelVal and adds it to the map if needed.
104  unsigned GetInstance(unsigned LocalLabelVal);
105 
106  /// The file name of the log file from the environment variable
107  /// AS_SECURE_LOG_FILE. Which must be set before the .secure_log_unique
108  /// directive is used or it is an error.
109  char *SecureLogFile;
110  /// The stream that gets written to for the .secure_log_unique directive.
111  raw_ostream *SecureLog;
112  /// Boolean toggled when .secure_log_unique / .secure_log_reset is seen to
113  /// catch errors if .secure_log_unique appears twice without
114  /// .secure_log_reset appearing between them.
115  bool SecureLogUsed;
116 
117  /// The compilation directory to use for DW_AT_comp_dir.
118  SmallString<128> CompilationDir;
119 
120  /// The main file name if passed in explicitly.
121  std::string MainFileName;
122 
123  /// The dwarf file and directory tables from the dwarf .file directive.
124  /// We now emit a line table for each compile unit. To reduce the prologue
125  /// size of each line table, the files and directories used by each compile
126  /// unit are separated.
127  std::map<unsigned, MCDwarfLineTable> MCDwarfLineTablesCUMap;
128 
129  /// The current dwarf line information from the last dwarf .loc directive.
130  MCDwarfLoc CurrentDwarfLoc;
131  bool DwarfLocSeen;
132 
133  /// Generate dwarf debugging info for assembly source files.
134  bool GenDwarfForAssembly;
135 
136  /// The current dwarf file number when generate dwarf debugging info for
137  /// assembly source files.
138  unsigned GenDwarfFileNumber;
139 
140  /// Sections for generating the .debug_ranges and .debug_aranges sections.
141  SetVector<MCSection *> SectionsForRanges;
142 
143  /// The information gathered from labels that will have dwarf label
144  /// entries when generating dwarf assembly source files.
145  std::vector<MCGenDwarfLabelEntry> MCGenDwarfLabelEntries;
146 
147  /// The string to embed in the debug information for the compile unit, if
148  /// non-empty.
149  StringRef DwarfDebugFlags;
150 
151  /// The string to embed in as the dwarf AT_producer for the compile unit, if
152  /// non-empty.
153  StringRef DwarfDebugProducer;
154 
155  /// The maximum version of dwarf that we should emit.
156  uint16_t DwarfVersion;
157 
158  /// Honor temporary labels, this is useful for debugging semantic
159  /// differences between temporary and non-temporary labels (primarily on
160  /// Darwin).
161  bool AllowTemporaryLabels;
162  bool UseNamesOnTempLabels = true;
163 
164  /// The Compile Unit ID that we are currently processing.
165  unsigned DwarfCompileUnitID;
166 
167  struct ELFSectionKey {
168  std::string SectionName;
169  StringRef GroupName;
170  unsigned UniqueID;
171  ELFSectionKey(StringRef SectionName, StringRef GroupName,
172  unsigned UniqueID)
173  : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
174  }
175  bool operator<(const ELFSectionKey &Other) const {
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;
181  }
182  };
183 
184  struct COFFSectionKey {
185  std::string SectionName;
186  StringRef GroupName;
187  int SelectionKey;
188  COFFSectionKey(StringRef SectionName, StringRef GroupName,
189  int SelectionKey)
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;
198  }
199  };
200 
201  StringMap<MCSectionMachO *> MachOUniquingMap;
202  std::map<ELFSectionKey, MCSectionELF *> ELFUniquingMap;
203  std::map<COFFSectionKey, MCSectionCOFF *> COFFUniquingMap;
204  StringMap<bool> ELFRelSecNames;
205 
206  /// Do automatic reset in destructor
207  bool AutoReset;
208 
209  MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
210  bool CanBeUnnamed);
211  MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix,
212  bool IsTemporary);
213 
214  MCSymbol *getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
215  unsigned Instance);
216 
217  public:
218  explicit MCContext(const MCAsmInfo *MAI, const MCRegisterInfo *MRI,
219  const MCObjectFileInfo *MOFI,
220  const SourceMgr *Mgr = nullptr, bool DoAutoReset = true);
221  ~MCContext();
222 
223  const SourceMgr *getSourceManager() const { return SrcMgr; }
224 
225  const MCAsmInfo *getAsmInfo() const { return MAI; }
226 
227  const MCRegisterInfo *getRegisterInfo() const { return MRI; }
228 
229  const MCObjectFileInfo *getObjectFileInfo() const { return MOFI; }
230 
231  void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }
232  void setUseNamesOnTempLabels(bool Value) { UseNamesOnTempLabels = Value; }
233 
234  /// \name Module Lifetime Management
235  /// @{
236 
237  /// reset - return object to right after construction state to prepare
238  /// to process a new module
239  void reset();
240 
241  /// @}
242 
243  /// \name Symbol Management
244  /// @{
245 
246  /// Create and return a new linker temporary symbol with a unique but
247  /// unspecified name.
249 
250  /// Create and return a new assembler temporary symbol with a unique but
251  /// unspecified name.
252  MCSymbol *createTempSymbol(bool CanBeUnnamed = true);
253 
254  MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix,
255  bool CanBeUnnamed = true);
256 
257  /// Create the definition of a directional local symbol for numbered label
258  /// (used for "1:" definitions).
259  MCSymbol *createDirectionalLocalSymbol(unsigned LocalLabelVal);
260 
261  /// Create and return a directional local symbol for numbered label (used
262  /// for "1b" or 1f" references).
263  MCSymbol *getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before);
264 
265  /// Lookup the symbol inside with the specified \p Name. If it exists,
266  /// return it. If not, create a forward reference and return it.
267  ///
268  /// \param Name - The symbol name, which must be unique across all symbols.
270 
272 
273  /// Gets a symbol that will be defined to the final stack offset of a local
274  /// variable after codegen.
275  ///
276  /// \param Idx - The index of a local variable passed to @llvm.localescape.
278 
280 
282 
283  /// Get the symbol for \p Name, or null.
284  MCSymbol *lookupSymbol(const Twine &Name) const;
285 
286  /// getSymbols - Get a reference for the symbol table for clients that
287  /// want to, for example, iterate over all symbols. 'const' because we
288  /// still want any modifications to the table itself to use the MCContext
289  /// APIs.
290  const SymbolTable &getSymbols() const { return Symbols; }
291 
292  /// @}
293 
294  /// \name Section Management
295  /// @{
296 
297  /// Return the MCSection for the specified mach-o section. This requires
298  /// the operands to be valid.
300  unsigned TypeAndAttributes,
301  unsigned Reserved2, SectionKind K,
302  const char *BeginSymName = nullptr);
303 
305  unsigned TypeAndAttributes, SectionKind K,
306  const char *BeginSymName = nullptr) {
307  return getMachOSection(Segment, Section, TypeAndAttributes, 0, K,
308  BeginSymName);
309  }
310 
312  unsigned Flags) {
313  return getELFSection(Section, Type, Flags, nullptr);
314  }
315 
317  unsigned Flags, const char *BeginSymName) {
318  return getELFSection(Section, Type, Flags, 0, "", BeginSymName);
319  }
320 
322  unsigned Flags, unsigned EntrySize,
323  StringRef Group) {
324  return getELFSection(Section, Type, Flags, EntrySize, Group, nullptr);
325  }
326 
328  unsigned Flags, unsigned EntrySize,
329  StringRef Group, const char *BeginSymName) {
330  return getELFSection(Section, Type, Flags, EntrySize, Group, ~0,
331  BeginSymName);
332  }
333 
335  unsigned Flags, unsigned EntrySize,
336  StringRef Group, unsigned UniqueID) {
337  return getELFSection(Section, Type, Flags, EntrySize, Group, UniqueID,
338  nullptr);
339  }
340 
342  unsigned Flags, unsigned EntrySize,
343  StringRef Group, unsigned UniqueID,
344  const char *BeginSymName);
345 
347  unsigned Flags, unsigned EntrySize,
348  const MCSymbolELF *Group, unsigned UniqueID,
349  const char *BeginSymName,
350  const MCSectionELF *Associated);
351 
353  unsigned Flags, unsigned EntrySize,
354  const MCSymbolELF *Group,
355  const MCSectionELF *Associated);
356 
358 
360 
362  SectionKind Kind, StringRef COMDATSymName,
363  int Selection,
364  const char *BeginSymName = nullptr);
365 
368  const char *BeginSymName = nullptr);
369 
371 
372  /// Gets or creates a section equivalent to Sec that is associated with the
373  /// section containing KeySym. For example, to create a debug info section
374  /// associated with an inline function, pass the normal debug info section
375  /// as Sec and the function symbol as KeySym.
377  const MCSymbol *KeySym);
378 
379  /// @}
380 
381  /// \name Dwarf Management
382  /// @{
383 
384  /// \brief Get the compilation directory for DW_AT_comp_dir
385  /// This can be overridden by clients which want to control the reported
386  /// compilation directory and have it be something other than the current
387  /// working directory.
388  /// Returns an empty string if the current directory cannot be determined.
389  StringRef getCompilationDir() const { return CompilationDir; }
390 
391  /// \brief Set the compilation directory for DW_AT_comp_dir
392  /// Override the default (CWD) compilation directory.
393  void setCompilationDir(StringRef S) { CompilationDir = S.str(); }
394 
395  /// \brief Get the main file name for use in error messages and debug
396  /// info. This can be set to ensure we've got the correct file name
397  /// after preprocessing or for -save-temps.
398  const std::string &getMainFileName() const { return MainFileName; }
399 
400  /// \brief Set the main file name and override the default.
401  void setMainFileName(StringRef S) { MainFileName = S; }
402 
403  /// Creates an entry in the dwarf file and directory tables.
404  unsigned getDwarfFile(StringRef Directory, StringRef FileName,
405  unsigned FileNumber, unsigned CUID);
406 
407  bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID = 0);
408 
409  const std::map<unsigned, MCDwarfLineTable> &getMCDwarfLineTables() const {
410  return MCDwarfLineTablesCUMap;
411  }
412 
414  return MCDwarfLineTablesCUMap[CUID];
415  }
416 
417  const MCDwarfLineTable &getMCDwarfLineTable(unsigned CUID) const {
418  auto I = MCDwarfLineTablesCUMap.find(CUID);
419  assert(I != MCDwarfLineTablesCUMap.end());
420  return I->second;
421  }
422 
423  const SmallVectorImpl<MCDwarfFile> &getMCDwarfFiles(unsigned CUID = 0) {
424  return getMCDwarfLineTable(CUID).getMCDwarfFiles();
425  }
426  const SmallVectorImpl<std::string> &getMCDwarfDirs(unsigned CUID = 0) {
427  return getMCDwarfLineTable(CUID).getMCDwarfDirs();
428  }
429 
430  bool hasMCLineSections() const {
431  for (const auto &Table : MCDwarfLineTablesCUMap)
432  if (!Table.second.getMCDwarfFiles().empty() || Table.second.getLabel())
433  return true;
434  return false;
435  }
436  unsigned getDwarfCompileUnitID() { return DwarfCompileUnitID; }
437  void setDwarfCompileUnitID(unsigned CUIndex) {
438  DwarfCompileUnitID = CUIndex;
439  }
440  void setMCLineTableCompilationDir(unsigned CUID, StringRef CompilationDir) {
441  getMCDwarfLineTable(CUID).setCompilationDir(CompilationDir);
442  }
443 
444  /// Saves the information from the currently parsed dwarf .loc directive
445  /// and sets DwarfLocSeen. When the next instruction is assembled an entry
446  /// in the line number table with this information and the address of the
447  /// instruction will be created.
448  void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column,
449  unsigned Flags, unsigned Isa,
450  unsigned Discriminator) {
451  CurrentDwarfLoc.setFileNum(FileNum);
452  CurrentDwarfLoc.setLine(Line);
453  CurrentDwarfLoc.setColumn(Column);
454  CurrentDwarfLoc.setFlags(Flags);
455  CurrentDwarfLoc.setIsa(Isa);
456  CurrentDwarfLoc.setDiscriminator(Discriminator);
457  DwarfLocSeen = true;
458  }
459  void clearDwarfLocSeen() { DwarfLocSeen = false; }
460 
461  bool getDwarfLocSeen() { return DwarfLocSeen; }
462  const MCDwarfLoc &getCurrentDwarfLoc() { return CurrentDwarfLoc; }
463 
464  bool getGenDwarfForAssembly() { return GenDwarfForAssembly; }
465  void setGenDwarfForAssembly(bool Value) { GenDwarfForAssembly = Value; }
466  unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }
467  void setGenDwarfFileNumber(unsigned FileNumber) {
468  GenDwarfFileNumber = FileNumber;
469  }
471  return SectionsForRanges;
472  }
474  return SectionsForRanges.insert(Sec);
475  }
476 
477  void finalizeDwarfSections(MCStreamer &MCOS);
478  const std::vector<MCGenDwarfLabelEntry> &getMCGenDwarfLabelEntries() const {
479  return MCGenDwarfLabelEntries;
480  }
482  MCGenDwarfLabelEntries.push_back(E);
483  }
484 
485  void setDwarfDebugFlags(StringRef S) { DwarfDebugFlags = S; }
486  StringRef getDwarfDebugFlags() { return DwarfDebugFlags; }
487 
488  void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
489  StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
490 
491  void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
492  uint16_t getDwarfVersion() const { return DwarfVersion; }
493 
494  /// @}
495 
496  char *getSecureLogFile() { return SecureLogFile; }
497  raw_ostream *getSecureLog() { return SecureLog; }
498  bool getSecureLogUsed() { return SecureLogUsed; }
499  void setSecureLog(raw_ostream *Value) { SecureLog = Value; }
500  void setSecureLogUsed(bool Value) { SecureLogUsed = Value; }
501 
502  void *allocate(unsigned Size, unsigned Align = 8) {
503  return Allocator.Allocate(Size, Align);
504  }
505  void deallocate(void *Ptr) {}
506 
507  // Unrecoverable error has occurred. Display the best diagnostic we can
508  // and bail via exit(1). For now, most MC backend errors are unrecoverable.
509  // FIXME: We should really do something about that.
511  const Twine &Msg) const;
512  };
513 
514 } // end namespace llvm
515 
516 // operator new and delete aren't allowed inside namespaces.
517 // The throw specifications are mandated by the standard.
518 /// \brief Placement new for using the MCContext's allocator.
519 ///
520 /// This placement form of operator new uses the MCContext's allocator for
521 /// obtaining memory. It is a non-throwing new, which means that it returns
522 /// null on error. (If that is what the allocator does. The current does, so if
523 /// this ever changes, this operator will have to be changed, too.)
524 /// Usage looks like this (assuming there's an MCContext 'Context' in scope):
525 /// \code
526 /// // Default alignment (8)
527 /// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
528 /// // Specific alignment
529 /// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
530 /// \endcode
531 /// Please note that you cannot use delete on the pointer; it must be
532 /// deallocated using an explicit destructor call followed by
533 /// \c Context.Deallocate(Ptr).
534 ///
535 /// \param Bytes The number of bytes to allocate. Calculated by the compiler.
536 /// \param C The MCContext that provides the allocator.
537 /// \param Alignment The alignment of the allocated memory (if the underlying
538 /// allocator supports it).
539 /// \return The allocated memory. Could be NULL.
540 inline void *operator new(size_t Bytes, llvm::MCContext &C,
541  size_t Alignment = 8) throw() {
542  return C.allocate(Bytes, Alignment);
543 }
544 /// \brief Placement delete companion to the new above.
545 ///
546 /// This operator is just a companion to the new above. There is no way of
547 /// invoking it directly; see the new operator for more details. This operator
548 /// is called implicitly by the compiler if a placement new expression using
549 /// the MCContext throws in the object constructor.
550 inline void operator delete(void *Ptr, llvm::MCContext &C, size_t)
551  throw () {
552  C.deallocate(Ptr);
553 }
554 
555 /// This placement form of operator new[] uses the MCContext's allocator for
556 /// obtaining memory. It is a non-throwing new[], which means that it returns
557 /// null on error.
558 /// Usage looks like this (assuming there's an MCContext 'Context' in scope):
559 /// \code
560 /// // Default alignment (8)
561 /// char *data = new (Context) char[10];
562 /// // Specific alignment
563 /// char *data = new (Context, 4) char[10];
564 /// \endcode
565 /// Please note that you cannot use delete on the pointer; it must be
566 /// deallocated using an explicit destructor call followed by
567 /// \c Context.Deallocate(Ptr).
568 ///
569 /// \param Bytes The number of bytes to allocate. Calculated by the compiler.
570 /// \param C The MCContext that provides the allocator.
571 /// \param Alignment The alignment of the allocated memory (if the underlying
572 /// allocator supports it).
573 /// \return The allocated memory. Could be NULL.
574 inline void *operator new[](size_t Bytes, llvm::MCContext& C,
575  size_t Alignment = 8) throw() {
576  return C.allocate(Bytes, Alignment);
577 }
578 
579 /// \brief Placement delete[] companion to the new[] above.
580 ///
581 /// This operator is just a companion to the new[] above. There is no way of
582 /// invoking it directly; see the new[] operator for more details. This operator
583 /// is called implicitly by the compiler if a placement new[] expression using
584 /// the MCContext throws in the object constructor.
585 inline void operator delete[](void *Ptr, llvm::MCContext &C) throw () {
586  C.deallocate(Ptr);
587 }
588 
589 #endif
void setCompilationDir(StringRef CompilationDir)
Definition: MCDwarf.h:234
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E)
Definition: MCContext.h:481
MCSymbolELF * getOrCreateSectionSymbol(const MCSectionELF &Section)
Definition: MCContext.cpp:124
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:48
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:253
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:225
void setGenDwarfForAssembly(bool Value)
Definition: MCContext.h:465
const MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID) const
Definition: MCContext.h:417
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 ...
Definition: MCSymbol.h:39
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:311
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
Definition: MCContext.h:423
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:146
void reset()
reset - return object to right after construction state to prepare to process a new module ...
Definition: MCContext.cpp:74
MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions)...
Definition: MCContext.cpp:248
LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L, const Twine &Msg) const
Definition: MCContext.cpp:474
MCSymbol * getOrCreateParentFrameOffsetSymbol(StringRef FuncName)
Definition: MCContext.cpp:152
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:188
void setDwarfVersion(uint16_t v)
Definition: MCContext.h:491
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
Definition: MCDwarf.h:122
StringMap< MCSymbol *, BumpPtrAllocator & > SymbolTable
Definition: MCContext.h:53
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
Definition: MCContext.cpp:261
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags, unsigned EntrySize, StringRef Group)
Definition: MCContext.h:321
uint16_t getDwarfVersion() const
Definition: MCContext.h:492
StringRef getDwarfDebugFlags()
Definition: MCContext.h:486
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags, unsigned EntrySize, StringRef Group, unsigned UniqueID)
Definition: MCContext.h:334
MCSectionCOFF - This represents a section on Windows.
Definition: MCSectionCOFF.h:25
StringRef getDwarfDebugProducer()
Definition: MCContext.h:489
MCSymbol * createLinkerPrivateTempSymbol()
Create and return a new linker temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:216
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
void renameELFSection(MCSectionELF *Section, StringRef Name)
Definition: MCContext.cpp:300
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APInt.h:33
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionStartEndSyms, to avoid generating useless debug info for them...
Definition: MCContext.cpp:469
void setUseNamesOnTempLabels(bool Value)
Definition: MCContext.h:232
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags, const char *BeginSymName)
Definition: MCContext.h:316
void * allocate(unsigned Size, unsigned Align=8)
Definition: MCContext.h:502
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:413
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:591
const SmallVectorImpl< std::string > & getMCDwarfDirs(unsigned CUID=0)
Definition: MCContext.h:426
Context object for machine code objects.
Definition: MCContext.h:48
void setCompilationDir(StringRef S)
Set the compilation directory for DW_AT_comp_dir Override the default (CWD) compilation directory...
Definition: MCContext.h:393
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
Definition: MCDwarf.h:107
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Definition: MCDwarf.h:246
void setDwarfCompileUnitID(unsigned CUIndex)
Definition: MCContext.h:437
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
const std::string & getMainFileName() const
Get the main file name for use in error messages and debug info.
Definition: MCContext.h:398
unsigned getDwarfCompileUnitID()
Definition: MCContext.h:436
Instances of this class represent the information from a dwarf .loc directive.
Definition: MCDwarf.h:56
static cl::opt< std::string > FuncName("cppfname", cl::desc("Specify the name of the generated function"), cl::value_desc("function name"))
unsigned getGenDwarfFileNumber()
Definition: MCContext.h:466
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:58
Streaming machine code generation interface.
Definition: MCStreamer.h:157
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:222
void setAllowTemporaryLabels(bool Value)
Definition: MCContext.h:231
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
const SymbolTable & getSymbols() const
getSymbols - Get a reference for the symbol table for clients that want to, for example, iterate over all symbols.
Definition: MCContext.h:290
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:135
void setDwarfDebugFlags(StringRef S)
Definition: MCContext.h:485
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:208
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
Definition: MCDwarf.h:238
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:28
const MCDwarfLoc & getCurrentDwarfLoc()
Definition: MCContext.h:462
MCSectionELF * createELFRelSection(StringRef Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *Associated)
Definition: MCContext.cpp:316
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Definition: SourceMgr.h:35
bool getSecureLogUsed()
Definition: MCContext.h:498
const SourceMgr * getSourceManager() const
Definition: MCContext.h:223
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, SectionKind K, const char *BeginSymName=nullptr)
Definition: MCContext.h:304
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:459
bool getGenDwarfForAssembly()
Definition: MCContext.h:464
void clearDwarfLocSeen()
Definition: MCContext.h:459
void setMainFileName(StringRef S)
Set the main file name and override the default.
Definition: MCContext.h:401
const SetVector< MCSection * > & getGenDwarfSectionSyms()
Definition: MCContext.h:470
MCSymbol * getOrCreateLSDASymbol(StringRef FuncName)
Definition: MCContext.cpp:157
bool hasMCLineSections() const
Definition: MCContext.h:430
void setDwarfDebugProducer(StringRef S)
Definition: MCContext.h:488
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags, unsigned EntrySize, StringRef Group, const char *BeginSymName)
Definition: MCContext.h:327
#define LLVM_ATTRIBUTE_NORETURN
Definition: Compiler.h:204
bool getDwarfLocSeen()
Definition: MCContext.h:461
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
Definition: MCContext.h:478
bool addGenDwarfSection(MCSection *Sec)
Definition: MCContext.h:473
void setSecureLog(raw_ostream *Value)
Definition: MCContext.h:499
const MCRegisterInfo * getRegisterInfo() const
Definition: MCContext.h:227
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir This can be overridden by clients which want to cont...
Definition: MCContext.h:389
raw_ostream * getSecureLog()
Definition: MCContext.h:497
char * getSecureLogFile()
Definition: MCContext.h:496
void setGenDwarfFileNumber(unsigned FileNumber)
Definition: MCContext.h:467
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:111
MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym...
Definition: MCContext.cpp:428
const std::map< unsigned, MCDwarfLineTable > & getMCDwarfLineTables() const
Definition: MCContext.h:409
void deallocate(void *Ptr)
Definition: MCContext.h:505
#define I(x, y, z)
Definition: MD5.cpp:54
COFFYAML::WeakExternalCharacteristics Characteristics
Definition: COFFYAML.cpp:268
MCSectionELF - This represents a section on linux, lots of unix variants and some bare metal systems...
Definition: MCSectionELF.h:30
void setFileNum(unsigned fileNum)
Set the FileNum of this MCDwarfLoc.
Definition: MCDwarf.h:104
void setFlags(unsigned flags)
Set the Flags of this MCDwarfLoc.
Definition: MCDwarf.h:116
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group)
Definition: MCContext.cpp:376
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, const char *BeginSymName=nullptr)
Definition: MCContext.cpp:383
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.
Definition: MCContext.h:448
const ARM::ArchExtKind Kind
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:332
LLVM Value Representation.
Definition: Value.h:69
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:229
unsigned getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
Definition: MCContext.cpp:451
A vector that has set insertion semantics.
Definition: SetVector.h:37
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
void setColumn(unsigned column)
Set the Column of this MCDwarfLoc.
Definition: MCDwarf.h:110
C - The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
Represents a location in source code.
Definition: SMLoc.h:23
void setMCLineTableCompilationDir(unsigned CUID, StringRef CompilationDir)
Definition: MCContext.h:440
void setDiscriminator(unsigned discriminator)
Set the Discriminator of this MCDwarfLoc.
Definition: MCDwarf.h:128
void setSecureLogUsed(bool Value)
Definition: MCContext.h:500