LLVM 19.0.0git
MCContext.h
Go to the documentation of this file.
1//===- MCContext.h - Machine Code Context -----------------------*- 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#ifndef LLVM_MC_MCCONTEXT_H
10#define LLVM_MC_MCCONTEXT_H
11
12#include "llvm/ADT/DenseMap.h"
13#include "llvm/ADT/SetVector.h"
15#include "llvm/ADT/StringMap.h"
16#include "llvm/ADT/StringRef.h"
17#include "llvm/ADT/Twine.h"
20#include "llvm/MC/MCAsmMacro.h"
21#include "llvm/MC/MCDwarf.h"
23#include "llvm/MC/MCSection.h"
24#include "llvm/MC/SectionKind.h"
27#include "llvm/Support/Error.h"
28#include "llvm/Support/MD5.h"
30#include <algorithm>
31#include <cassert>
32#include <cstddef>
33#include <cstdint>
34#include <functional>
35#include <map>
36#include <memory>
37#include <optional>
38#include <string>
39#include <utility>
40#include <vector>
41
42namespace llvm {
43
44class CodeViewContext;
45class MCAsmInfo;
46class MCInst;
47class MCLabel;
48class MCObjectFileInfo;
49class MCRegisterInfo;
50class MCSection;
51class MCSectionCOFF;
52class MCSectionDXContainer;
53class MCSectionELF;
54class MCSectionGOFF;
55class MCSectionMachO;
56class MCSectionSPIRV;
57class MCSectionWasm;
58class MCSectionXCOFF;
59class MCStreamer;
60class MCSubtargetInfo;
61class MCSymbol;
62class MCSymbolELF;
63class MCSymbolWasm;
64class MCSymbolXCOFF;
65class MCTargetOptions;
66class MDNode;
67template <typename T> class SmallVectorImpl;
68class SMDiagnostic;
69class SMLoc;
70class SourceMgr;
71enum class EmitDwarfUnwindType;
72
73/// Context object for machine code objects. This class owns all of the
74/// sections that it creates.
75///
76class MCContext {
77public:
80 std::function<void(const SMDiagnostic &, bool, const SourceMgr &,
81 std::vector<const MDNode *> &)>;
91 };
92
93private:
94 Environment Env;
95
96 /// The name of the Segment where Swift5 Reflection Section data will be
97 /// outputted
98 StringRef Swift5ReflectionSegmentName;
99
100 /// The triple for this object.
101 Triple TT;
102
103 /// The SourceMgr for this object, if any.
104 const SourceMgr *SrcMgr = nullptr;
105
106 /// The SourceMgr for inline assembly, if any.
107 std::unique_ptr<SourceMgr> InlineSrcMgr;
108 std::vector<const MDNode *> LocInfos;
109
110 DiagHandlerTy DiagHandler;
111
112 /// The MCAsmInfo for this target.
113 const MCAsmInfo *MAI = nullptr;
114
115 /// The MCRegisterInfo for this target.
116 const MCRegisterInfo *MRI = nullptr;
117
118 /// The MCObjectFileInfo for this target.
119 const MCObjectFileInfo *MOFI = nullptr;
120
121 /// The MCSubtargetInfo for this target.
122 const MCSubtargetInfo *MSTI = nullptr;
123
124 std::unique_ptr<CodeViewContext> CVContext;
125
126 /// Allocator object used for creating machine code objects.
127 ///
128 /// We use a bump pointer allocator to avoid the need to track all allocated
129 /// objects.
130 BumpPtrAllocator Allocator;
131
140 SpecificBumpPtrAllocator<MCInst> MCInstAllocator;
141
142 /// Bindings of names to symbols.
143 SymbolTable Symbols;
144
145 /// A mapping from a local label number and an instance count to a symbol.
146 /// For example, in the assembly
147 /// 1:
148 /// 2:
149 /// 1:
150 /// We have three labels represented by the pairs (1, 0), (2, 0) and (1, 1)
152
153 /// Keeps tracks of names that were used both for used declared and
154 /// artificial symbols. The value is "true" if the name has been used for a
155 /// non-section symbol (there can be at most one of those, plus an unlimited
156 /// number of section symbols with the same name).
158
159 /// Keeps track of labels that are used in inline assembly.
160 SymbolTable InlineAsmUsedLabelNames;
161
162 /// The next ID to dole out to an unnamed assembler temporary symbol with
163 /// a given prefix.
164 StringMap<unsigned> NextID;
165
166 /// Instances of directional local labels.
168 /// NextInstance() creates the next instance of the directional local label
169 /// for the LocalLabelVal and adds it to the map if needed.
170 unsigned NextInstance(unsigned LocalLabelVal);
171 /// GetInstance() gets the current instance of the directional local label
172 /// for the LocalLabelVal and adds it to the map if needed.
173 unsigned GetInstance(unsigned LocalLabelVal);
174
175 /// LLVM_BB_ADDR_MAP version to emit.
176 uint8_t BBAddrMapVersion = 2;
177
178 /// The file name of the log file from the environment variable
179 /// AS_SECURE_LOG_FILE. Which must be set before the .secure_log_unique
180 /// directive is used or it is an error.
181 std::string SecureLogFile;
182 /// The stream that gets written to for the .secure_log_unique directive.
183 std::unique_ptr<raw_fd_ostream> SecureLog;
184 /// Boolean toggled when .secure_log_unique / .secure_log_reset is seen to
185 /// catch errors if .secure_log_unique appears twice without
186 /// .secure_log_reset appearing between them.
187 bool SecureLogUsed = false;
188
189 /// The compilation directory to use for DW_AT_comp_dir.
190 SmallString<128> CompilationDir;
191
192 /// Prefix replacement map for source file information.
194
195 /// The main file name if passed in explicitly.
196 std::string MainFileName;
197
198 /// The dwarf file and directory tables from the dwarf .file directive.
199 /// We now emit a line table for each compile unit. To reduce the prologue
200 /// size of each line table, the files and directories used by each compile
201 /// unit are separated.
202 std::map<unsigned, MCDwarfLineTable> MCDwarfLineTablesCUMap;
203
204 /// The current dwarf line information from the last dwarf .loc directive.
205 MCDwarfLoc CurrentDwarfLoc;
206 bool DwarfLocSeen = false;
207
208 /// Generate dwarf debugging info for assembly source files.
209 bool GenDwarfForAssembly = false;
210
211 /// The current dwarf file number when generate dwarf debugging info for
212 /// assembly source files.
213 unsigned GenDwarfFileNumber = 0;
214
215 /// Sections for generating the .debug_ranges and .debug_aranges sections.
216 SetVector<MCSection *> SectionsForRanges;
217
218 /// The information gathered from labels that will have dwarf label
219 /// entries when generating dwarf assembly source files.
220 std::vector<MCGenDwarfLabelEntry> MCGenDwarfLabelEntries;
221
222 /// The string to embed in the debug information for the compile unit, if
223 /// non-empty.
224 StringRef DwarfDebugFlags;
225
226 /// The string to embed in as the dwarf AT_producer for the compile unit, if
227 /// non-empty.
228 StringRef DwarfDebugProducer;
229
230 /// The maximum version of dwarf that we should emit.
231 uint16_t DwarfVersion = 4;
232
233 /// The format of dwarf that we emit.
235
236 /// Honor temporary labels, this is useful for debugging semantic
237 /// differences between temporary and non-temporary labels (primarily on
238 /// Darwin).
239 bool AllowTemporaryLabels = true;
240 bool UseNamesOnTempLabels = false;
241
242 /// The Compile Unit ID that we are currently processing.
243 unsigned DwarfCompileUnitID = 0;
244
245 /// A collection of MCPseudoProbe in the current module
246 MCPseudoProbeTable PseudoProbeTable;
247
248 // Sections are differentiated by the quadruple (section_name, group_name,
249 // unique_id, link_to_symbol_name). Sections sharing the same quadruple are
250 // combined into one section.
251 struct ELFSectionKey {
252 std::string SectionName;
253 StringRef GroupName;
254 StringRef LinkedToName;
255 unsigned UniqueID;
256
257 ELFSectionKey(StringRef SectionName, StringRef GroupName,
258 StringRef LinkedToName, unsigned UniqueID)
259 : SectionName(SectionName), GroupName(GroupName),
260 LinkedToName(LinkedToName), UniqueID(UniqueID) {}
261
262 bool operator<(const ELFSectionKey &Other) const {
263 if (SectionName != Other.SectionName)
264 return SectionName < Other.SectionName;
265 if (GroupName != Other.GroupName)
266 return GroupName < Other.GroupName;
267 if (int O = LinkedToName.compare(Other.LinkedToName))
268 return O < 0;
269 return UniqueID < Other.UniqueID;
270 }
271 };
272
273 struct COFFSectionKey {
274 std::string SectionName;
275 StringRef GroupName;
276 int SelectionKey;
277 unsigned UniqueID;
278
279 COFFSectionKey(StringRef SectionName, StringRef GroupName, int SelectionKey,
280 unsigned UniqueID)
281 : SectionName(SectionName), GroupName(GroupName),
282 SelectionKey(SelectionKey), UniqueID(UniqueID) {}
283
284 bool operator<(const COFFSectionKey &Other) const {
285 if (SectionName != Other.SectionName)
286 return SectionName < Other.SectionName;
287 if (GroupName != Other.GroupName)
288 return GroupName < Other.GroupName;
289 if (SelectionKey != Other.SelectionKey)
290 return SelectionKey < Other.SelectionKey;
291 return UniqueID < Other.UniqueID;
292 }
293 };
294
295 struct WasmSectionKey {
296 std::string SectionName;
297 StringRef GroupName;
298 unsigned UniqueID;
299
300 WasmSectionKey(StringRef SectionName, StringRef GroupName,
301 unsigned UniqueID)
302 : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {}
303
304 bool operator<(const WasmSectionKey &Other) const {
305 if (SectionName != Other.SectionName)
306 return SectionName < Other.SectionName;
307 if (GroupName != Other.GroupName)
308 return GroupName < Other.GroupName;
309 return UniqueID < Other.UniqueID;
310 }
311 };
312
313 struct XCOFFSectionKey {
314 // Section name.
315 std::string SectionName;
316 // Section property.
317 // For csect section, it is storage mapping class.
318 // For debug section, it is section type flags.
319 union {
320 XCOFF::StorageMappingClass MappingClass;
321 XCOFF::DwarfSectionSubtypeFlags DwarfSubtypeFlags;
322 };
323 bool IsCsect;
324
325 XCOFFSectionKey(StringRef SectionName,
326 XCOFF::StorageMappingClass MappingClass)
327 : SectionName(SectionName), MappingClass(MappingClass), IsCsect(true) {}
328
329 XCOFFSectionKey(StringRef SectionName,
330 XCOFF::DwarfSectionSubtypeFlags DwarfSubtypeFlags)
331 : SectionName(SectionName), DwarfSubtypeFlags(DwarfSubtypeFlags),
332 IsCsect(false) {}
333
334 bool operator<(const XCOFFSectionKey &Other) const {
335 if (IsCsect && Other.IsCsect)
336 return std::tie(SectionName, MappingClass) <
337 std::tie(Other.SectionName, Other.MappingClass);
338 if (IsCsect != Other.IsCsect)
339 return IsCsect;
340 return std::tie(SectionName, DwarfSubtypeFlags) <
341 std::tie(Other.SectionName, Other.DwarfSubtypeFlags);
342 }
343 };
344
345 StringMap<MCSectionMachO *> MachOUniquingMap;
346 std::map<ELFSectionKey, MCSectionELF *> ELFUniquingMap;
347 std::map<COFFSectionKey, MCSectionCOFF *> COFFUniquingMap;
348 std::map<std::string, MCSectionGOFF *> GOFFUniquingMap;
349 std::map<WasmSectionKey, MCSectionWasm *> WasmUniquingMap;
350 std::map<XCOFFSectionKey, MCSectionXCOFF *> XCOFFUniquingMap;
351 StringMap<MCSectionDXContainer *> DXCUniquingMap;
352 StringMap<bool> RelSecNames;
353
354 SpecificBumpPtrAllocator<MCSubtargetInfo> MCSubtargetAllocator;
355
356 /// Do automatic reset in destructor
357 bool AutoReset;
358
359 MCTargetOptions const *TargetOptions;
360
361 bool HadError = false;
362
363 void reportCommon(SMLoc Loc,
364 std::function<void(SMDiagnostic &, const SourceMgr *)>);
365
366 MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
367 bool CanBeUnnamed);
368 MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix,
369 bool IsTemporary);
370
371 MCSymbol *getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
372 unsigned Instance);
373
374 MCSectionELF *createELFSectionImpl(StringRef Section, unsigned Type,
375 unsigned Flags, SectionKind K,
376 unsigned EntrySize,
377 const MCSymbolELF *Group, bool IsComdat,
378 unsigned UniqueID,
379 const MCSymbolELF *LinkedToSym);
380
381 MCSymbolXCOFF *createXCOFFSymbolImpl(const StringMapEntry<bool> *Name,
382 bool IsTemporary);
383
384 /// Map of currently defined macros.
385 StringMap<MCAsmMacro> MacroMap;
386
387 struct ELFEntrySizeKey {
388 std::string SectionName;
389 unsigned Flags;
390 unsigned EntrySize;
391
392 ELFEntrySizeKey(StringRef SectionName, unsigned Flags, unsigned EntrySize)
393 : SectionName(SectionName), Flags(Flags), EntrySize(EntrySize) {}
394
395 bool operator<(const ELFEntrySizeKey &Other) const {
396 if (SectionName != Other.SectionName)
397 return SectionName < Other.SectionName;
398 if (Flags != Other.Flags)
399 return Flags < Other.Flags;
400 return EntrySize < Other.EntrySize;
401 }
402 };
403
404 // Symbols must be assigned to a section with a compatible entry size and
405 // flags. This map is used to assign unique IDs to sections to distinguish
406 // between sections with identical names but incompatible entry sizes and/or
407 // flags. This can occur when a symbol is explicitly assigned to a section,
408 // e.g. via __attribute__((section("myname"))).
409 std::map<ELFEntrySizeKey, unsigned> ELFEntrySizeMap;
410
411 // This set is used to record the generic mergeable section names seen.
412 // These are sections that are created as mergeable e.g. .debug_str. We need
413 // to avoid assigning non-mergeable symbols to these sections. It is used
414 // to prevent non-mergeable symbols being explicitly assigned to mergeable
415 // sections (e.g. via _attribute_((section("myname")))).
416 DenseSet<StringRef> ELFSeenGenericMergeableSections;
417
418public:
419 explicit MCContext(const Triple &TheTriple, const MCAsmInfo *MAI,
420 const MCRegisterInfo *MRI, const MCSubtargetInfo *MSTI,
421 const SourceMgr *Mgr = nullptr,
422 MCTargetOptions const *TargetOpts = nullptr,
423 bool DoAutoReset = true,
424 StringRef Swift5ReflSegmentName = {});
425 MCContext(const MCContext &) = delete;
426 MCContext &operator=(const MCContext &) = delete;
427 ~MCContext();
428
429 Environment getObjectFileType() const { return Env; }
430
432 return Swift5ReflectionSegmentName;
433 }
434 const Triple &getTargetTriple() const { return TT; }
435 const SourceMgr *getSourceManager() const { return SrcMgr; }
436
438 SourceMgr *getInlineSourceManager() { return InlineSrcMgr.get(); }
439 std::vector<const MDNode *> &getLocInfos() { return LocInfos; }
441 this->DiagHandler = DiagHandler;
442 }
443
444 void setObjectFileInfo(const MCObjectFileInfo *Mofi) { MOFI = Mofi; }
445
446 const MCAsmInfo *getAsmInfo() const { return MAI; }
447
448 const MCRegisterInfo *getRegisterInfo() const { return MRI; }
449
450 const MCObjectFileInfo *getObjectFileInfo() const { return MOFI; }
451
452 const MCSubtargetInfo *getSubtargetInfo() const { return MSTI; }
453
455
457
458 void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }
459 void setUseNamesOnTempLabels(bool Value) { UseNamesOnTempLabels = Value; }
460
461 /// \name Module Lifetime Management
462 /// @{
463
464 /// reset - return object to right after construction state to prepare
465 /// to process a new module
466 void reset();
467
468 /// @}
469
470 /// \name McInst Management
471
472 /// Create and return a new MC instruction.
474
475 /// \name Symbol Management
476 /// @{
477
478 /// Create a new linker temporary symbol with the specified prefix (Name) or
479 /// "tmp". This creates a "l"-prefixed symbol for Mach-O and is identical to
480 /// createNamedTempSymbol for other object file formats.
483
484 /// Create a temporary symbol with a unique name. The name will be omitted
485 /// in the symbol table if UseNamesOnTempLabels is false (default except
486 /// MCAsmStreamer). The overload without Name uses an unspecified name.
488 MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix = true);
489
490 /// Create a temporary symbol with a unique name whose name cannot be
491 /// omitted in the symbol table. This is rarely used.
494
495 /// Create the definition of a directional local symbol for numbered label
496 /// (used for "1:" definitions).
497 MCSymbol *createDirectionalLocalSymbol(unsigned LocalLabelVal);
498
499 /// Create and return a directional local symbol for numbered label (used
500 /// for "1b" or 1f" references).
501 MCSymbol *getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before);
502
503 /// Lookup the symbol inside with the specified \p Name. If it exists,
504 /// return it. If not, create a forward reference and return it.
505 ///
506 /// \param Name - The symbol name, which must be unique across all symbols.
508
509 /// Gets a symbol that will be defined to the final stack offset of a local
510 /// variable after codegen.
511 ///
512 /// \param Idx - The index of a local variable passed to \@llvm.localescape.
513 MCSymbol *getOrCreateFrameAllocSymbol(const Twine &FuncName, unsigned Idx);
514
516
517 MCSymbol *getOrCreateLSDASymbol(const Twine &FuncName);
518
519 /// Get the symbol for \p Name, or null.
520 MCSymbol *lookupSymbol(const Twine &Name) const;
521
522 /// Set value for a symbol.
523 void setSymbolValue(MCStreamer &Streamer, const Twine &Sym, uint64_t Val);
524
525 /// getSymbols - Get a reference for the symbol table for clients that
526 /// want to, for example, iterate over all symbols. 'const' because we
527 /// still want any modifications to the table itself to use the MCContext
528 /// APIs.
529 const SymbolTable &getSymbols() const { return Symbols; }
530
531 /// isInlineAsmLabel - Return true if the name is a label referenced in
532 /// inline assembly.
534 return InlineAsmUsedLabelNames.lookup(Name);
535 }
536
537 /// registerInlineAsmLabel - Records that the name is a label referenced in
538 /// inline assembly.
540
541 /// @}
542
543 /// \name Section Management
544 /// @{
545
546 enum : unsigned {
547 /// Pass this value as the UniqueID during section creation to get the
548 /// generic section with the given name and characteristics. The usual
549 /// sections such as .text use this ID.
550 GenericSectionID = ~0U
551 };
552
553 /// Return the MCSection for the specified mach-o section. This requires
554 /// the operands to be valid.
556 unsigned TypeAndAttributes,
557 unsigned Reserved2, SectionKind K,
558 const char *BeginSymName = nullptr);
559
561 unsigned TypeAndAttributes, SectionKind K,
562 const char *BeginSymName = nullptr) {
563 return getMachOSection(Segment, Section, TypeAndAttributes, 0, K,
564 BeginSymName);
565 }
566
567 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
568 unsigned Flags) {
569 return getELFSection(Section, Type, Flags, 0, "", false);
570 }
571
572 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
573 unsigned Flags, unsigned EntrySize) {
574 return getELFSection(Section, Type, Flags, EntrySize, "", false,
575 MCSection::NonUniqueID, nullptr);
576 }
577
578 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
579 unsigned Flags, unsigned EntrySize,
580 const Twine &Group, bool IsComdat) {
581 return getELFSection(Section, Type, Flags, EntrySize, Group, IsComdat,
582 MCSection::NonUniqueID, nullptr);
583 }
584
585 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
586 unsigned Flags, unsigned EntrySize,
587 const Twine &Group, bool IsComdat,
588 unsigned UniqueID,
589 const MCSymbolELF *LinkedToSym);
590
591 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
592 unsigned Flags, unsigned EntrySize,
593 const MCSymbolELF *Group, bool IsComdat,
594 unsigned UniqueID,
595 const MCSymbolELF *LinkedToSym);
596
597 /// Get a section with the provided group identifier. This section is
598 /// named by concatenating \p Prefix with '.' then \p Suffix. The \p Type
599 /// describes the type of the section and \p Flags are used to further
600 /// configure this named section.
601 MCSectionELF *getELFNamedSection(const Twine &Prefix, const Twine &Suffix,
602 unsigned Type, unsigned Flags,
603 unsigned EntrySize = 0);
604
606 unsigned Flags, unsigned EntrySize,
607 const MCSymbolELF *Group,
608 const MCSectionELF *RelInfoSection);
609
610 MCSectionELF *createELFGroupSection(const MCSymbolELF *Group, bool IsComdat);
611
613 unsigned UniqueID, unsigned EntrySize);
614
616
618
619 /// Return the unique ID of the section with the given name, flags and entry
620 /// size, if it exists.
621 std::optional<unsigned> getELFUniqueIDForEntsize(StringRef SectionName,
622 unsigned Flags,
623 unsigned EntrySize);
624
626 MCSection *Parent, const MCExpr *SubsectionId);
627
629 SectionKind Kind, StringRef COMDATSymName,
630 int Selection,
631 unsigned UniqueID = GenericSectionID,
632 const char *BeginSymName = nullptr);
633
635 SectionKind Kind,
636 const char *BeginSymName = nullptr);
637
638 /// Gets or creates a section equivalent to Sec that is associated with the
639 /// section containing KeySym. For example, to create a debug info section
640 /// associated with an inline function, pass the normal debug info section
641 /// as Sec and the function symbol as KeySym.
644 unsigned UniqueID = GenericSectionID);
645
647
649 unsigned Flags = 0) {
650 return getWasmSection(Section, K, Flags, nullptr);
651 }
652
654 unsigned Flags, const char *BeginSymName) {
655 return getWasmSection(Section, K, Flags, "", ~0, BeginSymName);
656 }
657
659 unsigned Flags, const Twine &Group,
660 unsigned UniqueID) {
661 return getWasmSection(Section, K, Flags, Group, UniqueID, nullptr);
662 }
663
665 unsigned Flags, const Twine &Group,
666 unsigned UniqueID, const char *BeginSymName);
667
669 unsigned Flags, const MCSymbolWasm *Group,
670 unsigned UniqueID, const char *BeginSymName);
671
672 /// Get the section for the provided Section name
674
675 bool hasXCOFFSection(StringRef Section,
676 XCOFF::CsectProperties CsectProp) const;
677
679 StringRef Section, SectionKind K,
680 std::optional<XCOFF::CsectProperties> CsectProp = std::nullopt,
681 bool MultiSymbolsAllowed = false, const char *BeginSymName = nullptr,
682 std::optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSubtypeFlags =
683 std::nullopt);
684
685 // Create and save a copy of STI and return a reference to the copy.
687
688 uint8_t getBBAddrMapVersion() const { return BBAddrMapVersion; }
689
690 /// @}
691
692 /// \name Dwarf Management
693 /// @{
694
695 /// Get the compilation directory for DW_AT_comp_dir
696 /// The compilation directory should be set with \c setCompilationDir before
697 /// calling this function. If it is unset, an empty string will be returned.
698 StringRef getCompilationDir() const { return CompilationDir; }
699
700 /// Set the compilation directory for DW_AT_comp_dir
701 void setCompilationDir(StringRef S) { CompilationDir = S.str(); }
702
703 /// Add an entry to the debug prefix map.
704 void addDebugPrefixMapEntry(const std::string &From, const std::string &To);
705
706 /// Remap one path in-place as per the debug prefix map.
708
709 // Remaps all debug directory paths in-place as per the debug prefix map.
710 void RemapDebugPaths();
711
712 /// Get the main file name for use in error messages and debug
713 /// info. This can be set to ensure we've got the correct file name
714 /// after preprocessing or for -save-temps.
715 const std::string &getMainFileName() const { return MainFileName; }
716
717 /// Set the main file name and override the default.
718 void setMainFileName(StringRef S) { MainFileName = std::string(S); }
719
720 /// Creates an entry in the dwarf file and directory tables.
722 unsigned FileNumber,
723 std::optional<MD5::MD5Result> Checksum,
724 std::optional<StringRef> Source,
725 unsigned CUID);
726
727 bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID = 0);
728
729 const std::map<unsigned, MCDwarfLineTable> &getMCDwarfLineTables() const {
730 return MCDwarfLineTablesCUMap;
731 }
732
734 return MCDwarfLineTablesCUMap[CUID];
735 }
736
737 const MCDwarfLineTable &getMCDwarfLineTable(unsigned CUID) const {
738 auto I = MCDwarfLineTablesCUMap.find(CUID);
739 assert(I != MCDwarfLineTablesCUMap.end());
740 return I->second;
741 }
742
745 }
746
748 return getMCDwarfLineTable(CUID).getMCDwarfDirs();
749 }
750
751 unsigned getDwarfCompileUnitID() { return DwarfCompileUnitID; }
752
753 void setDwarfCompileUnitID(unsigned CUIndex) { DwarfCompileUnitID = CUIndex; }
754
755 /// Specifies the "root" file and directory of the compilation unit.
756 /// These are "file 0" and "directory 0" in DWARF v5.
757 void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir,
758 StringRef Filename,
759 std::optional<MD5::MD5Result> Checksum,
760 std::optional<StringRef> Source) {
761 getMCDwarfLineTable(CUID).setRootFile(CompilationDir, Filename, Checksum,
762 Source);
763 }
764
765 /// Reports whether MD5 checksum usage is consistent (all-or-none).
766 bool isDwarfMD5UsageConsistent(unsigned CUID) const {
768 }
769
770 /// Saves the information from the currently parsed dwarf .loc directive
771 /// and sets DwarfLocSeen. When the next instruction is assembled an entry
772 /// in the line number table with this information and the address of the
773 /// instruction will be created.
774 void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column,
775 unsigned Flags, unsigned Isa,
776 unsigned Discriminator) {
777 CurrentDwarfLoc.setFileNum(FileNum);
778 CurrentDwarfLoc.setLine(Line);
779 CurrentDwarfLoc.setColumn(Column);
780 CurrentDwarfLoc.setFlags(Flags);
781 CurrentDwarfLoc.setIsa(Isa);
782 CurrentDwarfLoc.setDiscriminator(Discriminator);
783 DwarfLocSeen = true;
784 }
785
786 void clearDwarfLocSeen() { DwarfLocSeen = false; }
787
788 bool getDwarfLocSeen() { return DwarfLocSeen; }
789 const MCDwarfLoc &getCurrentDwarfLoc() { return CurrentDwarfLoc; }
790
791 bool getGenDwarfForAssembly() { return GenDwarfForAssembly; }
792 void setGenDwarfForAssembly(bool Value) { GenDwarfForAssembly = Value; }
793 unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }
796
797 void setGenDwarfFileNumber(unsigned FileNumber) {
798 GenDwarfFileNumber = FileNumber;
799 }
800
801 /// Specifies information about the "root file" for assembler clients
802 /// (e.g., llvm-mc). Assumes compilation dir etc. have been set up.
803 void setGenDwarfRootFile(StringRef FileName, StringRef Buffer);
804
806 return SectionsForRanges;
807 }
808
810 return SectionsForRanges.insert(Sec);
811 }
812
814
815 const std::vector<MCGenDwarfLabelEntry> &getMCGenDwarfLabelEntries() const {
816 return MCGenDwarfLabelEntries;
817 }
818
820 MCGenDwarfLabelEntries.push_back(E);
821 }
822
823 void setDwarfDebugFlags(StringRef S) { DwarfDebugFlags = S; }
824 StringRef getDwarfDebugFlags() { return DwarfDebugFlags; }
825
826 void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
827 StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
828
831
832 void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
833 uint16_t getDwarfVersion() const { return DwarfVersion; }
834
835 /// @}
836
837 StringRef getSecureLogFile() { return SecureLogFile; }
838 raw_fd_ostream *getSecureLog() { return SecureLog.get(); }
839
840 void setSecureLog(std::unique_ptr<raw_fd_ostream> Value) {
841 SecureLog = std::move(Value);
842 }
843
844 bool getSecureLogUsed() { return SecureLogUsed; }
845 void setSecureLogUsed(bool Value) { SecureLogUsed = Value; }
846
847 void *allocate(unsigned Size, unsigned Align = 8) {
848 return Allocator.Allocate(Size, Align);
849 }
850
851 void deallocate(void *Ptr) {}
852
853 bool hadError() { return HadError; }
854 void diagnose(const SMDiagnostic &SMD);
855 void reportError(SMLoc L, const Twine &Msg);
856 void reportWarning(SMLoc L, const Twine &Msg);
857
859 StringMap<MCAsmMacro>::iterator I = MacroMap.find(Name);
860 return (I == MacroMap.end()) ? nullptr : &I->getValue();
861 }
862
864 MacroMap.insert(std::make_pair(Name, std::move(Macro)));
865 }
866
867 void undefineMacro(StringRef Name) { MacroMap.erase(Name); }
868
869 MCPseudoProbeTable &getMCPseudoProbeTable() { return PseudoProbeTable; }
870};
871
872} // end namespace llvm
873
874// operator new and delete aren't allowed inside namespaces.
875// The throw specifications are mandated by the standard.
876/// Placement new for using the MCContext's allocator.
877///
878/// This placement form of operator new uses the MCContext's allocator for
879/// obtaining memory. It is a non-throwing new, which means that it returns
880/// null on error. (If that is what the allocator does. The current does, so if
881/// this ever changes, this operator will have to be changed, too.)
882/// Usage looks like this (assuming there's an MCContext 'Context' in scope):
883/// \code
884/// // Default alignment (8)
885/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
886/// // Specific alignment
887/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
888/// \endcode
889/// Please note that you cannot use delete on the pointer; it must be
890/// deallocated using an explicit destructor call followed by
891/// \c Context.Deallocate(Ptr).
892///
893/// \param Bytes The number of bytes to allocate. Calculated by the compiler.
894/// \param C The MCContext that provides the allocator.
895/// \param Alignment The alignment of the allocated memory (if the underlying
896/// allocator supports it).
897/// \return The allocated memory. Could be NULL.
898inline void *operator new(size_t Bytes, llvm::MCContext &C,
899 size_t Alignment = 8) noexcept {
900 return C.allocate(Bytes, Alignment);
901}
902/// Placement delete companion to the new above.
903///
904/// This operator is just a companion to the new above. There is no way of
905/// invoking it directly; see the new operator for more details. This operator
906/// is called implicitly by the compiler if a placement new expression using
907/// the MCContext throws in the object constructor.
908inline void operator delete(void *Ptr, llvm::MCContext &C, size_t) noexcept {
909 C.deallocate(Ptr);
910}
911
912/// This placement form of operator new[] uses the MCContext's allocator for
913/// obtaining memory. It is a non-throwing new[], which means that it returns
914/// null on error.
915/// Usage looks like this (assuming there's an MCContext 'Context' in scope):
916/// \code
917/// // Default alignment (8)
918/// char *data = new (Context) char[10];
919/// // Specific alignment
920/// char *data = new (Context, 4) char[10];
921/// \endcode
922/// Please note that you cannot use delete on the pointer; it must be
923/// deallocated using an explicit destructor call followed by
924/// \c Context.Deallocate(Ptr).
925///
926/// \param Bytes The number of bytes to allocate. Calculated by the compiler.
927/// \param C The MCContext that provides the allocator.
928/// \param Alignment The alignment of the allocated memory (if the underlying
929/// allocator supports it).
930/// \return The allocated memory. Could be NULL.
931inline void *operator new[](size_t Bytes, llvm::MCContext &C,
932 size_t Alignment = 8) noexcept {
933 return C.allocate(Bytes, Alignment);
934}
935
936/// Placement delete[] companion to the new[] above.
937///
938/// This operator is just a companion to the new[] above. There is no way of
939/// invoking it directly; see the new[] operator for more details. This operator
940/// is called implicitly by the compiler if a placement new[] expression using
941/// the MCContext throws in the object constructor.
942inline void operator delete[](void *Ptr, llvm::MCContext &C) noexcept {
943 C.deallocate(Ptr);
944}
945
946#endif // LLVM_MC_MCCONTEXT_H
unsigned const MachineRegisterInfo * MRI
This file defines the StringMap class.
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
This file defines the BumpPtrAllocator interface.
basic Basic Alias true
BlockVerifier::State From
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
COFFYAML::WeakExternalCharacteristics Characteristics
Definition: COFFYAML.cpp:331
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
This file contains constants used for implementing Dwarf debug support.
std::string Name
uint64_t Size
Symbol * Sym
Definition: ELF_riscv.cpp:479
#define I(x, y, z)
Definition: MD5.cpp:58
Basic Register Allocator
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallString class.
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
Holds state from .cv_file and .cv_loc directives for later emission.
Definition: MCCodeView.h:144
Tagged union holding either a T or a Error.
Definition: Error.h:474
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
Context object for machine code objects.
Definition: MCContext.h:76
MCPseudoProbeTable & getMCPseudoProbeTable()
Definition: MCContext.h:869
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:450
void remapDebugPath(SmallVectorImpl< char > &Path)
Remap one path in-place as per the debug prefix map.
Definition: MCContext.cpp:893
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Definition: MCContext.cpp:884
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, const char *BeginSymName=nullptr)
Return the MCSection for the specified mach-o section.
Definition: MCContext.cpp:437
void * allocate(unsigned Size, unsigned Align=8)
Definition: MCContext.h:847
const SetVector< MCSection * > & getGenDwarfSectionSyms()
Definition: MCContext.h:805
void deallocate(void *Ptr)
Definition: MCContext.h:851
const SmallVectorImpl< std::string > & getMCDwarfDirs(unsigned CUID=0)
Definition: MCContext.h:747
Environment getObjectFileType() const
Definition: MCContext.h:429
bool isDwarfMD5UsageConsistent(unsigned CUID) const
Reports whether MD5 checksum usage is consistent (all-or-none).
Definition: MCContext.h:766
void setObjectFileInfo(const MCObjectFileInfo *Mofi)
Definition: MCContext.h:444
const MCAsmMacro * lookupMacro(StringRef Name)
Definition: MCContext.h:858
bool hadError()
Definition: MCContext.h:853
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags, const char *BeginSymName)
Definition: MCContext.h:653
StringRef getDwarfDebugProducer()
Definition: MCContext.h:827
void setSymbolValue(MCStreamer &Streamer, const Twine &Sym, uint64_t Val)
Set value for a symbol.
Definition: MCContext.cpp:368
const std::string & getMainFileName() const
Get the main file name for use in error messages and debug info.
Definition: MCContext.h:715
StringRef getDwarfDebugFlags()
Definition: MCContext.h:824
bool getDwarfLocSeen()
Definition: MCContext.h:788
void addDebugPrefixMapEntry(const std::string &From, const std::string &To)
Add an entry to the debug prefix map.
Definition: MCContext.cpp:888
MCContext(const MCContext &)=delete
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Definition: MCContext.cpp:321
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir The compilation directory should be set with setComp...
Definition: MCContext.h:698
bool getGenDwarfForAssembly()
Definition: MCContext.h:791
void RemapDebugPaths()
Definition: MCContext.cpp:899
MCInst * createMCInst()
Create and return a new MC instruction.
Definition: MCContext.cpp:192
MCSymbol * getOrCreateFrameAllocSymbol(const Twine &FuncName, unsigned Idx)
Gets a symbol that will be defined to the final stack offset of a local variable after codegen.
Definition: MCContext.cpp:213
MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *RelInfoSection)
Definition: MCContext.cpp:504
void setSecureLogUsed(bool Value)
Definition: MCContext.h:845
void defineMacro(StringRef Name, MCAsmMacro Macro)
Definition: MCContext.h:863
MCSymbol * createLinkerPrivateTempSymbol()
Create a new linker temporary symbol with the specified prefix (Name) or "tmp".
Definition: MCContext.cpp:311
void setAllowTemporaryLabels(bool Value)
Definition: MCContext.h:458
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
Definition: MCContext.h:648
void recordELFMergeableSectionInfo(StringRef SectionName, unsigned Flags, unsigned UniqueID, unsigned EntrySize)
Definition: MCContext.cpp:614
MCSymbol * getInlineAsmLabel(StringRef Name) const
isInlineAsmLabel - Return true if the name is a label referenced in inline assembly.
Definition: MCContext.h:533
Expected< unsigned > getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
Definition: MCContext.cpp:981
MCSectionELF * getELFNamedSection(const Twine &Prefix, const Twine &Suffix, unsigned Type, unsigned Flags, unsigned EntrySize=0)
Get a section with the provided group identifier.
Definition: MCContext.cpp:516
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize, const Twine &Group, bool IsComdat)
Definition: MCContext.h:578
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize)
Definition: MCContext.h:572
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:567
void setGenDwarfForAssembly(bool Value)
Definition: MCContext.h:792
uint8_t getBBAddrMapVersion() const
Definition: MCContext.h:688
void diagnose(const SMDiagnostic &SMD)
Definition: MCContext.cpp:1019
bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID=0)
isValidDwarfFileNumber - takes a dwarf file number and returns true if it currently is assigned and f...
Definition: MCContext.cpp:992
void setDwarfVersion(uint16_t v)
Definition: MCContext.h:832
void clearDwarfLocSeen()
Definition: MCContext.h:786
StringMap< MCSymbol *, BumpPtrAllocator & > SymbolTable
Definition: MCContext.h:78
const StringRef & getSwift5ReflectionSegmentName() const
Definition: MCContext.h:431
void registerInlineAsmLabel(MCSymbol *Sym)
registerInlineAsmLabel - Records that the name is a label referenced in inline assembly.
Definition: MCContext.cpp:374
bool addGenDwarfSection(MCSection *Sec)
Definition: MCContext.h:809
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:733
bool getSecureLogUsed()
Definition: MCContext.h:844
raw_fd_ostream * getSecureLog()
Definition: MCContext.h:838
void initInlineSourceManager()
Definition: MCContext.cpp:125
void setDiagnosticHandler(DiagHandlerTy DiagHandler)
Definition: MCContext.h:440
unsigned getDwarfCompileUnitID()
Definition: MCContext.h:751
MCSymbol * getOrCreateParentFrameOffsetSymbol(const Twine &FuncName)
Definition: MCContext.cpp:219
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
Definition: MCContext.cpp:362
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags, const Twine &Group, unsigned UniqueID)
Definition: MCContext.h:658
bool emitCompactUnwindNonCanonical() const
Definition: MCContext.cpp:934
void undefineMacro(StringRef Name)
Definition: MCContext.h:867
CodeViewContext & getCVContext()
Definition: MCContext.cpp:1009
const MCRegisterInfo * getRegisterInfo() const
Definition: MCContext.h:448
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
Definition: MCContext.h:743
void reset()
reset - return object to right after construction state to prepare to process a new module
Definition: MCContext.cpp:134
void setDwarfFormat(dwarf::DwarfFormat f)
Definition: MCContext.h:829
void setCompilationDir(StringRef S)
Set the compilation directory for DW_AT_comp_dir.
Definition: MCContext.h:701
const std::map< unsigned, MCDwarfLineTable > & getMCDwarfLineTables() const
Definition: MCContext.h:729
bool isELFGenericMergeableSection(StringRef Name)
Definition: MCContext.cpp:635
unsigned getGenDwarfFileNumber()
Definition: MCContext.h:793
void setDwarfDebugFlags(StringRef S)
Definition: MCContext.h:823
void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator)
Saves the information from the currently parsed dwarf .loc directive and sets DwarfLocSeen.
Definition: MCContext.h:774
MCContext(const Triple &TheTriple, const MCAsmInfo *MAI, const MCRegisterInfo *MRI, const MCSubtargetInfo *MSTI, const SourceMgr *Mgr=nullptr, MCTargetOptions const *TargetOpts=nullptr, bool DoAutoReset=true, StringRef Swift5ReflSegmentName={})
Definition: MCContext.cpp:66
@ GenericSectionID
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
Definition: MCContext.h:550
MCSectionXCOFF * getXCOFFSection(StringRef Section, SectionKind K, std::optional< XCOFF::CsectProperties > CsectProp=std::nullopt, bool MultiSymbolsAllowed=false, const char *BeginSymName=nullptr, std::optional< XCOFF::DwarfSectionSubtypeFlags > DwarfSubtypeFlags=std::nullopt)
Definition: MCContext.cpp:779
void setDwarfDebugProducer(StringRef S)
Definition: MCContext.h:826
std::optional< unsigned > getELFUniqueIDForEntsize(StringRef SectionName, unsigned Flags, unsigned EntrySize)
Return the unique ID of the section with the given name, flags and entry size, if it exists.
Definition: MCContext.cpp:641
MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions).
Definition: MCContext.cpp:349
void reportWarning(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1071
uint16_t getDwarfVersion() const
Definition: MCContext.h:833
const SourceMgr * getSourceManager() const
Definition: MCContext.h:435
const SymbolTable & getSymbols() const
getSymbols - Get a reference for the symbol table for clients that want to, for example,...
Definition: MCContext.h:529
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:446
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionsForRanges, to avoid generating useless debug info for them.
Definition: MCContext.cpp:1004
void setSecureLog(std::unique_ptr< raw_fd_ostream > Value)
Definition: MCContext.h:840
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1064
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
Definition: MCContext.cpp:667
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E)
Definition: MCContext.h:819
MCSymbol * getOrCreateLSDASymbol(const Twine &FuncName)
Definition: MCContext.cpp:224
MCSectionDXContainer * getDXContainerSection(StringRef Section, SectionKind K)
Get the section for the provided Section name.
Definition: MCContext.cpp:861
MCContext & operator=(const MCContext &)=delete
bool hasXCOFFSection(StringRef Section, XCOFF::CsectProperties CsectProp) const
Definition: MCContext.cpp:773
void setMainFileName(StringRef S)
Set the main file name and override the default.
Definition: MCContext.h:718
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:200
SourceMgr * getInlineSourceManager()
Definition: MCContext.h:438
MCSymbol * createLinkerPrivateSymbol(const Twine &Name)
Definition: MCContext.cpp:315
void setGenDwarfFileNumber(unsigned FileNumber)
Definition: MCContext.h:797
MCSectionSPIRV * getSPIRVSection()
Definition: MCContext.cpp:849
const MCTargetOptions * getTargetOptions() const
Definition: MCContext.h:454
void setDwarfCompileUnitID(unsigned CUIndex)
Definition: MCContext.h:753
const MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID) const
Definition: MCContext.h:737
EmitDwarfUnwindType emitDwarfUnwindInfo() const
Definition: MCContext.cpp:928
bool isELFImplicitMergeableSectionNamePrefix(StringRef Name)
Definition: MCContext.cpp:630
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group, bool IsComdat)
Definition: MCContext.cpp:607
void setUseNamesOnTempLabels(bool Value)
Definition: MCContext.h:459
std::function< void(const SMDiagnostic &, bool, const SourceMgr &, std::vector< const MDNode * > &)> DiagHandlerTy
Definition: MCContext.h:81
const MCDwarfLoc & getCurrentDwarfLoc()
Definition: MCContext.h:789
void setGenDwarfRootFile(StringRef FileName, StringRef Buffer)
Specifies information about the "root file" for assembler clients (e.g., llvm-mc).
Definition: MCContext.cpp:940
dwarf::DwarfFormat getDwarfFormat() const
Definition: MCContext.h:830
const std::vector< MCGenDwarfLabelEntry > & getMCGenDwarfLabelEntries() const
Definition: MCContext.h:815
MCSectionGOFF * getGOFFSection(StringRef Section, SectionKind Kind, MCSection *Parent, const MCExpr *SubsectionId)
Definition: MCContext.cpp:649
StringRef getSecureLogFile()
Definition: MCContext.h:837
MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=GenericSectionID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym.
Definition: MCContext.cpp:706
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, SectionKind K, const char *BeginSymName=nullptr)
Definition: MCContext.h:560
std::vector< const MDNode * > & getLocInfos()
Definition: MCContext.h:439
void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir, StringRef Filename, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
Specifies the "root" file and directory of the compilation unit.
Definition: MCContext.h:757
MCSymbol * getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before)
Create and return a directional local symbol for numbered label (used for "1b" or 1f" references).
Definition: MCContext.cpp:354
const MCSubtargetInfo * getSubtargetInfo() const
Definition: MCContext.h:452
MCSymbol * createNamedTempSymbol()
Create a temporary symbol with a unique name whose name cannot be omitted in the symbol table.
Definition: MCContext.cpp:323
const Triple & getTargetTriple() const
Definition: MCContext.h:434
bool isMD5UsageConsistent() const
Definition: MCDwarf.h:400
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
Definition: MCDwarf.h:410
void setRootFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
Definition: MCDwarf.h:380
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Definition: MCDwarf.h:418
Instances of this class represent the information from a dwarf .loc directive.
Definition: MCDwarf.h:105
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
Definition: MCDwarf.h:157
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
Definition: MCDwarf.h:172
void setDiscriminator(unsigned discriminator)
Set the Discriminator of this MCDwarfLoc.
Definition: MCDwarf.h:178
void setFlags(unsigned flags)
Set the Flags of this MCDwarfLoc.
Definition: MCDwarf.h:166
void setColumn(unsigned column)
Set the Column of this MCDwarfLoc.
Definition: MCDwarf.h:160
void setFileNum(unsigned fileNum)
Set the FileNum of this MCDwarfLoc.
Definition: MCDwarf.h:154
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This represents a section on Windows.
Definition: MCSectionCOFF.h:26
This represents a section on linux, lots of unix variants and some bare metal systems.
Definition: MCSectionELF.h:26
This represents a section on a Mach-O system (used by Mac OS X).
This represents a section on wasm.
Definition: MCSectionWasm.h:26
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
static constexpr unsigned NonUniqueID
Definition: MCSection.h:41
Streaming machine code generation interface.
Definition: MCStreamer.h:212
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:281
Represents a location in source code.
Definition: SMLoc.h:23
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
A vector that has set insertion semantics.
Definition: SetVector.h:57
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition: SetVector.h:162
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition: SourceMgr.h:31
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
Definition: Allocator.h:382
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:222
int compare(StringRef RHS) const
compare - Compare two strings; the result is negative, zero, or positive if this string is lexicograp...
Definition: StringRef.h:177
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:74
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:470
const char SectionName[]
Definition: AMDGPUPTNote.h:24
DwarfSectionSubtypeFlags
Values for defining the section subtype of sections of type STYP_DWARF as they would appear in the (s...
Definition: XCOFF.h:154
StorageMappingClass
Storage Mapping Class definitions.
Definition: XCOFF.h:103
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition: Dwarf.h:91
@ DWARF32
Definition: Dwarf.h:91
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:361
SourceMgr SrcMgr
Definition: Error.cpp:24
EmitDwarfUnwindType
@ Other
Any other memory.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39