LLVM  14.0.0git
MCDwarf.h
Go to the documentation of this file.
1 //===- MCDwarf.h - Machine Code Dwarf support -------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the declaration of the MCDwarfFile to support the dwarf
10 // .file directive and the .loc directive.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_MC_MCDWARF_H
15 #define LLVM_MC_MCDWARF_H
16 
17 #include "llvm/ADT/MapVector.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/MC/MCSection.h"
23 #include "llvm/Support/Error.h"
24 #include "llvm/Support/MD5.h"
25 #include <cassert>
26 #include <cstdint>
27 #include <string>
28 #include <tuple>
29 #include <utility>
30 #include <vector>
31 
32 namespace llvm {
33 
34 template <typename T> class ArrayRef;
35 class MCAsmBackend;
36 class MCContext;
37 class MCDwarfLineStr;
38 class MCObjectStreamer;
39 class MCStreamer;
40 class MCSymbol;
41 class raw_ostream;
42 class SMLoc;
43 class SourceMgr;
44 
45 namespace mcdwarf {
46 // Emit the common part of the DWARF 5 range/locations list tables header.
48 } // namespace mcdwarf
49 
50 /// Instances of this class represent the name of the dwarf .file directive and
51 /// its associated dwarf file number in the MC file. MCDwarfFile's are created
52 /// and uniqued by the MCContext class. In Dwarf 4 file numbers start from 1;
53 /// i.e. the entry with file number 1 is the first element in the vector of
54 /// DwarfFiles and there is no MCDwarfFile with file number 0. In Dwarf 5 file
55 /// numbers start from 0, with the MCDwarfFile with file number 0 being the
56 /// primary source file, and file numbers correspond to their index in the
57 /// vector.
58 struct MCDwarfFile {
59  // The base name of the file without its directory path.
60  std::string Name;
61 
62  // The index into the list of directory names for this file name.
63  unsigned DirIndex = 0;
64 
65  /// The MD5 checksum, if there is one. Non-owning pointer to data allocated
66  /// in MCContext.
68 
69  /// The source code of the file. Non-owning reference to data allocated in
70  /// MCContext.
72 };
73 
74 /// Instances of this class represent the information from a
75 /// dwarf .loc directive.
76 class MCDwarfLoc {
77  uint32_t FileNum;
78  uint32_t Line;
79  uint16_t Column;
80  // Flags (see #define's below)
81  uint8_t Flags;
82  uint8_t Isa;
83  uint32_t Discriminator;
84 
85 // Flag that indicates the initial value of the is_stmt_start flag.
86 #define DWARF2_LINE_DEFAULT_IS_STMT 1
87 
88 #define DWARF2_FLAG_IS_STMT (1 << 0)
89 #define DWARF2_FLAG_BASIC_BLOCK (1 << 1)
90 #define DWARF2_FLAG_PROLOGUE_END (1 << 2)
91 #define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3)
92 
93 private: // MCContext manages these
94  friend class MCContext;
95  friend class MCDwarfLineEntry;
96 
97  MCDwarfLoc(unsigned fileNum, unsigned line, unsigned column, unsigned flags,
98  unsigned isa, unsigned discriminator)
99  : FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(isa),
100  Discriminator(discriminator) {}
101 
102  // Allow the default copy constructor and assignment operator to be used
103  // for an MCDwarfLoc object.
104 
105 public:
106  /// Get the FileNum of this MCDwarfLoc.
107  unsigned getFileNum() const { return FileNum; }
108 
109  /// Get the Line of this MCDwarfLoc.
110  unsigned getLine() const { return Line; }
111 
112  /// Get the Column of this MCDwarfLoc.
113  unsigned getColumn() const { return Column; }
114 
115  /// Get the Flags of this MCDwarfLoc.
116  unsigned getFlags() const { return Flags; }
117 
118  /// Get the Isa of this MCDwarfLoc.
119  unsigned getIsa() const { return Isa; }
120 
121  /// Get the Discriminator of this MCDwarfLoc.
122  unsigned getDiscriminator() const { return Discriminator; }
123 
124  /// Set the FileNum of this MCDwarfLoc.
125  void setFileNum(unsigned fileNum) { FileNum = fileNum; }
126 
127  /// Set the Line of this MCDwarfLoc.
128  void setLine(unsigned line) { Line = line; }
129 
130  /// Set the Column of this MCDwarfLoc.
131  void setColumn(unsigned column) {
132  assert(column <= UINT16_MAX);
133  Column = column;
134  }
135 
136  /// Set the Flags of this MCDwarfLoc.
137  void setFlags(unsigned flags) {
138  assert(flags <= UINT8_MAX);
139  Flags = flags;
140  }
141 
142  /// Set the Isa of this MCDwarfLoc.
143  void setIsa(unsigned isa) {
144  assert(isa <= UINT8_MAX);
145  Isa = isa;
146  }
147 
148  /// Set the Discriminator of this MCDwarfLoc.
149  void setDiscriminator(unsigned discriminator) {
150  Discriminator = discriminator;
151  }
152 };
153 
154 /// Instances of this class represent the line information for
155 /// the dwarf line table entries. Which is created after a machine
156 /// instruction is assembled and uses an address from a temporary label
157 /// created at the current address in the current section and the info from
158 /// the last .loc directive seen as stored in the context.
159 class MCDwarfLineEntry : public MCDwarfLoc {
160  MCSymbol *Label;
161 
162 private:
163  // Allow the default copy constructor and assignment operator to be used
164  // for an MCDwarfLineEntry object.
165 
166 public:
167  // Constructor to create an MCDwarfLineEntry given a symbol and the dwarf loc.
169  : MCDwarfLoc(loc), Label(label) {}
170 
171  MCSymbol *getLabel() const { return Label; }
172 
173  // This is called when an instruction is assembled into the specified
174  // section and if there is information from the last .loc directive that
175  // has yet to have a line entry made for it is made.
176  static void make(MCStreamer *MCOS, MCSection *Section);
177 };
178 
179 /// Instances of this class represent the line information for a compile
180 /// unit where machine instructions have been assembled after seeing .loc
181 /// directives. This is the information used to build the dwarf line
182 /// table for a section.
184 public:
185  // Add an entry to this MCLineSection's line entries.
186  void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec) {
187  MCLineDivisions[Sec].push_back(LineEntry);
188  }
189 
190  using MCDwarfLineEntryCollection = std::vector<MCDwarfLineEntry>;
191  using iterator = MCDwarfLineEntryCollection::iterator;
192  using const_iterator = MCDwarfLineEntryCollection::const_iterator;
194 
195 private:
196  // A collection of MCDwarfLineEntry for each section.
197  MCLineDivisionMap MCLineDivisions;
198 
199 public:
200  // Returns the collection of MCDwarfLineEntry for a given Compile Unit ID.
202  return MCLineDivisions;
203  }
204 };
205 
207  /// First special line opcode - leave room for the standard opcodes.
208  /// Note: If you want to change this, you'll have to update the
209  /// "StandardOpcodeLengths" table that is emitted in
210  /// \c Emit().
211  uint8_t DWARF2LineOpcodeBase = 13;
212  /// Minimum line offset in a special line info. opcode. The value
213  /// -5 was chosen to give a reasonable range of values.
214  int8_t DWARF2LineBase = -5;
215  /// Range of line offsets in a special line info. opcode.
216  uint8_t DWARF2LineRange = 14;
217 };
218 
220  MCSymbol *Label = nullptr;
224  std::string CompilationDir;
226  bool HasSource = false;
227 private:
228  bool HasAllMD5 = true;
229  bool HasAnyMD5 = false;
230 
231 public:
232  MCDwarfLineTableHeader() = default;
233 
234  Expected<unsigned> tryGetFile(StringRef &Directory, StringRef &FileName,
235  Optional<MD5::MD5Result> Checksum,
237  uint16_t DwarfVersion,
238  unsigned FileNumber = 0);
239  std::pair<MCSymbol *, MCSymbol *>
240  Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
241  Optional<MCDwarfLineStr> &LineStr) const;
242  std::pair<MCSymbol *, MCSymbol *>
243  Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
244  ArrayRef<char> SpecialOpcodeLengths,
245  Optional<MCDwarfLineStr> &LineStr) const;
246  void resetMD5Usage() {
247  HasAllMD5 = true;
248  HasAnyMD5 = false;
249  }
250  void trackMD5Usage(bool MD5Used) {
251  HasAllMD5 &= MD5Used;
252  HasAnyMD5 |= MD5Used;
253  }
254  bool isMD5UsageConsistent() const {
255  return MCDwarfFiles.empty() || (HasAllMD5 == HasAnyMD5);
256  }
257 
258  void setRootFile(StringRef Directory, StringRef FileName,
259  Optional<MD5::MD5Result> Checksum,
261  CompilationDir = std::string(Directory);
262  RootFile.Name = std::string(FileName);
263  RootFile.DirIndex = 0;
264  RootFile.Checksum = Checksum;
266  trackMD5Usage(Checksum.hasValue());
267  HasSource = Source.hasValue();
268  }
269 
270  void resetFileTable() {
271  MCDwarfDirs.clear();
272  MCDwarfFiles.clear();
273  RootFile.Name.clear();
274  resetMD5Usage();
275  HasSource = false;
276  }
277 
278 private:
279  void emitV2FileDirTables(MCStreamer *MCOS) const;
280  void emitV5FileDirTables(MCStreamer *MCOS, Optional<MCDwarfLineStr> &LineStr) const;
281 };
282 
284  MCDwarfLineTableHeader Header;
285  bool HasSplitLineTable = false;
286 
287 public:
288  void maybeSetRootFile(StringRef Directory, StringRef FileName,
289  Optional<MD5::MD5Result> Checksum,
291  if (!Header.RootFile.Name.empty())
292  return;
293  Header.setRootFile(Directory, FileName, Checksum, Source);
294  }
295 
296  unsigned getFile(StringRef Directory, StringRef FileName,
297  Optional<MD5::MD5Result> Checksum, uint16_t DwarfVersion,
299  HasSplitLineTable = true;
300  return cantFail(Header.tryGetFile(Directory, FileName, Checksum, Source,
301  DwarfVersion));
302  }
303 
304  void Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params,
305  MCSection *Section) const;
306 };
307 
309  MCDwarfLineTableHeader Header;
310  MCLineSection MCLineSections;
311 
312 public:
313  // This emits the Dwarf file and the line tables for all Compile Units.
314  static void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params);
315 
316  // This emits the Dwarf file and the line tables for a given Compile Unit.
317  void emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params,
318  Optional<MCDwarfLineStr> &LineStr) const;
319 
320  Expected<unsigned> tryGetFile(StringRef &Directory, StringRef &FileName,
321  Optional<MD5::MD5Result> Checksum,
323  uint16_t DwarfVersion,
324  unsigned FileNumber = 0);
325  unsigned getFile(StringRef &Directory, StringRef &FileName,
327  uint16_t DwarfVersion, unsigned FileNumber = 0) {
328  return cantFail(tryGetFile(Directory, FileName, Checksum, Source,
329  DwarfVersion, FileNumber));
330  }
331 
332  void setRootFile(StringRef Directory, StringRef FileName,
334  Header.CompilationDir = std::string(Directory);
335  Header.RootFile.Name = std::string(FileName);
336  Header.RootFile.DirIndex = 0;
337  Header.RootFile.Checksum = Checksum;
338  Header.RootFile.Source = Source;
339  Header.trackMD5Usage(Checksum.hasValue());
340  Header.HasSource = Source.hasValue();
341  }
342 
343  void resetFileTable() { Header.resetFileTable(); }
344 
345  bool hasRootFile() const { return !Header.RootFile.Name.empty(); }
346 
347  const MCDwarfFile &getRootFile() const { return Header.RootFile; }
348 
349  // Report whether MD5 usage has been consistent (all-or-none).
350  bool isMD5UsageConsistent() const { return Header.isMD5UsageConsistent(); }
351 
352  MCSymbol *getLabel() const {
353  return Header.Label;
354  }
355 
356  void setLabel(MCSymbol *Label) {
357  Header.Label = Label;
358  }
359 
361  return Header.MCDwarfDirs;
362  }
363 
365  return Header.MCDwarfDirs;
366  }
367 
369  return Header.MCDwarfFiles;
370  }
371 
373  return Header.MCDwarfFiles;
374  }
375 
377  return MCLineSections;
378  }
380  return MCLineSections;
381  }
382 };
383 
385 public:
386  /// Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
387  static void Encode(MCContext &Context, MCDwarfLineTableParams Params,
388  int64_t LineDelta, uint64_t AddrDelta, raw_ostream &OS);
389 
390  /// Utility function to emit the encoding to a streamer.
391  static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
392  int64_t LineDelta, uint64_t AddrDelta);
393 };
394 
396 public:
397  //
398  // When generating dwarf for assembly source files this emits the Dwarf
399  // sections.
400  //
401  static void Emit(MCStreamer *MCOS);
402 };
403 
404 // When generating dwarf for assembly source files this is the info that is
405 // needed to be gathered for each symbol that will have a dwarf label.
407 private:
408  // Name of the symbol without a leading underbar, if any.
409  StringRef Name;
410  // The dwarf file number this symbol is in.
411  unsigned FileNumber;
412  // The line number this symbol is at.
413  unsigned LineNumber;
414  // The low_pc for the dwarf label is taken from this symbol.
415  MCSymbol *Label;
416 
417 public:
418  MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber,
419  MCSymbol *label)
420  : Name(name), FileNumber(fileNumber), LineNumber(lineNumber),
421  Label(label) {}
422 
423  StringRef getName() const { return Name; }
424  unsigned getFileNumber() const { return FileNumber; }
425  unsigned getLineNumber() const { return LineNumber; }
426  MCSymbol *getLabel() const { return Label; }
427 
428  // This is called when label is created when we are generating dwarf for
429  // assembly source files.
430  static void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr,
431  SMLoc &Loc);
432 };
433 
435 public:
436  enum OpType {
454  };
455 
456 private:
457  OpType Operation;
458  MCSymbol *Label;
459  unsigned Register;
460  union {
461  int Offset;
462  unsigned Register2;
463  };
464  unsigned AddressSpace;
465  std::vector<char> Values;
466  std::string Comment;
467 
468  MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, StringRef V,
469  StringRef Comment = "")
470  : Operation(Op), Label(L), Register(R), Offset(O),
471  Values(V.begin(), V.end()), Comment(Comment) {
473  }
474 
475  MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R1, unsigned R2)
476  : Operation(Op), Label(L), Register(R1), Register2(R2) {
477  assert(Op == OpRegister);
478  }
479 
480  MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, unsigned AS)
481  : Operation(Op), Label(L), Register(R), Offset(O), AddressSpace(AS) {
483  }
484 
485 public:
486  /// .cfi_def_cfa defines a rule for computing CFA as: take address from
487  /// Register and add Offset to it.
489  int Offset) {
490  return MCCFIInstruction(OpDefCfa, L, Register, Offset, "");
491  }
492 
493  /// .cfi_def_cfa_register modifies a rule for computing CFA. From now
494  /// on Register will be used instead of the old one. Offset remains the same.
496  return MCCFIInstruction(OpDefCfaRegister, L, Register, 0, "");
497  }
498 
499  /// .cfi_def_cfa_offset modifies a rule for computing CFA. Register
500  /// remains the same, but offset is new. Note that it is the absolute offset
501  /// that will be added to a defined register to the compute CFA address.
503  return MCCFIInstruction(OpDefCfaOffset, L, 0, Offset, "");
504  }
505 
506  /// .cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but
507  /// Offset is a relative value that is added/subtracted from the previous
508  /// offset.
509  static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment) {
510  return MCCFIInstruction(OpAdjustCfaOffset, L, 0, Adjustment, "");
511  }
512 
513  // FIXME: Update the remaining docs to use the new proposal wording.
514  /// .cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to
515  /// be the result of evaluating the DWARF operation expression
516  /// `DW_OP_constu AS; DW_OP_aspace_bregx R, B` as a location description.
518  int Offset,
519  unsigned AddressSpace) {
521  AddressSpace);
522  }
523 
524  /// .cfi_offset Previous value of Register is saved at offset Offset
525  /// from CFA.
527  int Offset) {
528  return MCCFIInstruction(OpOffset, L, Register, Offset, "");
529  }
530 
531  /// .cfi_rel_offset Previous value of Register is saved at offset
532  /// Offset from the current CFA register. This is transformed to .cfi_offset
533  /// using the known displacement of the CFA register from the CFA.
535  int Offset) {
536  return MCCFIInstruction(OpRelOffset, L, Register, Offset, "");
537  }
538 
539  /// .cfi_register Previous value of Register1 is saved in
540  /// register Register2.
541  static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1,
542  unsigned Register2) {
543  return MCCFIInstruction(OpRegister, L, Register1, Register2);
544  }
545 
546  /// .cfi_window_save SPARC register window is saved.
548  return MCCFIInstruction(OpWindowSave, L, 0, 0, "");
549  }
550 
551  /// .cfi_negate_ra_state AArch64 negate RA state.
553  return MCCFIInstruction(OpNegateRAState, L, 0, 0, "");
554  }
555 
556  /// .cfi_restore says that the rule for Register is now the same as it
557  /// was at the beginning of the function, after all initial instructions added
558  /// by .cfi_startproc were executed.
560  return MCCFIInstruction(OpRestore, L, Register, 0, "");
561  }
562 
563  /// .cfi_undefined From now on the previous value of Register can't be
564  /// restored anymore.
566  return MCCFIInstruction(OpUndefined, L, Register, 0, "");
567  }
568 
569  /// .cfi_same_value Current value of Register is the same as in the
570  /// previous frame. I.e., no restoration is needed.
572  return MCCFIInstruction(OpSameValue, L, Register, 0, "");
573  }
574 
575  /// .cfi_remember_state Save all current rules for all registers.
577  return MCCFIInstruction(OpRememberState, L, 0, 0, "");
578  }
579 
580  /// .cfi_restore_state Restore the previously saved state.
582  return MCCFIInstruction(OpRestoreState, L, 0, 0, "");
583  }
584 
585  /// .cfi_escape Allows the user to add arbitrary bytes to the unwind
586  /// info.
588  StringRef Comment = "") {
589  return MCCFIInstruction(OpEscape, L, 0, 0, Vals, Comment);
590  }
591 
592  /// A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE
594  return MCCFIInstruction(OpGnuArgsSize, L, 0, Size, "");
595  }
596 
597  OpType getOperation() const { return Operation; }
598  MCSymbol *getLabel() const { return Label; }
599 
600  unsigned getRegister() const {
606  return Register;
607  }
608 
609  unsigned getRegister2() const {
611  return Register2;
612  }
613 
614  unsigned getAddressSpace() const {
616  return AddressSpace;
617  }
618 
619  int getOffset() const {
624  return Offset;
625  }
626 
629  return StringRef(&Values[0], Values.size());
630  }
631 
633  return Comment;
634  }
635 };
636 
638  MCDwarfFrameInfo() = default;
639 
640  MCSymbol *Begin = nullptr;
641  MCSymbol *End = nullptr;
642  const MCSymbol *Personality = nullptr;
643  const MCSymbol *Lsda = nullptr;
644  std::vector<MCCFIInstruction> Instructions;
645  unsigned CurrentCfaRegister = 0;
646  unsigned PersonalityEncoding = 0;
647  unsigned LsdaEncoding = 0;
649  bool IsSignalFrame = false;
650  bool IsSimple = false;
651  unsigned RAReg = static_cast<unsigned>(INT_MAX);
652  bool IsBKeyFrame = false;
653 };
654 
656 public:
657  //
658  // This emits the frame info section.
659  //
660  static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH);
661  static void EmitAdvanceLoc(MCObjectStreamer &Streamer, uint64_t AddrDelta);
662  static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta,
663  raw_ostream &OS);
664 };
665 
666 } // end namespace llvm
667 
668 #endif // LLVM_MC_MCDWARF_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::MCDwarfLineTable::tryGetFile
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
Definition: MCDwarf.cpp:532
llvm::MCCFIInstruction::OpWindowSave
@ OpWindowSave
Definition: MCDwarf.h:451
llvm::MCDwarfFrameInfo::End
MCSymbol * End
Definition: MCDwarf.h:641
llvm::MCDwarfLoc::getColumn
unsigned getColumn() const
Get the Column of this MCDwarfLoc.
Definition: MCDwarf.h:113
llvm::MCGenDwarfInfo
Definition: MCDwarf.h:395
llvm::MCDwarfLineTableParams::DWARF2LineRange
uint8_t DWARF2LineRange
Range of line offsets in a special line info. opcode.
Definition: MCDwarf.h:216
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::MCCFIInstruction::OpRelOffset
@ OpRelOffset
Definition: MCDwarf.h:445
Optional.h
llvm::MCDwarfLineTableParams::DWARF2LineOpcodeBase
uint8_t DWARF2LineOpcodeBase
First special line opcode - leave room for the standard opcodes.
Definition: MCDwarf.h:211
llvm::MCCFIInstruction::OpDefCfaRegister
@ OpDefCfaRegister
Definition: MCDwarf.h:442
llvm::MCCFIInstruction::getComment
StringRef getComment() const
Definition: MCDwarf.h:632
llvm::MCDwarfLoc::setIsa
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
Definition: MCDwarf.h:143
llvm::MCDwarfLoc::setFileNum
void setFileNum(unsigned fileNum)
Set the FileNum of this MCDwarfLoc.
Definition: MCDwarf.h:125
llvm::MCDwarfLoc::getLine
unsigned getLine() const
Get the Line of this MCDwarfLoc.
Definition: MCDwarf.h:110
llvm::MCDwarfFrameInfo::Lsda
const MCSymbol * Lsda
Definition: MCDwarf.h:643
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:72
llvm::MCDwarfFrameInfo::Begin
MCSymbol * Begin
Definition: MCDwarf.h:640
StringRef.h
llvm::MCCFIInstruction::OpOffset
@ OpOffset
Definition: MCDwarf.h:440
llvm::MCGenDwarfLabelEntry::getLabel
MCSymbol * getLabel() const
Definition: MCDwarf.h:426
llvm::SmallVector< std::string, 3 >
llvm::isa
LLVM_NODISCARD bool isa(const Y &Val)
Definition: Casting.h:141
llvm::MCDwarfLineTableHeader::isMD5UsageConsistent
bool isMD5UsageConsistent() const
Definition: MCDwarf.h:254
llvm::MCLineSection::const_iterator
MCDwarfLineEntryCollection::const_iterator const_iterator
Definition: MCDwarf.h:192
MapVector.h
llvm::MCDwarfLineTableHeader::MCDwarfFiles
SmallVector< MCDwarfFile, 3 > MCDwarfFiles
Definition: MCDwarf.h:222
Error.h
llvm::MCGenDwarfLabelEntry::MCGenDwarfLabelEntry
MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber, MCSymbol *label)
Definition: MCDwarf.h:418
llvm::MCDwarfLineTableHeader::tryGetFile
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
Definition: MCDwarf.cpp:550
llvm::MCCFIInstruction::createRelOffset
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register.
Definition: MCDwarf.h:534
llvm::MCDwarfLineTableHeader::trackMD5Usage
void trackMD5Usage(bool MD5Used)
Definition: MCDwarf.h:250
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
llvm::sys::path::begin
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
llvm::MCDwarfLineTableHeader::Emit
std::pair< MCSymbol *, MCSymbol * > Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, Optional< MCDwarfLineStr > &LineStr) const
Definition: MCDwarf.cpp:273
llvm::MCDwarfFrameEmitter::EncodeAdvanceLoc
static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, raw_ostream &OS)
Definition: MCDwarf.cpp:1894
llvm::Optional
Definition: APInt.h:33
llvm::MapVector< MCSection *, MCDwarfLineEntryCollection >
llvm::MCDwarfFrameInfo::RAReg
unsigned RAReg
Definition: MCDwarf.h:651
llvm::MCDwarfLineTableHeader::RootFile
MCDwarfFile RootFile
Definition: MCDwarf.h:225
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::MCDwarfFile::Checksum
Optional< MD5::MD5Result > Checksum
The MD5 checksum, if there is one.
Definition: MCDwarf.h:67
llvm::MCDwarfFrameInfo::MCDwarfFrameInfo
MCDwarfFrameInfo()=default
llvm::MCDwarfFile::Name
std::string Name
Definition: MCDwarf.h:60
llvm::MCDwarfLoc::setColumn
void setColumn(unsigned column)
Set the Column of this MCDwarfLoc.
Definition: MCDwarf.h:131
llvm::MCCFIInstruction::createSameValue
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register)
.cfi_same_value Current value of Register is the same as in the previous frame.
Definition: MCDwarf.h:571
llvm::MCCFIInstruction::createLLVMDefAspaceCfa
static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register, int Offset, unsigned AddressSpace)
.cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to be the result of evaluating the DW...
Definition: MCDwarf.h:517
llvm::MCDwarfLoc::getDiscriminator
unsigned getDiscriminator() const
Get the Discriminator of this MCDwarfLoc.
Definition: MCDwarf.h:122
llvm::RISCVFenceField::R
@ R
Definition: RISCVBaseInfo.h:180
llvm::MCCFIInstruction::cfiDefCfaOffset
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
Definition: MCDwarf.h:502
llvm::MCDwarfLineTable::setRootFile
void setRootFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
Definition: MCDwarf.h:332
llvm::MCGenDwarfLabelEntry
Definition: MCDwarf.h:406
llvm::Optional::hasValue
constexpr bool hasValue() const
Definition: Optional.h:288
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::MCCFIInstruction::OpDefCfa
@ OpDefCfa
Definition: MCDwarf.h:444
llvm::MCDwarfLoc::setFlags
void setFlags(unsigned flags)
Set the Flags of this MCDwarfLoc.
Definition: MCDwarf.h:137
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:197
R2
#define R2(n)
llvm::MCCFIInstruction::OpUndefined
@ OpUndefined
Definition: MCDwarf.h:449
llvm::MCDwarfLoc::setDiscriminator
void setDiscriminator(unsigned discriminator)
Set the Discriminator of this MCDwarfLoc.
Definition: MCDwarf.h:149
llvm::MCGenDwarfInfo::Emit
static void Emit(MCStreamer *MCOS)
Definition: MCDwarf.cpp:1108
llvm::MCDwarfLoc::setLine
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
Definition: MCDwarf.h:128
llvm::MCAsmBackend
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:36
llvm::MCDwarfFrameInfo::CurrentCfaRegister
unsigned CurrentCfaRegister
Definition: MCDwarf.h:645
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
MD5.h
Operation
PowerPC Reduce CR logical Operation
Definition: PPCReduceCRLogicals.cpp:734
llvm::MCLineSection
Instances of this class represent the line information for a compile unit where machine instructions ...
Definition: MCDwarf.h:183
llvm::MCDwarfLineTableParams
Definition: MCDwarf.h:206
llvm::MCDwarfFrameInfo::Personality
const MCSymbol * Personality
Definition: MCDwarf.h:642
llvm::SrcMgr
SourceMgr SrcMgr
Definition: Error.cpp:24
llvm::MCDwarfLineTable::emitCU
void emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params, Optional< MCDwarfLineStr > &LineStr) const
Definition: MCDwarf.cpp:519
llvm::MCDwarfLineTableHeader::MCDwarfDirs
SmallVector< std::string, 3 > MCDwarfDirs
Definition: MCDwarf.h:221
llvm::MCDwarfLineTableHeader::HasSource
bool HasSource
Definition: MCDwarf.h:226
llvm::MCCFIInstruction::getOffset
int getOffset() const
Definition: MCDwarf.h:619
llvm::MCObjectStreamer
Streaming object file generation interface.
Definition: MCObjectStreamer.h:36
llvm::MCDwarfLineTable
Definition: MCDwarf.h:308
llvm::MCDwarfLineTable::emit
static void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params)
Definition: MCDwarf.cpp:236
llvm::MCCFIInstruction::createRestoreState
static MCCFIInstruction createRestoreState(MCSymbol *L)
.cfi_restore_state Restore the previously saved state.
Definition: MCDwarf.h:581
llvm::MCLineSection::getMCLineEntries
const MCLineDivisionMap & getMCLineEntries() const
Definition: MCDwarf.h:201
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::MCCFIInstruction::getOperation
OpType getOperation() const
Definition: MCDwarf.h:597
llvm::MCDwarfFrameEmitter::Emit
static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH)
Definition: MCDwarf.cpp:1816
StringMap.h
llvm::MCLineSection::MCDwarfLineEntryCollection
std::vector< MCDwarfLineEntry > MCDwarfLineEntryCollection
Definition: MCDwarf.h:190
llvm::MCCFIInstruction::createEscape
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Definition: MCDwarf.h:587
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::MCCFIInstruction::getRegister
unsigned getRegister() const
Definition: MCDwarf.h:600
llvm::MCDwarfLineTable::getLabel
MCSymbol * getLabel() const
Definition: MCDwarf.h:352
llvm::MCCFIInstruction
Definition: MCDwarf.h:434
llvm::MCCFIInstruction::createDefCfaRegister
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
Definition: MCDwarf.h:495
llvm::MCDwarfLineTable::getMCDwarfDirs
SmallVectorImpl< std::string > & getMCDwarfDirs()
Definition: MCDwarf.h:364
llvm::StringMap< unsigned >
llvm::MCDwarfLineTableParams::DWARF2LineBase
int8_t DWARF2LineBase
Minimum line offset in a special line info.
Definition: MCDwarf.h:214
llvm::MCDwarfLineTable::getMCLineSections
const MCLineSection & getMCLineSections() const
Definition: MCDwarf.h:376
llvm::MCGenDwarfLabelEntry::Make
static void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr, SMLoc &Loc)
Definition: MCDwarf.cpp:1171
llvm::MCDwarfLineAddr::Encode
static void Encode(MCContext &Context, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta, raw_ostream &OS)
Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
Definition: MCDwarf.cpp:655
llvm::MCDwarfLoc::getIsa
unsigned getIsa() const
Get the Isa of this MCDwarfLoc.
Definition: MCDwarf.h:119
llvm::MCDwarfLineTable::getFile
unsigned getFile(StringRef &Directory, StringRef &FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
Definition: MCDwarf.h:325
llvm::MCDwarfLineTable::getRootFile
const MCDwarfFile & getRootFile() const
Definition: MCDwarf.h:347
llvm::ISD::Register
@ Register
Definition: ISDOpcodes.h:74
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:179
llvm::MCCFIInstruction::OpDefCfaOffset
@ OpDefCfaOffset
Definition: MCDwarf.h:443
llvm::MCCFIInstruction::OpRestore
@ OpRestore
Definition: MCDwarf.h:448
llvm::MCDwarfLineAddr::Emit
static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
Definition: MCDwarf.cpp:639
llvm::MCCFIInstruction::createGnuArgsSize
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size)
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
Definition: MCDwarf.h:593
llvm::MCCFIInstruction::OpSameValue
@ OpSameValue
Definition: MCDwarf.h:437
llvm::MCDwarfLineTable::setLabel
void setLabel(MCSymbol *Label)
Definition: MCDwarf.h:356
llvm::MCCFIInstruction::createNegateRAState
static MCCFIInstruction createNegateRAState(MCSymbol *L)
.cfi_negate_ra_state AArch64 negate RA state.
Definition: MCDwarf.h:552
llvm::MCDwarfLineTableHeader::CompilationDir
std::string CompilationDir
Definition: MCDwarf.h:224
llvm::MCCFIInstruction::OpType
OpType
Definition: MCDwarf.h:436
llvm::MCDwarfFile
Instances of this class represent the name of the dwarf .file directive and its associated dwarf file...
Definition: MCDwarf.h:58
llvm::MCGenDwarfLabelEntry::getLineNumber
unsigned getLineNumber() const
Definition: MCDwarf.h:425
llvm::MCLineSection::iterator
MCDwarfLineEntryCollection::iterator iterator
Definition: MCDwarf.h:191
llvm::MCCFIInstruction::getRegister2
unsigned getRegister2() const
Definition: MCDwarf.h:609
llvm::MCDwarfFrameEmitter
Definition: MCDwarf.h:655
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::MCDwarfLineTable::getMCDwarfFiles
SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles()
Definition: MCDwarf.h:372
llvm::MCGenDwarfLabelEntry::getName
StringRef getName() const
Definition: MCDwarf.h:423
llvm::MCDwarfLineTableHeader::setRootFile
void setRootFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
Definition: MCDwarf.h:258
llvm::MCCFIInstruction::cfiDefCfa
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition: MCDwarf.h:488
llvm::MCCFIInstruction::OpAdjustCfaOffset
@ OpAdjustCfaOffset
Definition: MCDwarf.h:446
llvm::MCDwarfLineTable::getMCDwarfFiles
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Definition: MCDwarf.h:368
MCSection.h
llvm::MCCFIInstruction::Register2
unsigned Register2
Definition: MCDwarf.h:462
llvm::mcdwarf::emitListsTableHeaderStart
MCSymbol * emitListsTableHeaderStart(MCStreamer &S)
Definition: MCDwarf.cpp:48
llvm::MCCFIInstruction::OpEscape
@ OpEscape
Definition: MCDwarf.h:447
llvm::MCDwarfLineEntry::MCDwarfLineEntry
MCDwarfLineEntry(MCSymbol *label, const MCDwarfLoc loc)
Definition: MCDwarf.h:168
llvm::Sched::Source
@ Source
Definition: TargetLowering.h:99
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::MCDwarfLoc
Instances of this class represent the information from a dwarf .loc directive.
Definition: MCDwarf.h:76
llvm::MCCFIInstruction::getAddressSpace
unsigned getAddressSpace() const
Definition: MCDwarf.h:614
llvm::MCCFIInstruction::OpRememberState
@ OpRememberState
Definition: MCDwarf.h:438
llvm::MCDwarfDwoLineTable
Definition: MCDwarf.h:283
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::MCCFIInstruction::getValues
StringRef getValues() const
Definition: MCDwarf.h:627
llvm::MCDwarfLineEntry::make
static void make(MCStreamer *MCOS, MCSection *Section)
Definition: MCDwarf.cpp:108
llvm::MCGenDwarfLabelEntry::getFileNumber
unsigned getFileNumber() const
Definition: MCDwarf.h:424
llvm::cantFail
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:737
llvm::SourceMgr
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition: SourceMgr.h:31
llvm::MCDwarfLineTableHeader::Label
MCSymbol * Label
Definition: MCDwarf.h:220
uint32_t
llvm::MCCFIInstruction::OpLLVMDefAspaceCfa
@ OpLLVMDefAspaceCfa
Definition: MCDwarf.h:441
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::MCDwarfFrameInfo::CompactUnwindEncoding
uint32_t CompactUnwindEncoding
Definition: MCDwarf.h:648
llvm::MCCFIInstruction::createAdjustCfaOffset
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment)
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
Definition: MCDwarf.h:509
llvm::MCDwarfLineTableHeader::MCDwarfLineTableHeader
MCDwarfLineTableHeader()=default
llvm::MCDwarfFile::DirIndex
unsigned DirIndex
Definition: MCDwarf.h:63
llvm::MCDwarfDwoLineTable::maybeSetRootFile
void maybeSetRootFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
Definition: MCDwarf.h:288
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::MCDwarfLineTableHeader::SourceIdMap
StringMap< unsigned > SourceIdMap
Definition: MCDwarf.h:223
llvm::MCDwarfDwoLineTable::Emit
void Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params, MCSection *Section) const
Definition: MCDwarf.cpp:263
llvm::AVR::AddressSpace
AddressSpace
An integer that identifies all of the supported AVR address spaces.
Definition: AVR.h:42
llvm::MCDwarfFrameInfo::IsBKeyFrame
bool IsBKeyFrame
Definition: MCDwarf.h:652
llvm::MCDwarfFrameInfo::PersonalityEncoding
unsigned PersonalityEncoding
Definition: MCDwarf.h:646
name
static const char * name
Definition: SVEIntrinsicOpts.cpp:75
llvm::MCLineSection::addLineEntry
void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec)
Definition: MCDwarf.h:186
llvm::MCDwarfLoc::getFlags
unsigned getFlags() const
Get the Flags of this MCDwarfLoc.
Definition: MCDwarf.h:116
llvm::pdb::PDB_SymType::Label
@ Label
uint16_t
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:314
llvm::MCDwarfLineTableHeader::resetFileTable
void resetFileTable()
Definition: MCDwarf.h:270
llvm::MCCFIInstruction::OpGnuArgsSize
@ OpGnuArgsSize
Definition: MCDwarf.h:453
llvm::MCDwarfLineTable::resetFileTable
void resetFileTable()
Definition: MCDwarf.h:343
llvm::MCDwarfFrameInfo::IsSignalFrame
bool IsSignalFrame
Definition: MCDwarf.h:649
llvm::MCDwarfDwoLineTable::getFile
unsigned getFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, uint16_t DwarfVersion, Optional< StringRef > Source)
Definition: MCDwarf.h:296
llvm::MCDwarfFile::Source
Optional< StringRef > Source
The source code of the file.
Definition: MCDwarf.h:71
llvm::SmallVectorImpl::clear
void clear()
Definition: SmallVector.h:585
llvm::MCDwarfLoc::getFileNum
unsigned getFileNum() const
Get the FileNum of this MCDwarfLoc.
Definition: MCDwarf.h:107
llvm::MCDwarfLineTableHeader
Definition: MCDwarf.h:219
llvm::MCCFIInstruction::OpRegister
@ OpRegister
Definition: MCDwarf.h:450
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:79
llvm::MCDwarfLineTable::isMD5UsageConsistent
bool isMD5UsageConsistent() const
Definition: MCDwarf.h:350
llvm::MCDwarfLineTable::getMCLineSections
MCLineSection & getMCLineSections()
Definition: MCDwarf.h:379
llvm::MCDwarfLineTable::getMCDwarfDirs
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
Definition: MCDwarf.h:360
llvm::MCDwarfLineEntry::getLabel
MCSymbol * getLabel() const
Definition: MCDwarf.h:171
llvm::MCCFIInstruction::Offset
int Offset
Definition: MCDwarf.h:461
llvm::MCDwarfFrameInfo::Instructions
std::vector< MCCFIInstruction > Instructions
Definition: MCDwarf.h:644
llvm::MCCFIInstruction::createRegister
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.
Definition: MCDwarf.h:541
llvm::MCDwarfFrameInfo::LsdaEncoding
unsigned LsdaEncoding
Definition: MCDwarf.h:647
SmallVector.h
llvm::MCCFIInstruction::createUndefined
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register)
.cfi_undefined From now on the previous value of Register can't be restored anymore.
Definition: MCDwarf.h:565
llvm::MCDwarfFrameEmitter::EmitAdvanceLoc
static void EmitAdvanceLoc(MCObjectStreamer &Streamer, uint64_t AddrDelta)
Definition: MCDwarf.cpp:1885
llvm::SmallVectorImpl< std::string >
llvm::MCDwarfFrameInfo::IsSimple
bool IsSimple
Definition: MCDwarf.h:650
llvm::MCCFIInstruction::createOffset
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition: MCDwarf.h:526
llvm::MCCFIInstruction::createRememberState
static MCCFIInstruction createRememberState(MCSymbol *L)
.cfi_remember_state Save all current rules for all registers.
Definition: MCDwarf.h:576
llvm::MCDwarfLineEntry
Instances of this class represent the line information for the dwarf line table entries.
Definition: MCDwarf.h:159
llvm::MCDwarfLineTableHeader::resetMD5Usage
void resetMD5Usage()
Definition: MCDwarf.h:246
llvm::MCCFIInstruction::OpNegateRAState
@ OpNegateRAState
Definition: MCDwarf.h:452
llvm::MCDwarfFrameInfo
Definition: MCDwarf.h:637
llvm::MCDwarfLineAddr
Definition: MCDwarf.h:384
llvm::MCCFIInstruction::OpRestoreState
@ OpRestoreState
Definition: MCDwarf.h:439
llvm::MCCFIInstruction::createWindowSave
static MCCFIInstruction createWindowSave(MCSymbol *L)
.cfi_window_save SPARC register window is saved.
Definition: MCDwarf.h:547
llvm::ISD::MCSymbol
@ MCSymbol
Definition: ISDOpcodes.h:172
llvm::MCDwarfLineTable::hasRootFile
bool hasRootFile() const
Definition: MCDwarf.h:345
llvm::MCCFIInstruction::getLabel
MCSymbol * getLabel() const
Definition: MCDwarf.h:598
llvm::MCCFIInstruction::createRestore
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register)
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
Definition: MCDwarf.h:559