LLVM: lib/MC/MCContext.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
52#include
53#include
54#include
55#include
56#include
57
58using namespace llvm;
59
61 std::vector<const MDNode *> &) {
63}
64
68 bool DoAutoReset, StringRef Swift5ReflSegmentName)
69 : Swift5ReflectionSegmentName(Swift5ReflSegmentName), TT(TheTriple),
71 MAI(mai), MRI(mri), MSTI(msti), Symbols(Allocator),
72 InlineAsmUsedLabelNames(Allocator),
74 AutoReset(DoAutoReset), TargetOptions(TargetOpts) {
75 SaveTempLabels = TargetOptions && TargetOptions->MCSaveTempLabels;
76 if (SaveTempLabels)
78 SecureLogFile = TargetOptions ? TargetOptions->AsSecureLogFile : "";
79
80 if (SrcMgr && SrcMgr->getNumBuffers())
81 MainFileName = std::string(SrcMgr->getMemoryBuffer(SrcMgr->getMainFileID())
82 ->getBufferIdentifier());
83
85 case Triple::MachO:
86 Env = IsMachO;
87 break;
88 case Triple::COFF:
89 if (!TheTriple.isOSWindows() && !TheTriple.isUEFI()) {
90 reportFatalUsageError(
91 "cannot initialize MC for non-Windows COFF object files");
92 }
93
95 break;
98 break;
101 break;
104 break;
107 break;
110 break;
113 break;
115 report_fatal_error("Cannot initialize MC for unknown object file format.");
116 break;
117 }
118}
119
121 if (AutoReset)
123
124
125
126}
127
129 if (!InlineSrcMgr)
130 InlineSrcMgr.reset(new SourceMgr());
131}
132
133
134
135
136
138 SrcMgr = nullptr;
139 InlineSrcMgr.reset();
140 LocInfos.clear();
142
143
144 COFFAllocator.DestroyAll();
145 DXCAllocator.DestroyAll();
146 ELFAllocator.DestroyAll();
147 GOFFAllocator.DestroyAll();
148 MachOAllocator.DestroyAll();
149 WasmAllocator.DestroyAll();
150 XCOFFAllocator.DestroyAll();
151 MCInstAllocator.DestroyAll();
152 SPIRVAllocator.DestroyAll();
153 WasmSignatureAllocator.DestroyAll();
154
155 CVContext.reset();
156
157 MCSubtargetAllocator.DestroyAll();
158 InlineAsmUsedLabelNames.clear();
159 Symbols.clear();
160 Allocator.Reset();
161 Instances.clear();
162 CompilationDir.clear();
163 MainFileName.clear();
164 MCDwarfLineTablesCUMap.clear();
165 SectionsForRanges.clear();
166 MCGenDwarfLabelEntries.clear();
168 DwarfCompileUnitID = 0;
170
171 MachOUniquingMap.clear();
172 ELFUniquingMap.clear();
173 GOFFUniquingMap.clear();
174 COFFUniquingMap.clear();
175 WasmUniquingMap.clear();
176 XCOFFUniquingMap.clear();
177 DXCUniquingMap.clear();
178
179 RelSecNames.clear();
180 MacroMap.clear();
181 ELFEntrySizeMap.clear();
182 ELFSeenGenericMergeableSections.clear();
183
184 DwarfLocSeen = false;
185 GenDwarfForAssembly = false;
186 GenDwarfFileNumber = 0;
187
188 HadError = false;
189}
190
191
192
193
194
196 return new (MCInstAllocator.Allocate()) MCInst;
197}
198
199
200
201
202
205 StringRef NameRef = Name.toStringRef(NameSV);
206
207 assert(!NameRef.empty() && "Normal symbols cannot be unnamed!");
208
210 if (!Entry.second.Symbol) {
211 bool IsRenamable = NameRef.starts_with(MAI->getPrivateGlobalPrefix());
212 bool IsTemporary = IsRenamable && !SaveTempLabels;
213 if (!Entry.second.Used) {
214 Entry.second.Used = true;
215 Entry.second.Symbol = createSymbolImpl(&Entry, IsTemporary);
216 } else {
217 assert(IsRenamable && "cannot rename non-private symbol");
218
219 Entry.second.Symbol = createRenamableSymbol(NameRef, false, IsTemporary);
220 }
221 }
222
223 return Entry.second.Symbol;
224}
225
228 StringRef NameRef = Name.toStringRef(SV);
229 if (NameRef.contains('\\')) {
230 SV = NameRef;
231 size_t S = 0;
232
233
234
235 for (size_t I = 0, E = SV.size(); I != E; ++I) {
237 if (C == '\\' && I + 1 != E) {
238 switch (SV[I + 1]) {
239 case '"':
240 case '\\':
242 break;
243 }
244 }
245 SV[S++] = C;
246 }
248 NameRef = SV;
249 }
250
252}
253
255 unsigned Idx) {
256 return getOrCreateSymbol(MAI->getPrivateGlobalPrefix() + FuncName +
257 "$frame_escape_" + Twine(Idx));
258}
259
261 return getOrCreateSymbol(MAI->getPrivateGlobalPrefix() + FuncName +
262 "$parent_frame_offset");
263}
264
266 return getOrCreateSymbol(MAI->getPrivateGlobalPrefix() + "__ehtable$" +
267 FuncName);
268}
269
272}
273
275 bool IsTemporary) {
276 static_assert(std::is_trivially_destructible(),
277 "MCSymbol classes must be trivially destructible");
278 static_assert(std::is_trivially_destructible(),
279 "MCSymbol classes must be trivially destructible");
280 static_assert(std::is_trivially_destructible(),
281 "MCSymbol classes must be trivially destructible");
282 static_assert(std::is_trivially_destructible(),
283 "MCSymbol classes must be trivially destructible");
284 static_assert(std::is_trivially_destructible(),
285 "MCSymbol classes must be trivially destructible");
286
289 return new (Name, *this) MCSymbolCOFF(Name, IsTemporary);
291 return new (Name, *this) MCSymbolELF(Name, IsTemporary);
293 return new (Name, *this) MCSymbolGOFF(Name, IsTemporary);
295 return new (Name, *this) MCSymbolMachO(Name, IsTemporary);
297 return new (Name, *this) MCSymbolWasm(Name, IsTemporary);
299 return createXCOFFSymbolImpl(Name, IsTemporary);
301 break;
303 return new (Name, *this) MCSymbol(Name, IsTemporary);
304 }
305 return new (Name, *this) MCSymbol(Name, IsTemporary);
306}
307
310 auto Name = Sym.getNameEntryPtr();
313 NewSym =
315 break;
317 NewSym =
319 break;
321 NewSym = new (Name, *this)
323 break;
324 default:
326 break;
327 }
328
329 NewSym->getNameEntryPtr() = Name;
331
333
334
336 return NewSym;
337}
338
339MCSymbol *MCContext::createRenamableSymbol(const Twine &Name,
340 bool AlwaysAddSuffix,
341 bool IsTemporary) {
343 Name.toVector(NewName);
344 size_t NameLen = NewName.size();
345
348 while (AlwaysAddSuffix || EntryPtr->second.Used) {
349 AlwaysAddSuffix = false;
350
351 NewName.resize(NameLen);
353 EntryPtr = &getSymbolTableEntry(NewName.str());
354 }
355
356 EntryPtr->second.Used = true;
357 return createSymbolImpl(EntryPtr, IsTemporary);
358}
359
361 if (!UseNamesOnTempLabels)
362 return createSymbolImpl(nullptr, true);
363 return createRenamableSymbol(MAI->getPrivateGlobalPrefix() + Name,
364 AlwaysAddSuffix, true);
365}
366
368 return createRenamableSymbol(MAI->getPrivateGlobalPrefix() + Name, true,
369 !SaveTempLabels);
370}
371
373 if (AlwaysEmit)
375
376 bool IsTemporary = !SaveTempLabels;
377 if (IsTemporary && !UseNamesOnTempLabels)
378 return createSymbolImpl(nullptr, IsTemporary);
379 return createRenamableSymbol(MAI->getPrivateLabelPrefix() + Name,
380 false, IsTemporary);
381}
382
386
388 return createRenamableSymbol(MAI->getLinkerPrivateGlobalPrefix() + Name,
389 true,
390 false);
391}
392
394
398
401 return createSymbolImpl(&NameEntry, false);
402}
403
404unsigned MCContext::NextInstance(unsigned LocalLabelVal) {
405 MCLabel *&Label = Instances[LocalLabelVal];
406 if (!Label)
407 Label = new (*this) MCLabel(0);
408 return Label->incInstance();
409}
410
411unsigned MCContext::GetInstance(unsigned LocalLabelVal) {
412 MCLabel *&Label = Instances[LocalLabelVal];
413 if (!Label)
414 Label = new (*this) MCLabel(0);
415 return Label->getInstance();
416}
417
418MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
419 unsigned Instance) {
420 MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)];
421 if (!Sym)
423 return Sym;
424}
425
427 unsigned Instance = NextInstance(LocalLabelVal);
428 return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
429}
430
432 bool Before) {
433 unsigned Instance = GetInstance(LocalLabelVal);
434 if (!Before)
435 ++Instance;
436 return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
437}
438
439
440
441template
442Symbol *MCContext::getOrCreateSectionSymbol(StringRef Section) {
443 Symbol *R;
444 auto &SymEntry = getSymbolTableEntry(Section);
445 MCSymbol *Sym = SymEntry.second.Symbol;
449
450
451 if (Sym && Sym->getIndex() != -1u) {
452 R = static_cast<Symbol *>(Sym);
453 } else {
454 SymEntry.second.Used = true;
455 R = new (&SymEntry, *this) Symbol(&SymEntry, false);
456 if (!Sym)
457 SymEntry.second.Symbol = R;
458 }
459
460 R->setIndex(-1u);
461 return R;
462}
463
466 StringRef NameRef = Name.toStringRef(NameSV);
467 return Symbols.lookup(NameRef).Symbol;
468}
469
475
477 InlineAsmUsedLabelNames[Sym->getName()] = Sym;
478}
479
483
485 bool IsTemporary) {
486 if (!Name)
487 return new (nullptr, *this) MCSymbolXCOFF(nullptr, IsTemporary);
488
489 StringRef OriginalName = Name->first();
490 if (OriginalName.starts_with("._Renamed..") ||
493
495 return new (Name, *this) MCSymbolXCOFF(Name, IsTemporary);
496
497
498
499
501
502
503
504
505 const bool IsEntryPoint = InvalidName.starts_with(".");
507 StringRef(IsEntryPoint ? "._Renamed.." : "_Renamed..");
508
509
510
511 for (char &C : InvalidName) {
514 C = '_';
515 }
516 }
517
518
519
520 if (IsEntryPoint)
521 ValidName.append(InvalidName.substr(1, InvalidName.size() - 1));
522 else
523 ValidName.append(InvalidName);
524
526 assert(!NameEntry.second.Used && "This name is used somewhere else.");
527 NameEntry.second.Used = true;
528
529
530 MCSymbolXCOFF *XSym =
531 new (&NameEntry, *this) MCSymbolXCOFF(&NameEntry, IsTemporary);
533 return XSym;
534}
535
536
537
538
539
541 unsigned TypeAndAttributes,
543 const char *BeginSymName) {
544
545
546
547
548
549 assert(Section.size() <= 16 && "section name is too long");
550 assert(!memchr(Section.data(), '\0', Section.size()) &&
551 "section name cannot contain NUL");
552
553
554 auto R = MachOUniquingMap.try_emplace((Segment + Twine(',') + Section).str());
555 if (!R.second)
556 return R.first->second;
557
559 if (BeginSymName)
561
562
563 StringRef Name = R.first->first();
564 auto *Ret = new (MachOAllocator.Allocate())
565 MCSectionMachO(Segment, Name.substr(Name.size() - Section.size()),
566 TypeAndAttributes, Reserved2, Kind, Begin);
567 R.first->second = Ret;
568 return Ret;
569}
570
572 unsigned Flags,
573 unsigned EntrySize,
577 auto *R = getOrCreateSectionSymbol(Section);
578 return new (ELFAllocator.Allocate()) MCSectionELF(
579 Section, Type, Flags, EntrySize, Group, Comdat, UniqueID, R, LinkedToSym);
580}
581
584 unsigned EntrySize, const MCSymbolELF *Group,
587 bool Inserted;
588 std::tie(I, Inserted) = RelSecNames.insert(std::make_pair(Name.str(), true));
589
590 return createELFSectionImpl(
591 I->getKey(), Type, Flags, EntrySize, Group, true, true,
593}
594
596 const Twine &Suffix, unsigned Type,
597 unsigned Flags,
598 unsigned EntrySize) {
599 return getELFSection(Prefix + "." + Suffix, Type, Flags, EntrySize, Suffix,
600 true);
601}
602
604 unsigned Flags, unsigned EntrySize,
605 const Twine &Group, bool IsComdat,
611
612 return getELFSection(Section, Type, Flags, EntrySize, GroupSym, IsComdat,
614}
615
617 unsigned Flags, unsigned EntrySize,
619 bool IsComdat, unsigned UniqueID,
622
623
624
625
626
627 std::pair<StringMap<MCSectionELF *>::iterator, bool> EntryNewPair;
628
629 unsigned SectionLen;
632 Section.toVector(Buffer);
633 SectionLen = Buffer.size();
634 Buffer.push_back(0);
635 if (GroupSym)
637 Buffer.push_back(0);
638 if (LinkedToSym)
642 EntryNewPair = ELFUniquingMap.try_emplace(UniqueMapKey);
643 } else if (!Section.isSingleStringRef()) {
645 StringRef UniqueMapKey = Section.toStringRef(Buffer);
646 SectionLen = UniqueMapKey.size();
647 EntryNewPair = ELFUniquingMap.try_emplace(UniqueMapKey);
648 } else {
649 StringRef UniqueMapKey = Section.getSingleStringRef();
650 SectionLen = UniqueMapKey.size();
651 EntryNewPair = ELFUniquingMap.try_emplace(UniqueMapKey);
652 }
653
654 if (!EntryNewPair.second)
655 return EntryNewPair.first->second;
656
657 StringRef CachedName = EntryNewPair.first->getKey().take_front(SectionLen);
658
660 createELFSectionImpl(CachedName, Type, Flags, EntrySize, GroupSym,
661 IsComdat, UniqueID, LinkedToSym);
662 EntryNewPair.first->second = Result;
663
665 Result->getUniqueID(), Result->getEntrySize());
666
667 return Result;
668}
669
671 bool IsComdat) {
672 return createELFSectionImpl(".group", ELF::SHT_GROUP, 0, 4, Group, IsComdat,
674}
675
677 unsigned Flags, unsigned UniqueID,
678 unsigned EntrySize) {
681 ELFSeenGenericMergeableSections.insert(SectionName);
682
683
684 IsMergeable = true;
685 }
686
687
688
689
690
692 ELFEntrySizeMap.insert(std::make_pair(
694 }
695}
696
698 return SectionName.starts_with(".rodata.str") ||
700}
701
704 ELFSeenGenericMergeableSections.count(SectionName);
705}
706
707std::optional
709 unsigned EntrySize) {
710 auto I = ELFEntrySizeMap.find(std::make_tuple(SectionName, Flags, EntrySize));
711 return (I != ELFEntrySizeMap.end()) ? std::optional(I->second)
712 : std::nullopt;
713}
714
715template
717 TAttr Attributes, MCSection *Parent,
718 bool IsVirtual) {
719 std::string UniqueName(Name);
720 if (Parent) {
721 UniqueName.append("/").append(Parent->getName());
723 UniqueName.append("/").append(P->getName());
724 }
725
726 auto [Iter, Inserted] = GOFFUniquingMap.try_emplace(UniqueName);
727 if (!Inserted)
728 return Iter->second;
729
731 MCSectionGOFF *GOFFSection = new (GOFFAllocator.Allocate())
732 MCSectionGOFF(CachedName, Kind, IsVirtual, Attributes,
734 Iter->second = GOFFSection;
735 return GOFFSection;
736}
737
740 return getGOFFSectionGOFF::SDAttr(Kind, Name, SDAttributes, nullptr,
741 true);
742}
743
747 return getGOFFSectionGOFF::EDAttr(
748 Kind, Name, EDAttributes, Parent,
750}
751
755 return getGOFFSectionGOFF::PRAttr(Kind, Name, PRAttributes, Parent,
756 false);
757}
758
760 unsigned Characteristics,
763 MCSymbol *COMDATSymbol = nullptr;
764 if (!COMDATSymName.empty()) {
766 assert(COMDATSymbol && "COMDATSymbol is null");
767 COMDATSymName = COMDATSymbol->getName();
768
769
776 }
777
778
780 auto [Iter, Inserted] = COFFUniquingMap.try_emplace(T);
781 if (!Inserted)
782 return Iter->second;
783
784 StringRef CachedName = Iter->first.SectionName;
785 MCSymbol *Begin = getOrCreateSectionSymbol(Section);
787 CachedName, Characteristics, COMDATSymbol, Selection, UniqueID, Begin);
788 Iter->second = Result;
789 Begin->setFragment(&Result->getDummyFragment());
790 return Result;
791}
792
794 unsigned Characteristics) {
795 return getCOFFSection(Section, Characteristics, "", 0,
797}
798
802
804 return Sec;
805
806
807
809 if (KeySym) {
813 }
814
816}
817
819 unsigned Flags, const Twine &Group,
825 if (K.isMetadata() && !GroupSym->getType().has_value()) {
826
827
829 }
830 }
831
833}
834
836 unsigned Flags,
840 if (GroupSym)
841 Group = GroupSym->getName();
842
843 auto IterBool = WasmUniquingMap.insert(
844 std::make_pair(WasmSectionKey{Section.str(), Group, UniqueID}, nullptr));
845 auto &Entry = *IterBool.first;
846 if (!IterBool.second)
847 return Entry.second;
848
849 StringRef CachedName = Entry.first.SectionName;
850
851 MCSymbol *Begin = createRenamableSymbol(CachedName, true, false);
852
853 getSymbolTableEntry(Begin->getName()).second.Symbol = Begin;
855
856 MCSectionWasm *Result = new (WasmAllocator.Allocate())
858 Entry.second = Result;
859
860 return Result;
861}
862
865 return XCOFFUniquingMap.count(
866 XCOFFSectionKey(Section.str(), CsectProp.MappingClass)) != 0;
867}
868
871 std::optionalXCOFF::CsectProperties CsectProp, bool MultiSymbolsAllowed,
874 assert((IsDwarfSec != CsectProp.has_value()) && "Invalid XCOFF section!");
875
876
877 auto IterBool = XCOFFUniquingMap.insert(std::make_pair(
879 : XCOFFSectionKey(Section.str(), CsectProp->MappingClass),
880 nullptr));
881 auto &Entry = *IterBool.first;
882 if (!IterBool.second) {
885 report_fatal_error("section's multiply symbols policy does not match");
886
887 return ExistedEntry;
888 }
889
890
891 StringRef CachedName = Entry.first.SectionName;
893
894 if (IsDwarfSec)
896 else
898 CachedName + "[" +
900
901
902
904 if (IsDwarfSec)
905 Result = new (XCOFFAllocator.Allocate()) MCSectionXCOFF(
908 else
909 Result = new (XCOFFAllocator.Allocate())
911 CsectProp->Type, Kind, QualName, nullptr, CachedName,
912 MultiSymbolsAllowed);
913
914 Entry.second = Result;
915 return Result;
916}
917
922
925
926 auto ItInsertedPair = DXCUniquingMap.try_emplace(Section);
927 if (!ItInsertedPair.second)
928 return ItInsertedPair.first->second;
929
930 auto MapIt = ItInsertedPair.first;
931
932
933
935 MapIt->second =
937
938
939 return MapIt->second;
940}
941
943 return *new (MCSubtargetAllocator.Allocate()) MCSubtargetInfo(STI);
944}
945
947 const std::string &To) {
948 DebugPrefixMap.emplace_back(From, To);
949}
950
952 for (const auto &[From, To] : llvm::reverse(DebugPrefixMap))
954 break;
955}
956
958 const auto &DebugPrefixMap = this->DebugPrefixMap;
959 if (DebugPrefixMap.empty())
960 return;
961
962
964
965
967 for (auto &CUIDTablePair : MCDwarfLineTablesCUMap) {
968 for (auto &Dir : CUIDTablePair.second.getMCDwarfDirs()) {
969 P = Dir;
971 Dir = std::string(P);
972 }
973
974
975
976 P = CUIDTablePair.second.getRootFile().Name;
978 CUIDTablePair.second.getRootFile().Name = std::string(P);
979 }
980}
981
982
983
984
985
987 if (!TargetOptions)
989 return TargetOptions->EmitDwarfUnwind;
990}
991
993 if (TargetOptions)
994 return TargetOptions->EmitCompactUnwindNonCanonical;
995 return false;
996}
997
999
1000
1001 std::optionalMD5::MD5Result Cksum;
1003 MD5 Hash;
1005 Hash.update(Buffer);
1006 Hash.final(Sum);
1007 Cksum = Sum;
1008 }
1009
1010
1011
1012
1013
1014
1015
1016
1017
1019 if (FileNameBuf.empty() || FileNameBuf == "-")
1020 FileNameBuf = "";
1024 }
1025 StringRef FileName = FileNameBuf;
1031 0, getCompilationDir(), FileName, Cksum, std::nullopt);
1032}
1033
1034
1035
1036
1037
1040 unsigned FileNumber,
1041 std::optionalMD5::MD5Result Checksum,
1042 std::optional Source, unsigned CUID) {
1044 return Table.tryGetFile(Directory, FileName, Checksum, Source, DwarfVersion,
1045 FileNumber);
1046}
1047
1048
1049
1052 if (FileNumber == 0)
1055 return false;
1056
1057 return !LineTable.getMCDwarfFiles()[FileNumber].Name.empty();
1058}
1059
1060
1061
1063 SectionsForRanges.remove_if(
1065}
1066
1068 if (!CVContext)
1070 return *CVContext;
1071}
1072
1073
1074
1075
1076
1078 assert(DiagHandler && "MCContext::DiagHandler is not set");
1079 bool UseInlineSrcMgr = false;
1081 if (SrcMgr) {
1082 SMP = SrcMgr;
1083 } else if (InlineSrcMgr) {
1084 SMP = InlineSrcMgr.get();
1085 UseInlineSrcMgr = true;
1086 } else
1088 DiagHandler(SMD, UseInlineSrcMgr, *SMP, LocInfos);
1089}
1090
1091void MCContext::reportCommon(
1094
1095
1096
1097
1098
1101 bool UseInlineSrcMgr = false;
1102
1103
1104
1105
1106
1107 if (Loc.isValid()) {
1110 } else if (InlineSrcMgr) {
1111 SMP = InlineSrcMgr.get();
1112 UseInlineSrcMgr = true;
1113 } else
1115 }
1116
1117 SMDiagnostic D;
1118 GetMessage(D, SMP);
1119 DiagHandler(D, UseInlineSrcMgr, *SMP, LocInfos);
1120}
1121
1123 HadError = true;
1126 });
1127}
1128
1130 if (TargetOptions && TargetOptions->MCNoWarn)
1131 return;
1132 if (TargetOptions && TargetOptions->MCFatalWarnings) {
1134 } else {
1137 });
1138 }
1139}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
static const Function * getParent(const Value *V)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static void defaultDiagHandler(const SMDiagnostic &SMD, bool, const SourceMgr &, std::vector< const MDNode * > &)
Definition MCContext.cpp:60
#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.
This file defines the SmallString class.
This file defines the SmallVector class.
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...
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 LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
LLVM_ABI void remapDebugPath(SmallVectorImpl< char > &Path)
Remap one path in-place as per the debug prefix map.
Definition MCContext.cpp:951
LLVM_ABI MCSymbol * createBlockSymbol(const Twine &Name, bool AlwaysEmit=false)
Get or create a symbol for a basic block.
Definition MCContext.cpp:372
LLVM_ABI MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Definition MCContext.cpp:942
LLVM_ABI MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, const char *BeginSymName=nullptr)
Return the MCSection for the specified mach-o section.
Definition MCContext.cpp:540
Environment getObjectFileType() const
LLVM_ABI void setSymbolValue(MCStreamer &Streamer, const Twine &Sym, uint64_t Val)
Set value for a symbol.
Definition MCContext.cpp:470
const std::string & getMainFileName() const
Get the main file name for use in error messages and debug info.
LLVM_ABI MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, StringRef COMDATSymName, int Selection, unsigned UniqueID=MCSection::NonUniqueID)
Definition MCContext.cpp:759
LLVM_ABI void addDebugPrefixMapEntry(const std::string &From, const std::string &To)
Add an entry to the debug prefix map.
Definition MCContext.cpp:946
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Definition MCContext.cpp:393
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir The compilation directory should be set with setComp...
LLVM_ABI void RemapDebugPaths()
Definition MCContext.cpp:957
LLVM_ABI MCInst * createMCInst()
Create and return a new MC instruction.
Definition MCContext.cpp:195
LLVM_ABI MCSymbol * getOrCreateFrameAllocSymbol(const Twine &FuncName, unsigned Idx)
Gets a symbol that will be defined to the final stack offset of a local variable after codegen.
Definition MCContext.cpp:254
LLVM_ABI MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *RelInfoSection)
Definition MCContext.cpp:583
LLVM_ABI MCSymbol * createLinkerPrivateTempSymbol()
Create a new linker temporary symbol with the specified prefix (Name) or "tmp".
Definition MCContext.cpp:383
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
LLVM_ABI void recordELFMergeableSectionInfo(StringRef SectionName, unsigned Flags, unsigned UniqueID, unsigned EntrySize)
Definition MCContext.cpp:676
LLVM_ABI Expected< unsigned > getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
Definition MCContext.cpp:1039
LLVM_ABI wasm::WasmSignature * createWasmSignature()
Allocates and returns a new WasmSignature instance (with empty parameter and return type lists).
Definition MCContext.cpp:480
LLVM_ABI MCSectionELF * getELFNamedSection(const Twine &Prefix, const Twine &Suffix, unsigned Type, unsigned Flags, unsigned EntrySize=0)
Get a section with the provided group identifier.
Definition MCContext.cpp:595
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
LLVM_ABI MCSectionXCOFF * getXCOFFSection(StringRef Section, SectionKind K, std::optional< XCOFF::CsectProperties > CsectProp=std::nullopt, bool MultiSymbolsAllowed=false, std::optional< XCOFF::DwarfSectionSubtypeFlags > DwarfSubtypeFlags=std::nullopt)
Definition MCContext.cpp:869
LLVM_ABI void diagnose(const SMDiagnostic &SMD)
Definition MCContext.cpp:1077
LLVM_ABI bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID=0)
isValidDwarfFileNumber - takes a dwarf file number and returns true if it currently is assigned and f...
Definition MCContext.cpp:1050
LLVM_ABI void registerInlineAsmLabel(MCSymbol *Sym)
registerInlineAsmLabel - Records that the name is a label referenced in inline assembly.
Definition MCContext.cpp:476
LLVM_ABI MCSymbol * createLocalSymbol(StringRef Name)
Create a local, non-temporary symbol like an ELF mapping symbol.
Definition MCContext.cpp:399
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
LLVM_ABI void initInlineSourceManager()
Definition MCContext.cpp:128
LLVM_ABI MCSymbol * getOrCreateParentFrameOffsetSymbol(const Twine &FuncName)
Definition MCContext.cpp:260
LLVM_ABI MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
Definition MCContext.cpp:464
LLVM_ABI bool emitCompactUnwindNonCanonical() const
Definition MCContext.cpp:992
LLVM_ABI ~MCContext()
Definition MCContext.cpp:120
LLVM_ABI CodeViewContext & getCVContext()
Definition MCContext.cpp:1067
LLVM_ABI void reset()
reset - return object to right after construction state to prepare to process a new module
Definition MCContext.cpp:137
LLVM_ABI bool isELFGenericMergeableSection(StringRef Name)
Definition MCContext.cpp:702
LLVM_ABI MCContext(const Triple &TheTriple, const MCAsmInfo *MAI, const MCRegisterInfo *MRI, const MCSubtargetInfo *MSTI, const SourceMgr *Mgr=nullptr, MCTargetOptions const *TargetOpts=nullptr, bool DoAutoReset=true, StringRef Swift5ReflSegmentName={})
Definition MCContext.cpp:65
LLVM_ABI std::optional< unsigned > getELFUniqueIDForEntsize(StringRef SectionName, unsigned Flags, unsigned EntrySize)
Return the unique ID of the section with the given name, flags and entry size, if it exists.
Definition MCContext.cpp:708
LLVM_ABI MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions).
Definition MCContext.cpp:426
LLVM_ABI void reportWarning(SMLoc L, const Twine &Msg)
Definition MCContext.cpp:1129
uint16_t getDwarfVersion() const
LLVM_ABI void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionsForRanges, to avoid generating useless debug info for them.
Definition MCContext.cpp:1062
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
Definition MCContext.cpp:1122
LLVM_ABI MCSymbol * getOrCreateLSDASymbol(const Twine &FuncName)
Definition MCContext.cpp:265
LLVM_ABI MCSectionDXContainer * getDXContainerSection(StringRef Section, SectionKind K)
Get the section for the provided Section name.
Definition MCContext.cpp:923
LLVM_ABI bool hasXCOFFSection(StringRef Section, XCOFF::CsectProperties CsectProp) const
Definition MCContext.cpp:863
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition MCContext.cpp:203
LLVM_ABI MCSymbol * createLinkerPrivateSymbol(const Twine &Name)
Definition MCContext.cpp:387
LLVM_ABI MCSectionSPIRV * getSPIRVSection()
Definition MCContext.cpp:918
LLVM_ABI MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=MCSection::NonUniqueID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym.
Definition MCContext.cpp:799
LLVM_ABI MCSymbol * cloneSymbol(MCSymbol &Sym)
Clone a symbol for the .set directive, replacing it in the symbol table.
Definition MCContext.cpp:308
LLVM_ABI MCSymbol * parseSymbol(const Twine &Name)
Variant of getOrCreateSymbol that handles backslash-escaped symbols.
Definition MCContext.cpp:226
LLVM_ABI EmitDwarfUnwindType emitDwarfUnwindInfo() const
Definition MCContext.cpp:986
LLVM_ABI bool isELFImplicitMergeableSectionNamePrefix(StringRef Name)
Definition MCContext.cpp:697
LLVM_ABI MCSectionELF * createELFGroupSection(const MCSymbolELF *Group, bool IsComdat)
Definition MCContext.cpp:670
void setUseNamesOnTempLabels(bool Value)
LLVM_ABI void setGenDwarfRootFile(StringRef FileName, StringRef Buffer)
Specifies information about the "root file" for assembler clients (e.g., llvm-mc).
Definition MCContext.cpp:998
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.
LLVM_ABI MCSymbol * getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before)
Create and return a directional local symbol for numbered label (used for "1b" or 1f" references).
Definition MCContext.cpp:431
LLVM_ABI MCSymbol * createNamedTempSymbol()
Create a temporary symbol with a unique name whose name cannot be omitted in the symbol table.
Definition MCContext.cpp:395
LLVM_ABI 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.
MCSymbol * getCOMDATSymbol() const
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
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.
uint32_t getIndex() const
Get the (implementation defined) index.
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
unsigned IsTemporary
IsTemporary - True if this is an assembler temporary label, which typically does not survive in the ....
void setIsRegistered(bool Value) const
LLVM_ABI void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
LLVM_ABI void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
LLVM_ABI void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true, bool ShowLocation=true) const
Represents a location in source code.
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...
void push_back(const T &Elt)
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
LLVM_ABI 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.
StringMapIterBase< ValueTy, false > iterator
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.
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 contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Triple - Helper class for working with autoconf configuration names.
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI 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
@ C
The default llvm calling convention, compatible with C.
DwarfSectionSubtypeFlags
Values for defining the section subtype of sections of type STYP_DWARF as they would appear in the (s...
LLVM_ABI StringRef getMappingClassString(XCOFF::StorageMappingClass SMC)
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
LLVM_ABI void remove_filename(SmallVectorImpl< char > &path, Style style=Style::native)
Remove the last component from path unless it is the root dir.
LLVM_ABI bool replace_path_prefix(SmallVectorImpl< char > &Path, StringRef OldPrefix, StringRef NewPrefix, Style style=Style::native)
Replace matching path prefix with another path.
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
LLVM_ABI 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)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
StringMapEntry< MCSymbolTableValue > MCSymbolTableEntry
MCContext stores MCSymbolTableValue in a string map (see MCSymbol::operator new).
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
GOFF::ESDBindingAlgorithm BindAlgorithm
The value for an entry in the symbol table of an MCContext.
StorageMappingClass MappingClass