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 // Symbols must be assigned to a section with a compatible entry size and
395 // flags. This map is used to assign unique IDs to sections to distinguish
396 // between sections with identical names but incompatible entry sizes and/or
397 // flags. This can occur when a symbol is explicitly assigned to a section,
398 // e.g. via __attribute__((section("myname"))). The map key is the tuple
399 // (section name, flags, entry size).
400 DenseMap<std::tuple<StringRef, unsigned, unsigned>, unsigned> ELFEntrySizeMap;
401
402 // This set is used to record the generic mergeable section names seen.
403 // These are sections that are created as mergeable e.g. .debug_str. We need
404 // to avoid assigning non-mergeable symbols to these sections. It is used
405 // to prevent non-mergeable symbols being explicitly assigned to mergeable
406 // sections (e.g. via _attribute_((section("myname")))).
407 DenseSet<StringRef> ELFSeenGenericMergeableSections;
408
409public:
410 explicit MCContext(const Triple &TheTriple, const MCAsmInfo *MAI,
411 const MCRegisterInfo *MRI, const MCSubtargetInfo *MSTI,
412 const SourceMgr *Mgr = nullptr,
413 MCTargetOptions const *TargetOpts = nullptr,
414 bool DoAutoReset = true,
415 StringRef Swift5ReflSegmentName = {});
416 MCContext(const MCContext &) = delete;
417 MCContext &operator=(const MCContext &) = delete;
418 ~MCContext();
419
420 Environment getObjectFileType() const { return Env; }
421
423 return Swift5ReflectionSegmentName;
424 }
425 const Triple &getTargetTriple() const { return TT; }
426 const SourceMgr *getSourceManager() const { return SrcMgr; }
427
429 SourceMgr *getInlineSourceManager() { return InlineSrcMgr.get(); }
430 std::vector<const MDNode *> &getLocInfos() { return LocInfos; }
432 this->DiagHandler = DiagHandler;
433 }
434
435 void setObjectFileInfo(const MCObjectFileInfo *Mofi) { MOFI = Mofi; }
436
437 const MCAsmInfo *getAsmInfo() const { return MAI; }
438
439 const MCRegisterInfo *getRegisterInfo() const { return MRI; }
440
441 const MCObjectFileInfo *getObjectFileInfo() const { return MOFI; }
442
443 const MCSubtargetInfo *getSubtargetInfo() const { return MSTI; }
444
446
448
449 void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }
450 void setUseNamesOnTempLabels(bool Value) { UseNamesOnTempLabels = Value; }
451
452 /// \name Module Lifetime Management
453 /// @{
454
455 /// reset - return object to right after construction state to prepare
456 /// to process a new module
457 void reset();
458
459 /// @}
460
461 /// \name McInst Management
462
463 /// Create and return a new MC instruction.
465
466 /// \name Symbol Management
467 /// @{
468
469 /// Create a new linker temporary symbol with the specified prefix (Name) or
470 /// "tmp". This creates a "l"-prefixed symbol for Mach-O and is identical to
471 /// createNamedTempSymbol for other object file formats.
474
475 /// Create a temporary symbol with a unique name. The name will be omitted
476 /// in the symbol table if UseNamesOnTempLabels is false (default except
477 /// MCAsmStreamer). The overload without Name uses an unspecified name.
479 MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix = true);
480
481 /// Create a temporary symbol with a unique name whose name cannot be
482 /// omitted in the symbol table. This is rarely used.
485
486 /// Create the definition of a directional local symbol for numbered label
487 /// (used for "1:" definitions).
488 MCSymbol *createDirectionalLocalSymbol(unsigned LocalLabelVal);
489
490 /// Create and return a directional local symbol for numbered label (used
491 /// for "1b" or 1f" references).
492 MCSymbol *getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before);
493
494 /// Lookup the symbol inside with the specified \p Name. If it exists,
495 /// return it. If not, create a forward reference and return it.
496 ///
497 /// \param Name - The symbol name, which must be unique across all symbols.
499
500 /// Gets a symbol that will be defined to the final stack offset of a local
501 /// variable after codegen.
502 ///
503 /// \param Idx - The index of a local variable passed to \@llvm.localescape.
504 MCSymbol *getOrCreateFrameAllocSymbol(const Twine &FuncName, unsigned Idx);
505
507
508 MCSymbol *getOrCreateLSDASymbol(const Twine &FuncName);
509
510 /// Get the symbol for \p Name, or null.
511 MCSymbol *lookupSymbol(const Twine &Name) const;
512
513 /// Set value for a symbol.
514 void setSymbolValue(MCStreamer &Streamer, const Twine &Sym, uint64_t Val);
515
516 /// getSymbols - Get a reference for the symbol table for clients that
517 /// want to, for example, iterate over all symbols. 'const' because we
518 /// still want any modifications to the table itself to use the MCContext
519 /// APIs.
520 const SymbolTable &getSymbols() const { return Symbols; }
521
522 /// isInlineAsmLabel - Return true if the name is a label referenced in
523 /// inline assembly.
525 return InlineAsmUsedLabelNames.lookup(Name);
526 }
527
528 /// registerInlineAsmLabel - Records that the name is a label referenced in
529 /// inline assembly.
531
532 /// Allocates and returns a new `WasmSignature` instance (with empty parameter
533 /// and return type lists).
535
536 /// @}
537
538 /// \name Section Management
539 /// @{
540
541 enum : unsigned {
542 /// Pass this value as the UniqueID during section creation to get the
543 /// generic section with the given name and characteristics. The usual
544 /// sections such as .text use this ID.
545 GenericSectionID = ~0U
546 };
547
548 /// Return the MCSection for the specified mach-o section. This requires
549 /// the operands to be valid.
551 unsigned TypeAndAttributes,
552 unsigned Reserved2, SectionKind K,
553 const char *BeginSymName = nullptr);
554
556 unsigned TypeAndAttributes, SectionKind K,
557 const char *BeginSymName = nullptr) {
558 return getMachOSection(Segment, Section, TypeAndAttributes, 0, K,
559 BeginSymName);
560 }
561
562 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
563 unsigned Flags) {
564 return getELFSection(Section, Type, Flags, 0, "", false);
565 }
566
567 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
568 unsigned Flags, unsigned EntrySize) {
569 return getELFSection(Section, Type, Flags, EntrySize, "", false,
570 MCSection::NonUniqueID, nullptr);
571 }
572
573 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
574 unsigned Flags, unsigned EntrySize,
575 const Twine &Group, bool IsComdat) {
576 return getELFSection(Section, Type, Flags, EntrySize, Group, IsComdat,
577 MCSection::NonUniqueID, nullptr);
578 }
579
580 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
581 unsigned Flags, unsigned EntrySize,
582 const Twine &Group, bool IsComdat,
583 unsigned UniqueID,
584 const MCSymbolELF *LinkedToSym);
585
586 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
587 unsigned Flags, unsigned EntrySize,
588 const MCSymbolELF *Group, bool IsComdat,
589 unsigned UniqueID,
590 const MCSymbolELF *LinkedToSym);
591
592 /// Get a section with the provided group identifier. This section is
593 /// named by concatenating \p Prefix with '.' then \p Suffix. The \p Type
594 /// describes the type of the section and \p Flags are used to further
595 /// configure this named section.
596 MCSectionELF *getELFNamedSection(const Twine &Prefix, const Twine &Suffix,
597 unsigned Type, unsigned Flags,
598 unsigned EntrySize = 0);
599
601 unsigned Flags, unsigned EntrySize,
602 const MCSymbolELF *Group,
603 const MCSectionELF *RelInfoSection);
604
605 MCSectionELF *createELFGroupSection(const MCSymbolELF *Group, bool IsComdat);
606
608 unsigned UniqueID, unsigned EntrySize);
609
611
613
614 /// Return the unique ID of the section with the given name, flags and entry
615 /// size, if it exists.
616 std::optional<unsigned> getELFUniqueIDForEntsize(StringRef SectionName,
617 unsigned Flags,
618 unsigned EntrySize);
619
621 MCSection *Parent, const MCExpr *SubsectionId);
622
624 SectionKind Kind, StringRef COMDATSymName,
625 int Selection,
626 unsigned UniqueID = GenericSectionID,
627 const char *BeginSymName = nullptr);
628
630 SectionKind Kind,
631 const char *BeginSymName = nullptr);
632
633 /// Gets or creates a section equivalent to Sec that is associated with the
634 /// section containing KeySym. For example, to create a debug info section
635 /// associated with an inline function, pass the normal debug info section
636 /// as Sec and the function symbol as KeySym.
639 unsigned UniqueID = GenericSectionID);
640
642
644 unsigned Flags = 0) {
645 return getWasmSection(Section, K, Flags, nullptr);
646 }
647
649 unsigned Flags, const char *BeginSymName) {
650 return getWasmSection(Section, K, Flags, "", ~0, BeginSymName);
651 }
652
654 unsigned Flags, const Twine &Group,
655 unsigned UniqueID) {
656 return getWasmSection(Section, K, Flags, Group, UniqueID, nullptr);
657 }
658
660 unsigned Flags, const Twine &Group,
661 unsigned UniqueID, const char *BeginSymName);
662
664 unsigned Flags, const MCSymbolWasm *Group,
665 unsigned UniqueID, const char *BeginSymName);
666
667 /// Get the section for the provided Section name
669
670 bool hasXCOFFSection(StringRef Section,
671 XCOFF::CsectProperties CsectProp) const;
672
674 StringRef Section, SectionKind K,
675 std::optional<XCOFF::CsectProperties> CsectProp = std::nullopt,
676 bool MultiSymbolsAllowed = false, const char *BeginSymName = nullptr,
677 std::optional<XCOFF::DwarfSectionSubtypeFlags> DwarfSubtypeFlags =
678 std::nullopt);
679
680 // Create and save a copy of STI and return a reference to the copy.
682
683 uint8_t getBBAddrMapVersion() const { return BBAddrMapVersion; }
684
685 /// @}
686
687 /// \name Dwarf Management
688 /// @{
689
690 /// Get the compilation directory for DW_AT_comp_dir
691 /// The compilation directory should be set with \c setCompilationDir before
692 /// calling this function. If it is unset, an empty string will be returned.
693 StringRef getCompilationDir() const { return CompilationDir; }
694
695 /// Set the compilation directory for DW_AT_comp_dir
696 void setCompilationDir(StringRef S) { CompilationDir = S.str(); }
697
698 /// Add an entry to the debug prefix map.
699 void addDebugPrefixMapEntry(const std::string &From, const std::string &To);
700
701 /// Remap one path in-place as per the debug prefix map.
703
704 // Remaps all debug directory paths in-place as per the debug prefix map.
705 void RemapDebugPaths();
706
707 /// Get the main file name for use in error messages and debug
708 /// info. This can be set to ensure we've got the correct file name
709 /// after preprocessing or for -save-temps.
710 const std::string &getMainFileName() const { return MainFileName; }
711
712 /// Set the main file name and override the default.
713 void setMainFileName(StringRef S) { MainFileName = std::string(S); }
714
715 /// Creates an entry in the dwarf file and directory tables.
717 unsigned FileNumber,
718 std::optional<MD5::MD5Result> Checksum,
719 std::optional<StringRef> Source,
720 unsigned CUID);
721
722 bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID = 0);
723
724 const std::map<unsigned, MCDwarfLineTable> &getMCDwarfLineTables() const {
725 return MCDwarfLineTablesCUMap;
726 }
727
729 return MCDwarfLineTablesCUMap[CUID];
730 }
731
732 const MCDwarfLineTable &getMCDwarfLineTable(unsigned CUID) const {
733 auto I = MCDwarfLineTablesCUMap.find(CUID);
734 assert(I != MCDwarfLineTablesCUMap.end());
735 return I->second;
736 }
737
740 }
741
743 return getMCDwarfLineTable(CUID).getMCDwarfDirs();
744 }
745
746 unsigned getDwarfCompileUnitID() { return DwarfCompileUnitID; }
747
748 void setDwarfCompileUnitID(unsigned CUIndex) { DwarfCompileUnitID = CUIndex; }
749
750 /// Specifies the "root" file and directory of the compilation unit.
751 /// These are "file 0" and "directory 0" in DWARF v5.
752 void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir,
753 StringRef Filename,
754 std::optional<MD5::MD5Result> Checksum,
755 std::optional<StringRef> Source) {
756 getMCDwarfLineTable(CUID).setRootFile(CompilationDir, Filename, Checksum,
757 Source);
758 }
759
760 /// Reports whether MD5 checksum usage is consistent (all-or-none).
761 bool isDwarfMD5UsageConsistent(unsigned CUID) const {
763 }
764
765 /// Saves the information from the currently parsed dwarf .loc directive
766 /// and sets DwarfLocSeen. When the next instruction is assembled an entry
767 /// in the line number table with this information and the address of the
768 /// instruction will be created.
769 void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column,
770 unsigned Flags, unsigned Isa,
771 unsigned Discriminator) {
772 CurrentDwarfLoc.setFileNum(FileNum);
773 CurrentDwarfLoc.setLine(Line);
774 CurrentDwarfLoc.setColumn(Column);
775 CurrentDwarfLoc.setFlags(Flags);
776 CurrentDwarfLoc.setIsa(Isa);
777 CurrentDwarfLoc.setDiscriminator(Discriminator);
778 DwarfLocSeen = true;
779 }
780
781 void clearDwarfLocSeen() { DwarfLocSeen = false; }
782
783 bool getDwarfLocSeen() { return DwarfLocSeen; }
784 const MCDwarfLoc &getCurrentDwarfLoc() { return CurrentDwarfLoc; }
785
786 bool getGenDwarfForAssembly() { return GenDwarfForAssembly; }
787 void setGenDwarfForAssembly(bool Value) { GenDwarfForAssembly = Value; }
788 unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }
791
792 void setGenDwarfFileNumber(unsigned FileNumber) {
793 GenDwarfFileNumber = FileNumber;
794 }
795
796 /// Specifies information about the "root file" for assembler clients
797 /// (e.g., llvm-mc). Assumes compilation dir etc. have been set up.
798 void setGenDwarfRootFile(StringRef FileName, StringRef Buffer);
799
801 return SectionsForRanges;
802 }
803
805 return SectionsForRanges.insert(Sec);
806 }
807
809
810 const std::vector<MCGenDwarfLabelEntry> &getMCGenDwarfLabelEntries() const {
811 return MCGenDwarfLabelEntries;
812 }
813
815 MCGenDwarfLabelEntries.push_back(E);
816 }
817
818 void setDwarfDebugFlags(StringRef S) { DwarfDebugFlags = S; }
819 StringRef getDwarfDebugFlags() { return DwarfDebugFlags; }
820
821 void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
822 StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
823
826
827 void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
828 uint16_t getDwarfVersion() const { return DwarfVersion; }
829
830 /// @}
831
832 StringRef getSecureLogFile() { return SecureLogFile; }
833 raw_fd_ostream *getSecureLog() { return SecureLog.get(); }
834
835 void setSecureLog(std::unique_ptr<raw_fd_ostream> Value) {
836 SecureLog = std::move(Value);
837 }
838
839 bool getSecureLogUsed() { return SecureLogUsed; }
840 void setSecureLogUsed(bool Value) { SecureLogUsed = Value; }
841
842 void *allocate(unsigned Size, unsigned Align = 8) {
843 return Allocator.Allocate(Size, Align);
844 }
845
846 void deallocate(void *Ptr) {}
847
848 /// Allocates a copy of the given string on the allocator managed by this
849 /// context and returns the result.
851 return StringSaver(Allocator).save(s);
852 }
853
854 bool hadError() { return HadError; }
855 void diagnose(const SMDiagnostic &SMD);
856 void reportError(SMLoc L, const Twine &Msg);
857 void reportWarning(SMLoc L, const Twine &Msg);
858
860 StringMap<MCAsmMacro>::iterator I = MacroMap.find(Name);
861 return (I == MacroMap.end()) ? nullptr : &I->getValue();
862 }
863
865 MacroMap.insert(std::make_pair(Name, std::move(Macro)));
866 }
867
868 void undefineMacro(StringRef Name) { MacroMap.erase(Name); }
869
870 MCPseudoProbeTable &getMCPseudoProbeTable() { return PseudoProbeTable; }
871};
872
873} // end namespace llvm
874
875// operator new and delete aren't allowed inside namespaces.
876// The throw specifications are mandated by the standard.
877/// Placement new for using the MCContext's allocator.
878///
879/// This placement form of operator new uses the MCContext's allocator for
880/// obtaining memory. It is a non-throwing new, which means that it returns
881/// null on error. (If that is what the allocator does. The current does, so if
882/// this ever changes, this operator will have to be changed, too.)
883/// Usage looks like this (assuming there's an MCContext 'Context' in scope):
884/// \code
885/// // Default alignment (8)
886/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
887/// // Specific alignment
888/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
889/// \endcode
890/// Please note that you cannot use delete on the pointer; it must be
891/// deallocated using an explicit destructor call followed by
892/// \c Context.Deallocate(Ptr).
893///
894/// \param Bytes The number of bytes to allocate. Calculated by the compiler.
895/// \param C The MCContext that provides the allocator.
896/// \param Alignment The alignment of the allocated memory (if the underlying
897/// allocator supports it).
898/// \return The allocated memory. Could be NULL.
899inline void *operator new(size_t Bytes, llvm::MCContext &C,
900 size_t Alignment = 8) noexcept {
901 return C.allocate(Bytes, Alignment);
902}
903/// Placement delete companion to the new above.
904///
905/// This operator is just a companion to the new above. There is no way of
906/// invoking it directly; see the new operator for more details. This operator
907/// is called implicitly by the compiler if a placement new expression using
908/// the MCContext throws in the object constructor.
909inline void operator delete(void *Ptr, llvm::MCContext &C, size_t) noexcept {
910 C.deallocate(Ptr);
911}
912
913/// This placement form of operator new[] uses the MCContext's allocator for
914/// obtaining memory. It is a non-throwing new[], which means that it returns
915/// null on error.
916/// Usage looks like this (assuming there's an MCContext 'Context' in scope):
917/// \code
918/// // Default alignment (8)
919/// char *data = new (Context) char[10];
920/// // Specific alignment
921/// char *data = new (Context, 4) char[10];
922/// \endcode
923/// Please note that you cannot use delete on the pointer; it must be
924/// deallocated using an explicit destructor call followed by
925/// \c Context.Deallocate(Ptr).
926///
927/// \param Bytes The number of bytes to allocate. Calculated by the compiler.
928/// \param C The MCContext that provides the allocator.
929/// \param Alignment The alignment of the allocated memory (if the underlying
930/// allocator supports it).
931/// \return The allocated memory. Could be NULL.
932inline void *operator new[](size_t Bytes, llvm::MCContext &C,
933 size_t Alignment = 8) noexcept {
934 return C.allocate(Bytes, Alignment);
935}
936
937/// Placement delete[] companion to the new[] above.
938///
939/// This operator is just a companion to the new[] above. There is no way of
940/// invoking it directly; see the new[] operator for more details. This operator
941/// is called implicitly by the compiler if a placement new[] expression using
942/// the MCContext throws in the object constructor.
943inline void operator delete[](void *Ptr, llvm::MCContext &C) noexcept {
944 C.deallocate(Ptr);
945}
946
947#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:870
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:441
void remapDebugPath(SmallVectorImpl< char > &Path)
Remap one path in-place as per the debug prefix map.
Definition: MCContext.cpp:902
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Definition: MCContext.cpp:893
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:842
const SetVector< MCSection * > & getGenDwarfSectionSyms()
Definition: MCContext.h:800
void deallocate(void *Ptr)
Definition: MCContext.h:846
const SmallVectorImpl< std::string > & getMCDwarfDirs(unsigned CUID=0)
Definition: MCContext.h:742
Environment getObjectFileType() const
Definition: MCContext.h:420
bool isDwarfMD5UsageConsistent(unsigned CUID) const
Reports whether MD5 checksum usage is consistent (all-or-none).
Definition: MCContext.h:761
void setObjectFileInfo(const MCObjectFileInfo *Mofi)
Definition: MCContext.h:435
const MCAsmMacro * lookupMacro(StringRef Name)
Definition: MCContext.h:859
bool hadError()
Definition: MCContext.h:854
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags, const char *BeginSymName)
Definition: MCContext.h:648
StringRef getDwarfDebugProducer()
Definition: MCContext.h:822
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:710
StringRef getDwarfDebugFlags()
Definition: MCContext.h:819
bool getDwarfLocSeen()
Definition: MCContext.h:783
void addDebugPrefixMapEntry(const std::string &From, const std::string &To)
Add an entry to the debug prefix map.
Definition: MCContext.cpp:897
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:693
bool getGenDwarfForAssembly()
Definition: MCContext.h:786
void RemapDebugPaths()
Definition: MCContext.cpp:908
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:840
void defineMacro(StringRef Name, MCAsmMacro Macro)
Definition: MCContext.h:864
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:449
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
Definition: MCContext.h:643
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:524
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:990
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:573
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags, unsigned EntrySize)
Definition: MCContext.h:567
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:562
void setGenDwarfForAssembly(bool Value)
Definition: MCContext.h:787
uint8_t getBBAddrMapVersion() const
Definition: MCContext.h:683
void diagnose(const SMDiagnostic &SMD)
Definition: MCContext.cpp:1028
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:1001
void setDwarfVersion(uint16_t v)
Definition: MCContext.h:827
void clearDwarfLocSeen()
Definition: MCContext.h:781
StringMap< MCSymbol *, BumpPtrAllocator & > SymbolTable
Definition: MCContext.h:83
const StringRef & getSwift5ReflectionSegmentName() const
Definition: MCContext.h:422
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:804
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:850
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:728
bool getSecureLogUsed()
Definition: MCContext.h:839
raw_fd_ostream * getSecureLog()
Definition: MCContext.h:833
void initInlineSourceManager()
Definition: MCContext.cpp:125
void setDiagnosticHandler(DiagHandlerTy DiagHandler)
Definition: MCContext.h:431
unsigned getDwarfCompileUnitID()
Definition: MCContext.h:746
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:653
bool emitCompactUnwindNonCanonical() const
Definition: MCContext.cpp:943
void undefineMacro(StringRef Name)
Definition: MCContext.h:868
CodeViewContext & getCVContext()
Definition: MCContext.cpp:1018
const MCRegisterInfo * getRegisterInfo() const
Definition: MCContext.h:439
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
Definition: MCContext.h:738
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:824
void setCompilationDir(StringRef S)
Set the compilation directory for DW_AT_comp_dir.
Definition: MCContext.h:696
const std::map< unsigned, MCDwarfLineTable > & getMCDwarfLineTables() const
Definition: MCContext.h:724
bool isELFGenericMergeableSection(StringRef Name)
Definition: MCContext.cpp:645
unsigned getGenDwarfFileNumber()
Definition: MCContext.h:788
void setDwarfDebugFlags(StringRef S)
Definition: MCContext.h:818
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:769
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:788
void setDwarfDebugProducer(StringRef S)
Definition: MCContext.h:821
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:651
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:1080
uint16_t getDwarfVersion() const
Definition: MCContext.h:828
const SourceMgr * getSourceManager() const
Definition: MCContext.h:426
const SymbolTable & getSymbols() const
getSymbols - Get a reference for the symbol table for clients that want to, for example,...
Definition: MCContext.h:520
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:437
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionsForRanges, to avoid generating useless debug info for them.
Definition: MCContext.cpp:1013
void setSecureLog(std::unique_ptr< raw_fd_ostream > Value)
Definition: MCContext.h:835
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1073
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
Definition: MCContext.cpp:676
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E)
Definition: MCContext.h:814
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:870
MCContext & operator=(const MCContext &)=delete
bool hasXCOFFSection(StringRef Section, XCOFF::CsectProperties CsectProp) const
Definition: MCContext.cpp:782
@ GenericSectionID
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
Definition: MCContext.h:545
void setMainFileName(StringRef S)
Set the main file name and override the default.
Definition: MCContext.h:713
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:201
SourceMgr * getInlineSourceManager()
Definition: MCContext.h:429
MCSymbol * createLinkerPrivateSymbol(const Twine &Name)
Definition: MCContext.cpp:316
void setGenDwarfFileNumber(unsigned FileNumber)
Definition: MCContext.h:792
MCSectionSPIRV * getSPIRVSection()
Definition: MCContext.cpp:858
const MCTargetOptions * getTargetOptions() const
Definition: MCContext.h:445
void setDwarfCompileUnitID(unsigned CUIndex)
Definition: MCContext.h:748
const MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID) const
Definition: MCContext.h:732
EmitDwarfUnwindType emitDwarfUnwindInfo() const
Definition: MCContext.cpp:937
bool isELFImplicitMergeableSectionNamePrefix(StringRef Name)
Definition: MCContext.cpp:640
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group, bool IsComdat)
Definition: MCContext.cpp:612
void setUseNamesOnTempLabels(bool Value)
Definition: MCContext.h:450
std::function< void(const SMDiagnostic &, bool, const SourceMgr &, std::vector< const MDNode * > &)> DiagHandlerTy
Definition: MCContext.h:86
const MCDwarfLoc & getCurrentDwarfLoc()
Definition: MCContext.h:784
void setGenDwarfRootFile(StringRef FileName, StringRef Buffer)
Specifies information about the "root file" for assembler clients (e.g., llvm-mc).
Definition: MCContext.cpp:949
dwarf::DwarfFormat getDwarfFormat() const
Definition: MCContext.h:825
const std::vector< MCGenDwarfLabelEntry > & getMCGenDwarfLabelEntries() const
Definition: MCContext.h:810
MCSectionGOFF * getGOFFSection(StringRef Section, SectionKind Kind, MCSection *Parent, const MCExpr *SubsectionId)
Definition: MCContext.cpp:658
StringRef getSecureLogFile()
Definition: MCContext.h:832
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:715
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, SectionKind K, const char *BeginSymName=nullptr)
Definition: MCContext.h:555
std::vector< const MDNode * > & getLocInfos()
Definition: MCContext.h:430
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:752
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:443
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:425
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:387
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