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