LLVM 24.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"
19#include "llvm/ADT/StringMap.h"
20#include "llvm/ADT/StringRef.h"
23#include "llvm/Support/Error.h"
24#include "llvm/Support/MD5.h"
25#include "llvm/Support/SMLoc.h"
27#include <cassert>
28#include <cstdint>
29#include <optional>
30#include <string>
31#include <utility>
32#include <variant>
33#include <vector>
34
35namespace llvm {
36
37template <typename T> class ArrayRef;
38class MCAsmBackend;
39class MCContext;
41class MCSection;
42class MCStreamer;
43class MCSymbol;
44class raw_ostream;
45class SourceMgr;
46
47namespace mcdwarf {
48// Emit the common part of the DWARF 5 range/locations list tables header.
50} // namespace mcdwarf
51
52/// Manage the .debug_line_str section contents, if we use it.
54 BumpPtrAllocator Alloc;
55 StringSaver Saver{Alloc};
56 MCSymbol *LineStrLabel = nullptr;
58 bool UseRelocs = false;
59
60public:
61 /// Construct an instance that can emit .debug_line_str (for use in a normal
62 /// v5 line table).
63 LLVM_ABI explicit MCDwarfLineStr(MCContext &Ctx);
64
65 StringSaver &getSaver() { return Saver; }
66
67 /// Emit a reference to the string.
68 LLVM_ABI void emitRef(MCStreamer *MCOS, StringRef Path);
69
70 /// Emit the .debug_line_str section if appropriate.
72
73 /// Returns finalized section.
75
76 /// Adds path \p Path to the line string. Returns offset in the
77 /// .debug_line_str section.
78 LLVM_ABI size_t addString(StringRef Path);
79};
80
81/// Instances of this class represent the name of the dwarf .file directive and
82/// its associated dwarf file number in the MC file. MCDwarfFile's are created
83/// and uniqued by the MCContext class. In Dwarf 4 file numbers start from 1;
84/// i.e. the entry with file number 1 is the first element in the vector of
85/// DwarfFiles and there is no MCDwarfFile with file number 0. In Dwarf 5 file
86/// numbers start from 0, with the MCDwarfFile with file number 0 being the
87/// primary source file, and file numbers correspond to their index in the
88/// vector.
90 // The base name of the file without its directory path.
91 std::string Name;
92
93 // The index into the list of directory names for this file name.
94 unsigned DirIndex = 0;
95
96 /// The MD5 checksum, if there is one. Non-owning pointer to data allocated
97 /// in MCContext.
98 std::optional<MD5::MD5Result> Checksum;
99
100 /// The source code of the file. Non-owning reference to data allocated in
101 /// MCContext.
102 std::optional<StringRef> Source;
103};
104
105/// Instances of this class represent the information from a
106/// dwarf .loc directive.
107class MCDwarfLoc {
108 uint32_t FileNum;
109 uint32_t Line;
110 uint16_t Column;
111 // Flags (see #define's below)
112 uint8_t Flags;
113 uint8_t Isa;
114 uint32_t Discriminator;
115
116// Flag that indicates the initial value of the is_stmt_start flag.
117#define DWARF2_LINE_DEFAULT_IS_STMT 1
118
119#define DWARF2_FLAG_IS_STMT (1 << 0)
120#define DWARF2_FLAG_BASIC_BLOCK (1 << 1)
121#define DWARF2_FLAG_PROLOGUE_END (1 << 2)
122#define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3)
123
124private: // MCContext manages these
125 friend class MCContext;
126 friend class MCDwarfLineEntry;
127
128 MCDwarfLoc(unsigned fileNum, unsigned line, unsigned column, unsigned flags,
129 unsigned isa, unsigned discriminator)
130 : FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(isa),
131 Discriminator(discriminator) {}
132
133 // Allow the default copy constructor and assignment operator to be used
134 // for an MCDwarfLoc object.
135
136public:
137 /// Get the FileNum of this MCDwarfLoc.
138 unsigned getFileNum() const { return FileNum; }
139
140 /// Get the Line of this MCDwarfLoc.
141 unsigned getLine() const { return Line; }
142
143 /// Get the Column of this MCDwarfLoc.
144 unsigned getColumn() const { return Column; }
145
146 /// Get the Flags of this MCDwarfLoc.
147 unsigned getFlags() const { return Flags; }
148
149 /// Get the Isa of this MCDwarfLoc.
150 unsigned getIsa() const { return Isa; }
151
152 /// Get the Discriminator of this MCDwarfLoc.
153 unsigned getDiscriminator() const { return Discriminator; }
154
155 /// Set the FileNum of this MCDwarfLoc.
156 void setFileNum(unsigned fileNum) { FileNum = fileNum; }
157
158 /// Set the Line of this MCDwarfLoc.
159 void setLine(unsigned line) { Line = line; }
160
161 /// Set the Column of this MCDwarfLoc.
162 void setColumn(unsigned column) {
163 assert(column <= UINT16_MAX);
164 Column = column;
165 }
166
167 /// Set the Flags of this MCDwarfLoc.
168 void setFlags(unsigned flags) {
169 assert(flags <= UINT8_MAX);
170 Flags = flags;
171 }
172
173 /// Set the Isa of this MCDwarfLoc.
174 void setIsa(unsigned isa) {
175 assert(isa <= UINT8_MAX);
176 Isa = isa;
177 }
178
179 /// Set the Discriminator of this MCDwarfLoc.
180 void setDiscriminator(unsigned discriminator) {
181 Discriminator = discriminator;
182 }
183};
184
185/// Instances of this class represent the line information for
186/// the dwarf line table entries. Which is created after a machine
187/// instruction is assembled and uses an address from a temporary label
188/// created at the current address in the current section and the info from
189/// the last .loc directive seen as stored in the context.
190class MCDwarfLineEntry : public MCDwarfLoc {
191 MCSymbol *Label;
192
193private:
194 // Allow the default copy constructor and assignment operator to be used
195 // for an MCDwarfLineEntry object.
196
197public:
198 // Constructor to create an MCDwarfLineEntry given a symbol and the dwarf loc.
199 MCDwarfLineEntry(MCSymbol *label, const MCDwarfLoc loc,
200 MCSymbol *lineStreamLabel = nullptr,
201 SMLoc streamLabelDefLoc = {})
202 : MCDwarfLoc(loc), Label(label), LineStreamLabel(lineStreamLabel),
203 StreamLabelDefLoc(streamLabelDefLoc) {}
204
205 MCSymbol *getLabel() const { return Label; }
206
207 // This is the label that is to be emitted into the line stream. If this is
208 // non-null and we need to emit a label, also make sure to restart the current
209 // line sequence.
211
212 // Location where LineStreamLabel was defined. If there is an error emitting
213 // LineStreamLabel, we can use the SMLoc to report an error.
215
216 // This indicates the line entry is synthesized for an end entry.
217 bool IsEndEntry = false;
218
219 // The subsection that Label belongs to, used to emit entries in layout order.
220 unsigned Subsection = 0;
221
222 // Override the label with the given EndLabel.
223 void setEndLabel(MCSymbol *EndLabel) {
224 // If we're setting this to be an end entry, make sure we don't have
225 // LineStreamLabel set.
226 assert(LineStreamLabel == nullptr);
227 Label = EndLabel;
228 IsEndEntry = true;
229 }
230
231 // This is called when an instruction is assembled into the specified
232 // section and if there is information from the last .loc directive that
233 // has yet to have a line entry made for it is made.
234 LLVM_ABI static void make(MCStreamer *MCOS, MCSection *Section);
235};
236
237/// Instances of this class represent the line information for a compile
238/// unit where machine instructions have been assembled after seeing .loc
239/// directives. This is the information used to build the dwarf line
240/// table for a section.
242public:
243 // Add an entry to this MCLineSection's line entries.
244 void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec) {
245 MCLineDivisions[Sec].push_back(LineEntry);
246 }
247
248 // Add an end entry by cloning the last entry, if exists, for the section
249 // the given EndLabel belongs to. The label is replaced by the given EndLabel.
250 LLVM_ABI void addEndEntry(MCSymbol *EndLabel);
251
252 using MCDwarfLineEntryCollection = std::vector<MCDwarfLineEntry>;
253 using iterator = MCDwarfLineEntryCollection::iterator;
254 using const_iterator = MCDwarfLineEntryCollection::const_iterator;
256
257private:
258 // A collection of MCDwarfLineEntry for each section.
259 MCLineDivisionMap MCLineDivisions;
260
261public:
262 // Returns the collection of MCDwarfLineEntry for a given Compile Unit ID.
264 return MCLineDivisions;
265 }
266};
267
269 /// First special line opcode - leave room for the standard opcodes.
270 /// Note: If you want to change this, you'll have to update the
271 /// "StandardOpcodeLengths" table that is emitted in
272 /// \c Emit().
274 /// Minimum line offset in a special line info. opcode. The value
275 /// -5 was chosen to give a reasonable range of values.
276 int8_t DWARF2LineBase = -5;
277 /// Range of line offsets in a special line info. opcode.
279};
280
282 MCSymbol *Label = nullptr;
286 std::string CompilationDir;
288 bool HasAnySource = false;
289
290private:
291 bool HasAllMD5 = true;
292 bool HasAnyMD5 = false;
293
294public:
296
298 StringRef &FileName,
299 std::optional<MD5::MD5Result> Checksum,
300 std::optional<StringRef> Source,
301 uint16_t DwarfVersion,
302 unsigned FileNumber = 0);
303 LLVM_ABI std::pair<MCSymbol *, MCSymbol *>
305 std::optional<MCDwarfLineStr> &LineStr) const;
306 LLVM_ABI std::pair<MCSymbol *, MCSymbol *>
308 ArrayRef<char> SpecialOpcodeLengths,
309 std::optional<MCDwarfLineStr> &LineStr) const;
311 HasAllMD5 = true;
312 HasAnyMD5 = false;
313 }
314 void trackMD5Usage(bool MD5Used) {
315 HasAllMD5 &= MD5Used;
316 HasAnyMD5 |= MD5Used;
317 }
318 bool isMD5UsageConsistent() const {
319 return MCDwarfFiles.empty() || (HasAllMD5 == HasAnyMD5);
320 }
321
322 void setRootFile(StringRef Directory, StringRef FileName,
323 std::optional<MD5::MD5Result> Checksum,
324 std::optional<StringRef> Source) {
325 CompilationDir = std::string(Directory);
326 RootFile.Name = std::string(FileName);
327 RootFile.DirIndex = 0;
328 RootFile.Checksum = Checksum;
329 RootFile.Source = Source;
330 trackMD5Usage(Checksum.has_value());
331 HasAnySource |= Source.has_value();
332 }
333
335 MCDwarfDirs.clear();
336 MCDwarfFiles.clear();
337 RootFile.Name.clear();
339 HasAnySource = false;
340 }
341
342private:
343 void emitV2FileDirTables(MCStreamer *MCOS) const;
344 void emitV5FileDirTables(MCStreamer *MCOS,
345 std::optional<MCDwarfLineStr> &LineStr) const;
346};
347
350 bool HasSplitLineTable = false;
351
352public:
353 void maybeSetRootFile(StringRef Directory, StringRef FileName,
354 std::optional<MD5::MD5Result> Checksum,
355 std::optional<StringRef> Source) {
356 if (!Header.RootFile.Name.empty())
357 return;
358 Header.setRootFile(Directory, FileName, Checksum, Source);
359 }
360
361 unsigned getFile(StringRef Directory, StringRef FileName,
362 std::optional<MD5::MD5Result> Checksum,
363 uint16_t DwarfVersion, std::optional<StringRef> Source) {
364 HasSplitLineTable = true;
365 return cantFail(Header.tryGetFile(Directory, FileName, Checksum, Source,
366 DwarfVersion));
367 }
368
370 MCSection *Section) const;
371};
372
375 MCLineSection MCLineSections;
376
377public:
378 // This emits the Dwarf file and the line tables for all Compile Units.
379 LLVM_ABI static void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params);
380
381 // This emits the Dwarf file and the line tables for a given Compile Unit.
383 std::optional<MCDwarfLineStr> &LineStr) const;
384
385 // This emits a single line table associated with a given Section.
386 LLVM_ABI static void
387 emitOne(MCStreamer *MCOS, MCSection *Section,
389
391 SMLoc DefLoc,
392 StringRef Name);
393
395 StringRef &FileName,
396 std::optional<MD5::MD5Result> Checksum,
397 std::optional<StringRef> Source,
398 uint16_t DwarfVersion,
399 unsigned FileNumber = 0);
400 unsigned getFile(StringRef &Directory, StringRef &FileName,
401 std::optional<MD5::MD5Result> Checksum,
402 std::optional<StringRef> Source, uint16_t DwarfVersion,
403 unsigned FileNumber = 0) {
404 return cantFail(tryGetFile(Directory, FileName, Checksum, Source,
405 DwarfVersion, FileNumber));
406 }
407
408 void setRootFile(StringRef Directory, StringRef FileName,
409 std::optional<MD5::MD5Result> Checksum,
410 std::optional<StringRef> Source) {
411 Header.CompilationDir = std::string(Directory);
412 Header.RootFile.Name = std::string(FileName);
413 Header.RootFile.DirIndex = 0;
414 Header.RootFile.Checksum = Checksum;
415 Header.RootFile.Source = Source;
416 Header.trackMD5Usage(Checksum.has_value());
417 Header.HasAnySource |= Source.has_value();
418 }
419
420 void resetFileTable() { Header.resetFileTable(); }
421
422 bool hasRootFile() const { return !Header.RootFile.Name.empty(); }
423
424 MCDwarfFile &getRootFile() { return Header.RootFile; }
425 const MCDwarfFile &getRootFile() const { return Header.RootFile; }
426
427 // Report whether MD5 usage has been consistent (all-or-none).
428 bool isMD5UsageConsistent() const { return Header.isMD5UsageConsistent(); }
429
431 return Header.Label;
432 }
433
434 void setLabel(MCSymbol *Label) {
435 Header.Label = Label;
436 }
437
439 return Header.MCDwarfDirs;
440 }
441
443 return Header.MCDwarfDirs;
444 }
445
447 return Header.MCDwarfFiles;
448 }
449
451 return Header.MCDwarfFiles;
452 }
453
455 return MCLineSections;
456 }
458 return MCLineSections;
459 }
460};
461
463public:
464 /// Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
465 LLVM_ABI static void encode(MCContext &Context, MCDwarfLineTableParams Params,
466 int64_t LineDelta, uint64_t AddrDelta,
468
469 /// Utility function to emit the encoding to a streamer.
470 LLVM_ABI static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
471 int64_t LineDelta, uint64_t AddrDelta);
472};
473
475public:
476 //
477 // When generating dwarf for assembly source files this emits the Dwarf
478 // sections.
479 //
480 LLVM_ABI static void Emit(MCStreamer *MCOS);
481};
482
483// When generating dwarf for assembly source files this is the info that is
484// needed to be gathered for each symbol that will have a dwarf label.
486private:
487 // Name of the symbol without a leading underbar, if any.
488 StringRef Name;
489 // The dwarf file number this symbol is in.
490 unsigned FileNumber;
491 // The line number this symbol is at.
492 unsigned LineNumber;
493 // The low_pc for the dwarf label is taken from this symbol.
494 MCSymbol *Label;
495
496public:
497 MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber,
498 MCSymbol *label)
499 : Name(name), FileNumber(fileNumber), LineNumber(lineNumber),
500 Label(label) {}
501
502 StringRef getName() const { return Name; }
503 unsigned getFileNumber() const { return FileNumber; }
504 unsigned getLineNumber() const { return LineNumber; }
505 MCSymbol *getLabel() const { return Label; }
506
507 // This is called when label is created when we are generating dwarf for
508 // assembly source files.
509 LLVM_ABI static void Make(MCSymbol *Symbol, MCStreamer *MCOS,
511};
512
513class MCCFIInstruction {
514public:
542
543 // Held in ExtraFields for most common OpTypes, exceptions follow.
545 unsigned Register;
546 int64_t Offset;
547 unsigned Register2;
548 unsigned AddressSpace;
549 // FIXME: Workaround for GCC7 bug with nested class used as std::variant
550 // alternative where the compiler really wants a user-defined default
551 // constructor. Once we no longer support GCC7 these constructors can be
552 // replaced with default member initializers and aggregate initialization.
553 CommonFields(unsigned Reg, int64_t Off = 0,
554 unsigned Reg2 = std::numeric_limits<unsigned>::max(),
555 unsigned AddrSpace = 0)
556 : Register(Reg), Offset(Off), Register2(Reg2), AddressSpace(AddrSpace) {
557 }
558 CommonFields() : CommonFields(std::numeric_limits<unsigned>::max()) {}
559 };
560 // Held in ExtraFields when OpEscape.
562 std::vector<char> Values;
563 std::string Comment;
564 };
565 // Held in ExtraFields when OpLabel.
566 struct LabelFields {
567 MCSymbol *CfiLabel = nullptr;
568 };
569 /// Held in ExtraFields when OpLLVMRegisterPair.
571 unsigned Register;
572 unsigned Reg1, Reg2;
574 };
576 unsigned Register;
577 unsigned Lane;
578 unsigned SizeInBits;
579 };
580 /// Held in ExtraFields when OpLLVMVectorRegisters.
582 unsigned Register;
583 std::vector<VectorRegisterWithLane> VectorRegisters;
584 };
585 /// Held in ExtraFields when OpLLVMVectorOffset.
587 unsigned Register;
589 int64_t Offset;
590 unsigned MaskRegister;
592 };
593 /// Held in ExtraFields when OpLLVMVectorRegisterMask.
601 /// Held in ExtraFields when OpLLVMSetRAState.
603 /// The ra_state value (DW_AARCH64_RA_NOT_SIGNED, DW_AARCH64_RA_SIGNED_SP,
604 /// or DW_AARCH64_RA_SIGNED_SP_PC).
605 unsigned State;
606 /// Symbol pointing to the signing instruction.
607 /// Precisely one of \p PACSym xor \p Offset should be set.
609 /// Factored offset to the signing instruction.
610 /// Precisely one of \p PACSym xor \p Offset should be set.
611 int64_t Offset;
612 };
613
614private:
615 MCSymbol *Label;
619 ExtraFields;
620 OpType Operation;
621 SMLoc Loc;
622
623 template <class FieldsType>
624 MCCFIInstruction(OpType Op, MCSymbol *L, FieldsType &&EF, SMLoc Loc)
625 : Label(L), ExtraFields(std::forward<FieldsType>(EF)), Operation(Op),
626 Loc(Loc) {}
627
628public:
629 /// .cfi_def_cfa defines a rule for computing CFA as: take address from
630 /// Register and add Offset to it.
631 static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register,
632 int64_t Offset, SMLoc Loc = {}) {
633 return {OpDefCfa, L, CommonFields{Register, Offset}, Loc};
634 }
635
636 /// .cfi_def_cfa_register modifies a rule for computing CFA. From now
637 /// on Register will be used instead of the old one. Offset remains the same.
638 static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register,
639 SMLoc Loc = {}) {
640 return {OpDefCfaRegister, L, CommonFields{Register}, Loc};
641 }
642
643 /// .cfi_def_cfa_offset modifies a rule for computing CFA. Register
644 /// remains the same, but offset is new. Note that it is the absolute offset
645 /// that will be added to a defined register to the compute CFA address.
646 static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset,
647 SMLoc Loc = {}) {
648 return {OpDefCfaOffset, L, CommonFields{0, Offset}, Loc};
649 }
650
651 /// .cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but
652 /// Offset is a relative value that is added/subtracted from the previous
653 /// offset.
654 static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int64_t Adjustment,
655 SMLoc Loc = {}) {
656 return {OpAdjustCfaOffset, L, CommonFields{0, Adjustment}, Loc};
657 }
658
659 // FIXME: Update the remaining docs to use the new proposal wording.
660 /// .cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to
661 /// be the result of evaluating the DWARF operation expression
662 /// `DW_OP_constu AS; DW_OP_aspace_bregx R, B` as a location description.
663 static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register,
664 int64_t Offset,
665 unsigned AddressSpace,
666 SMLoc Loc) {
667 return {OpLLVMDefAspaceCfa, L,
669 }
670
671 /// .cfi_offset Previous value of Register is saved at offset Offset
672 /// from CFA.
673 static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register,
674 int64_t Offset, SMLoc Loc = {}) {
675 return {OpOffset, L, CommonFields{Register, Offset}, Loc};
676 }
677
678 /// .cfi_rel_offset Previous value of Register is saved at offset
679 /// Offset from the current CFA register. This is transformed to .cfi_offset
680 /// using the known displacement of the CFA register from the CFA.
681 static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register,
682 int64_t Offset, SMLoc Loc = {}) {
683 return {OpRelOffset, L, CommonFields{Register, Offset}, Loc};
684 }
685
686 /// .cfi_register Previous value of Register1 is saved in
687 /// register Register2.
688 static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1,
689 unsigned Register2, SMLoc Loc = {}) {
690 return {OpRegister, L, CommonFields{Register1, 0, Register2}, Loc};
691 }
692
693 /// .cfi_window_save SPARC register window is saved.
694 static MCCFIInstruction createWindowSave(MCSymbol *L, SMLoc Loc = {}) {
695 return {OpWindowSave, L, CommonFields{}, Loc};
696 }
697
698 /// .cfi_negate_ra_state AArch64 negate RA state.
699 static MCCFIInstruction createNegateRAState(MCSymbol *L, SMLoc Loc = {}) {
700 return {OpNegateRAState, L, CommonFields{}, Loc};
701 }
702
703 /// .cfi_negate_ra_state_with_pc AArch64 negate RA state with PC.
704 static MCCFIInstruction createNegateRAStateWithPC(MCSymbol *L,
705 SMLoc Loc = {}) {
706 return {OpNegateRAStateWithPC, L, CommonFields{}, Loc};
707 }
708
709 /// .cfi_set_ra_state AArch64 set RA sign state,
710 // with a symbolic offset to the signing instruction.
711 static MCCFIInstruction createSetRAState(MCSymbol *L, unsigned State,
712 MCSymbol *PACSym = nullptr,
713 SMLoc Loc = {}) {
714 return {OpLLVMSetRAState, L, LLVMSetRAStateFields{State, PACSym, 0}, Loc};
715 }
716
717 /// .cfi_set_ra_state AArch64 set RA sign state,
718 /// with a pre-computed factored offset to the signing instruction.
719 static MCCFIInstruction createSetRAState(MCSymbol *L, unsigned State,
720 int64_t Offset, SMLoc Loc = {}) {
721 return {OpLLVMSetRAState, L, LLVMSetRAStateFields{State, nullptr, Offset},
722 Loc};
723 }
724
725 /// .cfi_restore says that the rule for Register is now the same as it
726 /// was at the beginning of the function, after all initial instructions added
727 /// by .cfi_startproc were executed.
728 static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register,
729 SMLoc Loc = {}) {
730 return {OpRestore, L, CommonFields{Register}, Loc};
731 }
732
733 /// .cfi_undefined From now on the previous value of Register can't be
734 /// restored anymore.
735 static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register,
736 SMLoc Loc = {}) {
737 return {OpUndefined, L, CommonFields{Register}, Loc};
738 }
739
740 /// .cfi_same_value Current value of Register is the same as in the
741 /// previous frame. I.e., no restoration is needed.
742 static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register,
743 SMLoc Loc = {}) {
744 return {OpSameValue, L, CommonFields{Register}, Loc};
745 }
746
747 /// .cfi_remember_state Save all current rules for all registers.
748 static MCCFIInstruction createRememberState(MCSymbol *L, SMLoc Loc = {}) {
749 return {OpRememberState, L, CommonFields{}, Loc};
750 }
751
752 /// .cfi_restore_state Restore the previously saved state.
753 static MCCFIInstruction createRestoreState(MCSymbol *L, SMLoc Loc = {}) {
754 return {OpRestoreState, L, CommonFields{}, Loc};
755 }
756
757 /// .cfi_escape Allows the user to add arbitrary bytes to the unwind
758 /// info.
759 static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals,
760 SMLoc Loc = {}, StringRef Comment = "") {
761 return {OpEscape, L,
762 EscapeFields{std::vector<char>(Vals.begin(), Vals.end()),
763 Comment.str()},
764 Loc};
765 }
766
767 /// A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE
768 static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int64_t Size,
769 SMLoc Loc = {}) {
770 return {OpGnuArgsSize, L, CommonFields{0, Size}, Loc};
771 }
772
773 static MCCFIInstruction createLabel(MCSymbol *L, MCSymbol *CfiLabel,
774 SMLoc Loc) {
775 return {OpLabel, L, LabelFields{CfiLabel}, Loc};
776 }
777
778 /// .cfi_llvm_register_pair Previous value of Register is saved in R1:R2.
779 static MCCFIInstruction
780 createLLVMRegisterPair(MCSymbol *L, unsigned Register, unsigned R1,
781 unsigned R1SizeInBits, unsigned R2,
782 unsigned R2SizeInBits, SMLoc Loc = {}) {
783 RegisterPairFields Extra{Register, R1, R2, R1SizeInBits, R2SizeInBits};
784 return {OpLLVMRegisterPair, L, Extra, Loc};
785 }
786
787 /// .cfi_llvm_vector_registers Previous value of Register is saved in lanes of
788 /// vector registers.
789 static MCCFIInstruction
791 ArrayRef<VectorRegisterWithLane> VectorRegisters,
792 SMLoc Loc = {}) {
793 VectorRegistersFields Extra{Register, VectorRegisters};
794 return {OpLLVMVectorRegisters, L, std::move(Extra), Loc};
795 }
796
797 /// .cfi_llvm_vector_offset Previous value of Register is saved at Offset from
798 /// CFA. MaskRegister specifies the active lanes of register.
799 static MCCFIInstruction
801 unsigned RegisterSizeInBits, unsigned MaskRegister,
802 unsigned MaskRegisterSizeInBits, int64_t Offset,
803 SMLoc Loc = {}) {
804 VectorOffsetFields Extra{Register, RegisterSizeInBits, Offset, MaskRegister,
805 MaskRegisterSizeInBits};
806 return MCCFIInstruction(OpLLVMVectorOffset, L, Extra, Loc);
807 }
808
809 /// .cfi_llvm_vector_register_mask Previous value of Register is saved in
810 /// SpillRegister, predicated on the value of MaskRegister.
811 static MCCFIInstruction createLLVMVectorRegisterMask(
812 MCSymbol *L, unsigned Register, unsigned SpillRegister,
813 unsigned SpillRegisterLaneSizeInBits, unsigned MaskRegister,
814 unsigned MaskRegisterSizeInBits, SMLoc Loc = {}) {
815 VectorRegisterMaskFields Extra{
816 Register, SpillRegister, SpillRegisterLaneSizeInBits,
817 MaskRegister, MaskRegisterSizeInBits,
818 };
819 return MCCFIInstruction(OpLLVMVectorRegisterMask, L, Extra, Loc);
820 }
821
822 template <class ExtraFieldsTy> ExtraFieldsTy &getExtraFields() {
823 return std::get<ExtraFieldsTy>(ExtraFields);
824 }
825
826 template <class ExtraFieldsTy> const ExtraFieldsTy &getExtraFields() const {
827 return std::get<ExtraFieldsTy>(ExtraFields);
828 }
829 /// .cfi_val_offset Previous value of Register is offset Offset from the
830 /// current CFA register.
831 static MCCFIInstruction createValOffset(MCSymbol *L, unsigned Register,
832 int64_t Offset, SMLoc Loc = {}) {
833 return {OpValOffset, L, CommonFields{Register, Offset}, Loc};
834 }
835
836 OpType getOperation() const { return Operation; }
837 MCSymbol *getLabel() const { return Label; }
838
839 unsigned getRegister() const {
840 assert(Operation == OpDefCfa || Operation == OpOffset ||
841 Operation == OpRestore || Operation == OpUndefined ||
842 Operation == OpSameValue || Operation == OpDefCfaRegister ||
843 Operation == OpRelOffset || Operation == OpValOffset ||
844 Operation == OpRegister || Operation == OpLLVMDefAspaceCfa);
845 return std::get<CommonFields>(ExtraFields).Register;
846 }
847
848 unsigned getRegister2() const {
849 assert(Operation == OpRegister);
850 return std::get<CommonFields>(ExtraFields).Register2;
851 }
852
853 unsigned getAddressSpace() const {
854 assert(Operation == OpLLVMDefAspaceCfa);
855 return std::get<CommonFields>(ExtraFields).AddressSpace;
856 }
857
858 int64_t getOffset() const {
859 assert(Operation == OpDefCfa || Operation == OpOffset ||
860 Operation == OpRelOffset || Operation == OpDefCfaOffset ||
861 Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize ||
862 Operation == OpValOffset || Operation == OpLLVMDefAspaceCfa);
863 return std::get<CommonFields>(ExtraFields).Offset;
864 }
865
866 unsigned getRASignState() const {
867 assert(Operation == OpLLVMSetRAState);
868 return std::get<LLVMSetRAStateFields>(ExtraFields).State;
869 }
870
872 assert(Operation == OpLLVMSetRAState);
873 return std::get<LLVMSetRAStateFields>(ExtraFields).PACSym;
874 }
875
876 int64_t getRASignOffset() const {
877 assert(Operation == OpLLVMSetRAState);
878 return std::get<LLVMSetRAStateFields>(ExtraFields).Offset;
879 }
880
882 assert(Operation == OpLabel);
883 return std::get<LabelFields>(ExtraFields).CfiLabel;
884 }
885
887 assert(Operation == OpEscape);
888 auto &Values = std::get<EscapeFields>(ExtraFields).Values;
889 return StringRef(&Values[0], Values.size());
890 }
891
893 assert(Operation == OpEscape);
894 return std::get<EscapeFields>(ExtraFields).Comment;
895 }
896 SMLoc getLoc() const { return Loc; }
897
898 /// Replaces in place all references to FromReg with ToReg.
899 LLVM_ABI void replaceRegister(unsigned FromReg, unsigned ToReg);
900};
901
903 MCDwarfFrameInfo() = default;
904
905 MCSymbol *Begin = nullptr;
906 MCSymbol *End = nullptr;
907 const MCSymbol *Personality = nullptr;
908 const MCSymbol *Lsda = nullptr;
909 std::vector<MCCFIInstruction> Instructions;
910 unsigned CurrentCfaRegister = 0;
911 unsigned RememberStateDepth = 0;
913 unsigned LsdaEncoding = 0;
915 bool IsSignalFrame = false;
916 bool IsSimple = false;
917 unsigned RAReg = static_cast<unsigned>(INT_MAX);
918 bool IsBKeyFrame = false;
919 bool IsMTETaggedFrame = false;
921};
922
923// Emit DWARF call frame information and, when available, compact unwind
924// information.
926public:
927 LLVM_ABI static void emit(MCObjectStreamer &streamer, bool isEH);
928 LLVM_ABI static void encodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta,
930};
931
932} // end namespace llvm
933
934#endif // LLVM_MC_MCDWARF_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
uint64_t uint64_t
#define LLVM_ABI
Definition Compiler.h:211
Register Reg
This file implements a map that provides insertion order iteration.
#define R2(n)
static const char * name
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Tagged union holding either a T or a Error.
Definition Error.h:485
Generic interface to target specific assembler backends.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_def_cfa_register modifies a rule for computing CFA.
Definition MCDwarf.h:638
MCSymbol * getLabel() const
Definition MCDwarf.h:837
static MCCFIInstruction createLLVMVectorOffset(MCSymbol *L, unsigned Register, unsigned RegisterSizeInBits, unsigned MaskRegister, unsigned MaskRegisterSizeInBits, int64_t Offset, SMLoc Loc={})
.cfi_llvm_vector_offset Previous value of Register is saved at Offset from CFA.
Definition MCDwarf.h:800
unsigned getRASignState() const
Definition MCDwarf.h:866
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_undefined From now on the previous value of Register can't be restored anymore.
Definition MCDwarf.h:735
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int64_t Size, SMLoc Loc={})
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
Definition MCDwarf.h:768
unsigned getAddressSpace() const
Definition MCDwarf.h:853
static MCCFIInstruction createLLVMVectorRegisters(MCSymbol *L, unsigned Register, ArrayRef< VectorRegisterWithLane > VectorRegisters, SMLoc Loc={})
.cfi_llvm_vector_registers Previous value of Register is saved in lanes of vector registers.
Definition MCDwarf.h:790
MCSymbol * getRASignSymbol() const
Definition MCDwarf.h:871
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
Definition MCDwarf.h:728
const ExtraFieldsTy & getExtraFields() const
Definition MCDwarf.h:826
unsigned getRegister2() const
Definition MCDwarf.h:848
static MCCFIInstruction createSetRAState(MCSymbol *L, unsigned State, MCSymbol *PACSym=nullptr, SMLoc Loc={})
.cfi_set_ra_state AArch64 set RA sign state,
Definition MCDwarf.h:711
static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register, int64_t Offset, unsigned AddressSpace, SMLoc Loc)
.cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to be the result of evaluating the DW...
Definition MCDwarf.h:663
unsigned getRegister() const
Definition MCDwarf.h:839
static MCCFIInstruction createLLVMVectorRegisterMask(MCSymbol *L, unsigned Register, unsigned SpillRegister, unsigned SpillRegisterLaneSizeInBits, unsigned MaskRegister, unsigned MaskRegisterSizeInBits, SMLoc Loc={})
.cfi_llvm_vector_register_mask Previous value of Register is saved in SpillRegister,...
Definition MCDwarf.h:811
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2, SMLoc Loc={})
.cfi_register Previous value of Register1 is saved in register Register2.
Definition MCDwarf.h:688
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition MCDwarf.h:631
LLVM_ABI void replaceRegister(unsigned FromReg, unsigned ToReg)
Replaces in place all references to FromReg with ToReg.
Definition MCDwarf.cpp:1304
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition MCDwarf.h:673
SMLoc getLoc() const
Definition MCDwarf.h:896
static MCCFIInstruction createValOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_val_offset Previous value of Register is offset Offset from the current CFA register.
Definition MCDwarf.h:831
static MCCFIInstruction createNegateRAStateWithPC(MCSymbol *L, SMLoc Loc={})
.cfi_negate_ra_state_with_pc AArch64 negate RA state with PC.
Definition MCDwarf.h:704
static MCCFIInstruction createNegateRAState(MCSymbol *L, SMLoc Loc={})
.cfi_negate_ra_state AArch64 negate RA state.
Definition MCDwarf.h:699
static MCCFIInstruction createRememberState(MCSymbol *L, SMLoc Loc={})
.cfi_remember_state Save all current rules for all registers.
Definition MCDwarf.h:748
static MCCFIInstruction createSetRAState(MCSymbol *L, unsigned State, int64_t Offset, SMLoc Loc={})
.cfi_set_ra_state AArch64 set RA sign state, with a pre-computed factored offset to the signing instr...
Definition MCDwarf.h:719
OpType getOperation() const
Definition MCDwarf.h:836
static MCCFIInstruction createLLVMRegisterPair(MCSymbol *L, unsigned Register, unsigned R1, unsigned R1SizeInBits, unsigned R2, unsigned R2SizeInBits, SMLoc Loc={})
.cfi_llvm_register_pair Previous value of Register is saved in R1:R2.
Definition MCDwarf.h:780
StringRef getComment() const
Definition MCDwarf.h:892
int64_t getRASignOffset() const
Definition MCDwarf.h:876
StringRef getValues() const
Definition MCDwarf.h:886
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa_offset modifies a rule for computing CFA.
Definition MCDwarf.h:646
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, SMLoc Loc={}, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Definition MCDwarf.h:759
static MCCFIInstruction createWindowSave(MCSymbol *L, SMLoc Loc={})
.cfi_window_save SPARC register window is saved.
Definition MCDwarf.h:694
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int64_t Adjustment, SMLoc Loc={})
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
Definition MCDwarf.h:654
MCSymbol * getCfiLabel() const
Definition MCDwarf.h:881
static MCCFIInstruction createRestoreState(MCSymbol *L, SMLoc Loc={})
.cfi_restore_state Restore the previously saved state.
Definition MCDwarf.h:753
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_same_value Current value of Register is the same as in the previous frame.
Definition MCDwarf.h:742
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register.
Definition MCDwarf.h:681
ExtraFieldsTy & getExtraFields()
Definition MCDwarf.h:822
int64_t getOffset() const
Definition MCDwarf.h:858
static MCCFIInstruction createLabel(MCSymbol *L, MCSymbol *CfiLabel, SMLoc Loc)
Definition MCDwarf.h:773
Context object for machine code objects.
Definition MCContext.h:84
void maybeSetRootFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
Definition MCDwarf.h:353
unsigned getFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, uint16_t DwarfVersion, std::optional< StringRef > Source)
Definition MCDwarf.h:361
LLVM_ABI void Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params, MCSection *Section) const
Definition MCDwarf.cpp:342
static LLVM_ABI void emit(MCObjectStreamer &streamer, bool isEH)
Definition MCDwarf.cpp:2173
static LLVM_ABI void encodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, SmallVectorImpl< char > &OS)
Definition MCDwarf.cpp:2249
static LLVM_ABI void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
Definition MCDwarf.cpp:732
static LLVM_ABI void encode(MCContext &Context, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta, SmallVectorImpl< char > &OS)
Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
Definition MCDwarf.cpp:747
Instances of this class represent the line information for the dwarf line table entries.
Definition MCDwarf.h:190
void setEndLabel(MCSymbol *EndLabel)
Definition MCDwarf.h:223
MCSymbol * getLabel() const
Definition MCDwarf.h:205
MCDwarfLineEntry(MCSymbol *label, const MCDwarfLoc loc, MCSymbol *lineStreamLabel=nullptr, SMLoc streamLabelDefLoc={})
Definition MCDwarf.h:199
MCSymbol * LineStreamLabel
Definition MCDwarf.h:210
static LLVM_ABI void make(MCStreamer *MCOS, MCSection *Section)
Definition MCDwarf.cpp:91
StringSaver & getSaver()
Definition MCDwarf.h:65
LLVM_ABI void emitSection(MCStreamer *MCOS)
Emit the .debug_line_str section if appropriate.
Definition MCDwarf.cpp:392
LLVM_ABI MCDwarfLineStr(MCContext &Ctx)
Construct an instance that can emit .debug_line_str (for use in a normal v5 line table).
Definition MCDwarf.cpp:76
LLVM_ABI SmallString< 0 > getFinalizedData()
Returns finalized section.
Definition MCDwarf.cpp:400
LLVM_ABI void emitRef(MCStreamer *MCOS, StringRef Path)
Emit a reference to the string.
Definition MCDwarf.cpp:414
LLVM_ABI size_t addString(StringRef Path)
Adds path Path to the line string.
Definition MCDwarf.cpp:410
bool isMD5UsageConsistent() const
Definition MCDwarf.h:428
const MCDwarfFile & getRootFile() const
Definition MCDwarf.h:425
void setLabel(MCSymbol *Label)
Definition MCDwarf.h:434
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
Definition MCDwarf.h:438
LLVM_ABI void endCurrentSeqAndEmitLineStreamLabel(MCStreamer *MCOS, SMLoc DefLoc, StringRef Name)
Definition MCDwarf.cpp:295
void setRootFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
Definition MCDwarf.h:408
MCDwarfFile & getRootFile()
Definition MCDwarf.h:424
const MCLineSection & getMCLineSections() const
Definition MCDwarf.h:454
static LLVM_ABI void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params)
Definition MCDwarf.cpp:315
bool hasRootFile() const
Definition MCDwarf.h:422
unsigned getFile(StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
Definition MCDwarf.h:400
SmallVectorImpl< std::string > & getMCDwarfDirs()
Definition MCDwarf.h:442
SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles()
Definition MCDwarf.h:450
MCLineSection & getMCLineSections()
Definition MCDwarf.h:457
MCSymbol * getLabel() const
Definition MCDwarf.h:430
static LLVM_ABI void emitOne(MCStreamer *MCOS, MCSection *Section, const MCLineSection::MCDwarfLineEntryCollection &LineEntries)
Definition MCDwarf.cpp:171
LLVM_ABI Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
Definition MCDwarf.cpp:632
LLVM_ABI void emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params, std::optional< MCDwarfLineStr > &LineStr) const
Definition MCDwarf.cpp:618
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Definition MCDwarf.h:446
Instances of this class represent the information from a dwarf .loc directive.
Definition MCDwarf.h:107
friend class MCDwarfLineEntry
Definition MCDwarf.h:126
unsigned getLine() const
Get the Line of this MCDwarfLoc.
Definition MCDwarf.h:141
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
Definition MCDwarf.h:159
unsigned getIsa() const
Get the Isa of this MCDwarfLoc.
Definition MCDwarf.h:150
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
Definition MCDwarf.h:174
void setDiscriminator(unsigned discriminator)
Set the Discriminator of this MCDwarfLoc.
Definition MCDwarf.h:180
unsigned getFlags() const
Get the Flags of this MCDwarfLoc.
Definition MCDwarf.h:147
unsigned getColumn() const
Get the Column of this MCDwarfLoc.
Definition MCDwarf.h:144
friend class MCContext
Definition MCDwarf.h:125
void setFlags(unsigned flags)
Set the Flags of this MCDwarfLoc.
Definition MCDwarf.h:168
unsigned getDiscriminator() const
Get the Discriminator of this MCDwarfLoc.
Definition MCDwarf.h:153
void setColumn(unsigned column)
Set the Column of this MCDwarfLoc.
Definition MCDwarf.h:162
unsigned getFileNum() const
Get the FileNum of this MCDwarfLoc.
Definition MCDwarf.h:138
void setFileNum(unsigned fileNum)
Set the FileNum of this MCDwarfLoc.
Definition MCDwarf.h:156
static LLVM_ABI void Emit(MCStreamer *MCOS)
Definition MCDwarf.cpp:1204
MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber, MCSymbol *label)
Definition MCDwarf.h:497
StringRef getName() const
Definition MCDwarf.h:502
static LLVM_ABI void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr, SMLoc &Loc)
Definition MCDwarf.cpp:1267
MCSymbol * getLabel() const
Definition MCDwarf.h:505
unsigned getLineNumber() const
Definition MCDwarf.h:504
unsigned getFileNumber() const
Definition MCDwarf.h:503
Instances of this class represent the line information for a compile unit where machine instructions ...
Definition MCDwarf.h:241
const MCLineDivisionMap & getMCLineEntries() const
Definition MCDwarf.h:263
LLVM_ABI void addEndEntry(MCSymbol *EndLabel)
Definition MCDwarf.cpp:132
MapVector< MCSection *, MCDwarfLineEntryCollection > MCLineDivisionMap
Definition MCDwarf.h:255
MCDwarfLineEntryCollection::const_iterator const_iterator
Definition MCDwarf.h:254
MCDwarfLineEntryCollection::iterator iterator
Definition MCDwarf.h:253
void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec)
Definition MCDwarf.h:244
std::vector< MCDwarfLineEntry > MCDwarfLineEntryCollection
Definition MCDwarf.h:252
Streaming object file generation interface.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:580
Streaming machine code generation interface.
Definition MCStreamer.h:222
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
This class implements a map that also provides access to all stored values in a deterministic order.
Definition MapVector.h:39
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Represents a location in source code.
Definition SMLoc.h:22
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:28
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition SourceMgr.h:34
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:129
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
iterator begin() const
Definition StringRef.h:114
iterator end() const
Definition StringRef.h:116
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition StringSaver.h:22
Utility for building string tables with deduplicated suffixes.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
LLVM_ABI MCSymbol * emitListsTableHeaderStart(MCStreamer &S)
Definition MCDwarf.cpp:44
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
RelativeUniformCounterPtr Values
Definition InstrProf.h:91
LLVM_ABI SourceMgr SrcMgr
Definition Error.cpp:24
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition Error.h:769
constexpr NextUseDistance max(NextUseDistance A, NextUseDistance B)
DWARFExpression::Operation Op
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:391
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:879
CommonFields(unsigned Reg, int64_t Off=0, unsigned Reg2=std::numeric_limits< unsigned >::max(), unsigned AddrSpace=0)
Definition MCDwarf.h:553
Held in ExtraFields when OpLLVMSetRAState.
Definition MCDwarf.h:602
int64_t Offset
Factored offset to the signing instruction.
Definition MCDwarf.h:611
MCSymbol * PACSym
Symbol pointing to the signing instruction.
Definition MCDwarf.h:608
unsigned State
The ra_state value (DW_AARCH64_RA_NOT_SIGNED, DW_AARCH64_RA_SIGNED_SP, or DW_AARCH64_RA_SIGNED_SP_PC)...
Definition MCDwarf.h:605
Held in ExtraFields when OpLLVMRegisterPair.
Definition MCDwarf.h:570
Held in ExtraFields when OpLLVMVectorOffset.
Definition MCDwarf.h:586
Held in ExtraFields when OpLLVMVectorRegisterMask.
Definition MCDwarf.h:594
Held in ExtraFields when OpLLVMVectorRegisters.
Definition MCDwarf.h:581
std::vector< VectorRegisterWithLane > VectorRegisters
Definition MCDwarf.h:583
Instances of this class represent the name of the dwarf .file directive and its associated dwarf file...
Definition MCDwarf.h:89
std::optional< MD5::MD5Result > Checksum
The MD5 checksum, if there is one.
Definition MCDwarf.h:98
std::string Name
Definition MCDwarf.h:91
std::optional< StringRef > Source
The source code of the file.
Definition MCDwarf.h:102
unsigned DirIndex
Definition MCDwarf.h:94
const MCSymbol * Personality
Definition MCDwarf.h:907
unsigned RememberStateDepth
Definition MCDwarf.h:911
unsigned PersonalityEncoding
Definition MCDwarf.h:912
uint64_t CompactUnwindEncoding
Definition MCDwarf.h:914
std::vector< MCCFIInstruction > Instructions
Definition MCDwarf.h:909
const MCSymbol * Lsda
Definition MCDwarf.h:908
unsigned CurrentCfaRegister
Definition MCDwarf.h:910
void trackMD5Usage(bool MD5Used)
Definition MCDwarf.h:314
SmallVector< MCDwarfFile, 3 > MCDwarfFiles
Definition MCDwarf.h:284
bool isMD5UsageConsistent() const
Definition MCDwarf.h:318
SmallVector< std::string, 3 > MCDwarfDirs
Definition MCDwarf.h:283
LLVM_ABI std::pair< MCSymbol *, MCSymbol * > Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, std::optional< MCDwarfLineStr > &LineStr) const
Definition MCDwarf.cpp:352
StringMap< unsigned > SourceIdMap
Definition MCDwarf.h:285
void setRootFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
Definition MCDwarf.h:322
LLVM_ABI Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
Definition MCDwarf.cpp:649
uint8_t DWARF2LineOpcodeBase
First special line opcode - leave room for the standard opcodes.
Definition MCDwarf.h:273
uint8_t DWARF2LineRange
Range of line offsets in a special line info. opcode.
Definition MCDwarf.h:278
int8_t DWARF2LineBase
Minimum line offset in a special line info.
Definition MCDwarf.h:276