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