LLVM: lib/MC/MCContext.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
53#include
54#include
55#include
56#include
57#include
58
59using namespace llvm;
60
62 std::vector<const MDNode *> &) {
64}
65
69 bool DoAutoReset, StringRef Swift5ReflSegmentName)
70 : Swift5ReflectionSegmentName(Swift5ReflSegmentName), TT(TheTriple),
72 MAI(mai), MRI(mri), MSTI(msti), Symbols(Allocator),
73 InlineAsmUsedLabelNames(Allocator),
75 AutoReset(DoAutoReset), TargetOptions(TargetOpts) {
78
82
86 break;
90 "Cannot initialize MC for non-Windows COFF object files.");
91
93 break;
96 break;
99 break;
102 break;
105 break;
108 break;
111 break;
113 report_fatal_error("Cannot initialize MC for unknown object file format.");
114 break;
115 }
116}
117
119 if (AutoReset)
121
122
123
124}
125
127 if (!InlineSrcMgr)
128 InlineSrcMgr.reset(new SourceMgr());
129}
130
131
132
133
134
136 SrcMgr = nullptr;
137 InlineSrcMgr.reset();
138 LocInfos.clear();
140
141
142 COFFAllocator.DestroyAll();
143 DXCAllocator.DestroyAll();
144 ELFAllocator.DestroyAll();
145 GOFFAllocator.DestroyAll();
146 MachOAllocator.DestroyAll();
147 WasmAllocator.DestroyAll();
148 XCOFFAllocator.DestroyAll();
149 MCInstAllocator.DestroyAll();
150 SPIRVAllocator.DestroyAll();
151 WasmSignatureAllocator.DestroyAll();
152
153
154
155 CVContext.reset();
156
157 MCSubtargetAllocator.DestroyAll();
158 InlineAsmUsedLabelNames.clear();
160 Allocator.Reset();
161 FragmentAllocator.Reset();
162 Instances.clear();
163 CompilationDir.clear();
164 MainFileName.clear();
165 MCDwarfLineTablesCUMap.clear();
166 SectionsForRanges.clear();
167 MCGenDwarfLabelEntries.clear();
169 DwarfCompileUnitID = 0;
171
172 MachOUniquingMap.clear();
173 ELFUniquingMap.clear();
174 GOFFUniquingMap.clear();
175 COFFUniquingMap.clear();
176 WasmUniquingMap.clear();
177 XCOFFUniquingMap.clear();
178 DXCUniquingMap.clear();
179
180 ELFEntrySizeMap.clear();
181 ELFSeenGenericMergeableSections.clear();
182
183 DwarfLocSeen = false;
184 GenDwarfForAssembly = false;
185 GenDwarfFileNumber = 0;
186
187 HadError = false;
188}
189
190
191
192
193
195 return new (MCInstAllocator.Allocate()) MCInst;
196}
197
198
201 auto *F = allocFragment();
202 F->setParent(&Sec);
205 return F;
206}
207
208
209
210
211
215
216 assert(!NameRef.empty() && "Normal symbols cannot be unnamed!");
217
219 if (!Entry.second.Symbol) {
221 bool IsTemporary = IsRenamable && !SaveTempLabels;
222 if (!Entry.second.Used) {
223 Entry.second.Used = true;
224 Entry.second.Symbol = createSymbolImpl(&Entry, IsTemporary);
225 } else {
226 assert(IsRenamable && "cannot rename non-private symbol");
227
228 Entry.second.Symbol = createRenamableSymbol(NameRef, false, IsTemporary);
229 }
230 }
231
232 return Entry.second.Symbol;
233}
234
236 unsigned Idx) {
238 "$frame_escape_" + Twine(Idx));
239}
240
243 "$parent_frame_offset");
244}
245
248 FuncName);
249}
250
253}
254
256 bool IsTemporary) {
257 static_assert(std::is_trivially_destructible(),
258 "MCSymbol classes must be trivially destructible");
259 static_assert(std::is_trivially_destructible(),
260 "MCSymbol classes must be trivially destructible");
261 static_assert(std::is_trivially_destructible(),
262 "MCSymbol classes must be trivially destructible");
263 static_assert(std::is_trivially_destructible(),
264 "MCSymbol classes must be trivially destructible");
265 static_assert(std::is_trivially_destructible(),
266 "MCSymbol classes must be trivially destructible");
267
280 return createXCOFFSymbolImpl(Name, IsTemporary);
282 break;
284 return new (Name, *this)
286 }
287 return new (Name, *this)
289}
290
292 bool AlwaysAddSuffix,
293 bool IsTemporary) {
295 Name.toVector(NewName);
296 size_t NameLen = NewName.size();
297
300 while (AlwaysAddSuffix || EntryPtr->second.Used) {
301 AlwaysAddSuffix = false;
302
303 NewName.resize(NameLen);
305 EntryPtr = &getSymbolTableEntry(NewName.str());
306 }
307
308 EntryPtr->second.Used = true;
309 return createSymbolImpl(EntryPtr, IsTemporary);
310}
311
313 if (!UseNamesOnTempLabels)
314 return createSymbolImpl(nullptr, true);
316 AlwaysAddSuffix, true);
317}
318
321 !SaveTempLabels);
322}
323
325 if (AlwaysEmit)
327
328 bool IsTemporary = !SaveTempLabels;
329 if (IsTemporary && !UseNamesOnTempLabels)
330 return createSymbolImpl(nullptr, IsTemporary);
332 false, IsTemporary);
333}
334
337}
338
341 true,
342 false);
343}
344
346
349}
350
353 return createSymbolImpl(&NameEntry, false);
354}
355
356unsigned MCContext::NextInstance(unsigned LocalLabelVal) {
357 MCLabel *&Label = Instances[LocalLabelVal];
358 if (!Label)
359 Label = new (*this) MCLabel(0);
360 return Label->incInstance();
361}
362
363unsigned MCContext::GetInstance(unsigned LocalLabelVal) {
364 MCLabel *&Label = Instances[LocalLabelVal];
365 if (!Label)
366 Label = new (*this) MCLabel(0);
367 return Label->getInstance();
368}
369
370MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
371 unsigned Instance) {
372 MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)];
373 if ()
375 return Sym;
376}
377
379 unsigned Instance = NextInstance(LocalLabelVal);
380 return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
381}
382
385 unsigned Instance = GetInstance(LocalLabelVal);
387 ++Instance;
388 return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
389}
390
391template
392Symbol *MCContext::getOrCreateSectionSymbol(StringRef Section) {
393 Symbol *R;
394 auto &SymEntry = getSymbolTableEntry(Section);
396
397
398 if (Sym && Sym->isDefined() &&
399 (->isInSection() || Sym->getSection().getBeginSymbol() != Sym))
401 if (Sym && Sym->isUndefined()) {
402 R = cast(Sym);
403 } else {
404 SymEntry.second.Used = true;
405 R = new (&SymEntry, *this) Symbol(&SymEntry, false);
406 if ()
407 SymEntry.second.Symbol = R;
408 }
409 return R;
410}
411
416}
417
422}
423
425 InlineAsmUsedLabelNames[Sym->getName()] = Sym;
426}
427
430}
431
433 bool IsTemporary) {
435 return new (nullptr, *this) MCSymbolXCOFF(nullptr, IsTemporary);
436
438 if (OriginalName.starts_with("._Renamed..") ||
441
444
445
446
447
449
450
451
452
453 const bool IsEntryPoint = InvalidName.starts_with(".");
455 StringRef(IsEntryPoint ? "._Renamed.." : "_Renamed..");
456
457
458
459 for (size_t I = 0; I < InvalidName.size(); ++I) {
460 if (!MAI->isAcceptableChar(InvalidName[I]) || InvalidName[I] == '_') {
462 InvalidName[I] = '_';
463 }
464 }
465
466
467
468 if (IsEntryPoint)
469 ValidName.append(InvalidName.substr(1, InvalidName.size() - 1));
470 else
471 ValidName.append(InvalidName);
472
474 assert(!NameEntry.second.Used && "This name is used somewhere else.");
475 NameEntry.second.Used = true;
476
477
479 new (&NameEntry, *this) MCSymbolXCOFF(&NameEntry, IsTemporary);
481 return XSym;
482}
483
484
485
486
487
489 unsigned TypeAndAttributes,
491 const char *BeginSymName) {
492
493
494
495
496
497 assert(Section.size() <= 16 && "section name is too long");
498 assert(!memchr(Section.data(), '\0', Section.size()) &&
499 "section name cannot contain NUL");
500
501
502 auto R = MachOUniquingMap.try_emplace((Segment + Twine(',') + Section).str());
503 if (!R.second)
504 return R.first->second;
505
507 if (BeginSymName)
509
510
512 auto *Ret = new (MachOAllocator.Allocate())
514 TypeAndAttributes, Reserved2, Kind, Begin);
515 R.first->second = Ret;
516 allocInitialFragment(*Ret);
517 return Ret;
518}
519
521 unsigned Flags,
522 unsigned EntrySize,
524 bool Comdat, unsigned UniqueID,
526 auto *R = getOrCreateSectionSymbol(Section);
529
530 auto *Ret = new (ELFAllocator.Allocate()) MCSectionELF(
531 Section, Type, Flags, EntrySize, Group, Comdat, UniqueID, R, LinkedToSym);
532
533 auto *F = allocInitialFragment(*Ret);
534 R->setFragment(F);
535 return Ret;
536}
537
540 unsigned EntrySize, const MCSymbolELF *Group,
543 bool Inserted;
544 std::tie(I, Inserted) = RelSecNames.insert(std::make_pair(Name.str(), true));
545
546 return createELFSectionImpl(
547 I->getKey(), Type, Flags, EntrySize, Group, true, true,
548 cast(RelInfoSection->getBeginSymbol()));
549}
550
552 const Twine &Suffix, unsigned Type,
553 unsigned Flags,
554 unsigned EntrySize) {
555 return getELFSection(Prefix + "." + Suffix, Type, Flags, EntrySize, Suffix,
556 true);
557}
558
560 unsigned Flags, unsigned EntrySize,
561 const Twine &Group, bool IsComdat,
562 unsigned UniqueID,
567
568 return getELFSection(Section, Type, Flags, EntrySize, GroupSym, IsComdat,
569 UniqueID, LinkedToSym);
570}
571
573 unsigned Flags, unsigned EntrySize,
575 bool IsComdat, unsigned UniqueID,
578 if (GroupSym)
579 Group = GroupSym->getName();
581
582
583
584
585
586 std::pair<StringMap<MCSectionELF *>::iterator, bool> EntryNewPair;
587
588 unsigned SectionLen;
591 Section.toVector(Buffer);
592 SectionLen = Buffer.size();
593 Buffer.push_back(0);
594 if (GroupSym)
596 Buffer.push_back(0);
597 if (LinkedToSym)
601 EntryNewPair = ELFUniquingMap.insert(std::make_pair(UniqueMapKey, nullptr));
602 } else if (!Section.isSingleStringRef()) {
604 StringRef UniqueMapKey = Section.toStringRef(Buffer);
605 SectionLen = UniqueMapKey.size();
606 EntryNewPair = ELFUniquingMap.insert(std::make_pair(UniqueMapKey, nullptr));
607 } else {
608 StringRef UniqueMapKey = Section.getSingleStringRef();
609 SectionLen = UniqueMapKey.size();
610 EntryNewPair = ELFUniquingMap.insert(std::make_pair(UniqueMapKey, nullptr));
611 }
612
613 if (!EntryNewPair.second)
614 return EntryNewPair.first->second;
615
616 StringRef CachedName = EntryNewPair.first->getKey().take_front(SectionLen);
617
619 createELFSectionImpl(CachedName, Type, Flags, EntrySize, GroupSym,
620 IsComdat, UniqueID, LinkedToSym);
621 EntryNewPair.first->second = Result;
622
624 Result->getUniqueID(), Result->getEntrySize());
625
626 return Result;
627}
628
630 bool IsComdat) {
631 return createELFSectionImpl(".group", ELF::SHT_GROUP, 0, 4, Group, IsComdat,
633}
634
636 unsigned Flags, unsigned UniqueID,
637 unsigned EntrySize) {
640 ELFSeenGenericMergeableSections.insert(SectionName);
641
642
643 IsMergeable = true;
644 }
645
646
647
648
649
651 ELFEntrySizeMap.insert(std::make_pair(
652 std::make_tuple(SectionName, Flags, EntrySize), UniqueID));
653 }
654}
655
657 return SectionName.starts_with(".rodata.str") ||
659}
660
663 ELFSeenGenericMergeableSections.count(SectionName);
664}
665
666std::optional
668 unsigned EntrySize) {
669 auto I = ELFEntrySizeMap.find(std::make_tuple(SectionName, Flags, EntrySize));
670 return (I != ELFEntrySizeMap.end()) ? std::optional(I->second)
671 : std::nullopt;
672}
673
677
678 auto IterBool =
679 GOFFUniquingMap.insert(std::make_pair(Section.str(), nullptr));
680 auto Iter = IterBool.first;
681 if (!IterBool.second)
682 return Iter->second;
683
684 StringRef CachedName = Iter->first;
685 MCSectionGOFF *GOFFSection = new (GOFFAllocator.Allocate())
686 MCSectionGOFF(CachedName, Kind, Parent, Subsection);
687 Iter->second = GOFFSection;
688 allocInitialFragment(*GOFFSection);
689 return GOFFSection;
690}
691
695 unsigned UniqueID) {
696 MCSymbol *COMDATSymbol = nullptr;
697 if (!COMDATSymName.empty()) {
699 assert(COMDATSymbol && "COMDATSymbol is null");
700 COMDATSymName = COMDATSymbol->getName();
701
702
706 cast(COMDATSymbol->getSection()).getCOMDATSymbol() !=
707 COMDATSymbol))
709 }
710
711
712 COFFSectionKey T{Section, COMDATSymName, Selection, UniqueID};
713 auto IterBool = COFFUniquingMap.insert(std::make_pair(T, nullptr));
714 auto Iter = IterBool.first;
715 if (!IterBool.second)
716 return Iter->second;
717
718 StringRef CachedName = Iter->first.SectionName;
719 MCSymbol *Begin = getOrCreateSectionSymbol(Section);
722 Iter->second = Result;
723 auto *F = allocInitialFragment(*Result);
725 return Result;
726}
727
731}
732
735 unsigned UniqueID) {
736
738 return Sec;
739
740
741
743 if (KeySym) {
747 }
748
750}
751
753 unsigned Flags, const Twine &Group,
754 unsigned UniqueID) {
759 if (K.isMetadata() && !GroupSym->getType().has_value()) {
760
761
763 }
764 }
765
766 return getWasmSection(Section, K, Flags, GroupSym, UniqueID);
767}
768
770 unsigned Flags,
772 unsigned UniqueID) {
774 if (GroupSym)
775 Group = GroupSym->getName();
776
777 auto IterBool = WasmUniquingMap.insert(
778 std::make_pair(WasmSectionKey{Section.str(), Group, UniqueID}, nullptr));
779 auto &Entry = *IterBool.first;
780 if (!IterBool.second)
781 return Entry.second;
782
783 StringRef CachedName = Entry.first.SectionName;
784
785 MCSymbol *Begin = createRenamableSymbol(CachedName, true, false);
786
787 getSymbolTableEntry(Begin->getName()).second.Symbol = Begin;
789
790 MCSectionWasm *Result = new (WasmAllocator.Allocate())
791 MCSectionWasm(CachedName, Kind, Flags, GroupSym, UniqueID, Begin);
792 Entry.second = Result;
793
794 auto *F = allocInitialFragment(*Result);
796 return Result;
797}
798
801 return XCOFFUniquingMap.count(
802 XCOFFSectionKey(Section.str(), CsectProp.MappingClass)) != 0;
803}
804
807 std::optionalXCOFF::CsectProperties CsectProp, bool MultiSymbolsAllowed,
810 assert((IsDwarfSec != CsectProp.has_value()) && "Invalid XCOFF section!");
811
812
813 auto IterBool = XCOFFUniquingMap.insert(std::make_pair(
815 : XCOFFSectionKey(Section.str(), CsectProp->MappingClass),
816 nullptr));
817 auto &Entry = *IterBool.first;
818 if (!IterBool.second) {
821 report_fatal_error("section's multiply symbols policy does not match");
822
823 return ExistedEntry;
824 }
825
826
827 StringRef CachedName = Entry.first.SectionName;
829
830 if (IsDwarfSec)
832 else
834 CachedName + "[" +
836
837
838
840 if (IsDwarfSec)
841 Result = new (XCOFFAllocator.Allocate()) MCSectionXCOFF(
844 else
845 Result = new (XCOFFAllocator.Allocate())
847 CsectProp->Type, Kind, QualName, nullptr, CachedName,
848 MultiSymbolsAllowed);
849
850 Entry.second = Result;
851
852 auto *F = allocInitialFragment(*Result);
853
854
855
856
857
858
859 if (IsDwarfSec || CsectProp->MappingClass == XCOFF::XMC_PR)
861
862 return Result;
863}
864
867
868 allocInitialFragment(*Result);
869 return Result;
870}
871
874
875 auto ItInsertedPair = DXCUniquingMap.try_emplace(Section);
876 if (!ItInsertedPair.second)
877 return ItInsertedPair.first->second;
878
879 auto MapIt = ItInsertedPair.first;
880
881
882
884 MapIt->second =
886
887
888 allocInitialFragment(*MapIt->second);
889 return MapIt->second;
890}
891
893 return *new (MCSubtargetAllocator.Allocate()) MCSubtargetInfo(STI);
894}
895
897 const std::string &To) {
899}
900
904 break;
905}
906
908 const auto &DebugPrefixMap = this->DebugPrefixMap;
909 if (DebugPrefixMap.empty())
910 return;
911
912
914
915
917 for (auto &CUIDTablePair : MCDwarfLineTablesCUMap) {
918 for (auto &Dir : CUIDTablePair.second.getMCDwarfDirs()) {
919 P = Dir;
921 Dir = std::string(P);
922 }
923
924
925
926 P = CUIDTablePair.second.getRootFile().Name;
928 CUIDTablePair.second.getRootFile().Name = std::string(P);
929 }
930}
931
932
933
934
935
940}
941
944 return TargetOptions->EmitCompactUnwindNonCanonical;
945 return false;
946}
947
949
950
951 std::optionalMD5::MD5Result Cksum;
953 MD5 Hash;
957 Cksum = Sum;
958 }
959
960
961
962
963
964
965
966
967
969 if (FileNameBuf.empty() || FileNameBuf == "-")
970 FileNameBuf = "";
974 }
975 StringRef FileName = FileNameBuf;
982}
983
984
985
986
987
990 unsigned FileNumber,
991 std::optionalMD5::MD5Result Checksum,
992 std::optional Source, unsigned CUID) {
994 return Table.tryGetFile(Directory, FileName, Checksum, Source, DwarfVersion,
995 FileNumber);
996}
997
998
999
1002 if (FileNumber == 0)
1005 return false;
1006
1007 return !LineTable.getMCDwarfFiles()[FileNumber].Name.empty();
1008}
1009
1010
1011
1013 SectionsForRanges.remove_if(
1015}
1016
1018 if (!CVContext)
1020 return *CVContext;
1021}
1022
1023
1024
1025
1026
1028 assert(DiagHandler && "MCContext::DiagHandler is not set");
1029 bool UseInlineSrcMgr = false;
1031 if (SrcMgr) {
1032 SMP = SrcMgr;
1033 } else if (InlineSrcMgr) {
1034 SMP = InlineSrcMgr.get();
1035 UseInlineSrcMgr = true;
1036 } else
1038 DiagHandler(SMD, UseInlineSrcMgr, *SMP, LocInfos);
1039}
1040
1041void MCContext::reportCommon(
1044
1045
1046
1047
1048
1051 bool UseInlineSrcMgr = false;
1052
1053
1054
1055
1056
1058 if (SrcMgr) {
1059 SMP = SrcMgr;
1060 } else if (InlineSrcMgr) {
1061 SMP = InlineSrcMgr.get();
1062 UseInlineSrcMgr = true;
1063 } else
1065 }
1066
1068 GetMessage(D, SMP);
1069 DiagHandler(D, UseInlineSrcMgr, *SMP, LocInfos);
1070}
1071
1073 HadError = true;
1076 });
1077}
1078
1081 return;
1084 } else {
1087 });
1088 }
1089}
unsigned const MachineRegisterInfo * MRI
This file defines the StringMap class.
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
BlockVerifier::State From
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
COFFYAML::WeakExternalCharacteristics Characteristics
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
static void defaultDiagHandler(const SMDiagnostic &SMD, bool, const SourceMgr &, std::vector< const MDNode * > &)
#define DWARF2_FLAG_IS_STMT
This file declares the MCSectionGOFF class, which contains all of the necessary machine code sections...
This file contains the MCSymbolGOFF class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
static void DiagHandler(const SMDiagnostic &Diag, void *Context)
void Reset()
Deallocate all but the current slab and reset the current pointer to the beginning of it,...
Holds state from .cv_file and .cv_loc directives for later emission.
Tagged union holding either a T or a Error.
This class is intended to be used as a base class for asm properties and features specific to the tar...
StringRef getPrivateGlobalPrefix() const
StringRef getLinkerPrivateGlobalPrefix() const
StringRef getPrivateLabelPrefix() const
virtual bool isAcceptableChar(char C) const
Return true if C is an acceptable character inside a symbol name.
virtual bool isValidUnquotedName(StringRef Name) const
Return true if the identifier Name does not need quotes to be syntactically correct.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
void remapDebugPath(SmallVectorImpl< char > &Path)
Remap one path in-place as per the debug prefix map.
MCSymbol * createBlockSymbol(const Twine &Name, bool AlwaysEmit=false)
Get or create a symbol for a basic block.
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
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.
Environment getObjectFileType() const
void setSymbolValue(MCStreamer &Streamer, const Twine &Sym, uint64_t Val)
Set value for a symbol.
const std::string & getMainFileName() const
Get the main file name for use in error messages and debug info.
void addDebugPrefixMapEntry(const std::string &From, const std::string &To)
Add an entry to the debug prefix map.
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir The compilation directory should be set with setComp...
MCInst * createMCInst()
Create and return a new MC instruction.
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.
MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *RelInfoSection)
MCSymbol * createLinkerPrivateTempSymbol()
Create a new linker temporary symbol with the specified prefix (Name) or "tmp".
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
void recordELFMergeableSectionInfo(StringRef SectionName, unsigned Flags, unsigned UniqueID, unsigned EntrySize)
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.
wasm::WasmSignature * createWasmSignature()
Allocates and returns a new WasmSignature instance (with empty parameter and return type lists).
MCSectionELF * getELFNamedSection(const Twine &Prefix, const Twine &Suffix, unsigned Type, unsigned Flags, unsigned EntrySize=0)
Get a section with the provided group identifier.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
MCSectionXCOFF * getXCOFFSection(StringRef Section, SectionKind K, std::optional< XCOFF::CsectProperties > CsectProp=std::nullopt, bool MultiSymbolsAllowed=false, std::optional< XCOFF::DwarfSectionSubtypeFlags > DwarfSubtypeFlags=std::nullopt)
void diagnose(const SMDiagnostic &SMD)
bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID=0)
isValidDwarfFileNumber - takes a dwarf file number and returns true if it currently is assigned and f...
void registerInlineAsmLabel(MCSymbol *Sym)
registerInlineAsmLabel - Records that the name is a label referenced in inline assembly.
MCSymbol * createLocalSymbol(StringRef Name)
Create a local, non-temporary symbol like an ELF mapping symbol.
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
void initInlineSourceManager()
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID)
MCSymbol * getOrCreateParentFrameOffsetSymbol(const Twine &FuncName)
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
bool emitCompactUnwindNonCanonical() const
CodeViewContext & getCVContext()
void reset()
reset - return object to right after construction state to prepare to process a new module
MCSectionGOFF * getGOFFSection(StringRef Section, SectionKind Kind, MCSection *Parent, uint32_t Subsection=0)
bool isELFGenericMergeableSection(StringRef Name)
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={})
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.
MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions).
void reportWarning(SMLoc L, const Twine &Msg)
uint16_t getDwarfVersion() const
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionsForRanges, to avoid generating useless debug info for them.
void reportError(SMLoc L, const Twine &Msg)
MCSymbol * getOrCreateLSDASymbol(const Twine &FuncName)
MCSectionDXContainer * getDXContainerSection(StringRef Section, SectionKind K)
Get the section for the provided Section name.
bool hasXCOFFSection(StringRef Section, XCOFF::CsectProperties CsectProp) const
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
MCSymbol * createLinkerPrivateSymbol(const Twine &Name)
MCSectionSPIRV * getSPIRVSection()
EmitDwarfUnwindType emitDwarfUnwindInfo() const
bool isELFImplicitMergeableSectionNamePrefix(StringRef Name)
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group, bool IsComdat)
void setGenDwarfRootFile(StringRef FileName, StringRef Buffer)
Specifies information about the "root file" for assembler clients (e.g., llvm-mc).
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.
@ GenericSectionID
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
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.
MCSymbol * getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before)
Create and return a directional local symbol for numbered label (used for "1b" or 1f" references).
MCSymbol * createNamedTempSymbol()
Create a temporary symbol with a unique name whose name cannot be omitted in the symbol table.
Fragment for data and encoded instructions.
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Instances of this class represent the information from a dwarf .loc directive.
Instances of this class represent a single low-level machine instruction.
Instances of this class represent a label name in the MC file, and MCLabel are created and uniqued by...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This represents a section on Windows.
unsigned getCharacteristics() const
This represents a section on linux, lots of unix variants and some bare metal systems.
This represents a section on a Mach-O system (used by Mac OS X).
This represents a section on wasm.
bool isMultiSymbolsAllowed() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
static constexpr unsigned NonUniqueID
StringRef getName() const
FragList * curFragList() const
MCSymbol * getBeginSymbol()
Streaming machine code generation interface.
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual bool mayHaveInstructions(MCSection &Sec) const
Generic base class for all target subtargets.
void setComdat(bool isComdat)
void setType(wasm::WasmSymbolType type)
std::optional< wasm::WasmSymbolType > getType() const
static StringRef getUnqualifiedName(StringRef Name)
void setSymbolTableName(StringRef STN)
StringRef getUnqualifiedName() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute).
StringRef getName() const
getName - Get the symbol name.
void setFragment(MCFragment *F) const
Mark the symbol as defined in the fragment F.
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true, bool ShowLocation=true) const
Represents a location in source code.
constexpr bool isValid() const
SectionKind - This is a simple POD value that classifies the properties of a section.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void append(StringRef RHS)
Append from a StringRef.
StringRef str() const
Explicit conversion to StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
unsigned getMainFileID() const
const MemoryBuffer * getMemoryBuffer(unsigned i) const
unsigned getNumBuffers() const
SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges={}, ArrayRef< SMFixIt > FixIts={}) const
Return an SMDiagnostic at the specified location with the specified string.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
std::pair< iterator, bool > try_emplace(StringRef Key, ArgsTy &&...Args)
Emplace a new element for the specified key into the map if the key isn't already in the map.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
StringRef - Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
constexpr size_t size() const
size - Get the string size.
char front() const
front - Get the first character in the string.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
Triple - Helper class for working with autoconf configuration names.
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
bool isUEFI() const
Tests whether the OS is UEFI.
bool isOSWindows() const
Tests whether the OS is Windows.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string str() const
Return the twine contents as a std::string.
bool isTriviallyEmpty() const
Check if this twine is trivially empty; a false return value does not necessarily mean the twine is e...
The instances of the Type class are immutable: once they are created, they are never changed.
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_COMDAT_SELECT_ASSOCIATIVE
DwarfSectionSubtypeFlags
Values for defining the section subtype of sections of type STYP_DWARF as they would appear in the (s...
StringRef getMappingClassString(XCOFF::StorageMappingClass SMC)
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
void remove_filename(SmallVectorImpl< char > &path, Style style=Style::native)
Remove the last component from path unless it is the root dir.
bool replace_path_prefix(SmallVectorImpl< char > &Path, StringRef OldPrefix, StringRef NewPrefix, Style style=Style::native)
Replace matching path prefix with another path.
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
bool is_separator(char value, Style style=Style::native)
Check whether the given char is a path separator on the host OS.
@ WASM_SYMBOL_TYPE_SECTION
This is an optimization pass for GlobalISel generic memory operations.
auto reverse(ContainerTy &&C)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
The value for an entry in the symbol table of an MCContext.
MCSymbol * Symbol
The symbol associated with the name, if any.
StorageMappingClass MappingClass