LLVM 22.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"
24#include "llvm/MC/MCSection.h"
27#include "llvm/MC/SectionKind.h"
30#include "llvm/Support/Error.h"
31#include "llvm/Support/MD5.h"
34#include <algorithm>
35#include <cassert>
36#include <cstddef>
37#include <cstdint>
38#include <functional>
39#include <map>
40#include <memory>
41#include <optional>
42#include <string>
43#include <utility>
44#include <vector>
45
46namespace llvm {
47
48class CodeViewContext;
49class MCAsmInfo;
50class MCInst;
51class MCLabel;
52class MCObjectFileInfo;
53class MCRegisterInfo;
54class MCSection;
55class MCSectionCOFF;
56class MCSectionDXContainer;
57class MCSectionELF;
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 /// SHT_LLVM_BB_ADDR_MAP version to emit.
178 uint8_t BBAddrMapVersion = 3;
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 return std::tie(SectionName, GroupName, SelectionKey, UniqueID) <
263 std::tie(Other.SectionName, Other.GroupName, Other.SelectionKey,
264 Other.UniqueID);
265 }
266 };
267
268 struct WasmSectionKey {
269 std::string SectionName;
270 StringRef GroupName;
271 unsigned UniqueID;
272
273 WasmSectionKey(StringRef SectionName, StringRef GroupName,
274 unsigned UniqueID)
275 : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {}
276
277 bool operator<(const WasmSectionKey &Other) const {
278 return std::tie(SectionName, GroupName, UniqueID) <
279 std::tie(Other.SectionName, Other.GroupName, Other.UniqueID);
280 }
281 };
282
283 struct XCOFFSectionKey {
284 // Section name.
285 std::string SectionName;
286 // Section property.
287 // For csect section, it is storage mapping class.
288 // For debug section, it is section type flags.
289 union {
290 XCOFF::StorageMappingClass MappingClass;
291 XCOFF::DwarfSectionSubtypeFlags DwarfSubtypeFlags;
292 };
293 bool IsCsect;
294
295 XCOFFSectionKey(StringRef SectionName,
296 XCOFF::StorageMappingClass MappingClass)
297 : SectionName(SectionName), MappingClass(MappingClass), IsCsect(true) {}
298
299 XCOFFSectionKey(StringRef SectionName,
300 XCOFF::DwarfSectionSubtypeFlags DwarfSubtypeFlags)
301 : SectionName(SectionName), DwarfSubtypeFlags(DwarfSubtypeFlags),
302 IsCsect(false) {}
303
304 bool operator<(const XCOFFSectionKey &Other) const {
305 if (IsCsect && Other.IsCsect)
306 return std::tie(SectionName, MappingClass) <
307 std::tie(Other.SectionName, Other.MappingClass);
308 if (IsCsect != Other.IsCsect)
309 return IsCsect;
310 return std::tie(SectionName, DwarfSubtypeFlags) <
311 std::tie(Other.SectionName, Other.DwarfSubtypeFlags);
312 }
313 };
314
315 StringMap<MCSectionMachO *> MachOUniquingMap;
316 std::map<COFFSectionKey, MCSectionCOFF *> COFFUniquingMap;
317 StringMap<MCSectionELF *> ELFUniquingMap;
318 std::map<std::string, MCSectionGOFF *> GOFFUniquingMap;
319 std::map<WasmSectionKey, MCSectionWasm *> WasmUniquingMap;
320 std::map<XCOFFSectionKey, MCSectionXCOFF *> XCOFFUniquingMap;
321 StringMap<MCSectionDXContainer *> DXCUniquingMap;
322 StringMap<bool> RelSecNames;
323
324 SpecificBumpPtrAllocator<MCSubtargetInfo> MCSubtargetAllocator;
325
326 /// Do automatic reset in destructor
327 bool AutoReset;
328
329 MCTargetOptions const *TargetOptions;
330
331 bool HadError = false;
332
333 void reportCommon(SMLoc Loc,
334 std::function<void(SMDiagnostic &, const SourceMgr *)>);
335
336 MCSymbolTableEntry &getSymbolTableEntry(StringRef Name);
337
338 MCSymbol *createSymbolImpl(const MCSymbolTableEntry *Name, bool IsTemporary);
339 MCSymbol *createRenamableSymbol(const Twine &Name, bool AlwaysAddSuffix,
340 bool IsTemporary);
341
342 MCSymbol *getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
343 unsigned Instance);
344
345 template <typename Symbol>
346 Symbol *getOrCreateSectionSymbol(StringRef Section);
347
348 MCSectionELF *createELFSectionImpl(StringRef Section, unsigned Type,
349 unsigned Flags, unsigned EntrySize,
350 const MCSymbolELF *Group, bool IsComdat,
351 unsigned UniqueID,
352 const MCSymbolELF *LinkedToSym);
353
354 MCSymbolXCOFF *createXCOFFSymbolImpl(const MCSymbolTableEntry *Name,
355 bool IsTemporary);
356
357 template <typename TAttr>
358 MCSectionGOFF *getGOFFSection(SectionKind Kind, StringRef Name,
359 TAttr SDAttributes, MCSection *Parent,
360 bool IsVirtual);
361
362 /// Map of currently defined macros.
363 StringMap<MCAsmMacro> MacroMap;
364
365 // Symbols must be assigned to a section with a compatible entry size and
366 // flags. This map is used to assign unique IDs to sections to distinguish
367 // between sections with identical names but incompatible entry sizes and/or
368 // flags. This can occur when a symbol is explicitly assigned to a section,
369 // e.g. via __attribute__((section("myname"))). The map key is the tuple
370 // (section name, flags, entry size).
371 DenseMap<std::tuple<StringRef, unsigned, unsigned>, unsigned> ELFEntrySizeMap;
372
373 // This set is used to record the generic mergeable section names seen.
374 // These are sections that are created as mergeable e.g. .debug_str. We need
375 // to avoid assigning non-mergeable symbols to these sections. It is used
376 // to prevent non-mergeable symbols being explicitly assigned to mergeable
377 // sections (e.g. via _attribute_((section("myname")))).
378 DenseSet<StringRef> ELFSeenGenericMergeableSections;
379
380public:
381 LLVM_ABI explicit MCContext(const Triple &TheTriple, const MCAsmInfo *MAI,
382 const MCRegisterInfo *MRI,
383 const MCSubtargetInfo *MSTI,
384 const SourceMgr *Mgr = nullptr,
385 MCTargetOptions const *TargetOpts = nullptr,
386 bool DoAutoReset = true,
387 StringRef Swift5ReflSegmentName = {});
388 MCContext(const MCContext &) = delete;
389 MCContext &operator=(const MCContext &) = delete;
391
392 Environment getObjectFileType() const { return Env; }
393 bool isELF() const { return Env == IsELF; }
394 bool isMachO() const { return Env == IsMachO; }
395 bool isXCOFF() const { return Env == IsXCOFF; }
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 LLVM_ABI void reset();
432
433 /// @}
434
435 /// \name McInst Management
436
437 /// Create and return a new MC instruction.
439
440 /// \name Symbol Management
441 /// @{
442
443 /// Create a new linker temporary symbol with the specified prefix (Name) or
444 /// "tmp". This creates a "l"-prefixed symbol for Mach-O and is identical to
445 /// createNamedTempSymbol for other object file formats.
448
449 /// Create a temporary symbol with a unique name. The name will be omitted
450 /// in the symbol table if UseNamesOnTempLabels is false (default except
451 /// MCAsmStreamer). The overload without Name uses an unspecified name.
454 bool AlwaysAddSuffix = true);
455
456 /// Create a temporary symbol with a unique name whose name cannot be
457 /// omitted in the symbol table. This is rarely used.
460
461 /// Get or create a symbol for a basic block. For non-always-emit symbols,
462 /// this behaves like createTempSymbol, except that it uses the
463 /// PrivateLabelPrefix instead of the PrivateGlobalPrefix. When AlwaysEmit is
464 /// true, behaves like getOrCreateSymbol, prefixed with PrivateLabelPrefix.
466 bool AlwaysEmit = false);
467
468 /// Create a local, non-temporary symbol like an ELF mapping symbol. Calling
469 /// the function with the same name will generate new, unique instances.
471
472 /// Create the definition of a directional local symbol for numbered label
473 /// (used for "1:" definitions).
474 LLVM_ABI MCSymbol *createDirectionalLocalSymbol(unsigned LocalLabelVal);
475
476 /// Create and return a directional local symbol for numbered label (used
477 /// for "1b" or 1f" references).
478 LLVM_ABI MCSymbol *getDirectionalLocalSymbol(unsigned LocalLabelVal,
479 bool Before);
480
481 /// Lookup the symbol inside with the specified \p Name. If it exists,
482 /// return it. If not, create a forward reference and return it.
483 ///
484 /// \param Name - The symbol name, which must be unique across all symbols.
486
487 /// Gets a symbol that will be defined to the final stack offset of a local
488 /// variable after codegen.
489 ///
490 /// \param Idx - The index of a local variable passed to \@llvm.localescape.
492 unsigned Idx);
493
495
497
498 /// Get the symbol for \p Name, or null.
499 LLVM_ABI MCSymbol *lookupSymbol(const Twine &Name) const;
500
501 /// Clone a symbol for the .set directive, replacing it in the symbol table.
502 /// Existing references to the original symbol remain unchanged, and the
503 /// original symbol is not emitted to the symbol table.
505
506 /// Set value for a symbol.
507 LLVM_ABI void setSymbolValue(MCStreamer &Streamer, const Twine &Sym,
508 uint64_t Val);
509
510 /// getSymbols - Get a reference for the symbol table for clients that
511 /// want to, for example, iterate over all symbols. 'const' because we
512 /// still want any modifications to the table itself to use the MCContext
513 /// APIs.
514 const SymbolTable &getSymbols() const { return Symbols; }
515
516 /// isInlineAsmLabel - Return true if the name is a label referenced in
517 /// inline assembly.
519 return InlineAsmUsedLabelNames.lookup(Name);
520 }
521
522 /// registerInlineAsmLabel - Records that the name is a label referenced in
523 /// inline assembly.
525
526 /// Allocates and returns a new `WasmSignature` instance (with empty parameter
527 /// and return type lists).
529
530 /// @}
531
532 /// \name Section Management
533 /// @{
534
535 /// Return the MCSection for the specified mach-o section. This requires
536 /// the operands to be valid.
538 unsigned TypeAndAttributes,
539 unsigned Reserved2, SectionKind K,
540 const char *BeginSymName = nullptr);
541
543 unsigned TypeAndAttributes, SectionKind K,
544 const char *BeginSymName = nullptr) {
545 return getMachOSection(Segment, Section, TypeAndAttributes, 0, K,
546 BeginSymName);
547 }
548
549 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
550 unsigned Flags) {
551 return getELFSection(Section, Type, Flags, 0, "", false);
552 }
553
554 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
555 unsigned Flags, unsigned EntrySize) {
556 return getELFSection(Section, Type, Flags, EntrySize, "", false,
557 MCSection::NonUniqueID, nullptr);
558 }
559
560 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
561 unsigned Flags, unsigned EntrySize,
562 const Twine &Group, bool IsComdat) {
563 return getELFSection(Section, Type, Flags, EntrySize, Group, IsComdat,
564 MCSection::NonUniqueID, nullptr);
565 }
566
567 LLVM_ABI MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
568 unsigned Flags, unsigned EntrySize,
569 const Twine &Group, bool IsComdat,
570 unsigned UniqueID,
571 const MCSymbolELF *LinkedToSym);
572
573 LLVM_ABI MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
574 unsigned Flags, unsigned EntrySize,
575 const MCSymbolELF *Group, bool IsComdat,
576 unsigned UniqueID,
577 const MCSymbolELF *LinkedToSym);
578
579 /// Get a section with the provided group identifier. This section is
580 /// named by concatenating \p Prefix with '.' then \p Suffix. The \p Type
581 /// describes the type of the section and \p Flags are used to further
582 /// configure this named section.
584 const Twine &Suffix, unsigned Type,
585 unsigned Flags,
586 unsigned EntrySize = 0);
587
589 createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags,
590 unsigned EntrySize, const MCSymbolELF *Group,
591 const MCSectionELF *RelInfoSection);
592
594 bool IsComdat);
595
597 unsigned Flags, unsigned UniqueID,
598 unsigned EntrySize);
599
601
603
604 /// Return the unique ID of the section with the given name, flags and entry
605 /// size, if it exists.
606 LLVM_ABI std::optional<unsigned>
608 unsigned EntrySize);
609
610 LLVM_ABI MCSectionGOFF *getGOFFSection(SectionKind Kind, StringRef Name,
611 GOFF::SDAttr SDAttributes);
612 LLVM_ABI MCSectionGOFF *getGOFFSection(SectionKind Kind, StringRef Name,
613 GOFF::EDAttr EDAttributes,
614 MCSection *Parent);
615 LLVM_ABI MCSectionGOFF *getGOFFSection(SectionKind Kind, StringRef Name,
616 GOFF::PRAttr PRAttributes,
617 MCSection *Parent);
618
620 getCOFFSection(StringRef Section, unsigned Characteristics,
621 StringRef COMDATSymName, int Selection,
622 unsigned UniqueID = MCSection::NonUniqueID);
623
625 unsigned Characteristics);
626
627 /// Gets or creates a section equivalent to Sec that is associated with the
628 /// section containing KeySym. For example, to create a debug info section
629 /// associated with an inline function, pass the normal debug info section
630 /// as Sec and the function symbol as KeySym.
633 unsigned UniqueID = MCSection::NonUniqueID);
634
636
638 unsigned Flags = 0) {
639 return getWasmSection(Section, K, Flags, "", ~0);
640 }
641
643 unsigned Flags, const Twine &Group,
644 unsigned UniqueID);
645
647 unsigned Flags,
648 const MCSymbolWasm *Group,
649 unsigned UniqueID);
650
651 /// Get the section for the provided Section name
653 SectionKind K);
654
656 XCOFF::CsectProperties CsectProp) const;
657
659 StringRef Section, SectionKind K,
660 std::optional<XCOFF::CsectProperties> CsectProp = std::nullopt,
661 bool MultiSymbolsAllowed = false,
662 std::optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSubtypeFlags =
663 std::nullopt);
664
665 // Create and save a copy of STI and return a reference to the copy.
667
668 uint8_t getBBAddrMapVersion() const { return BBAddrMapVersion; }
669
670 /// @}
671
672 /// \name Dwarf Management
673 /// @{
674
675 /// Get the compilation directory for DW_AT_comp_dir
676 /// The compilation directory should be set with \c setCompilationDir before
677 /// calling this function. If it is unset, an empty string will be returned.
678 StringRef getCompilationDir() const { return CompilationDir; }
679
680 /// Set the compilation directory for DW_AT_comp_dir
681 void setCompilationDir(StringRef S) { CompilationDir = S.str(); }
682
683 /// Add an entry to the debug prefix map.
684 LLVM_ABI void addDebugPrefixMapEntry(const std::string &From,
685 const std::string &To);
686
687 /// Remap one path in-place as per the debug prefix map.
689
690 // Remaps all debug directory paths in-place as per the debug prefix map.
692
693 /// Get the main file name for use in error messages and debug
694 /// info. This can be set to ensure we've got the correct file name
695 /// after preprocessing or for -save-temps.
696 const std::string &getMainFileName() const { return MainFileName; }
697
698 /// Set the main file name and override the default.
699 void setMainFileName(StringRef S) { MainFileName = std::string(S); }
700
701 /// Creates an entry in the dwarf file and directory tables.
703 getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber,
704 std::optional<MD5::MD5Result> Checksum,
705 std::optional<StringRef> Source, unsigned CUID);
706
707 LLVM_ABI bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID = 0);
708
709 const std::map<unsigned, MCDwarfLineTable> &getMCDwarfLineTables() const {
710 return MCDwarfLineTablesCUMap;
711 }
712
714 return MCDwarfLineTablesCUMap[CUID];
715 }
716
717 const MCDwarfLineTable &getMCDwarfLineTable(unsigned CUID) const {
718 auto I = MCDwarfLineTablesCUMap.find(CUID);
719 assert(I != MCDwarfLineTablesCUMap.end());
720 return I->second;
721 }
722
725 }
726
728 return getMCDwarfLineTable(CUID).getMCDwarfDirs();
729 }
730
731 unsigned getDwarfCompileUnitID() { return DwarfCompileUnitID; }
732
733 void setDwarfCompileUnitID(unsigned CUIndex) { DwarfCompileUnitID = CUIndex; }
734
735 /// Specifies the "root" file and directory of the compilation unit.
736 /// These are "file 0" and "directory 0" in DWARF v5.
737 void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir,
738 StringRef Filename,
739 std::optional<MD5::MD5Result> Checksum,
740 std::optional<StringRef> Source) {
741 getMCDwarfLineTable(CUID).setRootFile(CompilationDir, Filename, Checksum,
742 Source);
743 }
744
745 /// Reports whether MD5 checksum usage is consistent (all-or-none).
746 bool isDwarfMD5UsageConsistent(unsigned CUID) const {
748 }
749
750 /// Saves the information from the currently parsed dwarf .loc directive
751 /// and sets DwarfLocSeen. When the next instruction is assembled an entry
752 /// in the line number table with this information and the address of the
753 /// instruction will be created.
754 void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column,
755 unsigned Flags, unsigned Isa,
756 unsigned Discriminator) {
757 CurrentDwarfLoc.setFileNum(FileNum);
758 CurrentDwarfLoc.setLine(Line);
759 CurrentDwarfLoc.setColumn(Column);
760 CurrentDwarfLoc.setFlags(Flags);
761 CurrentDwarfLoc.setIsa(Isa);
762 CurrentDwarfLoc.setDiscriminator(Discriminator);
763 DwarfLocSeen = true;
764 }
765
766 void clearDwarfLocSeen() { DwarfLocSeen = false; }
767
768 bool getDwarfLocSeen() { return DwarfLocSeen; }
769 const MCDwarfLoc &getCurrentDwarfLoc() { return CurrentDwarfLoc; }
770
771 bool getGenDwarfForAssembly() { return GenDwarfForAssembly; }
772 void setGenDwarfForAssembly(bool Value) { GenDwarfForAssembly = Value; }
773 unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }
776
777 void setGenDwarfFileNumber(unsigned FileNumber) {
778 GenDwarfFileNumber = FileNumber;
779 }
780
781 /// Specifies information about the "root file" for assembler clients
782 /// (e.g., llvm-mc). Assumes compilation dir etc. have been set up.
783 LLVM_ABI void setGenDwarfRootFile(StringRef FileName, StringRef Buffer);
784
786 return SectionsForRanges;
787 }
788
790 return SectionsForRanges.insert(Sec);
791 }
792
794
795 const std::vector<MCGenDwarfLabelEntry> &getMCGenDwarfLabelEntries() const {
796 return MCGenDwarfLabelEntries;
797 }
798
800 MCGenDwarfLabelEntries.push_back(E);
801 }
802
803 void setDwarfDebugFlags(StringRef S) { DwarfDebugFlags = S; }
804 StringRef getDwarfDebugFlags() { return DwarfDebugFlags; }
805
806 void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
807 StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
808
809 void setDwarfFormat(dwarf::DwarfFormat f) { DwarfFormat = f; }
810 dwarf::DwarfFormat getDwarfFormat() const { return DwarfFormat; }
811
812 void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
813 uint16_t getDwarfVersion() const { return DwarfVersion; }
814
815 /// @}
816
817 StringRef getSecureLogFile() { return SecureLogFile; }
818 raw_fd_ostream *getSecureLog() { return SecureLog.get(); }
819
820 void setSecureLog(std::unique_ptr<raw_fd_ostream> Value) {
821 SecureLog = std::move(Value);
822 }
823
824 bool getSecureLogUsed() { return SecureLogUsed; }
825 void setSecureLogUsed(bool Value) { SecureLogUsed = Value; }
826
827 void *allocate(unsigned Size, unsigned Align = 8) {
828 return Allocator.Allocate(Size, Align);
829 }
830
831 void deallocate(void *Ptr) {}
832
833 /// Allocates a copy of the given string on the allocator managed by this
834 /// context and returns the result.
836 return StringSaver(Allocator).save(s);
837 }
838
839 bool hadError() { return HadError; }
840 LLVM_ABI void diagnose(const SMDiagnostic &SMD);
841 LLVM_ABI void reportError(SMLoc L, const Twine &Msg);
842 LLVM_ABI void reportWarning(SMLoc L, const Twine &Msg);
843
845 StringMap<MCAsmMacro>::iterator I = MacroMap.find(Name);
846 return (I == MacroMap.end()) ? nullptr : &I->getValue();
847 }
848
850 MacroMap.insert(std::make_pair(Name, std::move(Macro)));
851 }
852
853 void undefineMacro(StringRef Name) { MacroMap.erase(Name); }
854
855 MCPseudoProbeTable &getMCPseudoProbeTable() { return PseudoProbeTable; }
856};
857
858} // end namespace llvm
859
860// operator new and delete aren't allowed inside namespaces.
861// The throw specifications are mandated by the standard.
862/// Placement new for using the MCContext's allocator.
863///
864/// This placement form of operator new uses the MCContext's allocator for
865/// obtaining memory. It is a non-throwing new, which means that it returns
866/// null on error. (If that is what the allocator does. The current does, so if
867/// this ever changes, this operator will have to be changed, too.)
868/// Usage looks like this (assuming there's an MCContext 'Context' in scope):
869/// \code
870/// // Default alignment (8)
871/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
872/// // Specific alignment
873/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
874/// \endcode
875/// Please note that you cannot use delete on the pointer; it must be
876/// deallocated using an explicit destructor call followed by
877/// \c Context.Deallocate(Ptr).
878///
879/// \param Bytes The number of bytes to allocate. Calculated by the compiler.
880/// \param C The MCContext that provides the allocator.
881/// \param Alignment The alignment of the allocated memory (if the underlying
882/// allocator supports it).
883/// \return The allocated memory. Could be NULL.
884inline void *operator new(size_t Bytes, llvm::MCContext &C,
885 size_t Alignment = 8) noexcept {
886 return C.allocate(Bytes, Alignment);
887}
888/// Placement delete companion to the new above.
889///
890/// This operator is just a companion to the new above. There is no way of
891/// invoking it directly; see the new operator for more details. This operator
892/// is called implicitly by the compiler if a placement new expression using
893/// the MCContext throws in the object constructor.
894inline void operator delete(void *Ptr, llvm::MCContext &C, size_t) noexcept {
895 C.deallocate(Ptr);
896}
897
898/// This placement form of operator new[] uses the MCContext's allocator for
899/// obtaining memory. It is a non-throwing new[], which means that it returns
900/// null on error.
901/// Usage looks like this (assuming there's an MCContext 'Context' in scope):
902/// \code
903/// // Default alignment (8)
904/// char *data = new (Context) char[10];
905/// // Specific alignment
906/// char *data = new (Context, 4) char[10];
907/// \endcode
908/// Please note that you cannot use delete on the pointer; it must be
909/// deallocated using an explicit destructor call followed by
910/// \c Context.Deallocate(Ptr).
911///
912/// \param Bytes The number of bytes to allocate. Calculated by the compiler.
913/// \param C The MCContext that provides the allocator.
914/// \param Alignment The alignment of the allocated memory (if the underlying
915/// allocator supports it).
916/// \return The allocated memory. Could be NULL.
917inline void *operator new[](size_t Bytes, llvm::MCContext &C,
918 size_t Alignment = 8) noexcept {
919 return C.allocate(Bytes, Alignment);
920}
921
922/// Placement delete[] companion to the new[] above.
923///
924/// This operator is just a companion to the new[] above. There is no way of
925/// invoking it directly; see the new[] operator for more details. This operator
926/// is called implicitly by the compiler if a placement new[] expression using
927/// the MCContext throws in the object constructor.
928inline void operator delete[](void *Ptr, llvm::MCContext &C) noexcept {
929 C.deallocate(Ptr);
930}
931
932#endif // LLVM_MC_MCCONTEXT_H
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
This file defines the BumpPtrAllocator interface.
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:350
#define LLVM_ABI
Definition: Compiler.h:213
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
This file declares the MCSectionGOFF class, which contains all of the necessary machine code sections...
#define I(x, y, z)
Definition: MD5.cpp:58
Basic Register Allocator
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:67
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:485
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:64
Context object for machine code objects.
Definition: MCContext.h:83
MCPseudoProbeTable & getMCPseudoProbeTable()
Definition: MCContext.h:855
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:416
LLVM_ABI void remapDebugPath(SmallVectorImpl< char > &Path)
Remap one path in-place as per the debug prefix map.
Definition: MCContext.cpp:944
LLVM_ABI MCSymbol * createBlockSymbol(const Twine &Name, bool AlwaysEmit=false)
Get or create a symbol for a basic block.
Definition: MCContext.cpp:365
LLVM_ABI MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Definition: MCContext.cpp:935
LLVM_ABI 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:533
void * allocate(unsigned Size, unsigned Align=8)
Definition: MCContext.h:827
const SetVector< MCSection * > & getGenDwarfSectionSyms()
Definition: MCContext.h:785
void deallocate(void *Ptr)
Definition: MCContext.h:831
const SmallVectorImpl< std::string > & getMCDwarfDirs(unsigned CUID=0)
Definition: MCContext.h:727
Environment getObjectFileType() const
Definition: MCContext.h:392
bool isDwarfMD5UsageConsistent(unsigned CUID) const
Reports whether MD5 checksum usage is consistent (all-or-none).
Definition: MCContext.h:746
void setObjectFileInfo(const MCObjectFileInfo *Mofi)
Definition: MCContext.h:410
bool hadError()
Definition: MCContext.h:839
StringRef getDwarfDebugProducer()
Definition: MCContext.h:807
LLVM_ABI void setSymbolValue(MCStreamer &Streamer, const Twine &Sym, uint64_t Val)
Set value for a symbol.
Definition: MCContext.cpp:463
bool isMachO() const
Definition: MCContext.h:394
const std::string & getMainFileName() const
Get the main file name for use in error messages and debug info.
Definition: MCContext.h:696
LLVM_ABI MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, StringRef COMDATSymName, int Selection, unsigned UniqueID=MCSection::NonUniqueID)
Definition: MCContext.cpp:752
StringRef getDwarfDebugFlags()
Definition: MCContext.h:804
bool getDwarfLocSeen()
Definition: MCContext.h:768
LLVM_ABI void addDebugPrefixMapEntry(const std::string &From, const std::string &To)
Add an entry to the debug prefix map.
Definition: MCContext.cpp:939
MCContext(const MCContext &)=delete
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Definition: MCContext.cpp:386
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir The compilation directory should be set with setComp...
Definition: MCContext.h:678
bool getGenDwarfForAssembly()
Definition: MCContext.h:771
LLVM_ABI void RemapDebugPaths()
Definition: MCContext.cpp:950
LLVM_ABI MCInst * createMCInst()
Create and return a new MC instruction.
Definition: MCContext.cpp:195
LLVM_ABI 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:247
LLVM_ABI MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *RelInfoSection)
Definition: MCContext.cpp:576
void setSecureLogUsed(bool Value)
Definition: MCContext.h:825
void defineMacro(StringRef Name, MCAsmMacro Macro)
Definition: MCContext.h:849
LLVM_ABI MCSymbol * createLinkerPrivateTempSymbol()
Create a new linker temporary symbol with the specified prefix (Name) or "tmp".
Definition: MCContext.cpp:376
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
Definition: MCContext.h:637
LLVM_ABI void recordELFMergeableSectionInfo(StringRef SectionName, unsigned Flags, unsigned UniqueID, unsigned EntrySize)
Definition: MCContext.cpp:669
MCSymbol * getInlineAsmLabel(StringRef Name) const
isInlineAsmLabel - Return true if the name is a label referenced in inline assembly.
Definition: MCContext.h:518
LLVM_ABI 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:1032
bool isXCOFF() const
Definition: MCContext.h:395
LLVM_ABI wasm::WasmSignature * createWasmSignature()
Allocates and returns a new WasmSignature instance (with empty parameter and return type lists).
Definition: MCContext.cpp:473
LLVM_ABI 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:588
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize, const Twine &Group, bool IsComdat)
Definition: MCContext.h:560
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize)
Definition: MCContext.h:554
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:549
LLVM_ABI MCSectionXCOFF * getXCOFFSection(StringRef Section, SectionKind K, std::optional< XCOFF::CsectProperties > CsectProp=std::nullopt, bool MultiSymbolsAllowed=false, std::optional< XCOFF::DwarfSectionSubtypeFlags > DwarfSubtypeFlags=std::nullopt)
Definition: MCContext.cpp:862
void setGenDwarfForAssembly(bool Value)
Definition: MCContext.h:772
uint8_t getBBAddrMapVersion() const
Definition: MCContext.h:668
LLVM_ABI void diagnose(const SMDiagnostic &SMD)
Definition: MCContext.cpp:1070
LLVM_ABI 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:1043
void setDwarfVersion(uint16_t v)
Definition: MCContext.h:812
void clearDwarfLocSeen()
Definition: MCContext.h:766
const StringRef & getSwift5ReflectionSegmentName() const
Definition: MCContext.h:397
LLVM_ABI void registerInlineAsmLabel(MCSymbol *Sym)
registerInlineAsmLabel - Records that the name is a label referenced in inline assembly.
Definition: MCContext.cpp:469
LLVM_ABI MCSymbol * createLocalSymbol(StringRef Name)
Create a local, non-temporary symbol like an ELF mapping symbol.
Definition: MCContext.cpp:392
bool addGenDwarfSection(MCSection *Sec)
Definition: MCContext.h:789
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:835
MCAsmMacro * lookupMacro(StringRef Name)
Definition: MCContext.h:844
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:713
bool getSecureLogUsed()
Definition: MCContext.h:824
raw_fd_ostream * getSecureLog()
Definition: MCContext.h:818
LLVM_ABI void initInlineSourceManager()
Definition: MCContext.cpp:128
void setDiagnosticHandler(DiagHandlerTy DiagHandler)
Definition: MCContext.h:406
unsigned getDwarfCompileUnitID()
Definition: MCContext.h:731
LLVM_ABI MCSymbol * getOrCreateParentFrameOffsetSymbol(const Twine &FuncName)
Definition: MCContext.cpp:253
LLVM_ABI MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
Definition: MCContext.cpp:457
LLVM_ABI bool emitCompactUnwindNonCanonical() const
Definition: MCContext.cpp:985
LLVM_ABI ~MCContext()
Definition: MCContext.cpp:120
void undefineMacro(StringRef Name)
Definition: MCContext.h:853
LLVM_ABI CodeViewContext & getCVContext()
Definition: MCContext.cpp:1060
const MCRegisterInfo * getRegisterInfo() const
Definition: MCContext.h:414
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
Definition: MCContext.h:723
LLVM_ABI void reset()
reset - return object to right after construction state to prepare to process a new module
Definition: MCContext.cpp:137
void setDwarfFormat(dwarf::DwarfFormat f)
Definition: MCContext.h:809
void setCompilationDir(StringRef S)
Set the compilation directory for DW_AT_comp_dir.
Definition: MCContext.h:681
const std::map< unsigned, MCDwarfLineTable > & getMCDwarfLineTables() const
Definition: MCContext.h:709
LLVM_ABI bool isELFGenericMergeableSection(StringRef Name)
Definition: MCContext.cpp:695
unsigned getGenDwarfFileNumber()
Definition: MCContext.h:773
void setDwarfDebugFlags(StringRef S)
Definition: MCContext.h:803
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:754
LLVM_ABI 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:65
void setDwarfDebugProducer(StringRef S)
Definition: MCContext.h:806
LLVM_ABI 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:701
LLVM_ABI MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions).
Definition: MCContext.cpp:419
LLVM_ABI void reportWarning(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1122
uint16_t getDwarfVersion() const
Definition: MCContext.h:813
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:514
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:412
StringMap< MCSymbolTableValue, BumpPtrAllocator & > SymbolTable
Definition: MCContext.h:85
LLVM_ABI void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionsForRanges, to avoid generating useless debug info for them.
Definition: MCContext.cpp:1055
void setSecureLog(std::unique_ptr< raw_fd_ostream > Value)
Definition: MCContext.h:820
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1115
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E)
Definition: MCContext.h:799
LLVM_ABI MCSymbol * getOrCreateLSDASymbol(const Twine &FuncName)
Definition: MCContext.cpp:258
LLVM_ABI MCSectionDXContainer * getDXContainerSection(StringRef Section, SectionKind K)
Get the section for the provided Section name.
Definition: MCContext.cpp:916
MCContext & operator=(const MCContext &)=delete
LLVM_ABI bool hasXCOFFSection(StringRef Section, XCOFF::CsectProperties CsectProp) const
Definition: MCContext.cpp:856
void setMainFileName(StringRef S)
Set the main file name and override the default.
Definition: MCContext.h:699
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:203
SourceMgr * getInlineSourceManager()
Definition: MCContext.h:404
LLVM_ABI MCSymbol * createLinkerPrivateSymbol(const Twine &Name)
Definition: MCContext.cpp:380
bool isELF() const
Definition: MCContext.h:393
void setGenDwarfFileNumber(unsigned FileNumber)
Definition: MCContext.h:777
LLVM_ABI MCSectionSPIRV * getSPIRVSection()
Definition: MCContext.cpp:911
LLVM_ABI MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=MCSection::NonUniqueID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym.
Definition: MCContext.cpp:792
LLVM_ABI MCSymbol * cloneSymbol(MCSymbol &Sym)
Clone a symbol for the .set directive, replacing it in the symbol table.
Definition: MCContext.cpp:301
const MCTargetOptions * getTargetOptions() const
Definition: MCContext.h:420
void setDwarfCompileUnitID(unsigned CUIndex)
Definition: MCContext.h:733
const MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID) const
Definition: MCContext.h:717
LLVM_ABI EmitDwarfUnwindType emitDwarfUnwindInfo() const
Definition: MCContext.cpp:979
LLVM_ABI bool isELFImplicitMergeableSectionNamePrefix(StringRef Name)
Definition: MCContext.cpp:690
LLVM_ABI MCSectionELF * createELFGroupSection(const MCSymbolELF *Group, bool IsComdat)
Definition: MCContext.cpp:663
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:769
LLVM_ABI void setGenDwarfRootFile(StringRef FileName, StringRef Buffer)
Specifies information about the "root file" for assembler clients (e.g., llvm-mc).
Definition: MCContext.cpp:991
dwarf::DwarfFormat getDwarfFormat() const
Definition: MCContext.h:810
const std::vector< MCGenDwarfLabelEntry > & getMCGenDwarfLabelEntries() const
Definition: MCContext.h:795
StringRef getSecureLogFile()
Definition: MCContext.h:817
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, SectionKind K, const char *BeginSymName=nullptr)
Definition: MCContext.h:542
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:737
LLVM_ABI 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:424
const MCSubtargetInfo * getSubtargetInfo() const
Definition: MCContext.h:418
LLVM_ABI MCSymbol * createNamedTempSymbol()
Create a temporary symbol with a unique name whose name cannot be omitted in the symbol table.
Definition: MCContext.cpp:388
const Triple & getTargetTriple() const
Definition: MCContext.h:400
bool isMD5UsageConsistent() const
Definition: MCDwarf.h:424
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
Definition: MCDwarf.h:434
void setRootFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
Definition: MCDwarf.h:404
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Definition: MCDwarf.h:442
Instances of this class represent the information from a dwarf .loc directive.
Definition: MCDwarf.h:106
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
Definition: MCDwarf.h:158
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
Definition: MCDwarf.h:173
void setDiscriminator(unsigned discriminator)
Set the Discriminator of this MCDwarfLoc.
Definition: MCDwarf.h:179
void setFlags(unsigned flags)
Set the Flags of this MCDwarfLoc.
Definition: MCDwarf.h:167
void setColumn(unsigned column)
Set the Column of this MCDwarfLoc.
Definition: MCDwarf.h:161
void setFileNum(unsigned fileNum)
Set the FileNum of this MCDwarfLoc.
Definition: MCDwarf.h:155
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:188
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:496
static constexpr unsigned NonUniqueID
Definition: MCSection.h:501
Streaming machine code generation interface.
Definition: MCStreamer.h:220
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:42
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:282
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:59
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition: SetVector.h:168
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:574
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition: SourceMgr.h:32
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
Definition: Allocator.h:390
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:257
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:233
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition: StringSaver.h:22
StringRef save(const char *S)
Definition: StringSaver.h:31
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:47
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:82
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:75
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:461
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:155
StorageMappingClass
Storage Mapping Class definitions.
Definition: XCOFF.h:104
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition: Dwarf.h:92
@ DWARF32
Definition: Dwarf.h:92
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:362
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