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"
25#include "llvm/MC/SectionKind.h"
28#include "llvm/Support/Error.h"
29#include "llvm/Support/MD5.h"
32#include <algorithm>
33#include <cassert>
34#include <cstddef>
35#include <cstdint>
36#include <functional>
37#include <map>
38#include <memory>
39#include <optional>
40#include <string>
41#include <utility>
42#include <vector>
43
44namespace llvm {
45
46class CodeViewContext;
47class MCAsmInfo;
48class MCDataFragment;
49class MCInst;
50class MCLabel;
51class MCObjectFileInfo;
52class MCRegisterInfo;
53class MCSection;
54class MCSectionCOFF;
55class MCSectionDXContainer;
56class MCSectionELF;
57class MCSectionGOFF;
58class MCSectionMachO;
59class MCSectionSPIRV;
60class MCSectionWasm;
61class MCSectionXCOFF;
62class MCStreamer;
63class MCSubtargetInfo;
64class MCSymbol;
65class MCSymbolELF;
66class MCSymbolWasm;
67class MCSymbolXCOFF;
68class MCTargetOptions;
69class MDNode;
70template <typename T> class SmallVectorImpl;
71class SMDiagnostic;
72class SMLoc;
73class SourceMgr;
74enum class EmitDwarfUnwindType;
75
76namespace wasm {
77struct WasmSignature;
78}
79
80/// Context object for machine code objects. This class owns all of the
81/// sections that it creates.
82///
83class MCContext {
84public:
87 std::function<void(const SMDiagnostic &, bool, const SourceMgr &,
88 std::vector<const MDNode *> &)>;
98 };
99
100private:
101 Environment Env;
102
103 /// The name of the Segment where Swift5 Reflection Section data will be
104 /// outputted
105 StringRef Swift5ReflectionSegmentName;
106
107 /// The triple for this object.
108 Triple TT;
109
110 /// The SourceMgr for this object, if any.
111 const SourceMgr *SrcMgr = nullptr;
112
113 /// The SourceMgr for inline assembly, if any.
114 std::unique_ptr<SourceMgr> InlineSrcMgr;
115 std::vector<const MDNode *> LocInfos;
116
117 DiagHandlerTy DiagHandler;
118
119 /// The MCAsmInfo for this target.
120 const MCAsmInfo *MAI = nullptr;
121
122 /// The MCRegisterInfo for this target.
123 const MCRegisterInfo *MRI = nullptr;
124
125 /// The MCObjectFileInfo for this target.
126 const MCObjectFileInfo *MOFI = nullptr;
127
128 /// The MCSubtargetInfo for this target.
129 const MCSubtargetInfo *MSTI = nullptr;
130
131 std::unique_ptr<CodeViewContext> CVContext;
132
133 /// Allocator object used for creating machine code objects.
134 ///
135 /// We use a bump pointer allocator to avoid the need to track all allocated
136 /// objects.
137 BumpPtrAllocator Allocator;
138
139 /// For MCFragment instances.
140 BumpPtrAllocator FragmentAllocator;
141
150 SpecificBumpPtrAllocator<MCInst> MCInstAllocator;
151
153
154 /// Bindings of names to symbol table values.
155 SymbolTable Symbols;
156
157 /// A mapping from a local label number and an instance count to a symbol.
158 /// For example, in the assembly
159 /// 1:
160 /// 2:
161 /// 1:
162 /// We have three labels represented by the pairs (1, 0), (2, 0) and (1, 1)
164
165 /// Keeps track of labels that are used in inline assembly.
166 StringMap<MCSymbol *, BumpPtrAllocator &> InlineAsmUsedLabelNames;
167
168 /// Instances of directional local labels.
170 /// NextInstance() creates the next instance of the directional local label
171 /// for the LocalLabelVal and adds it to the map if needed.
172 unsigned NextInstance(unsigned LocalLabelVal);
173 /// GetInstance() gets the current instance of the directional local label
174 /// for the LocalLabelVal and adds it to the map if needed.
175 unsigned GetInstance(unsigned LocalLabelVal);
176
177 /// LLVM_BB_ADDR_MAP version to emit.
178 uint8_t BBAddrMapVersion = 2;
179
180 /// The file name of the log file from the environment variable
181 /// AS_SECURE_LOG_FILE. Which must be set before the .secure_log_unique
182 /// directive is used or it is an error.
183 std::string SecureLogFile;
184 /// The stream that gets written to for the .secure_log_unique directive.
185 std::unique_ptr<raw_fd_ostream> SecureLog;
186 /// Boolean toggled when .secure_log_unique / .secure_log_reset is seen to
187 /// catch errors if .secure_log_unique appears twice without
188 /// .secure_log_reset appearing between them.
189 bool SecureLogUsed = false;
190
191 /// The compilation directory to use for DW_AT_comp_dir.
192 SmallString<128> CompilationDir;
193
194 /// Prefix replacement map for source file information.
196
197 /// The main file name if passed in explicitly.
198 std::string MainFileName;
199
200 /// The dwarf file and directory tables from the dwarf .file directive.
201 /// We now emit a line table for each compile unit. To reduce the prologue
202 /// size of each line table, the files and directories used by each compile
203 /// unit are separated.
204 std::map<unsigned, MCDwarfLineTable> MCDwarfLineTablesCUMap;
205
206 /// The current dwarf line information from the last dwarf .loc directive.
207 MCDwarfLoc CurrentDwarfLoc;
208 bool DwarfLocSeen = false;
209
210 /// Generate dwarf debugging info for assembly source files.
211 bool GenDwarfForAssembly = false;
212
213 /// The current dwarf file number when generate dwarf debugging info for
214 /// assembly source files.
215 unsigned GenDwarfFileNumber = 0;
216
217 /// Sections for generating the .debug_ranges and .debug_aranges sections.
218 SetVector<MCSection *> SectionsForRanges;
219
220 /// The information gathered from labels that will have dwarf label
221 /// entries when generating dwarf assembly source files.
222 std::vector<MCGenDwarfLabelEntry> MCGenDwarfLabelEntries;
223
224 /// The string to embed in the debug information for the compile unit, if
225 /// non-empty.
226 StringRef DwarfDebugFlags;
227
228 /// The string to embed in as the dwarf AT_producer for the compile unit, if
229 /// non-empty.
230 StringRef DwarfDebugProducer;
231
232 /// The maximum version of dwarf that we should emit.
233 uint16_t DwarfVersion = 4;
234
235 /// The format of dwarf that we emit.
237
238 /// Honor temporary labels, this is useful for debugging semantic
239 /// differences between temporary and non-temporary labels (primarily on
240 /// Darwin).
241 bool SaveTempLabels = false;
242 bool UseNamesOnTempLabels = false;
243
244 /// The Compile Unit ID that we are currently processing.
245 unsigned DwarfCompileUnitID = 0;
246
247 /// A collection of MCPseudoProbe in the current module
248 MCPseudoProbeTable PseudoProbeTable;
249
250 struct COFFSectionKey {
251 std::string SectionName;
252 StringRef GroupName;
253 int SelectionKey;
254 unsigned UniqueID;
255
256 COFFSectionKey(StringRef SectionName, StringRef GroupName, int SelectionKey,
257 unsigned UniqueID)
258 : SectionName(SectionName), GroupName(GroupName),
259 SelectionKey(SelectionKey), UniqueID(UniqueID) {}
260
261 bool operator<(const COFFSectionKey &Other) const {
262 if (SectionName != Other.SectionName)
263 return SectionName < Other.SectionName;
264 if (GroupName != Other.GroupName)
265 return GroupName < Other.GroupName;
266 if (SelectionKey != Other.SelectionKey)
267 return SelectionKey < Other.SelectionKey;
268 return UniqueID < Other.UniqueID;
269 }
270 };
271
272 struct WasmSectionKey {
273 std::string SectionName;
274 StringRef GroupName;
275 unsigned UniqueID;
276
277 WasmSectionKey(StringRef SectionName, StringRef GroupName,
278 unsigned UniqueID)
279 : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {}
280
281 bool operator<(const WasmSectionKey &Other) const {
282 if (SectionName != Other.SectionName)
283 return SectionName < Other.SectionName;
284 if (GroupName != Other.GroupName)
285 return GroupName < Other.GroupName;
286 return UniqueID < Other.UniqueID;
287 }
288 };
289
290 struct XCOFFSectionKey {
291 // Section name.
292 std::string SectionName;
293 // Section property.
294 // For csect section, it is storage mapping class.
295 // For debug section, it is section type flags.
296 union {
297 XCOFF::StorageMappingClass MappingClass;
298 XCOFF::DwarfSectionSubtypeFlags DwarfSubtypeFlags;
299 };
300 bool IsCsect;
301
302 XCOFFSectionKey(StringRef SectionName,
303 XCOFF::StorageMappingClass MappingClass)
304 : SectionName(SectionName), MappingClass(MappingClass), IsCsect(true) {}
305
306 XCOFFSectionKey(StringRef SectionName,
307 XCOFF::DwarfSectionSubtypeFlags DwarfSubtypeFlags)
308 : SectionName(SectionName), DwarfSubtypeFlags(DwarfSubtypeFlags),
309 IsCsect(false) {}
310
311 bool operator<(const XCOFFSectionKey &Other) const {
312 if (IsCsect && Other.IsCsect)
313 return std::tie(SectionName, MappingClass) <
314 std::tie(Other.SectionName, Other.MappingClass);
315 if (IsCsect != Other.IsCsect)
316 return IsCsect;
317 return std::tie(SectionName, DwarfSubtypeFlags) <
318 std::tie(Other.SectionName, Other.DwarfSubtypeFlags);
319 }
320 };
321
322 StringMap<MCSectionMachO *> MachOUniquingMap;
323 std::map<COFFSectionKey, MCSectionCOFF *> COFFUniquingMap;
324 StringMap<MCSectionELF *> ELFUniquingMap;
325 std::map<std::string, MCSectionGOFF *> GOFFUniquingMap;
326 std::map<WasmSectionKey, MCSectionWasm *> WasmUniquingMap;
327 std::map<XCOFFSectionKey, MCSectionXCOFF *> XCOFFUniquingMap;
328 StringMap<MCSectionDXContainer *> DXCUniquingMap;
329 StringMap<bool> RelSecNames;
330
331 SpecificBumpPtrAllocator<MCSubtargetInfo> MCSubtargetAllocator;
332
333 /// Do automatic reset in destructor
334 bool AutoReset;
335
336 MCTargetOptions const *TargetOptions;
337
338 bool HadError = false;
339
340 void reportCommon(SMLoc Loc,
341 std::function<void(SMDiagnostic &, const SourceMgr *)>);
342
343 MCDataFragment *allocInitialFragment(MCSection &Sec);
344
345 MCSymbolTableEntry &getSymbolTableEntry(StringRef Name);
346
347 MCSymbol *createSymbolImpl(const MCSymbolTableEntry *Name, bool IsTemporary);
348 MCSymbol *createRenamableSymbol(const Twine &Name, bool AlwaysAddSuffix,
349 bool IsTemporary);
350
351 MCSymbol *getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
352 unsigned Instance);
353
354 template <typename Symbol>
355 Symbol *getOrCreateSectionSymbol(StringRef Section);
356
357 MCSectionELF *createELFSectionImpl(StringRef Section, unsigned Type,
358 unsigned Flags, unsigned EntrySize,
359 const MCSymbolELF *Group, bool IsComdat,
360 unsigned UniqueID,
361 const MCSymbolELF *LinkedToSym);
362
363 MCSymbolXCOFF *createXCOFFSymbolImpl(const MCSymbolTableEntry *Name,
364 bool IsTemporary);
365
366 /// Map of currently defined macros.
367 StringMap<MCAsmMacro> MacroMap;
368
369 // Symbols must be assigned to a section with a compatible entry size and
370 // flags. This map is used to assign unique IDs to sections to distinguish
371 // between sections with identical names but incompatible entry sizes and/or
372 // flags. This can occur when a symbol is explicitly assigned to a section,
373 // e.g. via __attribute__((section("myname"))). The map key is the tuple
374 // (section name, flags, entry size).
375 DenseMap<std::tuple<StringRef, unsigned, unsigned>, unsigned> ELFEntrySizeMap;
376
377 // This set is used to record the generic mergeable section names seen.
378 // These are sections that are created as mergeable e.g. .debug_str. We need
379 // to avoid assigning non-mergeable symbols to these sections. It is used
380 // to prevent non-mergeable symbols being explicitly assigned to mergeable
381 // sections (e.g. via _attribute_((section("myname")))).
382 DenseSet<StringRef> ELFSeenGenericMergeableSections;
383
384public:
385 explicit MCContext(const Triple &TheTriple, const MCAsmInfo *MAI,
386 const MCRegisterInfo *MRI, const MCSubtargetInfo *MSTI,
387 const SourceMgr *Mgr = nullptr,
388 MCTargetOptions const *TargetOpts = nullptr,
389 bool DoAutoReset = true,
390 StringRef Swift5ReflSegmentName = {});
391 MCContext(const MCContext &) = delete;
392 MCContext &operator=(const MCContext &) = delete;
393 ~MCContext();
394
395 Environment getObjectFileType() const { return Env; }
396
398 return Swift5ReflectionSegmentName;
399 }
400 const Triple &getTargetTriple() const { return TT; }
401 const SourceMgr *getSourceManager() const { return SrcMgr; }
402
404 SourceMgr *getInlineSourceManager() { return InlineSrcMgr.get(); }
405 std::vector<const MDNode *> &getLocInfos() { return LocInfos; }
407 this->DiagHandler = DiagHandler;
408 }
409
410 void setObjectFileInfo(const MCObjectFileInfo *Mofi) { MOFI = Mofi; }
411
412 const MCAsmInfo *getAsmInfo() const { return MAI; }
413
414 const MCRegisterInfo *getRegisterInfo() const { return MRI; }
415
416 const MCObjectFileInfo *getObjectFileInfo() const { return MOFI; }
417
418 const MCSubtargetInfo *getSubtargetInfo() const { return MSTI; }
419
421
423
424 void setUseNamesOnTempLabels(bool Value) { UseNamesOnTempLabels = Value; }
425
426 /// \name Module Lifetime Management
427 /// @{
428
429 /// reset - return object to right after construction state to prepare
430 /// to process a new module
431 void reset();
432
433 /// @}
434
435 /// \name McInst Management
436
437 /// Create and return a new MC instruction.
439
440 template <typename F, typename... Args> F *allocFragment(Args &&...args) {
441 return new (FragmentAllocator.Allocate(sizeof(F), alignof(F)))
442 F(std::forward<Args>(args)...);
443 }
444
445 /// \name Symbol Management
446 /// @{
447
448 /// Create a new linker temporary symbol with the specified prefix (Name) or
449 /// "tmp". This creates a "l"-prefixed symbol for Mach-O and is identical to
450 /// createNamedTempSymbol for other object file formats.
453
454 /// Create a temporary symbol with a unique name. The name will be omitted
455 /// in the symbol table if UseNamesOnTempLabels is false (default except
456 /// MCAsmStreamer). The overload without Name uses an unspecified name.
458 MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix = true);
459
460 /// Create a temporary symbol with a unique name whose name cannot be
461 /// omitted in the symbol table. This is rarely used.
464
465 /// Get or create a symbol for a basic block. For non-always-emit symbols,
466 /// this behaves like createTempSymbol, except that it uses the
467 /// PrivateLabelPrefix instead of the PrivateGlobalPrefix. When AlwaysEmit is
468 /// true, behaves like getOrCreateSymbol, prefixed with PrivateLabelPrefix.
469 MCSymbol *createBlockSymbol(const Twine &Name, bool AlwaysEmit = false);
470
471 /// Create the definition of a directional local symbol for numbered label
472 /// (used for "1:" definitions).
473 MCSymbol *createDirectionalLocalSymbol(unsigned LocalLabelVal);
474
475 /// Create and return a directional local symbol for numbered label (used
476 /// for "1b" or 1f" references).
477 MCSymbol *getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before);
478
479 /// Lookup the symbol inside with the specified \p Name. If it exists,
480 /// return it. If not, create a forward reference and return it.
481 ///
482 /// \param Name - The symbol name, which must be unique across all symbols.
484
485 /// Gets a symbol that will be defined to the final stack offset of a local
486 /// variable after codegen.
487 ///
488 /// \param Idx - The index of a local variable passed to \@llvm.localescape.
489 MCSymbol *getOrCreateFrameAllocSymbol(const Twine &FuncName, unsigned Idx);
490
492
493 MCSymbol *getOrCreateLSDASymbol(const Twine &FuncName);
494
495 /// Get the symbol for \p Name, or null.
496 MCSymbol *lookupSymbol(const Twine &Name) const;
497
498 /// Set value for a symbol.
499 void setSymbolValue(MCStreamer &Streamer, const Twine &Sym, uint64_t Val);
500
501 /// getSymbols - Get a reference for the symbol table for clients that
502 /// want to, for example, iterate over all symbols. 'const' because we
503 /// still want any modifications to the table itself to use the MCContext
504 /// APIs.
505 const SymbolTable &getSymbols() const { return Symbols; }
506
507 /// isInlineAsmLabel - Return true if the name is a label referenced in
508 /// inline assembly.
510 return InlineAsmUsedLabelNames.lookup(Name);
511 }
512
513 /// registerInlineAsmLabel - Records that the name is a label referenced in
514 /// inline assembly.
516
517 /// Allocates and returns a new `WasmSignature` instance (with empty parameter
518 /// and return type lists).
520
521 /// @}
522
523 /// \name Section Management
524 /// @{
525
526 enum : unsigned {
527 /// Pass this value as the UniqueID during section creation to get the
528 /// generic section with the given name and characteristics. The usual
529 /// sections such as .text use this ID.
530 GenericSectionID = ~0U
531 };
532
533 /// Return the MCSection for the specified mach-o section. This requires
534 /// the operands to be valid.
536 unsigned TypeAndAttributes,
537 unsigned Reserved2, SectionKind K,
538 const char *BeginSymName = nullptr);
539
541 unsigned TypeAndAttributes, SectionKind K,
542 const char *BeginSymName = nullptr) {
543 return getMachOSection(Segment, Section, TypeAndAttributes, 0, K,
544 BeginSymName);
545 }
546
547 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
548 unsigned Flags) {
549 return getELFSection(Section, Type, Flags, 0, "", false);
550 }
551
552 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
553 unsigned Flags, unsigned EntrySize) {
554 return getELFSection(Section, Type, Flags, EntrySize, "", false,
555 MCSection::NonUniqueID, nullptr);
556 }
557
558 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
559 unsigned Flags, unsigned EntrySize,
560 const Twine &Group, bool IsComdat) {
561 return getELFSection(Section, Type, Flags, EntrySize, Group, IsComdat,
562 MCSection::NonUniqueID, nullptr);
563 }
564
565 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
566 unsigned Flags, unsigned EntrySize,
567 const Twine &Group, bool IsComdat,
568 unsigned UniqueID,
569 const MCSymbolELF *LinkedToSym);
570
571 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
572 unsigned Flags, unsigned EntrySize,
573 const MCSymbolELF *Group, bool IsComdat,
574 unsigned UniqueID,
575 const MCSymbolELF *LinkedToSym);
576
577 /// Get a section with the provided group identifier. This section is
578 /// named by concatenating \p Prefix with '.' then \p Suffix. The \p Type
579 /// describes the type of the section and \p Flags are used to further
580 /// configure this named section.
581 MCSectionELF *getELFNamedSection(const Twine &Prefix, const Twine &Suffix,
582 unsigned Type, unsigned Flags,
583 unsigned EntrySize = 0);
584
586 unsigned Flags, unsigned EntrySize,
587 const MCSymbolELF *Group,
588 const MCSectionELF *RelInfoSection);
589
590 MCSectionELF *createELFGroupSection(const MCSymbolELF *Group, bool IsComdat);
591
593 unsigned UniqueID, unsigned EntrySize);
594
596
598
599 /// Return the unique ID of the section with the given name, flags and entry
600 /// size, if it exists.
601 std::optional<unsigned> getELFUniqueIDForEntsize(StringRef SectionName,
602 unsigned Flags,
603 unsigned EntrySize);
604
606 MCSection *Parent, uint32_t Subsection = 0);
607
609 StringRef COMDATSymName, int Selection,
610 unsigned UniqueID = GenericSectionID);
611
613
614 /// Gets or creates a section equivalent to Sec that is associated with the
615 /// section containing KeySym. For example, to create a debug info section
616 /// associated with an inline function, pass the normal debug info section
617 /// as Sec and the function symbol as KeySym.
620 unsigned UniqueID = GenericSectionID);
621
623
625 unsigned Flags = 0) {
626 return getWasmSection(Section, K, Flags, nullptr);
627 }
628
630 unsigned Flags, const char *BeginSymName) {
631 return getWasmSection(Section, K, Flags, "", ~0, BeginSymName);
632 }
633
635 unsigned Flags, const Twine &Group,
636 unsigned UniqueID) {
637 return getWasmSection(Section, K, Flags, Group, UniqueID, nullptr);
638 }
639
641 unsigned Flags, const Twine &Group,
642 unsigned UniqueID, const char *BeginSymName);
643
645 unsigned Flags, const MCSymbolWasm *Group,
646 unsigned UniqueID, const char *BeginSymName);
647
648 /// Get the section for the provided Section name
650
651 bool hasXCOFFSection(StringRef Section,
652 XCOFF::CsectProperties CsectProp) const;
653
655 StringRef Section, SectionKind K,
656 std::optional<XCOFF::CsectProperties> CsectProp = std::nullopt,
657 bool MultiSymbolsAllowed = false, const char *BeginSymName = nullptr,
658 std::optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSubtypeFlags =
659 std::nullopt);
660
661 // Create and save a copy of STI and return a reference to the copy.
663
664 uint8_t getBBAddrMapVersion() const { return BBAddrMapVersion; }
665
666 /// @}
667
668 /// \name Dwarf Management
669 /// @{
670
671 /// Get the compilation directory for DW_AT_comp_dir
672 /// The compilation directory should be set with \c setCompilationDir before
673 /// calling this function. If it is unset, an empty string will be returned.
674 StringRef getCompilationDir() const { return CompilationDir; }
675
676 /// Set the compilation directory for DW_AT_comp_dir
677 void setCompilationDir(StringRef S) { CompilationDir = S.str(); }
678
679 /// Add an entry to the debug prefix map.
680 void addDebugPrefixMapEntry(const std::string &From, const std::string &To);
681
682 /// Remap one path in-place as per the debug prefix map.
684
685 // Remaps all debug directory paths in-place as per the debug prefix map.
686 void RemapDebugPaths();
687
688 /// Get the main file name for use in error messages and debug
689 /// info. This can be set to ensure we've got the correct file name
690 /// after preprocessing or for -save-temps.
691 const std::string &getMainFileName() const { return MainFileName; }
692
693 /// Set the main file name and override the default.
694 void setMainFileName(StringRef S) { MainFileName = std::string(S); }
695
696 /// Creates an entry in the dwarf file and directory tables.
698 unsigned FileNumber,
699 std::optional<MD5::MD5Result> Checksum,
700 std::optional<StringRef> Source,
701 unsigned CUID);
702
703 bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID = 0);
704
705 const std::map<unsigned, MCDwarfLineTable> &getMCDwarfLineTables() const {
706 return MCDwarfLineTablesCUMap;
707 }
708
710 return MCDwarfLineTablesCUMap[CUID];
711 }
712
713 const MCDwarfLineTable &getMCDwarfLineTable(unsigned CUID) const {
714 auto I = MCDwarfLineTablesCUMap.find(CUID);
715 assert(I != MCDwarfLineTablesCUMap.end());
716 return I->second;
717 }
718
721 }
722
724 return getMCDwarfLineTable(CUID).getMCDwarfDirs();
725 }
726
727 unsigned getDwarfCompileUnitID() { return DwarfCompileUnitID; }
728
729 void setDwarfCompileUnitID(unsigned CUIndex) { DwarfCompileUnitID = CUIndex; }
730
731 /// Specifies the "root" file and directory of the compilation unit.
732 /// These are "file 0" and "directory 0" in DWARF v5.
733 void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir,
734 StringRef Filename,
735 std::optional<MD5::MD5Result> Checksum,
736 std::optional<StringRef> Source) {
737 getMCDwarfLineTable(CUID).setRootFile(CompilationDir, Filename, Checksum,
738 Source);
739 }
740
741 /// Reports whether MD5 checksum usage is consistent (all-or-none).
742 bool isDwarfMD5UsageConsistent(unsigned CUID) const {
744 }
745
746 /// Saves the information from the currently parsed dwarf .loc directive
747 /// and sets DwarfLocSeen. When the next instruction is assembled an entry
748 /// in the line number table with this information and the address of the
749 /// instruction will be created.
750 void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column,
751 unsigned Flags, unsigned Isa,
752 unsigned Discriminator) {
753 CurrentDwarfLoc.setFileNum(FileNum);
754 CurrentDwarfLoc.setLine(Line);
755 CurrentDwarfLoc.setColumn(Column);
756 CurrentDwarfLoc.setFlags(Flags);
757 CurrentDwarfLoc.setIsa(Isa);
758 CurrentDwarfLoc.setDiscriminator(Discriminator);
759 DwarfLocSeen = true;
760 }
761
762 void clearDwarfLocSeen() { DwarfLocSeen = false; }
763
764 bool getDwarfLocSeen() { return DwarfLocSeen; }
765 const MCDwarfLoc &getCurrentDwarfLoc() { return CurrentDwarfLoc; }
766
767 bool getGenDwarfForAssembly() { return GenDwarfForAssembly; }
768 void setGenDwarfForAssembly(bool Value) { GenDwarfForAssembly = Value; }
769 unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }
772
773 void setGenDwarfFileNumber(unsigned FileNumber) {
774 GenDwarfFileNumber = FileNumber;
775 }
776
777 /// Specifies information about the "root file" for assembler clients
778 /// (e.g., llvm-mc). Assumes compilation dir etc. have been set up.
779 void setGenDwarfRootFile(StringRef FileName, StringRef Buffer);
780
782 return SectionsForRanges;
783 }
784
786 return SectionsForRanges.insert(Sec);
787 }
788
790
791 const std::vector<MCGenDwarfLabelEntry> &getMCGenDwarfLabelEntries() const {
792 return MCGenDwarfLabelEntries;
793 }
794
796 MCGenDwarfLabelEntries.push_back(E);
797 }
798
799 void setDwarfDebugFlags(StringRef S) { DwarfDebugFlags = S; }
800 StringRef getDwarfDebugFlags() { return DwarfDebugFlags; }
801
802 void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
803 StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
804
807
808 void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
809 uint16_t getDwarfVersion() const { return DwarfVersion; }
810
811 /// @}
812
813 StringRef getSecureLogFile() { return SecureLogFile; }
814 raw_fd_ostream *getSecureLog() { return SecureLog.get(); }
815
816 void setSecureLog(std::unique_ptr<raw_fd_ostream> Value) {
817 SecureLog = std::move(Value);
818 }
819
820 bool getSecureLogUsed() { return SecureLogUsed; }
821 void setSecureLogUsed(bool Value) { SecureLogUsed = Value; }
822
823 void *allocate(unsigned Size, unsigned Align = 8) {
824 return Allocator.Allocate(Size, Align);
825 }
826
827 void deallocate(void *Ptr) {}
828
829 /// Allocates a copy of the given string on the allocator managed by this
830 /// context and returns the result.
832 return StringSaver(Allocator).save(s);
833 }
834
835 bool hadError() { return HadError; }
836 void diagnose(const SMDiagnostic &SMD);
837 void reportError(SMLoc L, const Twine &Msg);
838 void reportWarning(SMLoc L, const Twine &Msg);
839
841 StringMap<MCAsmMacro>::iterator I = MacroMap.find(Name);
842 return (I == MacroMap.end()) ? nullptr : &I->getValue();
843 }
844
846 MacroMap.insert(std::make_pair(Name, std::move(Macro)));
847 }
848
849 void undefineMacro(StringRef Name) { MacroMap.erase(Name); }
850
851 MCPseudoProbeTable &getMCPseudoProbeTable() { return PseudoProbeTable; }
852};
853
854} // end namespace llvm
855
856// operator new and delete aren't allowed inside namespaces.
857// The throw specifications are mandated by the standard.
858/// Placement new for using the MCContext's allocator.
859///
860/// This placement form of operator new uses the MCContext's allocator for
861/// obtaining memory. It is a non-throwing new, which means that it returns
862/// null on error. (If that is what the allocator does. The current does, so if
863/// this ever changes, this operator will have to be changed, too.)
864/// Usage looks like this (assuming there's an MCContext 'Context' in scope):
865/// \code
866/// // Default alignment (8)
867/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
868/// // Specific alignment
869/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
870/// \endcode
871/// Please note that you cannot use delete on the pointer; it must be
872/// deallocated using an explicit destructor call followed by
873/// \c Context.Deallocate(Ptr).
874///
875/// \param Bytes The number of bytes to allocate. Calculated by the compiler.
876/// \param C The MCContext that provides the allocator.
877/// \param Alignment The alignment of the allocated memory (if the underlying
878/// allocator supports it).
879/// \return The allocated memory. Could be NULL.
880inline void *operator new(size_t Bytes, llvm::MCContext &C,
881 size_t Alignment = 8) noexcept {
882 return C.allocate(Bytes, Alignment);
883}
884/// Placement delete companion to the new above.
885///
886/// This operator is just a companion to the new above. There is no way of
887/// invoking it directly; see the new operator for more details. This operator
888/// is called implicitly by the compiler if a placement new expression using
889/// the MCContext throws in the object constructor.
890inline void operator delete(void *Ptr, llvm::MCContext &C, size_t) noexcept {
891 C.deallocate(Ptr);
892}
893
894/// This placement form of operator new[] uses the MCContext's allocator for
895/// obtaining memory. It is a non-throwing new[], which means that it returns
896/// null on error.
897/// Usage looks like this (assuming there's an MCContext 'Context' in scope):
898/// \code
899/// // Default alignment (8)
900/// char *data = new (Context) char[10];
901/// // Specific alignment
902/// char *data = new (Context, 4) char[10];
903/// \endcode
904/// Please note that you cannot use delete on the pointer; it must be
905/// deallocated using an explicit destructor call followed by
906/// \c Context.Deallocate(Ptr).
907///
908/// \param Bytes The number of bytes to allocate. Calculated by the compiler.
909/// \param C The MCContext that provides the allocator.
910/// \param Alignment The alignment of the allocated memory (if the underlying
911/// allocator supports it).
912/// \return The allocated memory. Could be NULL.
913inline void *operator new[](size_t Bytes, llvm::MCContext &C,
914 size_t Alignment = 8) noexcept {
915 return C.allocate(Bytes, Alignment);
916}
917
918/// Placement delete[] companion to the new[] above.
919///
920/// This operator is just a companion to the new[] above. There is no way of
921/// invoking it directly; see the new[] operator for more details. This operator
922/// is called implicitly by the compiler if a placement new[] expression using
923/// the MCContext throws in the object constructor.
924inline void operator delete[](void *Ptr, llvm::MCContext &C) noexcept {
925 C.deallocate(Ptr);
926}
927
928#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 F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
nvptx lower args
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
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:148
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:481
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:83
MCPseudoProbeTable & getMCPseudoProbeTable()
Definition: MCContext.h:851
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:416
void remapDebugPath(SmallVectorImpl< char > &Path)
Remap one path in-place as per the debug prefix map.
Definition: MCContext.cpp:899
MCSymbol * createBlockSymbol(const Twine &Name, bool AlwaysEmit=false)
Get or create a symbol for a basic block.
Definition: MCContext.cpp:324
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Definition: MCContext.cpp:890
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:483
void * allocate(unsigned Size, unsigned Align=8)
Definition: MCContext.h:823
const SetVector< MCSection * > & getGenDwarfSectionSyms()
Definition: MCContext.h:781
void deallocate(void *Ptr)
Definition: MCContext.h:827
const SmallVectorImpl< std::string > & getMCDwarfDirs(unsigned CUID=0)
Definition: MCContext.h:723
Environment getObjectFileType() const
Definition: MCContext.h:395
bool isDwarfMD5UsageConsistent(unsigned CUID) const
Reports whether MD5 checksum usage is consistent (all-or-none).
Definition: MCContext.h:742
void setObjectFileInfo(const MCObjectFileInfo *Mofi)
Definition: MCContext.h:410
bool hadError()
Definition: MCContext.h:835
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags, const char *BeginSymName)
Definition: MCContext.h:629
StringRef getDwarfDebugProducer()
Definition: MCContext.h:803
void setSymbolValue(MCStreamer &Streamer, const Twine &Sym, uint64_t Val)
Set value for a symbol.
Definition: MCContext.cpp:413
const std::string & getMainFileName() const
Get the main file name for use in error messages and debug info.
Definition: MCContext.h:691
StringRef getDwarfDebugFlags()
Definition: MCContext.h:800
bool getDwarfLocSeen()
Definition: MCContext.h:764
void addDebugPrefixMapEntry(const std::string &From, const std::string &To)
Add an entry to the debug prefix map.
Definition: MCContext.cpp:894
MCContext(const MCContext &)=delete
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Definition: MCContext.cpp:345
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir The compilation directory should be set with setComp...
Definition: MCContext.h:674
bool getGenDwarfForAssembly()
Definition: MCContext.h:767
void RemapDebugPaths()
Definition: MCContext.cpp:905
MCInst * createMCInst()
Create and return a new MC instruction.
Definition: MCContext.cpp:195
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:235
MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *RelInfoSection)
Definition: MCContext.cpp:534
void setSecureLogUsed(bool Value)
Definition: MCContext.h:821
void defineMacro(StringRef Name, MCAsmMacro Macro)
Definition: MCContext.h:845
MCSymbol * createLinkerPrivateTempSymbol()
Create a new linker temporary symbol with the specified prefix (Name) or "tmp".
Definition: MCContext.cpp:335
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
Definition: MCContext.h:624
void recordELFMergeableSectionInfo(StringRef SectionName, unsigned Flags, unsigned UniqueID, unsigned EntrySize)
Definition: MCContext.cpp:630
MCSymbol * getInlineAsmLabel(StringRef Name) const
isInlineAsmLabel - Return true if the name is a label referenced in inline assembly.
Definition: MCContext.h:509
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:987
wasm::WasmSignature * createWasmSignature()
Allocates and returns a new WasmSignature instance (with empty parameter and return type lists).
Definition: MCContext.cpp:423
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:546
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize, const Twine &Group, bool IsComdat)
Definition: MCContext.h:558
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize)
Definition: MCContext.h:552
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:547
void setGenDwarfForAssembly(bool Value)
Definition: MCContext.h:768
uint8_t getBBAddrMapVersion() const
Definition: MCContext.h:664
void diagnose(const SMDiagnostic &SMD)
Definition: MCContext.cpp:1025
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:998
void setDwarfVersion(uint16_t v)
Definition: MCContext.h:808
void clearDwarfLocSeen()
Definition: MCContext.h:762
const StringRef & getSwift5ReflectionSegmentName() const
Definition: MCContext.h:397
void registerInlineAsmLabel(MCSymbol *Sym)
registerInlineAsmLabel - Records that the name is a label referenced in inline assembly.
Definition: MCContext.cpp:419
bool addGenDwarfSection(MCSection *Sec)
Definition: MCContext.h:785
StringRef allocateString(StringRef s)
Allocates a copy of the given string on the allocator managed by this context and returns the result.
Definition: MCContext.h:831
MCAsmMacro * lookupMacro(StringRef Name)
Definition: MCContext.h:840
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:709
bool getSecureLogUsed()
Definition: MCContext.h:820
raw_fd_ostream * getSecureLog()
Definition: MCContext.h:814
void initInlineSourceManager()
Definition: MCContext.cpp:127
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID)
Definition: MCContext.cpp:687
void setDiagnosticHandler(DiagHandlerTy DiagHandler)
Definition: MCContext.h:406
unsigned getDwarfCompileUnitID()
Definition: MCContext.h:727
MCSymbol * getOrCreateParentFrameOffsetSymbol(const Twine &FuncName)
Definition: MCContext.cpp:241
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
Definition: MCContext.cpp:407
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags, const Twine &Group, unsigned UniqueID)
Definition: MCContext.h:634
bool emitCompactUnwindNonCanonical() const
Definition: MCContext.cpp:940
void undefineMacro(StringRef Name)
Definition: MCContext.h:849
CodeViewContext & getCVContext()
Definition: MCContext.cpp:1015
const MCRegisterInfo * getRegisterInfo() const
Definition: MCContext.h:414
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
Definition: MCContext.h:719
void reset()
reset - return object to right after construction state to prepare to process a new module
Definition: MCContext.cpp:136
MCSectionGOFF * getGOFFSection(StringRef Section, SectionKind Kind, MCSection *Parent, uint32_t Subsection=0)
Definition: MCContext.cpp:669
void setDwarfFormat(dwarf::DwarfFormat f)
Definition: MCContext.h:805
void setCompilationDir(StringRef S)
Set the compilation directory for DW_AT_comp_dir.
Definition: MCContext.h:677
const std::map< unsigned, MCDwarfLineTable > & getMCDwarfLineTables() const
Definition: MCContext.h:705
bool isELFGenericMergeableSection(StringRef Name)
Definition: MCContext.cpp:656
unsigned getGenDwarfFileNumber()
Definition: MCContext.h:769
void setDwarfDebugFlags(StringRef S)
Definition: MCContext.h:799
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:750
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:67
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:796
void setDwarfDebugProducer(StringRef S)
Definition: MCContext.h:802
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:662
MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions).
Definition: MCContext.cpp:373
void reportWarning(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1077
uint16_t getDwarfVersion() const
Definition: MCContext.h:809
const SourceMgr * getSourceManager() const
Definition: MCContext.h:401
const SymbolTable & getSymbols() const
getSymbols - Get a reference for the symbol table for clients that want to, for example,...
Definition: MCContext.h:505
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:412
StringMap< MCSymbolTableValue, BumpPtrAllocator & > SymbolTable
Definition: MCContext.h:85
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionsForRanges, to avoid generating useless debug info for them.
Definition: MCContext.cpp:1010
void setSecureLog(std::unique_ptr< raw_fd_ostream > Value)
Definition: MCContext.h:816
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1070
@ GenericSectionID
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
Definition: MCContext.h:530
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E)
Definition: MCContext.h:795
MCSymbol * getOrCreateLSDASymbol(const Twine &FuncName)
Definition: MCContext.cpp:246
MCSectionDXContainer * getDXContainerSection(StringRef Section, SectionKind K)
Get the section for the provided Section name.
Definition: MCContext.cpp:870
MCContext & operator=(const MCContext &)=delete
bool hasXCOFFSection(StringRef Section, XCOFF::CsectProperties CsectProp) const
Definition: MCContext.cpp:790
void setMainFileName(StringRef S)
Set the main file name and override the default.
Definition: MCContext.h:694
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:212
SourceMgr * getInlineSourceManager()
Definition: MCContext.h:404
MCSymbol * createLinkerPrivateSymbol(const Twine &Name)
Definition: MCContext.cpp:339
void setGenDwarfFileNumber(unsigned FileNumber)
Definition: MCContext.h:773
MCSectionSPIRV * getSPIRVSection()
Definition: MCContext.cpp:863
const MCTargetOptions * getTargetOptions() const
Definition: MCContext.h:420
void setDwarfCompileUnitID(unsigned CUIndex)
Definition: MCContext.h:729
const MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID) const
Definition: MCContext.h:713
EmitDwarfUnwindType emitDwarfUnwindInfo() const
Definition: MCContext.cpp:934
bool isELFImplicitMergeableSectionNamePrefix(StringRef Name)
Definition: MCContext.cpp:651
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group, bool IsComdat)
Definition: MCContext.cpp:624
void setUseNamesOnTempLabels(bool Value)
Definition: MCContext.h:424
std::function< void(const SMDiagnostic &, bool, const SourceMgr &, std::vector< const MDNode * > &)> DiagHandlerTy
Definition: MCContext.h:88
const MCDwarfLoc & getCurrentDwarfLoc()
Definition: MCContext.h:765
void setGenDwarfRootFile(StringRef FileName, StringRef Buffer)
Specifies information about the "root file" for assembler clients (e.g., llvm-mc).
Definition: MCContext.cpp:946
dwarf::DwarfFormat getDwarfFormat() const
Definition: MCContext.h:806
const std::vector< MCGenDwarfLabelEntry > & getMCGenDwarfLabelEntries() const
Definition: MCContext.h:791
F * allocFragment(Args &&...args)
Definition: MCContext.h:440
StringRef getSecureLogFile()
Definition: MCContext.h:813
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:727
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, SectionKind K, const char *BeginSymName=nullptr)
Definition: MCContext.h:540
std::vector< const MDNode * > & getLocInfos()
Definition: MCContext.h:405
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:733
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:378
const MCSubtargetInfo * getSubtargetInfo() const
Definition: MCContext.h:418
MCSymbol * createNamedTempSymbol()
Create a temporary symbol with a unique name whose name cannot be omitted in the symbol table.
Definition: MCContext.cpp:347
const Triple & getTargetTriple() const
Definition: MCContext.h:400
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
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:27
This represents a section on linux, lots of unix variants and some bare metal systems.
Definition: MCSectionELF.h:27
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:36
static constexpr unsigned NonUniqueID
Definition: MCSection.h:40
Streaming machine code generation interface.
Definition: MCStreamer.h:213
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:41
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:387
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: StringMap.h:253
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:223
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition: StringSaver.h:21
StringRef save(const char *S)
Definition: StringSaver.h:30
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:471
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
StringMapEntry< MCSymbolTableValue > MCSymbolTableEntry
MCContext stores MCSymbolTableValue in a string map (see MCSymbol::operator new).
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