LLVM 17.0.0git
MCStreamer.cpp
Go to the documentation of this file.
1//===- lib/MC/MCStreamer.cpp - Streaming Machine Code Output --------------===//
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
11#include "llvm/ADT/StringRef.h"
12#include "llvm/ADT/Twine.h"
17#include "llvm/MC/MCAsmInfo.h"
18#include "llvm/MC/MCCodeView.h"
19#include "llvm/MC/MCContext.h"
20#include "llvm/MC/MCDwarf.h"
21#include "llvm/MC/MCExpr.h"
22#include "llvm/MC/MCInst.h"
26#include "llvm/MC/MCRegister.h"
28#include "llvm/MC/MCSection.h"
30#include "llvm/MC/MCSymbol.h"
31#include "llvm/MC/MCWin64EH.h"
32#include "llvm/MC/MCWinEH.h"
35#include "llvm/Support/LEB128.h"
38#include <cassert>
39#include <cstdint>
40#include <cstdlib>
41#include <optional>
42#include <utility>
43
44using namespace llvm;
45
47 S.setTargetStreamer(this);
48}
49
50// Pin the vtables to this file.
52
54
56
58
60 MCSection *Section,
61 const MCExpr *Subsection,
62 raw_ostream &OS) {
63 Section->printSwitchToSection(*Streamer.getContext().getAsmInfo(),
65 Subsection);
66}
67
70}
71
74 raw_svector_ostream OS(Str);
75
78}
79
81 const MCAsmInfo *MAI = Streamer.getContext().getAsmInfo();
82 const char *Directive = MAI->getData8bitsDirective();
83 for (const unsigned char C : Data.bytes()) {
85 raw_svector_ostream OS(Str);
86
87 OS << Directive << (unsigned)C;
89 }
90}
91
93
95 : Context(Ctx), CurrentWinFrameInfo(nullptr),
96 CurrentProcWinFrameInfoStartIndex(0), UseAssemblerInfoForParsing(false) {
97 SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
98}
99
100MCStreamer::~MCStreamer() = default;
101
103 DwarfFrameInfos.clear();
104 CurrentWinFrameInfo = nullptr;
105 WinFrameInfos.clear();
106 SymbolOrdering.clear();
107 SectionStack.clear();
108 SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
109}
110
112 // By default, discard comments.
113 return nulls();
114}
115
116unsigned MCStreamer::getNumFrameInfos() { return DwarfFrameInfos.size(); }
118 return DwarfFrameInfos;
119}
120
121void MCStreamer::emitRawComment(const Twine &T, bool TabPrefix) {}
122
125
127 for (auto &FI : DwarfFrameInfos)
128 FI.CompactUnwindEncoding =
129 (MAB ? MAB->generateCompactUnwindEncoding(FI.Instructions) : 0);
130}
131
132/// EmitIntValue - Special case of EmitValue that avoids the client having to
133/// pass in a MCExpr for constant integers.
135 assert(1 <= Size && Size <= 8 && "Invalid size");
136 assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
137 "Invalid size");
138 const bool IsLittleEndian = Context.getAsmInfo()->isLittleEndian();
140 Value, IsLittleEndian ? support::little : support::big);
141 unsigned Index = IsLittleEndian ? 0 : 8 - Size;
142 emitBytes(StringRef(reinterpret_cast<char *>(&Swapped) + Index, Size));
143}
145 if (Value.getNumWords() == 1) {
146 emitIntValue(Value.getLimitedValue(), Value.getBitWidth() / 8);
147 return;
148 }
149
150 const bool IsLittleEndianTarget = Context.getAsmInfo()->isLittleEndian();
151 const bool ShouldSwap = sys::IsLittleEndianHost != IsLittleEndianTarget;
152 const APInt Swapped = ShouldSwap ? Value.byteSwap() : Value;
153 const unsigned Size = Value.getBitWidth() / 8;
154 SmallString<10> Tmp;
155 Tmp.resize(Size);
156 StoreIntToMemory(Swapped, reinterpret_cast<uint8_t *>(Tmp.data()), Size);
157 emitBytes(Tmp.str());
158}
159
160/// EmitULEB128IntValue - Special case of EmitULEB128Value that avoids the
161/// client having to pass in a MCExpr for constant integers.
164 raw_svector_ostream OSE(Tmp);
165 encodeULEB128(Value, OSE, PadTo);
166 emitBytes(OSE.str());
167 return Tmp.size();
168}
169
170/// EmitSLEB128IntValue - Special case of EmitSLEB128Value that avoids the
171/// client having to pass in a MCExpr for constant integers.
174 raw_svector_ostream OSE(Tmp);
175 encodeSLEB128(Value, OSE);
176 emitBytes(OSE.str());
177 return Tmp.size();
178}
179
180void MCStreamer::emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc) {
181 emitValueImpl(Value, Size, Loc);
182}
183
184void MCStreamer::emitSymbolValue(const MCSymbol *Sym, unsigned Size,
185 bool IsSectionRelative) {
186 assert((!IsSectionRelative || Size == 4) &&
187 "SectionRelative value requires 4-bytes");
188
189 if (!IsSectionRelative)
191 else
192 emitCOFFSecRel32(Sym, /*Offset=*/0);
193}
194
196 report_fatal_error("unsupported directive in streamer");
197}
198
200 report_fatal_error("unsupported directive in streamer");
201}
202
204 report_fatal_error("unsupported directive in streamer");
205}
206
208 report_fatal_error("unsupported directive in streamer");
209}
210
212 report_fatal_error("unsupported directive in streamer");
213}
214
216 report_fatal_error("unsupported directive in streamer");
217}
218
219/// Emit NumBytes bytes worth of the value specified by FillValue.
220/// This implements directives such as '.space'.
221void MCStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
222 emitFill(*MCConstantExpr::create(NumBytes, getContext()), FillValue);
223}
224
225void llvm::MCStreamer::emitNops(int64_t NumBytes, int64_t ControlledNopLen,
226 llvm::SMLoc, const MCSubtargetInfo& STI) {}
227
228/// The implementation in this class just redirects to emitFill.
229void MCStreamer::emitZeros(uint64_t NumBytes) { emitFill(NumBytes, 0); }
230
232 unsigned FileNo, StringRef Directory, StringRef Filename,
233 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
234 unsigned CUID) {
235 return getContext().getDwarfFile(Directory, Filename, FileNo, Checksum,
236 Source, CUID);
237}
238
240 StringRef Filename,
241 std::optional<MD5::MD5Result> Checksum,
242 std::optional<StringRef> Source,
243 unsigned CUID) {
244 getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
245 Source);
246}
247
249 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
250 if (!CurFrame)
251 return;
252 CurFrame->IsBKeyFrame = true;
253}
254
256 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
257 if (!CurFrame)
258 return;
259 CurFrame->IsMTETaggedFrame = true;
260}
261
262void MCStreamer::emitDwarfLocDirective(unsigned FileNo, unsigned Line,
263 unsigned Column, unsigned Flags,
264 unsigned Isa, unsigned Discriminator,
265 StringRef FileName) {
266 getContext().setCurrentDwarfLoc(FileNo, Line, Column, Flags, Isa,
267 Discriminator);
268}
269
272 if (!Table.getLabel()) {
273 StringRef Prefix = Context.getAsmInfo()->getPrivateGlobalPrefix();
274 Table.setLabel(
275 Context.getOrCreateSymbol(Prefix + "line_table_start" + Twine(CUID)));
276 }
277 return Table.getLabel();
278}
279
281 return !FrameInfoStack.empty();
282}
283
284MCDwarfFrameInfo *MCStreamer::getCurrentDwarfFrameInfo() {
287 "this directive must appear between "
288 ".cfi_startproc and .cfi_endproc directives");
289 return nullptr;
290 }
291 return &DwarfFrameInfos[FrameInfoStack.back().first];
292}
293
294bool MCStreamer::emitCVFileDirective(unsigned FileNo, StringRef Filename,
295 ArrayRef<uint8_t> Checksum,
296 unsigned ChecksumKind) {
297 return getContext().getCVContext().addFile(*this, FileNo, Filename, Checksum,
298 ChecksumKind);
299}
300
301bool MCStreamer::emitCVFuncIdDirective(unsigned FunctionId) {
302 return getContext().getCVContext().recordFunctionId(FunctionId);
303}
304
306 unsigned IAFunc, unsigned IAFile,
307 unsigned IALine, unsigned IACol,
308 SMLoc Loc) {
309 if (getContext().getCVContext().getCVFunctionInfo(IAFunc) == nullptr) {
310 getContext().reportError(Loc, "parent function id not introduced by "
311 ".cv_func_id or .cv_inline_site_id");
312 return true;
313 }
314
316 FunctionId, IAFunc, IAFile, IALine, IACol);
317}
318
319void MCStreamer::emitCVLocDirective(unsigned FunctionId, unsigned FileNo,
320 unsigned Line, unsigned Column,
321 bool PrologueEnd, bool IsStmt,
322 StringRef FileName, SMLoc Loc) {}
323
324bool MCStreamer::checkCVLocSection(unsigned FuncId, unsigned FileNo,
325 SMLoc Loc) {
328 if (!FI) {
330 Loc, "function id not introduced by .cv_func_id or .cv_inline_site_id");
331 return false;
332 }
333
334 // Track the section
335 if (FI->Section == nullptr)
337 else if (FI->Section != getCurrentSectionOnly()) {
339 Loc,
340 "all .cv_loc directives for a function must be in the same section");
341 return false;
342 }
343 return true;
344}
345
347 const MCSymbol *Begin,
348 const MCSymbol *End) {}
349
350void MCStreamer::emitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
351 unsigned SourceFileId,
352 unsigned SourceLineNum,
353 const MCSymbol *FnStartSym,
354 const MCSymbol *FnEndSym) {}
355
356/// Only call this on endian-specific types like ulittle16_t and little32_t, or
357/// structs composed of them.
358template <typename T>
359static void copyBytesForDefRange(SmallString<20> &BytePrefix,
360 codeview::SymbolKind SymKind,
361 const T &DefRangeHeader) {
362 BytePrefix.resize(2 + sizeof(T));
363 codeview::ulittle16_t SymKindLE = codeview::ulittle16_t(SymKind);
364 memcpy(&BytePrefix[0], &SymKindLE, 2);
365 memcpy(&BytePrefix[2], &DefRangeHeader, sizeof(T));
366}
367
369 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
370 StringRef FixedSizePortion) {}
371
373 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
375 SmallString<20> BytePrefix;
376 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_REGISTER_REL, DRHdr);
377 emitCVDefRangeDirective(Ranges, BytePrefix);
378}
379
381 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
383 SmallString<20> BytePrefix;
384 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_SUBFIELD_REGISTER,
385 DRHdr);
386 emitCVDefRangeDirective(Ranges, BytePrefix);
387}
388
390 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
392 SmallString<20> BytePrefix;
393 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_REGISTER, DRHdr);
394 emitCVDefRangeDirective(Ranges, BytePrefix);
395}
396
398 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
400 SmallString<20> BytePrefix;
401 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_FRAMEPOINTER_REL,
402 DRHdr);
403 emitCVDefRangeDirective(Ranges, BytePrefix);
404}
405
407 MCSymbol *EHSymbol) {
408}
409
410void MCStreamer::initSections(bool NoExecStack, const MCSubtargetInfo &STI) {
411 switchSection(getContext().getObjectFileInfo()->getTextSection());
412}
413
415 assert(Fragment);
416 Symbol->setFragment(Fragment);
417
418 // As we emit symbols into a section, track the order so that they can
419 // be sorted upon later. Zero is reserved to mean 'unemitted'.
420 SymbolOrdering[Symbol] = 1 + SymbolOrdering.size();
421}
422
424 Symbol->redefineIfPossible();
425
426 if (!Symbol->isUndefined() || Symbol->isVariable())
427 return getContext().reportError(Loc, "symbol '" + Twine(Symbol->getName()) +
428 "' is already defined");
429
430 assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
431 assert(getCurrentSectionOnly() && "Cannot emit before setting section!");
432 assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
433 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
434
435 Symbol->setFragment(&getCurrentSectionOnly()->getDummyFragment());
436
438 if (TS)
439 TS->emitLabel(Symbol);
440}
441
443 const MCExpr *Value) {}
444
445void MCStreamer::emitCFISections(bool EH, bool Debug) {}
446
447void MCStreamer::emitCFIStartProc(bool IsSimple, SMLoc Loc) {
448 if (!FrameInfoStack.empty() &&
449 getCurrentSectionOnly() == FrameInfoStack.back().second)
450 return getContext().reportError(
451 Loc, "starting new .cfi frame before finishing the previous one");
452
453 MCDwarfFrameInfo Frame;
454 Frame.IsSimple = IsSimple;
456
457 const MCAsmInfo* MAI = Context.getAsmInfo();
458 if (MAI) {
459 for (const MCCFIInstruction& Inst : MAI->getInitialFrameState()) {
460 if (Inst.getOperation() == MCCFIInstruction::OpDefCfa ||
461 Inst.getOperation() == MCCFIInstruction::OpDefCfaRegister ||
462 Inst.getOperation() == MCCFIInstruction::OpLLVMDefAspaceCfa) {
463 Frame.CurrentCfaRegister = Inst.getRegister();
464 }
465 }
466 }
467
468 FrameInfoStack.emplace_back(DwarfFrameInfos.size(), getCurrentSectionOnly());
469 DwarfFrameInfos.push_back(Frame);
470}
471
473}
474
476 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
477 if (!CurFrame)
478 return;
479 emitCFIEndProcImpl(*CurFrame);
480 FrameInfoStack.pop_back();
481}
482
484 // Put a dummy non-null value in Frame.End to mark that this frame has been
485 // closed.
486 Frame.End = (MCSymbol *)1;
487}
488
490 // Return a dummy non-null value so that label fields appear filled in when
491 // generating textual assembly.
492 return (MCSymbol *)1;
493}
494
496 MCSymbol *Label = emitCFILabel();
499 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
500 if (!CurFrame)
501 return;
502 CurFrame->Instructions.push_back(Instruction);
503 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
504}
505
507 MCSymbol *Label = emitCFILabel();
510 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
511 if (!CurFrame)
512 return;
513 CurFrame->Instructions.push_back(Instruction);
514}
515
516void MCStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment) {
517 MCSymbol *Label = emitCFILabel();
520 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
521 if (!CurFrame)
522 return;
523 CurFrame->Instructions.push_back(Instruction);
524}
525
527 MCSymbol *Label = emitCFILabel();
530 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
531 if (!CurFrame)
532 return;
533 CurFrame->Instructions.push_back(Instruction);
534 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
535}
536
538 int64_t AddressSpace) {
539 MCSymbol *Label = emitCFILabel();
541 Label, Register, Offset, AddressSpace);
542 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
543 if (!CurFrame)
544 return;
545 CurFrame->Instructions.push_back(Instruction);
546 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
547}
548
550 MCSymbol *Label = emitCFILabel();
553 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
554 if (!CurFrame)
555 return;
556 CurFrame->Instructions.push_back(Instruction);
557}
558
560 MCSymbol *Label = emitCFILabel();
563 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
564 if (!CurFrame)
565 return;
566 CurFrame->Instructions.push_back(Instruction);
567}
568
570 unsigned Encoding) {
571 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
572 if (!CurFrame)
573 return;
574 CurFrame->Personality = Sym;
575 CurFrame->PersonalityEncoding = Encoding;
576}
577
578void MCStreamer::emitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
579 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
580 if (!CurFrame)
581 return;
582 CurFrame->Lsda = Sym;
583 CurFrame->LsdaEncoding = Encoding;
584}
585
587 MCSymbol *Label = emitCFILabel();
589 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
590 if (!CurFrame)
591 return;
592 CurFrame->Instructions.push_back(Instruction);
593}
594
596 // FIXME: Error if there is no matching cfi_remember_state.
597 MCSymbol *Label = emitCFILabel();
599 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
600 if (!CurFrame)
601 return;
602 CurFrame->Instructions.push_back(Instruction);
603}
604
606 MCSymbol *Label = emitCFILabel();
609 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
610 if (!CurFrame)
611 return;
612 CurFrame->Instructions.push_back(Instruction);
613}
614
616 MCSymbol *Label = emitCFILabel();
619 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
620 if (!CurFrame)
621 return;
622 CurFrame->Instructions.push_back(Instruction);
623}
624
626 MCSymbol *Label = emitCFILabel();
628 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
629 if (!CurFrame)
630 return;
631 CurFrame->Instructions.push_back(Instruction);
632}
633
635 MCSymbol *Label = emitCFILabel();
638 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
639 if (!CurFrame)
640 return;
641 CurFrame->Instructions.push_back(Instruction);
642}
643
645 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
646 if (!CurFrame)
647 return;
648 CurFrame->IsSignalFrame = true;
649}
650
652 MCSymbol *Label = emitCFILabel();
655 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
656 if (!CurFrame)
657 return;
658 CurFrame->Instructions.push_back(Instruction);
659}
660
661void MCStreamer::emitCFIRegister(int64_t Register1, int64_t Register2) {
662 MCSymbol *Label = emitCFILabel();
664 MCCFIInstruction::createRegister(Label, Register1, Register2);
665 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
666 if (!CurFrame)
667 return;
668 CurFrame->Instructions.push_back(Instruction);
669}
670
672 MCSymbol *Label = emitCFILabel();
675 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
676 if (!CurFrame)
677 return;
678 CurFrame->Instructions.push_back(Instruction);
679}
680
682 MCSymbol *Label = emitCFILabel();
684 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
685 if (!CurFrame)
686 return;
687 CurFrame->Instructions.push_back(Instruction);
688}
689
691 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
692 if (!CurFrame)
693 return;
694 CurFrame->RAReg = Register;
695}
696
698 const MCAsmInfo *MAI = Context.getAsmInfo();
699 if (!MAI->usesWindowsCFI()) {
701 Loc, ".seh_* directives are not supported on this target");
702 return nullptr;
703 }
704 if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End) {
706 Loc, ".seh_ directive must appear within an active frame");
707 return nullptr;
708 }
709 return CurrentWinFrameInfo;
710}
711
713 const MCAsmInfo *MAI = Context.getAsmInfo();
714 if (!MAI->usesWindowsCFI())
715 return getContext().reportError(
716 Loc, ".seh_* directives are not supported on this target");
717 if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End)
719 Loc, "Starting a function before ending the previous one!");
720
721 MCSymbol *StartProc = emitCFILabel();
722
723 CurrentProcWinFrameInfoStartIndex = WinFrameInfos.size();
724 WinFrameInfos.emplace_back(
725 std::make_unique<WinEH::FrameInfo>(Symbol, StartProc));
726 CurrentWinFrameInfo = WinFrameInfos.back().get();
727 CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
728}
729
732 if (!CurFrame)
733 return;
734 if (CurFrame->ChainedParent)
735 getContext().reportError(Loc, "Not all chained regions terminated!");
736
737 MCSymbol *Label = emitCFILabel();
738 CurFrame->End = Label;
739 if (!CurFrame->FuncletOrFuncEnd)
740 CurFrame->FuncletOrFuncEnd = CurFrame->End;
741
742 for (size_t I = CurrentProcWinFrameInfoStartIndex, E = WinFrameInfos.size();
743 I != E; ++I)
744 emitWindowsUnwindTables(WinFrameInfos[I].get());
745 switchSection(CurFrame->TextSection);
746}
747
750 if (!CurFrame)
751 return;
752 if (CurFrame->ChainedParent)
753 getContext().reportError(Loc, "Not all chained regions terminated!");
754
755 MCSymbol *Label = emitCFILabel();
756 CurFrame->FuncletOrFuncEnd = Label;
757}
758
761 if (!CurFrame)
762 return;
763
764 MCSymbol *StartProc = emitCFILabel();
765
766 WinFrameInfos.emplace_back(std::make_unique<WinEH::FrameInfo>(
767 CurFrame->Function, StartProc, CurFrame));
768 CurrentWinFrameInfo = WinFrameInfos.back().get();
769 CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
770}
771
774 if (!CurFrame)
775 return;
776 if (!CurFrame->ChainedParent)
777 return getContext().reportError(
778 Loc, "End of a chained region outside a chained region!");
779
780 MCSymbol *Label = emitCFILabel();
781
782 CurFrame->End = Label;
783 CurrentWinFrameInfo = const_cast<WinEH::FrameInfo *>(CurFrame->ChainedParent);
784}
785
786void MCStreamer::emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except,
787 SMLoc Loc) {
789 if (!CurFrame)
790 return;
791 if (CurFrame->ChainedParent)
792 return getContext().reportError(
793 Loc, "Chained unwind areas can't have handlers!");
794 CurFrame->ExceptionHandler = Sym;
795 if (!Except && !Unwind)
796 getContext().reportError(Loc, "Don't know what kind of handler this is!");
797 if (Unwind)
798 CurFrame->HandlesUnwind = true;
799 if (Except)
800 CurFrame->HandlesExceptions = true;
801}
802
805 if (!CurFrame)
806 return;
807 if (CurFrame->ChainedParent)
808 getContext().reportError(Loc, "Chained unwind areas can't have handlers!");
809}
810
812 const MCSymbolRefExpr *To, uint64_t Count) {
813}
814
815static MCSection *getWinCFISection(MCContext &Context, unsigned *NextWinCFIID,
816 MCSection *MainCFISec,
817 const MCSection *TextSec) {
818 // If this is the main .text section, use the main unwind info section.
819 if (TextSec == Context.getObjectFileInfo()->getTextSection())
820 return MainCFISec;
821
822 const auto *TextSecCOFF = cast<MCSectionCOFF>(TextSec);
823 auto *MainCFISecCOFF = cast<MCSectionCOFF>(MainCFISec);
824 unsigned UniqueID = TextSecCOFF->getOrAssignWinCFISectionID(NextWinCFIID);
825
826 // If this section is COMDAT, this unwind section should be COMDAT associative
827 // with its group.
828 const MCSymbol *KeySym = nullptr;
829 if (TextSecCOFF->getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) {
830 KeySym = TextSecCOFF->getCOMDATSymbol();
831
832 // In a GNU environment, we can't use associative comdats. Instead, do what
833 // GCC does, which is to make plain comdat selectany section named like
834 // ".[px]data$_Z3foov".
835 if (!Context.getAsmInfo()->hasCOFFAssociativeComdats()) {
836 std::string SectionName = (MainCFISecCOFF->getName() + "$" +
837 TextSecCOFF->getName().split('$').second)
838 .str();
839 return Context.getCOFFSection(
841 MainCFISecCOFF->getCharacteristics() | COFF::IMAGE_SCN_LNK_COMDAT,
842 MainCFISecCOFF->getKind(), "", COFF::IMAGE_COMDAT_SELECT_ANY);
843 }
844 }
845
846 return Context.getAssociativeCOFFSection(MainCFISecCOFF, KeySym, UniqueID);
847}
848
850 return getWinCFISection(getContext(), &NextWinCFIID,
851 getContext().getObjectFileInfo()->getPDataSection(),
852 TextSec);
853}
854
856 return getWinCFISection(getContext(), &NextWinCFIID,
857 getContext().getObjectFileInfo()->getXDataSection(),
858 TextSec);
859}
860
862
863static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg) {
864 return Ctx.getRegisterInfo()->getSEHRegNum(Reg);
865}
866
869 if (!CurFrame)
870 return;
871
872 MCSymbol *Label = emitCFILabel();
873
876 CurFrame->Instructions.push_back(Inst);
877}
878
880 SMLoc Loc) {
882 if (!CurFrame)
883 return;
884 if (CurFrame->LastFrameInst >= 0)
885 return getContext().reportError(
886 Loc, "frame register and offset can be set at most once");
887 if (Offset & 0x0F)
888 return getContext().reportError(Loc, "offset is not a multiple of 16");
889 if (Offset > 240)
890 return getContext().reportError(
891 Loc, "frame offset must be less than or equal to 240");
892
893 MCSymbol *Label = emitCFILabel();
894
897 CurFrame->LastFrameInst = CurFrame->Instructions.size();
898 CurFrame->Instructions.push_back(Inst);
899}
900
903 if (!CurFrame)
904 return;
905 if (Size == 0)
906 return getContext().reportError(Loc,
907 "stack allocation size must be non-zero");
908 if (Size & 7)
909 return getContext().reportError(
910 Loc, "stack allocation size is not a multiple of 8");
911
912 MCSymbol *Label = emitCFILabel();
913
915 CurFrame->Instructions.push_back(Inst);
916}
917
919 SMLoc Loc) {
921 if (!CurFrame)
922 return;
923
924 if (Offset & 7)
925 return getContext().reportError(
926 Loc, "register save offset is not 8 byte aligned");
927
928 MCSymbol *Label = emitCFILabel();
929
932 CurFrame->Instructions.push_back(Inst);
933}
934
936 SMLoc Loc) {
938 if (!CurFrame)
939 return;
940 if (Offset & 0x0F)
941 return getContext().reportError(Loc, "offset is not a multiple of 16");
942
943 MCSymbol *Label = emitCFILabel();
944
947 CurFrame->Instructions.push_back(Inst);
948}
949
952 if (!CurFrame)
953 return;
954 if (!CurFrame->Instructions.empty())
955 return getContext().reportError(
956 Loc, "If present, PushMachFrame must be the first UOP");
957
958 MCSymbol *Label = emitCFILabel();
959
961 CurFrame->Instructions.push_back(Inst);
962}
963
966 if (!CurFrame)
967 return;
968
969 MCSymbol *Label = emitCFILabel();
970
971 CurFrame->PrologEnd = Label;
972}
973
975
977
979
981
982void MCStreamer::emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) {}
983
984/// EmitRawText - If this file is backed by an assembly streamer, this dumps
985/// the specified string in the output .s file. This capability is
986/// indicated by the hasRawTextSupport() predicate.
988 // This is not llvm_unreachable for the sake of out of tree backend
989 // developers who may not have assembly streamers and should serve as a
990 // reminder to not accidentally call EmitRawText in the absence of such.
991 report_fatal_error("EmitRawText called on an MCStreamer that doesn't support "
992 "it (target backend is likely missing an AsmStreamer "
993 "implementation)");
994}
995
998 emitRawTextImpl(T.toStringRef(Str));
999}
1000
1002
1004
1006 if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) ||
1007 (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
1008 getContext().reportError(EndLoc, "Unfinished frame!");
1009 return;
1010 }
1011
1013 if (TS)
1014 TS->finish();
1015
1016 finishImpl();
1017}
1018
1020 if (Context.getDwarfFormat() != dwarf::DWARF64)
1021 return;
1022 AddComment("DWARF64 Mark");
1024}
1025
1027 assert(Context.getDwarfFormat() == dwarf::DWARF64 ||
1030 AddComment(Comment);
1032}
1033
1035 const Twine &Comment) {
1037 AddComment(Comment);
1038 MCSymbol *Lo = Context.createTempSymbol(Prefix + "_start");
1039 MCSymbol *Hi = Context.createTempSymbol(Prefix + "_end");
1040
1042 Hi, Lo, dwarf::getDwarfOffsetByteSize(Context.getDwarfFormat()));
1043 // emit the begin symbol after we generate the length field.
1044 emitLabel(Lo);
1045 // Return the Hi symbol to the caller.
1046 return Hi;
1047}
1048
1050 // Set the value of the symbol, as we are at the start of the line table.
1051 emitLabel(StartSym);
1052}
1053
1056 Symbol->setVariableValue(Value);
1057
1059 if (TS)
1060 TS->emitAssignment(Symbol, Value);
1061}
1062
1064 uint64_t Address, const MCInst &Inst,
1065 const MCSubtargetInfo &STI,
1066 raw_ostream &OS) {
1067 InstPrinter.printInst(&Inst, Address, "", STI, OS);
1068}
1069
1071}
1072
1074 switch (Expr.getKind()) {
1075 case MCExpr::Target:
1076 cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
1077 break;
1078
1079 case MCExpr::Constant:
1080 break;
1081
1082 case MCExpr::Binary: {
1083 const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
1084 visitUsedExpr(*BE.getLHS());
1085 visitUsedExpr(*BE.getRHS());
1086 break;
1087 }
1088
1089 case MCExpr::SymbolRef:
1090 visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
1091 break;
1092
1093 case MCExpr::Unary:
1094 visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
1095 break;
1096 }
1097}
1098
1100 // Scan for values.
1101 for (unsigned i = Inst.getNumOperands(); i--;)
1102 if (Inst.getOperand(i).isExpr())
1103 visitUsedExpr(*Inst.getOperand(i).getExpr());
1104}
1105
1107 uint64_t Attr,
1108 const MCPseudoProbeInlineStack &InlineStack,
1109 MCSymbol *FnSym) {
1110 auto &Context = getContext();
1111
1112 // Create a symbol at in the current section for use in the probe.
1113 MCSymbol *ProbeSym = Context.createTempSymbol();
1114
1115 // Set the value of the symbol to use for the MCPseudoProbe.
1116 emitLabel(ProbeSym);
1117
1118 // Create a (local) probe entry with the symbol.
1119 MCPseudoProbe Probe(ProbeSym, Guid, Index, Type, Attr);
1120
1121 // Add the probe entry to this section's entries.
1122 Context.getMCPseudoProbeTable().getProbeSections().addPseudoProbe(
1123 FnSym, Probe, InlineStack);
1124}
1125
1127 unsigned Size) {
1128 // Get the Hi-Lo expression.
1129 const MCExpr *Diff =
1132
1133 const MCAsmInfo *MAI = Context.getAsmInfo();
1134 if (!MAI->doesSetDirectiveSuppressReloc()) {
1135 emitValue(Diff, Size);
1136 return;
1137 }
1138
1139 // Otherwise, emit with .set (aka assignment).
1140 MCSymbol *SetLabel = Context.createTempSymbol("set");
1141 emitAssignment(SetLabel, Diff);
1142 emitSymbolValue(SetLabel, Size);
1143}
1144
1146 const MCSymbol *Lo) {
1147 // Get the Hi-Lo expression.
1148 const MCExpr *Diff =
1151
1152 emitULEB128Value(Diff);
1153}
1154
1157void MCStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
1159 llvm_unreachable("this directive only supported on COFF targets");
1160}
1162 llvm_unreachable("this directive only supported on COFF targets");
1163}
1166 StringRef TimeStamp, StringRef Description) {
1167}
1169 llvm_unreachable("this directive only supported on COFF targets");
1170}
1172 llvm_unreachable("this directive only supported on COFF targets");
1173}
1175 MCSymbol *CsectSym,
1176 Align Alignment) {
1177 llvm_unreachable("this directive only supported on XCOFF targets");
1178}
1179
1181 MCSymbolAttr Linkage,
1182 MCSymbolAttr Visibility) {
1183 llvm_unreachable("emitXCOFFSymbolLinkageWithVisibility is only supported on "
1184 "XCOFF targets");
1185}
1186
1188 StringRef Rename) {
1189 llvm_unreachable("emitXCOFFRenameDirective is only supported on "
1190 "XCOFF targets");
1191}
1192
1194 llvm_unreachable("emitXCOFFRefDirective is only supported on XCOFF targets");
1195}
1196
1198 const MCSymbol *Trap,
1199 unsigned Lang, unsigned Reason,
1200 unsigned FunctionSize,
1201 bool hasDebug) {
1202 report_fatal_error("emitXCOFFExceptDirective is only supported on "
1203 "XCOFF targets");
1204}
1205
1208 StringRef Name, bool KeepOriginalSym) {}
1210 Align ByteAlignment) {}
1212 uint64_t Size, Align ByteAlignment) {}
1217void MCStreamer::emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) {
1219}
1222void MCStreamer::emitFill(const MCExpr &NumBytes, uint64_t Value, SMLoc Loc) {}
1223void MCStreamer::emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
1224 SMLoc Loc) {}
1226 unsigned ValueSize,
1227 unsigned MaxBytesToEmit) {}
1229 unsigned MaxBytesToEmit) {}
1231 SMLoc Loc) {}
1233void MCStreamer::emitBundleLock(bool AlignToEnd) {}
1236
1237void MCStreamer::switchSection(MCSection *Section, const MCExpr *Subsection) {
1238 assert(Section && "Cannot switch to a null section!");
1239 MCSectionSubPair curSection = SectionStack.back().first;
1240 SectionStack.back().second = curSection;
1241 if (MCSectionSubPair(Section, Subsection) != curSection) {
1242 changeSection(Section, Subsection);
1243 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
1244 assert(!Section->hasEnded() && "Section already ended");
1245 MCSymbol *Sym = Section->getBeginSymbol();
1246 if (Sym && !Sym->isInSection())
1247 emitLabel(Sym);
1248 }
1249}
1250
1252 // TODO: keep track of the last subsection so that this symbol appears in the
1253 // correct place.
1254 MCSymbol *Sym = Section->getEndSymbol(Context);
1255 if (Sym->isInSection())
1256 return Sym;
1257
1258 switchSection(Section);
1259 emitLabel(Sym);
1260 return Sym;
1261}
1262
1263static VersionTuple
1265 VersionTuple TargetVersion) {
1266 VersionTuple Min = Target.getMinimumSupportedOSVersion();
1267 return !Min.empty() && Min > TargetVersion ? Min : TargetVersion;
1268}
1269
1270static MCVersionMinType
1272 assert(Target.isOSDarwin() && "expected a darwin OS");
1273 switch (Target.getOS()) {
1274 case Triple::MacOSX:
1275 case Triple::Darwin:
1276 return MCVM_OSXVersionMin;
1277 case Triple::IOS:
1278 assert(!Target.isMacCatalystEnvironment() &&
1279 "mac Catalyst should use LC_BUILD_VERSION");
1280 return MCVM_IOSVersionMin;
1281 case Triple::TvOS:
1282 return MCVM_TvOSVersionMin;
1283 case Triple::WatchOS:
1285 default:
1286 break;
1287 }
1288 llvm_unreachable("unexpected OS type");
1289}
1290
1292 assert(Target.isOSDarwin() && "expected a darwin OS");
1293 switch (Target.getOS()) {
1294 case Triple::MacOSX:
1295 case Triple::Darwin:
1296 return VersionTuple(10, 14);
1297 case Triple::IOS:
1298 // Mac Catalyst always uses the build version load command.
1299 if (Target.isMacCatalystEnvironment())
1300 return VersionTuple();
1301 [[fallthrough]];
1302 case Triple::TvOS:
1303 return VersionTuple(12);
1304 case Triple::WatchOS:
1305 return VersionTuple(5);
1306 case Triple::DriverKit:
1307 // DriverKit always uses the build version load command.
1308 return VersionTuple();
1309 default:
1310 break;
1311 }
1312 llvm_unreachable("unexpected OS type");
1313}
1314
1317 assert(Target.isOSDarwin() && "expected a darwin OS");
1318 switch (Target.getOS()) {
1319 case Triple::MacOSX:
1320 case Triple::Darwin:
1321 return MachO::PLATFORM_MACOS;
1322 case Triple::IOS:
1323 if (Target.isMacCatalystEnvironment())
1325 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_IOSSIMULATOR
1327 case Triple::TvOS:
1328 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_TVOSSIMULATOR
1330 case Triple::WatchOS:
1331 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_WATCHOSSIMULATOR
1333 case Triple::DriverKit:
1335 default:
1336 break;
1337 }
1338 llvm_unreachable("unexpected OS type");
1339}
1340
1342 const Triple &Target, const VersionTuple &SDKVersion,
1343 const Triple *DarwinTargetVariantTriple,
1344 const VersionTuple &DarwinTargetVariantSDKVersion) {
1345 if (!Target.isOSBinFormatMachO() || !Target.isOSDarwin())
1346 return;
1347 // Do we even know the version?
1348 if (Target.getOSMajorVersion() == 0)
1349 return;
1350
1351 VersionTuple Version;
1352 switch (Target.getOS()) {
1353 case Triple::MacOSX:
1354 case Triple::Darwin:
1355 Target.getMacOSXVersion(Version);
1356 break;
1357 case Triple::IOS:
1358 case Triple::TvOS:
1359 Version = Target.getiOSVersion();
1360 break;
1361 case Triple::WatchOS:
1362 Version = Target.getWatchOSVersion();
1363 break;
1364 case Triple::DriverKit:
1365 Version = Target.getDriverKitVersion();
1366 break;
1367 default:
1368 llvm_unreachable("unexpected OS type");
1369 }
1370 assert(Version.getMajor() != 0 && "A non-zero major version is expected");
1371 auto LinkedTargetVersion =
1373 auto BuildVersionOSVersion = getMachoBuildVersionSupportedOS(Target);
1374 bool ShouldEmitBuildVersion = false;
1375 if (BuildVersionOSVersion.empty() ||
1376 LinkedTargetVersion >= BuildVersionOSVersion) {
1377 if (Target.isMacCatalystEnvironment() && DarwinTargetVariantTriple &&
1378 DarwinTargetVariantTriple->isMacOSX()) {
1379 emitVersionForTarget(*DarwinTargetVariantTriple,
1380 DarwinTargetVariantSDKVersion,
1381 /*DarwinTargetVariantTriple=*/nullptr,
1382 /*DarwinTargetVariantSDKVersion=*/VersionTuple());
1385 LinkedTargetVersion.getMajor(),
1386 LinkedTargetVersion.getMinor().value_or(0),
1387 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1388 return;
1389 }
1391 LinkedTargetVersion.getMajor(),
1392 LinkedTargetVersion.getMinor().value_or(0),
1393 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1394 ShouldEmitBuildVersion = true;
1395 }
1396
1397 if (const Triple *TVT = DarwinTargetVariantTriple) {
1398 if (Target.isMacOSX() && TVT->isMacCatalystEnvironment()) {
1399 auto TVLinkedTargetVersion =
1400 targetVersionOrMinimumSupportedOSVersion(*TVT, TVT->getiOSVersion());
1403 TVLinkedTargetVersion.getMajor(),
1404 TVLinkedTargetVersion.getMinor().value_or(0),
1405 TVLinkedTargetVersion.getSubminor().value_or(0),
1406 DarwinTargetVariantSDKVersion);
1407 }
1408 }
1409
1410 if (ShouldEmitBuildVersion)
1411 return;
1412
1414 LinkedTargetVersion.getMajor(),
1415 LinkedTargetVersion.getMinor().value_or(0),
1416 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1417}
BlockVerifier::State From
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::string Name
uint64_t Size
static VersionTuple getMachoBuildVersionSupportedOS(const Triple &Target)
static void copyBytesForDefRange(SmallString< 20 > &BytePrefix, codeview::SymbolKind SymKind, const T &DefRangeHeader)
Only call this on endian-specific types like ulittle16_t and little32_t, or structs composed of them.
Definition: MCStreamer.cpp:359
static MCVersionMinType getMachoVersionMinLoadCommandType(const Triple &Target)
static VersionTuple targetVersionOrMinimumSupportedOSVersion(const Triple &Target, VersionTuple TargetVersion)
static MCSection * getWinCFISection(MCContext &Context, unsigned *NextWinCFIID, MCSection *MainCFISec, const MCSection *TextSec)
Definition: MCStreamer.cpp:815
static MachO::PlatformType getMachoBuildVersionPlatformType(const Triple &Target)
static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg)
Definition: MCStreamer.cpp:863
#define I(x, y, z)
Definition: MD5.cpp:58
LLVMContext & Context
bool Debug
Profile::FuncID FuncId
Definition: Profile.cpp:321
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
Class for arbitrary precision integers.
Definition: APInt.h:75
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Holds state from .cv_file and .cv_loc directives for later emission.
Definition: MCCodeView.h:144
bool addFile(MCStreamer &OS, unsigned FileNumber, StringRef Filename, ArrayRef< uint8_t > ChecksumBytes, uint8_t ChecksumKind)
Definition: MCCodeView.cpp:47
MCCVFunctionInfo * getCVFunctionInfo(unsigned FuncId)
Retreive the function info if this is a valid function id, or nullptr.
Definition: MCCodeView.cpp:79
bool recordFunctionId(unsigned FuncId)
Records the function id of a normal function.
Definition: MCCodeView.cpp:87
bool recordInlinedCallSiteId(unsigned FuncId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol)
Records the function id of an inlined call site.
Definition: MCCodeView.cpp:100
unsigned size() const
Definition: DenseMap.h:99
Tagged union holding either a T or a Error.
Definition: Error.h:470
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:41
virtual uint32_t generateCompactUnwindEncoding(ArrayRef< MCCFIInstruction >) const
Generate the compact unwind encoding for the CFI instructions.
Definition: MCAsmBackend.h:214
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
StringRef getPrivateGlobalPrefix() const
Definition: MCAsmInfo.h:668
bool isLittleEndian() const
True if the target is little endian.
Definition: MCAsmInfo.h:559
const std::vector< MCCFIInstruction > & getInitialFrameState() const
Definition: MCAsmInfo.h:831
const char * getData8bitsDirective() const
Definition: MCAsmInfo.h:568
bool doesSetDirectiveSuppressReloc() const
Definition: MCAsmInfo.h:728
bool usesWindowsCFI() const
Definition: MCAsmInfo.h:797
Binary assembler expressions.
Definition: MCExpr.h:481
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition: MCExpr.h:628
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition: MCExpr.h:631
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:610
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
Definition: MCDwarf.h:547
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register)
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
Definition: MCDwarf.h:604
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register)
.cfi_same_value Current value of Register is the same as in the previous frame.
Definition: MCDwarf.h:616
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size)
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
Definition: MCDwarf.h:638
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
Definition: MCDwarf.h:540
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register)
.cfi_undefined From now on the previous value of Register can't be restored anymore.
Definition: MCDwarf.h:610
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment)
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
Definition: MCDwarf.h:554
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition: MCDwarf.h:533
static MCCFIInstruction createRememberState(MCSymbol *L)
.cfi_remember_state Save all current rules for all registers.
Definition: MCDwarf.h:621
static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register, int Offset, unsigned AddressSpace)
.cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to be the result of evaluating the DW...
Definition: MCDwarf.h:562
static MCCFIInstruction createWindowSave(MCSymbol *L)
.cfi_window_save SPARC register window is saved.
Definition: MCDwarf.h:592
static MCCFIInstruction createRestoreState(MCSymbol *L)
.cfi_restore_state Restore the previously saved state.
Definition: MCDwarf.h:626
static MCCFIInstruction createNegateRAState(MCSymbol *L)
.cfi_negate_ra_state AArch64 negate RA state.
Definition: MCDwarf.h:597
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Definition: MCDwarf.h:632
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition: MCDwarf.h:571
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register.
Definition: MCDwarf.h:579
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.
Definition: MCDwarf.h:586
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:194
Context object for machine code objects.
Definition: MCContext.h:76
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:972
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:729
CodeViewContext & getCVContext()
Definition: MCContext.cpp:1000
const MCRegisterInfo * getRegisterInfo() const
Definition: MCContext.h:448
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:770
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:446
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1055
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:201
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:753
const Triple & getTargetTriple() const
Definition: MCContext.h:434
void setLabel(MCSymbol *Label)
Definition: MCDwarf.h:401
MCSymbol * getLabel() const
Definition: MCDwarf.h:397
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
@ Unary
Unary expressions.
Definition: MCExpr.h:41
@ Constant
Constant expressions.
Definition: MCExpr.h:39
@ SymbolRef
References to labels and assigned expressions.
Definition: MCExpr.h:40
@ Target
Target specific expression.
Definition: MCExpr.h:42
@ Binary
Binary expressions.
Definition: MCExpr.h:38
ExprKind getKind() const
Definition: MCExpr.h:81
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:44
virtual void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS)=0
Print the specified MCInst to the specified raw_ostream.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
unsigned getNumOperands() const
Definition: MCInst.h:208
const MCOperand & getOperand(unsigned i) const
Definition: MCInst.h:206
const MCExpr * getExpr() const
Definition: MCInst.h:114
bool isExpr() const
Definition: MCInst.h:65
Instances of this class represent a pseudo probe instance for a pseudo probe table entry,...
int getSEHRegNum(MCRegister RegNum) const
Map a target register to an equivalent SEH register number.
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:24
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
Streaming machine code generation interface.
Definition: MCStreamer.h:212
virtual void emitNops(int64_t NumBytes, int64_t ControlledNopLength, SMLoc Loc, const MCSubtargetInfo &STI)
Definition: MCStreamer.cpp:225
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void visitUsedSymbol(const MCSymbol &Sym)
void emitCFIStartProc(bool IsSimple, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:447
virtual bool emitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
Definition: MCStreamer.cpp:301
virtual void finishImpl()
Streamer specific finalization.
void assignFragment(MCSymbol *Symbol, MCFragment *Fragment)
Sets the symbol's section.
Definition: MCStreamer.cpp:414
virtual void emitDTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
Definition: MCStreamer.cpp:195
virtual void emitCFIDefCfaOffset(int64_t Offset)
Definition: MCStreamer.cpp:506
virtual void emitCFIBKeyFrame()
Definition: MCStreamer.cpp:248
void generateCompactUnwindEncodings(MCAsmBackend *MAB)
Definition: MCStreamer.cpp:126
virtual void beginCOFFSymbolDef(const MCSymbol *Symbol)
Start emitting COFF symbol definition.
virtual void emitSyntaxDirective()
Definition: MCStreamer.cpp:861
virtual void emitWinCFIPushReg(MCRegister Register, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:867
virtual void emitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
virtual void initSections(bool NoExecStack, const MCSubtargetInfo &STI)
Create the default sections and set the initial one.
Definition: MCStreamer.cpp:410
virtual MCSymbol * emitCFILabel()
When emitting an object file, create and emit a real label.
Definition: MCStreamer.cpp:489
virtual void emitWindowsUnwindTables()
virtual raw_ostream & getCommentOS()
Return a raw_ostream that comments can be written to.
Definition: MCStreamer.cpp:111
virtual void emitCFIGnuArgsSize(int64_t Size)
Definition: MCStreamer.cpp:634
virtual void emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:786
virtual void emitBundleLock(bool AlignToEnd)
The following instructions are a bundle-locked group.
MCSection * getAssociatedPDataSection(const MCSection *TextSec)
Get the .pdata section used for the given section.
Definition: MCStreamer.cpp:849
bool hasUnfinishedDwarfFrameInfo()
Definition: MCStreamer.cpp:280
virtual ~MCStreamer()
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
virtual void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset, int64_t AddressSpace)
Definition: MCStreamer.cpp:537
virtual void emitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
Definition: MCStreamer.cpp:211
virtual void emitCFIRegister(int64_t Register1, int64_t Register2)
Definition: MCStreamer.cpp:661
virtual bool emitCVFileDirective(unsigned FileNo, StringRef Filename, ArrayRef< uint8_t > Checksum, unsigned ChecksumKind)
Associate a filename with a specified logical file number, and also specify that file's checksum info...
Definition: MCStreamer.cpp:294
virtual void emitCFIReturnColumn(int64_t Register)
Definition: MCStreamer.cpp:690
virtual void emitCOFFSymbolType(int Type)
Emit the type of the symbol.
virtual void emitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:569
virtual void emitDwarfUnitLength(uint64_t Length, const Twine &Comment)
Emit a unit length field.
virtual void emitCOFFSymbolIndex(MCSymbol const *Symbol)
Emits the symbol table index of a Symbol into the current section.
Definition: MCStreamer.cpp:976
virtual void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName)
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
Definition: MCStreamer.cpp:262
virtual void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset)
Emits a COFF image relative relocation.
Definition: MCStreamer.cpp:982
virtual void endCOFFSymbolDef()
Marks the end of the symbol definition.
virtual void emitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:950
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:803
virtual void emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo)
Emit the absolute difference between two symbols encoded with ULEB128.
virtual void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol, MCSymbolAttr Linkage, MCSymbolAttr Visibility)
Emit a symbol's linkage and visibility with a linkage directive for XCOFF.
void setTargetStreamer(MCTargetStreamer *TS)
Definition: MCStreamer.h:284
virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:935
virtual void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
Definition: MCStreamer.cpp:472
virtual void emitXCOFFRefDirective(StringRef Sym)
Emit a XCOFF .ref directive which creates R_REF type entry in the relocation table for one or more sy...
virtual void emitGPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
Definition: MCStreamer.cpp:215
virtual void emitCFILsda(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:578
virtual void emitCFIRememberState()
Definition: MCStreamer.cpp:586
MCContext & getContext() const
Definition: MCStreamer.h:297
SMLoc getStartTokLoc() const
Definition: MCStreamer.h:289
virtual void emitBundleUnlock()
Ends a bundle-locked group.
virtual Expected< unsigned > tryEmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, std::optional< MD5::MD5Result > Checksum=std::nullopt, std::optional< StringRef > Source=std::nullopt, unsigned CUID=0)
Associate a filename with a specified logical file number.
Definition: MCStreamer.cpp:231
virtual void addExplicitComment(const Twine &T)
Add explicit comment T.
Definition: MCStreamer.cpp:123
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
Definition: MCStreamer.h:359
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
virtual void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t Size, MCSymbol *CsectSym, Align Alignment)
Emits an lcomm directive with XCOFF csect information.
virtual void emitCFIMTETaggedFrame()
Definition: MCStreamer.cpp:255
virtual void emitTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (32-bit TP relative) value.
Definition: MCStreamer.cpp:207
virtual void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)
Emits a COFF section relative relocation.
Definition: MCStreamer.cpp:980
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
Definition: MCStreamer.cpp:855
virtual void emitCFIOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:549
virtual void emitRawComment(const Twine &T, bool TabPrefix=true)
Print T and prefix it with the comment string (normally #) and optionally a tab.
Definition: MCStreamer.cpp:121
virtual void emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:712
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:180
void emitSymbolValue(const MCSymbol *Sym, unsigned Size, bool IsSectionRelative=false)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
Definition: MCStreamer.cpp:184
bool checkCVLocSection(unsigned FuncId, unsigned FileNo, SMLoc Loc)
Returns true if the the .cv_loc directive is in the right section.
Definition: MCStreamer.cpp:324
virtual void emitCFIWindowSave()
Definition: MCStreamer.cpp:671
virtual void emitCFIRestoreState()
Definition: MCStreamer.cpp:595
virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)
Emit the debug line start label.
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
virtual void emitXCOFFExceptDirective(const MCSymbol *Symbol, const MCSymbol *Trap, unsigned Lang, unsigned Reason, unsigned FunctionSize, bool hasDebug)
Emit an XCOFF .except directive which adds information about a trap instruction to the object file ex...
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:423
virtual void emitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
Definition: MCStreamer.cpp:978
virtual void reset()
State management.
Definition: MCStreamer.cpp:102
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
Definition: MCStreamer.cpp:346
virtual void emitCFIRestore(int64_t Register)
Definition: MCStreamer.cpp:615
virtual void emitTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (64-bit TP relative) value.
Definition: MCStreamer.cpp:203
virtual void emitCFISections(bool EH, bool Debug)
Definition: MCStreamer.cpp:445
MCTargetStreamer * getTargetStreamer()
Definition: MCStreamer.h:304
MCStreamer(MCContext &Ctx)
Definition: MCStreamer.cpp:94
virtual void emitAssemblerFlag(MCAssemblerFlag Flag)
Note in the output the specified Flag.
virtual void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Definition: MCStreamer.h:516
virtual void emitValueToAlignment(Align Alignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
virtual void emitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers.
Definition: MCStreamer.cpp:134
unsigned getNumFrameInfos()
Definition: MCStreamer.cpp:116
virtual void emitWinCFISaveReg(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:918
virtual void emitWinCFIEndChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:772
virtual void emitWinCFIEndProlog(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:964
virtual void emitWinCFIEndProc(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:730
void emitVersionForTarget(const Triple &Target, const VersionTuple &SDKVersion, const Triple *DarwinTargetVariantTriple, const VersionTuple &DarwinTargetVariantSDKVersion)
virtual void emitCodeAlignment(Align Alignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
virtual void emitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
Definition: MCStreamer.cpp:483
virtual void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
Set the DescValue for the Symbol.
virtual void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment)
Emit a local common (.lcomm) symbol.
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
Definition: MCStreamer.cpp:270
virtual void emitCOFFSafeSEH(MCSymbol const *Symbol)
Definition: MCStreamer.cpp:974
virtual void emitWinCFIFuncletOrFuncEnd(SMLoc Loc=SMLoc())
This is used on platforms, such as Windows on ARM64, that require function or funclet sizes to be emi...
Definition: MCStreamer.cpp:748
virtual void changeSection(MCSection *, const MCExpr *)
Update streamer for a new active section.
virtual void emitXCOFFRenameDirective(const MCSymbol *Name, StringRef Rename)
Emit a XCOFF .rename directive which creates a synonym for an illegal or undesirable name.
virtual void emitCFIUndefined(int64_t Register)
Definition: MCStreamer.cpp:651
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
Definition: MCStreamer.cpp:811
virtual void emitCFIDefCfaRegister(int64_t Register)
Definition: MCStreamer.cpp:526
unsigned emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:162
virtual void emitULEB128Value(const MCExpr *Value)
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
Definition: MCStreamer.cpp:117
virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc)
Emit some number of copies of Value until the byte offset Offset is reached.
MCSymbol * endSection(MCSection *Section)
virtual void switchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
virtual void emitExplicitComments()
Emit added explicit comments.
Definition: MCStreamer.cpp:124
WinEH::FrameInfo * EnsureValidWinFrameInfo(SMLoc Loc)
Retrieve the current frame info if one is available and it is not yet closed.
Definition: MCStreamer.cpp:697
virtual void emitThumbFunc(MCSymbol *Func)
Note in the output that the specified Func is a Thumb mode function (ARM target only).
virtual void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol)
Definition: MCStreamer.cpp:406
virtual void emitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
Definition: MCStreamer.cpp:368
void emitInt32(uint64_t Value)
Definition: MCStreamer.h:748
virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:879
virtual void emitCFINegateRAState()
Definition: MCStreamer.cpp:681
void maybeEmitDwarf64Mark()
Emit a special value of 0xffffffff if producing 64-bit debugging info.
virtual void emitCFIAdjustCfaOffset(int64_t Adjustment)
Definition: MCStreamer.cpp:516
virtual void emitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
Definition: MCStreamer.cpp:199
virtual void emitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc)
This implements the CodeView '.cv_loc' assembler directive.
Definition: MCStreamer.cpp:319
virtual void emitPseudoProbe(uint64_t Guid, uint64_t Index, uint64_t Type, uint64_t Attr, const MCPseudoProbeInlineStack &InlineStack, MCSymbol *FnSym)
Emit the a pseudo probe into the current section.
virtual void emitCFISameValue(int64_t Register)
Definition: MCStreamer.cpp:605
virtual void emitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:901
virtual void emitFileDirective(StringRef Filename)
Switch to a new logical file.
virtual void emitSLEB128Value(const MCExpr *Value)
virtual void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name, bool KeepOriginalSym)
Emit an ELF .symver directive.
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:393
virtual void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
void emitRawText(const Twine &String)
If this file is backed by a assembly streamer, this dumps the specified string in the output ....
Definition: MCStreamer.cpp:996
void emitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Definition: MCStreamer.cpp:229
unsigned emitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:172
virtual bool emitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol, SMLoc Loc)
Introduces an inline call site id for use with .cv_loc.
Definition: MCStreamer.cpp:305
virtual void emitCFISignalFrame()
Definition: MCStreamer.cpp:644
virtual void emitCFIDefCfa(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:495
virtual void emitVersionMin(MCVersionMinType Type, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Specify the Mach-O minimum deployment target version.
Definition: MCStreamer.h:506
virtual void emitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
virtual void emitCFIRelOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:559
virtual void emitConditionalAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol, but only if Value is also emitted.
Definition: MCStreamer.cpp:442
virtual void emitWinCFIStartChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:759
virtual void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment=Align(1))
Emit a thread local bss (.tbss) symbol.
virtual void emitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView '.cv_inline_linetable' assembler directive.
Definition: MCStreamer.cpp:350
void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
Definition: MCStreamer.cpp:221
virtual void emitBundleAlignMode(Align Alignment)
Set the bundle alignment mode from now on in the section.
virtual void emitRawTextImpl(StringRef String)
EmitRawText - If this file is backed by an assembly streamer, this dumps the specified string in the ...
Definition: MCStreamer.cpp:987
virtual void emitCFIEscape(StringRef Values)
Definition: MCStreamer.cpp:625
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
void finish(SMLoc EndLoc=SMLoc())
Finish emission of machine code.
virtual void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol)
Emit an weak reference from Alias to Symbol.
void visitUsedExpr(const MCExpr &Expr)
virtual void emitDwarfFile0Directive(StringRef Directory, StringRef Filename, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, unsigned CUID=0)
Specify the "root" file of the compilation, using the ".file 0" extension.
Definition: MCStreamer.cpp:239
virtual void emitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Emit/Specify Mach-O build version command.
Definition: MCStreamer.h:512
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:192
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:386
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute).
Definition: MCSymbol.h:252
Target specific streamer interface.
Definition: MCStreamer.h:93
virtual void emitDwarfFileDirective(StringRef Directive)
Definition: MCStreamer.cpp:68
virtual void emitValue(const MCExpr *Value)
Definition: MCStreamer.cpp:72
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, uint64_t Address, const MCInst &Inst, const MCSubtargetInfo &STI, raw_ostream &OS)
virtual void finish()
Definition: MCStreamer.cpp:55
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Definition: MCStreamer.cpp:92
virtual void emitRawBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition: MCStreamer.cpp:80
MCStreamer & Streamer
Definition: MCStreamer.h:95
MCTargetStreamer(MCStreamer &S)
Definition: MCStreamer.cpp:46
virtual void emitLabel(MCSymbol *Symbol)
Definition: MCStreamer.cpp:53
virtual void changeSection(const MCSection *CurSection, MCSection *Section, const MCExpr *SubSection, raw_ostream &OS)
Update streamer for a new active section.
Definition: MCStreamer.cpp:59
virtual void emitConstantPools()
Definition: MCStreamer.cpp:57
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
Represents a location in source code.
Definition: SMLoc.h:23
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:261
size_t size() const
Definition: SmallVector.h:91
void resize(size_type N)
Definition: SmallVector.h:642
void push_back(const T &Elt)
Definition: SmallVector.h:416
pointer data()
Return a pointer to the vector's buffer, even if empty().
Definition: SmallVector.h:289
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
bool isMacOSX() const
Is this a Mac OS X triple.
Definition: Triple.h:485
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
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
Definition: AsmWriter.cpp:4695
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:31
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
Definition: VersionTuple.h:68
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:672
StringRef str() const
Return a StringRef for the vector contents.
Definition: raw_ostream.h:697
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_SCN_LNK_COMDAT
Definition: COFF.h:294
@ IMAGE_COMDAT_SELECT_ANY
Definition: COFF.h:408
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
PlatformType
Definition: MachO.h:497
@ PLATFORM_MACCATALYST
Definition: MachO.h:504
@ PLATFORM_DRIVERKIT
Definition: MachO.h:508
@ PLATFORM_WATCHOS
Definition: MachO.h:502
@ PLATFORM_WATCHOSSIMULATOR
Definition: MachO.h:507
@ PLATFORM_IOS
Definition: MachO.h:500
@ PLATFORM_TVOS
Definition: MachO.h:501
@ PLATFORM_TVOSSIMULATOR
Definition: MachO.h:506
@ PLATFORM_MACOS
Definition: MachO.h:499
@ PLATFORM_IOSSIMULATOR
Definition: MachO.h:505
StorageClass
Definition: XCOFF.h:169
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
Definition: CodeView.h:47
@ DWARF64
Definition: Dwarf.h:91
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:718
@ DW_LENGTH_lo_reserved
Special values for an initial length field.
Definition: Dwarf.h:54
@ DW_LENGTH_DWARF64
Indicator of 64-bit DWARF format.
Definition: Dwarf.h:55
value_type byte_swap(value_type value, endianness endian)
Definition: Endian.h:49
static const bool IsLittleEndianHost
Definition: SwapByteOrder.h:67
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:406
@ Length
Definition: DWP.cpp:406
void StoreIntToMemory(const APInt &IntVal, uint8_t *Dst, unsigned StoreBytes)
StoreIntToMemory - Fills the StoreBytes bytes of memory starting from Dst with the integer held in In...
Definition: APInt.cpp:3002
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:252
AddressSpace
Definition: NVPTXBaseInfo.h:21
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
MCVersionMinType
Definition: MCDirectives.h:68
@ MCVM_WatchOSVersionMin
.watchos_version_min
Definition: MCDirectives.h:72
@ MCVM_OSXVersionMin
.macosx_version_min
Definition: MCDirectives.h:70
@ MCVM_TvOSVersionMin
.tvos_version_min
Definition: MCDirectives.h:71
@ MCVM_IOSVersionMin
.ios_version_min
Definition: MCDirectives.h:69
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:145
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
MCAssemblerFlag
Definition: MCDirectives.h:52
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:257
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
Definition: MCStreamer.h:66
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
Definition: LEB128.h:23
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
Definition: LEB128.h:80
MCSymbolAttr
Definition: MCDirectives.h:18
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Information describing a function or inlined call site introduced by .cv_func_id or ....
Definition: MCCodeView.h:98
MCSection * Section
The section of the first .cv_loc directive used for this function, or null if none has been seen yet.
Definition: MCCodeView.h:118
const MCSymbol * Personality
Definition: MCDwarf.h:687
unsigned PersonalityEncoding
Definition: MCDwarf.h:691
std::vector< MCCFIInstruction > Instructions
Definition: MCDwarf.h:689
unsigned LsdaEncoding
Definition: MCDwarf.h:692
const MCSymbol * Lsda
Definition: MCDwarf.h:688
unsigned CurrentCfaRegister
Definition: MCDwarf.h:690
static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition: MCWin64EH.h:42
static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg)
Definition: MCWin64EH.h:26
static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code)
Definition: MCWin64EH.h:33
static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition: MCWin64EH.h:36
static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size)
Definition: MCWin64EH.h:29
static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off)
Definition: MCWin64EH.h:48
std::vector< Instruction > Instructions
Definition: MCWinEH.h:58
const MCSymbol * Function
Definition: MCWinEH.h:44
MCSection * TextSection
Definition: MCWinEH.h:47
const MCSymbol * PrologEnd
Definition: MCWinEH.h:45
const MCSymbol * FuncletOrFuncEnd
Definition: MCWinEH.h:42
const MCSymbol * End
Definition: MCWinEH.h:41
const FrameInfo * ChainedParent
Definition: MCWinEH.h:57
const MCSymbol * ExceptionHandler
Definition: MCWinEH.h:43