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