LLVM 20.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, uint32_t Subsection,
61 raw_ostream &OS) {
62 Section->printSwitchToSection(*Streamer.getContext().getAsmInfo(),
64 Subsection);
65}
66
69}
70
74
76 Streamer.emitRawText(OS.str());
77}
78
80 const MCAsmInfo *MAI = Streamer.getContext().getAsmInfo();
81 const char *Directive = MAI->getData8bitsDirective();
82 for (const unsigned char C : Data.bytes()) {
85
86 OS << Directive << (unsigned)C;
87 Streamer.emitRawText(OS.str());
88 }
89}
90
92
94 : Context(Ctx), CurrentWinFrameInfo(nullptr),
95 CurrentProcWinFrameInfoStartIndex(0) {
96 SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
97}
98
99MCStreamer::~MCStreamer() = default;
100
102 DwarfFrameInfos.clear();
103 CurrentWinFrameInfo = nullptr;
104 WinFrameInfos.clear();
105 SectionStack.clear();
106 SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
107 CurFrag = nullptr;
108}
109
111 // By default, discard comments.
112 return nulls();
113}
114
115unsigned MCStreamer::getNumFrameInfos() { return DwarfFrameInfos.size(); }
117 return DwarfFrameInfos;
118}
119
120void MCStreamer::emitRawComment(const Twine &T, bool TabPrefix) {}
121
124
126 for (auto &FI : DwarfFrameInfos)
127 FI.CompactUnwindEncoding =
128 (MAB ? MAB->generateCompactUnwindEncoding(&FI, &Context) : 0);
129}
130
131/// EmitIntValue - Special case of EmitValue that avoids the client having to
132/// pass in a MCExpr for constant integers.
134 assert(1 <= Size && Size <= 8 && "Invalid size");
135 assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
136 "Invalid size");
137 const bool IsLittleEndian = Context.getAsmInfo()->isLittleEndian();
140 unsigned Index = IsLittleEndian ? 0 : 8 - Size;
141 emitBytes(StringRef(reinterpret_cast<char *>(&Swapped) + Index, Size));
142}
144 if (Value.getNumWords() == 1) {
145 emitIntValue(Value.getLimitedValue(), Value.getBitWidth() / 8);
146 return;
147 }
148
149 const bool IsLittleEndianTarget = Context.getAsmInfo()->isLittleEndian();
150 const bool ShouldSwap = sys::IsLittleEndianHost != IsLittleEndianTarget;
151 const APInt Swapped = ShouldSwap ? Value.byteSwap() : Value;
152 const unsigned Size = Value.getBitWidth() / 8;
153 SmallString<10> Tmp;
154 Tmp.resize(Size);
155 StoreIntToMemory(Swapped, reinterpret_cast<uint8_t *>(Tmp.data()), Size);
156 emitBytes(Tmp.str());
157}
158
159/// EmitULEB128IntValue - Special case of EmitULEB128Value that avoids the
160/// client having to pass in a MCExpr for constant integers.
163 raw_svector_ostream OSE(Tmp);
164 encodeULEB128(Value, OSE, PadTo);
165 emitBytes(OSE.str());
166 return Tmp.size();
167}
168
169/// EmitSLEB128IntValue - Special case of EmitSLEB128Value that avoids the
170/// client having to pass in a MCExpr for constant integers.
173 raw_svector_ostream OSE(Tmp);
174 encodeSLEB128(Value, OSE);
175 emitBytes(OSE.str());
176 return Tmp.size();
177}
178
179void MCStreamer::emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc) {
180 emitValueImpl(Value, Size, Loc);
181}
182
184 bool IsSectionRelative) {
185 assert((!IsSectionRelative || Size == 4) &&
186 "SectionRelative value requires 4-bytes");
187
188 if (!IsSectionRelative)
190 else
191 emitCOFFSecRel32(Sym, /*Offset=*/0);
192}
193
195 report_fatal_error("unsupported directive in streamer");
196}
197
199 report_fatal_error("unsupported directive in streamer");
200}
201
203 report_fatal_error("unsupported directive in streamer");
204}
205
207 report_fatal_error("unsupported directive in streamer");
208}
209
211 report_fatal_error("unsupported directive in streamer");
212}
213
215 report_fatal_error("unsupported directive in streamer");
216}
217
218/// Emit NumBytes bytes worth of the value specified by FillValue.
219/// This implements directives such as '.space'.
220void MCStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
221 if (NumBytes)
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
271 getContext()
272 .getMCDwarfLineTable(getContext().getDwarfCompileUnitID())
274}
275
278 if (!Table.getLabel()) {
279 StringRef Prefix = Context.getAsmInfo()->getPrivateGlobalPrefix();
280 Table.setLabel(
281 Context.getOrCreateSymbol(Prefix + "line_table_start" + Twine(CUID)));
282 }
283 return Table.getLabel();
284}
285
287 return !FrameInfoStack.empty();
288}
289
290MCDwarfFrameInfo *MCStreamer::getCurrentDwarfFrameInfo() {
293 "this directive must appear between "
294 ".cfi_startproc and .cfi_endproc directives");
295 return nullptr;
296 }
297 return &DwarfFrameInfos[FrameInfoStack.back().first];
298}
299
300bool MCStreamer::emitCVFileDirective(unsigned FileNo, StringRef Filename,
301 ArrayRef<uint8_t> Checksum,
302 unsigned ChecksumKind) {
303 return getContext().getCVContext().addFile(*this, FileNo, Filename, Checksum,
304 ChecksumKind);
305}
306
309}
310
312 unsigned IAFunc, unsigned IAFile,
313 unsigned IALine, unsigned IACol,
314 SMLoc Loc) {
315 if (getContext().getCVContext().getCVFunctionInfo(IAFunc) == nullptr) {
316 getContext().reportError(Loc, "parent function id not introduced by "
317 ".cv_func_id or .cv_inline_site_id");
318 return true;
319 }
320
322 FunctionId, IAFunc, IAFile, IALine, IACol);
323}
324
325void MCStreamer::emitCVLocDirective(unsigned FunctionId, unsigned FileNo,
326 unsigned Line, unsigned Column,
327 bool PrologueEnd, bool IsStmt,
328 StringRef FileName, SMLoc Loc) {}
329
330bool MCStreamer::checkCVLocSection(unsigned FuncId, unsigned FileNo,
331 SMLoc Loc) {
334 if (!FI) {
336 Loc, "function id not introduced by .cv_func_id or .cv_inline_site_id");
337 return false;
338 }
339
340 // Track the section
341 if (FI->Section == nullptr)
343 else if (FI->Section != getCurrentSectionOnly()) {
345 Loc,
346 "all .cv_loc directives for a function must be in the same section");
347 return false;
348 }
349 return true;
350}
351
353 const MCSymbol *Begin,
354 const MCSymbol *End) {}
355
356void MCStreamer::emitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
357 unsigned SourceFileId,
358 unsigned SourceLineNum,
359 const MCSymbol *FnStartSym,
360 const MCSymbol *FnEndSym) {}
361
362/// Only call this on endian-specific types like ulittle16_t and little32_t, or
363/// structs composed of them.
364template <typename T>
365static void copyBytesForDefRange(SmallString<20> &BytePrefix,
366 codeview::SymbolKind SymKind,
367 const T &DefRangeHeader) {
368 BytePrefix.resize(2 + sizeof(T));
369 codeview::ulittle16_t SymKindLE = codeview::ulittle16_t(SymKind);
370 memcpy(&BytePrefix[0], &SymKindLE, 2);
371 memcpy(&BytePrefix[2], &DefRangeHeader, sizeof(T));
372}
373
375 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
376 StringRef FixedSizePortion) {}
377
379 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
381 SmallString<20> BytePrefix;
382 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_REGISTER_REL, DRHdr);
383 emitCVDefRangeDirective(Ranges, BytePrefix);
384}
385
387 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
389 SmallString<20> BytePrefix;
390 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_SUBFIELD_REGISTER,
391 DRHdr);
392 emitCVDefRangeDirective(Ranges, BytePrefix);
393}
394
396 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
398 SmallString<20> BytePrefix;
399 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_REGISTER, DRHdr);
400 emitCVDefRangeDirective(Ranges, BytePrefix);
401}
402
404 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
406 SmallString<20> BytePrefix;
407 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_FRAMEPOINTER_REL,
408 DRHdr);
409 emitCVDefRangeDirective(Ranges, BytePrefix);
410}
411
413 MCSymbol *EHSymbol) {
414}
415
416void MCStreamer::initSections(bool NoExecStack, const MCSubtargetInfo &STI) {
417 switchSection(getContext().getObjectFileInfo()->getTextSection());
418}
419
421 Symbol->redefineIfPossible();
422
423 if (!Symbol->isUndefined() || Symbol->isVariable())
424 return getContext().reportError(Loc, "symbol '" + Twine(Symbol->getName()) +
425 "' is already defined");
426
427 assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
428 assert(getCurrentSectionOnly() && "Cannot emit before setting section!");
429 assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
430 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
431
432 Symbol->setFragment(&getCurrentSectionOnly()->getDummyFragment());
433
435 if (TS)
436 TS->emitLabel(Symbol);
437}
438
440 const MCExpr *Value) {}
441
442void MCStreamer::emitCFISections(bool EH, bool Debug) {}
443
444void MCStreamer::emitCFIStartProc(bool IsSimple, SMLoc Loc) {
445 if (!FrameInfoStack.empty() &&
446 getCurrentSectionOnly() == FrameInfoStack.back().second)
447 return getContext().reportError(
448 Loc, "starting new .cfi frame before finishing the previous one");
449
450 MCDwarfFrameInfo Frame;
451 Frame.IsSimple = IsSimple;
453
454 const MCAsmInfo* MAI = Context.getAsmInfo();
455 if (MAI) {
456 for (const MCCFIInstruction& Inst : MAI->getInitialFrameState()) {
457 if (Inst.getOperation() == MCCFIInstruction::OpDefCfa ||
458 Inst.getOperation() == MCCFIInstruction::OpDefCfaRegister ||
459 Inst.getOperation() == MCCFIInstruction::OpLLVMDefAspaceCfa) {
460 Frame.CurrentCfaRegister = Inst.getRegister();
461 }
462 }
463 }
464
465 FrameInfoStack.emplace_back(DwarfFrameInfos.size(), getCurrentSectionOnly());
466 DwarfFrameInfos.push_back(std::move(Frame));
467}
468
470}
471
473 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
474 if (!CurFrame)
475 return;
476 emitCFIEndProcImpl(*CurFrame);
477 FrameInfoStack.pop_back();
478}
479
481 // Put a dummy non-null value in Frame.End to mark that this frame has been
482 // closed.
483 Frame.End = (MCSymbol *)1;
484}
485
487 // Create a label and insert it into the line table and return this label
488 const MCDwarfLoc &DwarfLoc = getContext().getCurrentDwarfLoc();
489
490 MCSymbol *LineStreamLabel = getContext().createTempSymbol();
491 MCDwarfLineEntry LabelLineEntry(nullptr, DwarfLoc, LineStreamLabel);
492 getContext()
493 .getMCDwarfLineTable(getContext().getDwarfCompileUnitID())
495 .addLineEntry(LabelLineEntry, getCurrentSectionOnly() /*Section*/);
496
497 return LineStreamLabel;
498}
499
501 // Return a dummy non-null value so that label fields appear filled in when
502 // generating textual assembly.
503 return (MCSymbol *)1;
504}
505
506void MCStreamer::emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc) {
507 MCSymbol *Label = emitCFILabel();
510 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
511 if (!CurFrame)
512 return;
513 CurFrame->Instructions.push_back(std::move(Instruction));
514 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
515}
516
518 MCSymbol *Label = emitCFILabel();
521 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
522 if (!CurFrame)
523 return;
524 CurFrame->Instructions.push_back(std::move(Instruction));
525}
526
527void MCStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc) {
528 MCSymbol *Label = emitCFILabel();
530 MCCFIInstruction::createAdjustCfaOffset(Label, Adjustment, Loc);
531 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
532 if (!CurFrame)
533 return;
534 CurFrame->Instructions.push_back(std::move(Instruction));
535}
536
538 MCSymbol *Label = emitCFILabel();
541 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
542 if (!CurFrame)
543 return;
544 CurFrame->Instructions.push_back(std::move(Instruction));
545 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
546}
547
549 int64_t AddressSpace, SMLoc Loc) {
550 MCSymbol *Label = emitCFILabel();
552 Label, Register, Offset, AddressSpace, Loc);
553 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
554 if (!CurFrame)
555 return;
556 CurFrame->Instructions.push_back(std::move(Instruction));
557 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
558}
559
560void MCStreamer::emitCFIOffset(int64_t Register, int64_t Offset, SMLoc Loc) {
561 MCSymbol *Label = emitCFILabel();
564 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
565 if (!CurFrame)
566 return;
567 CurFrame->Instructions.push_back(std::move(Instruction));
568}
569
571 MCSymbol *Label = emitCFILabel();
574 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
575 if (!CurFrame)
576 return;
577 CurFrame->Instructions.push_back(std::move(Instruction));
578}
579
581 unsigned Encoding) {
582 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
583 if (!CurFrame)
584 return;
585 CurFrame->Personality = Sym;
586 CurFrame->PersonalityEncoding = Encoding;
587}
588
589void MCStreamer::emitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
590 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
591 if (!CurFrame)
592 return;
593 CurFrame->Lsda = Sym;
594 CurFrame->LsdaEncoding = Encoding;
595}
596
598 MCSymbol *Label = emitCFILabel();
601 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
602 if (!CurFrame)
603 return;
604 CurFrame->Instructions.push_back(std::move(Instruction));
605}
606
608 // FIXME: Error if there is no matching cfi_remember_state.
609 MCSymbol *Label = emitCFILabel();
612 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
613 if (!CurFrame)
614 return;
615 CurFrame->Instructions.push_back(std::move(Instruction));
616}
617
619 MCSymbol *Label = emitCFILabel();
622 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
623 if (!CurFrame)
624 return;
625 CurFrame->Instructions.push_back(std::move(Instruction));
626}
627
629 MCSymbol *Label = emitCFILabel();
632 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
633 if (!CurFrame)
634 return;
635 CurFrame->Instructions.push_back(std::move(Instruction));
636}
637
639 MCSymbol *Label = emitCFILabel();
641 MCCFIInstruction::createEscape(Label, Values, Loc, "");
642 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
643 if (!CurFrame)
644 return;
645 CurFrame->Instructions.push_back(std::move(Instruction));
646}
647
649 MCSymbol *Label = emitCFILabel();
652 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
653 if (!CurFrame)
654 return;
655 CurFrame->Instructions.push_back(std::move(Instruction));
656}
657
659 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
660 if (!CurFrame)
661 return;
662 CurFrame->IsSignalFrame = true;
663}
664
666 MCSymbol *Label = emitCFILabel();
669 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
670 if (!CurFrame)
671 return;
672 CurFrame->Instructions.push_back(std::move(Instruction));
673}
674
675void MCStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
676 SMLoc Loc) {
677 MCSymbol *Label = emitCFILabel();
679 MCCFIInstruction::createRegister(Label, Register1, Register2, Loc);
680 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
681 if (!CurFrame)
682 return;
683 CurFrame->Instructions.push_back(std::move(Instruction));
684}
685
687 MCSymbol *Label = emitCFILabel();
689 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
690 if (!CurFrame)
691 return;
692 CurFrame->Instructions.push_back(std::move(Instruction));
693}
694
696 MCSymbol *Label = emitCFILabel();
699 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
700 if (!CurFrame)
701 return;
702 CurFrame->Instructions.push_back(std::move(Instruction));
703}
704
706 MCSymbol *Label = emitCFILabel();
709 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
710 if (!CurFrame)
711 return;
712 CurFrame->Instructions.push_back(std::move(Instruction));
713}
714
716 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
717 if (!CurFrame)
718 return;
719 CurFrame->RAReg = Register;
720}
721
723 MCSymbol *Label = emitCFILabel();
725 if (MCDwarfFrameInfo *F = getCurrentDwarfFrameInfo())
726 F->Instructions.push_back(MCCFIInstruction::createLabel(Label, Sym, Loc));
727}
728
730 MCSymbol *Label = emitCFILabel();
733 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
734 if (!CurFrame)
735 return;
736 CurFrame->Instructions.push_back(std::move(Instruction));
737}
738
740 const MCAsmInfo *MAI = Context.getAsmInfo();
741 if (!MAI->usesWindowsCFI()) {
743 Loc, ".seh_* directives are not supported on this target");
744 return nullptr;
745 }
746 if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End) {
748 Loc, ".seh_ directive must appear within an active frame");
749 return nullptr;
750 }
751 return CurrentWinFrameInfo;
752}
753
755 const MCAsmInfo *MAI = Context.getAsmInfo();
756 if (!MAI->usesWindowsCFI())
757 return getContext().reportError(
758 Loc, ".seh_* directives are not supported on this target");
759 if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End)
761 Loc, "Starting a function before ending the previous one!");
762
763 MCSymbol *StartProc = emitCFILabel();
764
765 CurrentProcWinFrameInfoStartIndex = WinFrameInfos.size();
766 WinFrameInfos.emplace_back(
767 std::make_unique<WinEH::FrameInfo>(Symbol, StartProc));
768 CurrentWinFrameInfo = WinFrameInfos.back().get();
769 CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
770}
771
774 if (!CurFrame)
775 return;
776 if (CurFrame->ChainedParent)
777 getContext().reportError(Loc, "Not all chained regions terminated!");
778
779 MCSymbol *Label = emitCFILabel();
780 CurFrame->End = Label;
781 if (!CurFrame->FuncletOrFuncEnd)
782 CurFrame->FuncletOrFuncEnd = CurFrame->End;
783
784 for (size_t I = CurrentProcWinFrameInfoStartIndex, E = WinFrameInfos.size();
785 I != E; ++I)
786 emitWindowsUnwindTables(WinFrameInfos[I].get());
787 switchSection(CurFrame->TextSection);
788}
789
792 if (!CurFrame)
793 return;
794 if (CurFrame->ChainedParent)
795 getContext().reportError(Loc, "Not all chained regions terminated!");
796
797 MCSymbol *Label = emitCFILabel();
798 CurFrame->FuncletOrFuncEnd = Label;
799}
800
803 if (!CurFrame)
804 return;
805
806 MCSymbol *StartProc = emitCFILabel();
807
808 WinFrameInfos.emplace_back(std::make_unique<WinEH::FrameInfo>(
809 CurFrame->Function, StartProc, CurFrame));
810 CurrentWinFrameInfo = WinFrameInfos.back().get();
811 CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
813
816 if (!CurFrame)
817 return;
818 if (!CurFrame->ChainedParent)
819 return getContext().reportError(
820 Loc, "End of a chained region outside a chained region!");
821
822 MCSymbol *Label = emitCFILabel();
823
824 CurFrame->End = Label;
825 CurrentWinFrameInfo = const_cast<WinEH::FrameInfo *>(CurFrame->ChainedParent);
826}
827
828void MCStreamer::emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except,
829 SMLoc Loc) {
831 if (!CurFrame)
832 return;
833 if (CurFrame->ChainedParent)
834 return getContext().reportError(
835 Loc, "Chained unwind areas can't have handlers!");
836 CurFrame->ExceptionHandler = Sym;
837 if (!Except && !Unwind)
838 getContext().reportError(Loc, "Don't know what kind of handler this is!");
839 if (Unwind)
840 CurFrame->HandlesUnwind = true;
841 if (Except)
842 CurFrame->HandlesExceptions = true;
843}
844
847 if (!CurFrame)
848 return;
849 if (CurFrame->ChainedParent)
850 getContext().reportError(Loc, "Chained unwind areas can't have handlers!");
851}
852
854 const MCSymbolRefExpr *To, uint64_t Count) {
855}
856
857static MCSection *getWinCFISection(MCContext &Context, unsigned *NextWinCFIID,
858 MCSection *MainCFISec,
859 const MCSection *TextSec) {
860 // If this is the main .text section, use the main unwind info section.
861 if (TextSec == Context.getObjectFileInfo()->getTextSection())
862 return MainCFISec;
863
864 const auto *TextSecCOFF = cast<MCSectionCOFF>(TextSec);
865 auto *MainCFISecCOFF = cast<MCSectionCOFF>(MainCFISec);
866 unsigned UniqueID = TextSecCOFF->getOrAssignWinCFISectionID(NextWinCFIID);
867
868 // If this section is COMDAT, this unwind section should be COMDAT associative
869 // with its group.
870 const MCSymbol *KeySym = nullptr;
871 if (TextSecCOFF->getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) {
872 KeySym = TextSecCOFF->getCOMDATSymbol();
873
874 // In a GNU environment, we can't use associative comdats. Instead, do what
875 // GCC does, which is to make plain comdat selectany section named like
876 // ".[px]data$_Z3foov".
877 if (!Context.getAsmInfo()->hasCOFFAssociativeComdats()) {
878 std::string SectionName = (MainCFISecCOFF->getName() + "$" +
879 TextSecCOFF->getName().split('$').second)
880 .str();
881 return Context.getCOFFSection(SectionName,
882 MainCFISecCOFF->getCharacteristics() |
885 }
886 }
887
888 return Context.getAssociativeCOFFSection(MainCFISecCOFF, KeySym, UniqueID);
889}
890
892 return getWinCFISection(getContext(), &NextWinCFIID,
893 getContext().getObjectFileInfo()->getPDataSection(),
894 TextSec);
895}
896
898 return getWinCFISection(getContext(), &NextWinCFIID,
899 getContext().getObjectFileInfo()->getXDataSection(),
900 TextSec);
901}
902
904
905static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg) {
906 return Ctx.getRegisterInfo()->getSEHRegNum(Reg);
907}
908
911 if (!CurFrame)
912 return;
913
914 MCSymbol *Label = emitCFILabel();
915
917 Label, encodeSEHRegNum(Context, Register));
918 CurFrame->Instructions.push_back(Inst);
919}
920
922 SMLoc Loc) {
924 if (!CurFrame)
925 return;
926 if (CurFrame->LastFrameInst >= 0)
927 return getContext().reportError(
928 Loc, "frame register and offset can be set at most once");
929 if (Offset & 0x0F)
930 return getContext().reportError(Loc, "offset is not a multiple of 16");
931 if (Offset > 240)
932 return getContext().reportError(
933 Loc, "frame offset must be less than or equal to 240");
934
935 MCSymbol *Label = emitCFILabel();
936
939 CurFrame->LastFrameInst = CurFrame->Instructions.size();
940 CurFrame->Instructions.push_back(Inst);
941}
942
945 if (!CurFrame)
946 return;
947 if (Size == 0)
948 return getContext().reportError(Loc,
949 "stack allocation size must be non-zero");
950 if (Size & 7)
951 return getContext().reportError(
952 Loc, "stack allocation size is not a multiple of 8");
953
954 MCSymbol *Label = emitCFILabel();
955
957 CurFrame->Instructions.push_back(Inst);
958}
959
961 SMLoc Loc) {
963 if (!CurFrame)
964 return;
965
966 if (Offset & 7)
967 return getContext().reportError(
968 Loc, "register save offset is not 8 byte aligned");
969
970 MCSymbol *Label = emitCFILabel();
971
973 Label, encodeSEHRegNum(Context, Register), Offset);
974 CurFrame->Instructions.push_back(Inst);
975}
976
978 SMLoc Loc) {
980 if (!CurFrame)
981 return;
982 if (Offset & 0x0F)
983 return getContext().reportError(Loc, "offset is not a multiple of 16");
984
985 MCSymbol *Label = emitCFILabel();
986
988 Label, encodeSEHRegNum(Context, Register), Offset);
989 CurFrame->Instructions.push_back(Inst);
990}
991
994 if (!CurFrame)
995 return;
996 if (!CurFrame->Instructions.empty())
997 return getContext().reportError(
998 Loc, "If present, PushMachFrame must be the first UOP");
999
1000 MCSymbol *Label = emitCFILabel();
1001
1003 CurFrame->Instructions.push_back(Inst);
1004}
1005
1008 if (!CurFrame)
1009 return;
1010
1011 MCSymbol *Label = emitCFILabel();
1012
1013 CurFrame->PrologEnd = Label;
1014}
1015
1017
1019
1021
1023
1024void MCStreamer::emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) {}
1025
1026/// EmitRawText - If this file is backed by an assembly streamer, this dumps
1027/// the specified string in the output .s file. This capability is
1028/// indicated by the hasRawTextSupport() predicate.
1030 // This is not llvm_unreachable for the sake of out of tree backend
1031 // developers who may not have assembly streamers and should serve as a
1032 // reminder to not accidentally call EmitRawText in the absence of such.
1033 report_fatal_error("EmitRawText called on an MCStreamer that doesn't support "
1034 "it (target backend is likely missing an AsmStreamer "
1035 "implementation)");
1036}
1037
1039 SmallString<128> Str;
1040 emitRawTextImpl(T.toStringRef(Str));
1041}
1042
1044
1046
1048 if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) ||
1049 (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
1050 getContext().reportError(EndLoc, "Unfinished frame!");
1051 return;
1052 }
1053
1055 if (TS)
1056 TS->finish();
1057
1058 finishImpl();
1059}
1060
1062 if (Context.getDwarfFormat() != dwarf::DWARF64)
1063 return;
1064 AddComment("DWARF64 Mark");
1066}
1067
1069 assert(Context.getDwarfFormat() == dwarf::DWARF64 ||
1072 AddComment(Comment);
1074}
1075
1077 const Twine &Comment) {
1079 AddComment(Comment);
1080 MCSymbol *Lo = Context.createTempSymbol(Prefix + "_start");
1081 MCSymbol *Hi = Context.createTempSymbol(Prefix + "_end");
1082
1085 // emit the begin symbol after we generate the length field.
1086 emitLabel(Lo);
1087 // Return the Hi symbol to the caller.
1088 return Hi;
1089}
1090
1092 // Set the value of the symbol, as we are at the start of the line table.
1093 emitLabel(StartSym);
1094}
1095
1098 Symbol->setVariableValue(Value);
1099
1101 if (TS)
1102 TS->emitAssignment(Symbol, Value);
1103}
1104
1106 uint64_t Address, const MCInst &Inst,
1107 const MCSubtargetInfo &STI,
1108 raw_ostream &OS) {
1109 InstPrinter.printInst(&Inst, Address, "", STI, OS);
1110}
1111
1113}
1114
1116 switch (Expr.getKind()) {
1117 case MCExpr::Target:
1118 cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
1119 break;
1120
1121 case MCExpr::Constant:
1122 break;
1123
1124 case MCExpr::Binary: {
1125 const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
1126 visitUsedExpr(*BE.getLHS());
1127 visitUsedExpr(*BE.getRHS());
1128 break;
1129 }
1130
1131 case MCExpr::SymbolRef:
1132 visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
1133 break;
1134
1135 case MCExpr::Unary:
1136 visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
1137 break;
1138 }
1139}
1140
1142 // Scan for values.
1143 for (unsigned i = Inst.getNumOperands(); i--;)
1144 if (Inst.getOperand(i).isExpr())
1145 visitUsedExpr(*Inst.getOperand(i).getExpr());
1146}
1147
1149 uint64_t Attr, uint64_t Discriminator,
1150 const MCPseudoProbeInlineStack &InlineStack,
1151 MCSymbol *FnSym) {
1152 auto &Context = getContext();
1153
1154 // Create a symbol at in the current section for use in the probe.
1155 MCSymbol *ProbeSym = Context.createTempSymbol();
1156
1157 // Set the value of the symbol to use for the MCPseudoProbe.
1158 emitLabel(ProbeSym);
1159
1160 // Create a (local) probe entry with the symbol.
1161 MCPseudoProbe Probe(ProbeSym, Guid, Index, Type, Attr, Discriminator);
1162
1163 // Add the probe entry to this section's entries.
1165 FnSym, Probe, InlineStack);
1166}
1167
1169 unsigned Size) {
1170 // Get the Hi-Lo expression.
1171 const MCExpr *Diff =
1173 MCSymbolRefExpr::create(Lo, Context), Context);
1174
1175 const MCAsmInfo *MAI = Context.getAsmInfo();
1176 if (!MAI->doesSetDirectiveSuppressReloc()) {
1177 emitValue(Diff, Size);
1178 return;
1179 }
1180
1181 // Otherwise, emit with .set (aka assignment).
1182 MCSymbol *SetLabel = Context.createTempSymbol("set");
1183 emitAssignment(SetLabel, Diff);
1184 emitSymbolValue(SetLabel, Size);
1185}
1186
1188 const MCSymbol *Lo) {
1189 // Get the Hi-Lo expression.
1190 const MCExpr *Diff =
1192 MCSymbolRefExpr::create(Lo, Context), Context);
1193
1194 emitULEB128Value(Diff);
1195}
1196
1199void MCStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
1201 llvm_unreachable("this directive only supported on COFF targets");
1202}
1204 llvm_unreachable("this directive only supported on COFF targets");
1205}
1208 StringRef CompilerVersion,
1209 StringRef TimeStamp, StringRef Description) {
1210}
1212 llvm_unreachable("this directive only supported on COFF targets");
1213}
1215 llvm_unreachable("this directive only supported on COFF targets");
1216}
1218 MCSymbol *CsectSym,
1219 Align Alignment) {
1220 llvm_unreachable("this directive only supported on XCOFF targets");
1221}
1222
1224 MCSymbolAttr Linkage,
1225 MCSymbolAttr Visibility) {
1226 llvm_unreachable("emitXCOFFSymbolLinkageWithVisibility is only supported on "
1227 "XCOFF targets");
1228}
1229
1231 StringRef Rename) {}
1232
1234 llvm_unreachable("emitXCOFFRefDirective is only supported on XCOFF targets");
1235}
1236
1238 const MCSymbol *Trap,
1239 unsigned Lang, unsigned Reason,
1240 unsigned FunctionSize,
1241 bool hasDebug) {
1242 report_fatal_error("emitXCOFFExceptDirective is only supported on "
1243 "XCOFF targets");
1244}
1245
1247 llvm_unreachable("emitXCOFFCInfoSym is only supported on"
1248 "XCOFF targets");
1249}
1250
1253 StringRef Name, bool KeepOriginalSym) {}
1255 Align ByteAlignment) {}
1257 uint64_t Size, Align ByteAlignment) {}
1259 CurFrag = &Section->getDummyFragment();
1260}
1264void MCStreamer::emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) {
1266}
1269void MCStreamer::emitFill(const MCExpr &NumBytes, uint64_t Value, SMLoc Loc) {}
1270void MCStreamer::emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
1271 SMLoc Loc) {}
1273 unsigned ValueSize,
1274 unsigned MaxBytesToEmit) {}
1276 unsigned MaxBytesToEmit) {}
1278 SMLoc Loc) {}
1280void MCStreamer::emitBundleLock(bool AlignToEnd) {}
1283
1285 if (SectionStack.size() <= 1)
1286 return false;
1287 auto I = SectionStack.end();
1288 --I;
1289 MCSectionSubPair OldSec = I->first;
1290 --I;
1291 MCSectionSubPair NewSec = I->first;
1292
1293 if (NewSec.first && OldSec != NewSec)
1294 changeSection(NewSec.first, NewSec.second);
1295 SectionStack.pop_back();
1296 return true;
1297}
1298
1300 assert(Section && "Cannot switch to a null section!");
1301 MCSectionSubPair curSection = SectionStack.back().first;
1302 SectionStack.back().second = curSection;
1303 if (MCSectionSubPair(Section, Subsection) != curSection) {
1304 changeSection(Section, Subsection);
1305 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
1306 assert(!Section->hasEnded() && "Section already ended");
1307 MCSymbol *Sym = Section->getBeginSymbol();
1308 if (Sym && !Sym->isInSection())
1309 emitLabel(Sym);
1310 }
1311}
1312
1313bool MCStreamer::switchSection(MCSection *Section, const MCExpr *SubsecExpr) {
1314 int64_t Subsec = 0;
1315 if (SubsecExpr) {
1316 if (!SubsecExpr->evaluateAsAbsolute(Subsec, getAssemblerPtr())) {
1317 getContext().reportError(SubsecExpr->getLoc(),
1318 "cannot evaluate subsection number");
1319 return true;
1320 }
1321 if (!isUInt<31>(Subsec)) {
1322 getContext().reportError(SubsecExpr->getLoc(),
1323 "subsection number " + Twine(Subsec) +
1324 " is not within [0,2147483647]");
1325 return true;
1326 }
1327 }
1328 switchSection(Section, Subsec);
1329 return false;
1330}
1331
1333 SectionStack.back().second = SectionStack.back().first;
1334 SectionStack.back().first = MCSectionSubPair(Section, 0);
1335 CurFrag = &Section->getDummyFragment();
1336}
1337
1339 // TODO: keep track of the last subsection so that this symbol appears in the
1340 // correct place.
1341 MCSymbol *Sym = Section->getEndSymbol(Context);
1342 if (Sym->isInSection())
1343 return Sym;
1344
1345 switchSection(Section);
1346 emitLabel(Sym);
1347 return Sym;
1348}
1349
1350static VersionTuple
1352 VersionTuple TargetVersion) {
1353 VersionTuple Min = Target.getMinimumSupportedOSVersion();
1354 return !Min.empty() && Min > TargetVersion ? Min : TargetVersion;
1355}
1356
1357static MCVersionMinType
1359 assert(Target.isOSDarwin() && "expected a darwin OS");
1360 switch (Target.getOS()) {
1361 case Triple::MacOSX:
1362 case Triple::Darwin:
1363 return MCVM_OSXVersionMin;
1364 case Triple::IOS:
1365 assert(!Target.isMacCatalystEnvironment() &&
1366 "mac Catalyst should use LC_BUILD_VERSION");
1367 return MCVM_IOSVersionMin;
1368 case Triple::TvOS:
1369 return MCVM_TvOSVersionMin;
1370 case Triple::WatchOS:
1372 default:
1373 break;
1374 }
1375 llvm_unreachable("unexpected OS type");
1376}
1377
1379 assert(Target.isOSDarwin() && "expected a darwin OS");
1380 switch (Target.getOS()) {
1381 case Triple::MacOSX:
1382 case Triple::Darwin:
1383 return VersionTuple(10, 14);
1384 case Triple::IOS:
1385 // Mac Catalyst always uses the build version load command.
1386 if (Target.isMacCatalystEnvironment())
1387 return VersionTuple();
1388 [[fallthrough]];
1389 case Triple::TvOS:
1390 return VersionTuple(12);
1391 case Triple::WatchOS:
1392 return VersionTuple(5);
1393 case Triple::DriverKit:
1394 // DriverKit always uses the build version load command.
1395 return VersionTuple();
1396 case Triple::XROS:
1397 // XROS always uses the build version load command.
1398 return VersionTuple();
1399 default:
1400 break;
1401 }
1402 llvm_unreachable("unexpected OS type");
1403}
1404
1407 assert(Target.isOSDarwin() && "expected a darwin OS");
1408 switch (Target.getOS()) {
1409 case Triple::MacOSX:
1410 case Triple::Darwin:
1411 return MachO::PLATFORM_MACOS;
1412 case Triple::IOS:
1413 if (Target.isMacCatalystEnvironment())
1414 return MachO::PLATFORM_MACCATALYST;
1415 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_IOSSIMULATOR
1416 : MachO::PLATFORM_IOS;
1417 case Triple::TvOS:
1418 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_TVOSSIMULATOR
1419 : MachO::PLATFORM_TVOS;
1420 case Triple::WatchOS:
1421 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_WATCHOSSIMULATOR
1422 : MachO::PLATFORM_WATCHOS;
1423 case Triple::DriverKit:
1424 return MachO::PLATFORM_DRIVERKIT;
1425 case Triple::XROS:
1426 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_XROS_SIMULATOR
1427 : MachO::PLATFORM_XROS;
1428 default:
1429 break;
1430 }
1431 llvm_unreachable("unexpected OS type");
1432}
1433
1435 const Triple &Target, const VersionTuple &SDKVersion,
1436 const Triple *DarwinTargetVariantTriple,
1437 const VersionTuple &DarwinTargetVariantSDKVersion) {
1438 if (!Target.isOSBinFormatMachO() || !Target.isOSDarwin())
1439 return;
1440 // Do we even know the version?
1441 if (Target.getOSMajorVersion() == 0)
1442 return;
1443
1445 switch (Target.getOS()) {
1446 case Triple::MacOSX:
1447 case Triple::Darwin:
1448 Target.getMacOSXVersion(Version);
1449 break;
1450 case Triple::IOS:
1451 case Triple::TvOS:
1452 Version = Target.getiOSVersion();
1453 break;
1454 case Triple::WatchOS:
1455 Version = Target.getWatchOSVersion();
1456 break;
1457 case Triple::DriverKit:
1458 Version = Target.getDriverKitVersion();
1459 break;
1460 case Triple::XROS:
1461 Version = Target.getOSVersion();
1462 break;
1463 default:
1464 llvm_unreachable("unexpected OS type");
1465 }
1466 assert(Version.getMajor() != 0 && "A non-zero major version is expected");
1467 auto LinkedTargetVersion =
1469 auto BuildVersionOSVersion = getMachoBuildVersionSupportedOS(Target);
1470 bool ShouldEmitBuildVersion = false;
1471 if (BuildVersionOSVersion.empty() ||
1472 LinkedTargetVersion >= BuildVersionOSVersion) {
1473 if (Target.isMacCatalystEnvironment() && DarwinTargetVariantTriple &&
1474 DarwinTargetVariantTriple->isMacOSX()) {
1475 emitVersionForTarget(*DarwinTargetVariantTriple,
1476 DarwinTargetVariantSDKVersion,
1477 /*DarwinTargetVariantTriple=*/nullptr,
1478 /*DarwinTargetVariantSDKVersion=*/VersionTuple());
1481 LinkedTargetVersion.getMajor(),
1482 LinkedTargetVersion.getMinor().value_or(0),
1483 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1484 return;
1485 }
1487 LinkedTargetVersion.getMajor(),
1488 LinkedTargetVersion.getMinor().value_or(0),
1489 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1490 ShouldEmitBuildVersion = true;
1491 }
1492
1493 if (const Triple *TVT = DarwinTargetVariantTriple) {
1494 if (Target.isMacOSX() && TVT->isMacCatalystEnvironment()) {
1495 auto TVLinkedTargetVersion =
1496 targetVersionOrMinimumSupportedOSVersion(*TVT, TVT->getiOSVersion());
1499 TVLinkedTargetVersion.getMajor(),
1500 TVLinkedTargetVersion.getMinor().value_or(0),
1501 TVLinkedTargetVersion.getSubminor().value_or(0),
1502 DarwinTargetVariantSDKVersion);
1503 }
1504 }
1505
1506 if (ShouldEmitBuildVersion)
1507 return;
1508
1510 LinkedTargetVersion.getMajor(),
1511 LinkedTargetVersion.getMinor().value_or(0),
1512 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1513}
BlockVerifier::State From
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
Definition: Debug.cpp:108
std::string Name
uint64_t Size
bool End
Definition: ELF_riscv.cpp:480
Symbol * Sym
Definition: ELF_riscv.cpp:479
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:365
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:857
static MachO::PlatformType getMachoBuildVersionPlatformType(const Triple &Target)
static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg)
Definition: MCStreamer.cpp:905
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
Profile::FuncID FuncId
Definition: Profile.cpp:321
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file defines the SmallString class.
Class for arbitrary precision integers.
Definition: APInt.h:78
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:44
MCCVFunctionInfo * getCVFunctionInfo(unsigned FuncId)
Retreive the function info if this is a valid function id, or nullptr.
Definition: MCCodeView.cpp:76
bool recordFunctionId(unsigned FuncId)
Records the function id of a normal function.
Definition: MCCodeView.cpp:84
bool recordInlinedCallSiteId(unsigned FuncId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol)
Records the function id of an inlined call site.
Definition: MCCodeView.cpp:97
Tagged union holding either a T or a Error.
Definition: Error.h:481
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:42
virtual uint64_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI, const MCContext *Ctxt) const
Generate the compact unwind encoding for the CFI instructions.
Definition: MCAsmBackend.h:229
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:628
bool hasCOFFAssociativeComdats() const
Definition: MCAsmInfo.h:594
bool isLittleEndian() const
True if the target is little endian.
Definition: MCAsmInfo.h:527
const std::vector< MCCFIInstruction > & getInitialFrameState() const
Definition: MCAsmInfo.h:793
const char * getData8bitsDirective() const
Definition: MCAsmInfo.h:536
bool doesSetDirectiveSuppressReloc() const
Definition: MCAsmInfo.h:691
bool usesWindowsCFI() const
Definition: MCAsmInfo.h:759
Binary assembler expressions.
Definition: MCExpr.h:493
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition: MCExpr.h:640
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition: MCExpr.h:643
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:622
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_def_cfa_register modifies a rule for computing CFA.
Definition: MCDwarf.h:582
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_undefined From now on the previous value of Register can't be restored anymore.
Definition: MCDwarf.h:663
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int64_t Size, SMLoc Loc={})
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
Definition: MCDwarf.h:693
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
Definition: MCDwarf.h:656
static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register, int64_t Offset, unsigned AddressSpace, SMLoc Loc)
.cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to be the result of evaluating the DW...
Definition: MCDwarf.h:607
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2, SMLoc Loc={})
.cfi_register Previous value of Register1 is saved in register Register2.
Definition: MCDwarf.h:632
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition: MCDwarf.h:575
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition: MCDwarf.h:617
static MCCFIInstruction createValOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_val_offset Previous value of Register is offset Offset from the current CFA register.
Definition: MCDwarf.h:705
static MCCFIInstruction createNegateRAStateWithPC(MCSymbol *L, SMLoc Loc={})
.cfi_negate_ra_state_with_pc AArch64 negate RA state with PC.
Definition: MCDwarf.h:648
static MCCFIInstruction createNegateRAState(MCSymbol *L, SMLoc Loc={})
.cfi_negate_ra_state AArch64 negate RA state.
Definition: MCDwarf.h:643
static MCCFIInstruction createRememberState(MCSymbol *L, SMLoc Loc={})
.cfi_remember_state Save all current rules for all registers.
Definition: MCDwarf.h:676
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa_offset modifies a rule for computing CFA.
Definition: MCDwarf.h:590
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, SMLoc Loc={}, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Definition: MCDwarf.h:687
static MCCFIInstruction createWindowSave(MCSymbol *L, SMLoc Loc={})
.cfi_window_save SPARC register window is saved.
Definition: MCDwarf.h:638
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int64_t Adjustment, SMLoc Loc={})
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
Definition: MCDwarf.h:598
static MCCFIInstruction createRestoreState(MCSymbol *L, SMLoc Loc={})
.cfi_restore_state Restore the previously saved state.
Definition: MCDwarf.h:681
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_same_value Current value of Register is the same as in the previous frame.
Definition: MCDwarf.h:670
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register.
Definition: MCDwarf.h:625
static MCCFIInstruction createLabel(MCSymbol *L, MCSymbol *CfiLabel, SMLoc Loc)
Definition: MCDwarf.h:698
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:222
Context object for machine code objects.
Definition: MCContext.h:83
MCPseudoProbeTable & getMCPseudoProbeTable()
Definition: MCContext.h:844
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:416
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Definition: MCContext.cpp:345
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:989
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:702
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID)
Definition: MCContext.cpp:692
CodeViewContext & getCVContext()
Definition: MCContext.cpp:1017
const MCRegisterInfo * getRegisterInfo() const
Definition: MCContext.h:414
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:743
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:412
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1072
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:212
const MCDwarfLoc & getCurrentDwarfLoc()
Definition: MCContext.h:758
dwarf::DwarfFormat getDwarfFormat() const
Definition: MCContext.h:799
MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=GenericSectionID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym.
Definition: MCContext.cpp:733
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:726
const Triple & getTargetTriple() const
Definition: MCContext.h:400
Instances of this class represent the line information for the dwarf line table entries.
Definition: MCDwarf.h:188
void setLabel(MCSymbol *Label)
Definition: MCDwarf.h:421
void endCurrentSeqAndEmitLineStreamLabel(MCStreamer *MCOS, SMLoc DefLoc, StringRef Name)
Definition: MCDwarf.cpp:267
const MCLineSection & getMCLineSections() const
Definition: MCDwarf.h:441
MCSymbol * getLabel() const
Definition: MCDwarf.h:417
Instances of this class represent the information from a dwarf .loc directive.
Definition: MCDwarf.h:105
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
@ Unary
Unary expressions.
Definition: MCExpr.h:40
@ Constant
Constant expressions.
Definition: MCExpr.h:38
@ SymbolRef
References to labels and assigned expressions.
Definition: MCExpr.h:39
@ Target
Target specific expression.
Definition: MCExpr.h:41
@ Binary
Binary expressions.
Definition: MCExpr.h:37
ExprKind getKind() const
Definition: MCExpr.h:78
SMLoc getLoc() const
Definition: MCExpr.h:79
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:46
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:185
unsigned getNumOperands() const
Definition: MCInst.h:209
const MCOperand & getOperand(unsigned i) const
Definition: MCInst.h:207
void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec)
Definition: MCDwarf.h:236
MCSection * getTextSection() const
const MCExpr * getExpr() const
Definition: MCInst.h:115
bool isExpr() const
Definition: MCInst.h:66
void addPseudoProbe(MCSymbol *FuncSym, const MCPseudoProbe &Probe, const MCPseudoProbeInlineStack &InlineStack)
MCPseudoProbeSections & getProbeSections()
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:33
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:36
Streaming machine code generation interface.
Definition: MCStreamer.h:213
virtual void emitCFIGnuArgsSize(int64_t Size, SMLoc Loc={})
Definition: MCStreamer.cpp:648
virtual void emitNops(int64_t NumBytes, int64_t ControlledNopLength, SMLoc Loc, const MCSubtargetInfo &STI)
Definition: MCStreamer.cpp:225
MCSymbol * emitLineTableLabel()
Definition: MCStreamer.cpp:486
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void switchSectionNoPrint(MCSection *Section)
Similar to switchSection, but does not print the section directive.
virtual void emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc={})
Definition: MCStreamer.cpp:506
virtual void visitUsedSymbol(const MCSymbol &Sym)
void emitCFIStartProc(bool IsSimple, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:444
virtual bool emitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
Definition: MCStreamer.cpp:307
virtual void finishImpl()
Streamer specific finalization.
virtual void emitDTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
Definition: MCStreamer.cpp:194
virtual void emitCFIBKeyFrame()
Definition: MCStreamer.cpp:248
void generateCompactUnwindEncodings(MCAsmBackend *MAB)
Definition: MCStreamer.cpp:125
virtual void beginCOFFSymbolDef(const MCSymbol *Symbol)
Start emitting COFF symbol definition.
virtual void emitSyntaxDirective()
Definition: MCStreamer.cpp:903
virtual void emitWinCFIPushReg(MCRegister Register, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:909
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:416
bool popSection()
Restore the current and previous section from the section stack.
virtual MCSymbol * emitCFILabel()
When emitting an object file, create and emit a real label.
Definition: MCStreamer.cpp:500
virtual void emitWindowsUnwindTables()
virtual raw_ostream & getCommentOS()
Return a raw_ostream that comments can be written to.
Definition: MCStreamer.cpp:110
virtual void emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:828
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:891
virtual void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
This implements the '.loc_label Name' directive.
Definition: MCStreamer.cpp:270
bool hasUnfinishedDwarfFrameInfo()
Definition: MCStreamer.cpp:286
virtual ~MCStreamer()
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
virtual void emitCFINegateRAStateWithPC(SMLoc Loc={})
Definition: MCStreamer.cpp:705
virtual void emitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
Definition: MCStreamer.cpp:210
virtual void emitCFISameValue(int64_t Register, SMLoc Loc={})
Definition: MCStreamer.cpp:618
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:300
virtual void emitCFIReturnColumn(int64_t Register)
Definition: MCStreamer.cpp:715
virtual void emitCOFFSymbolType(int Type)
Emit the type of the symbol.
virtual void emitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:580
virtual void emitDwarfUnitLength(uint64_t Length, const Twine &Comment)
Emit a unit length field.
virtual void emitCFIWindowSave(SMLoc Loc={})
Definition: MCStreamer.cpp:686
virtual void emitCOFFSymbolIndex(MCSymbol const *Symbol)
Emits the symbol table index of a Symbol into the current section.
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.
virtual void endCOFFSymbolDef()
Marks the end of the symbol definition.
virtual void emitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:992
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:845
virtual MCAssembler * getAssemblerPtr()
Definition: MCStreamer.h:304
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.
virtual void emitCFIUndefined(int64_t Register, SMLoc Loc={})
Definition: MCStreamer.cpp:665
void setTargetStreamer(MCTargetStreamer *TS)
Definition: MCStreamer.h:287
virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:977
virtual void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
Definition: MCStreamer.cpp:469
virtual void emitCFINegateRAState(SMLoc Loc={})
Definition: MCStreamer.cpp:695
virtual void emitGPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
Definition: MCStreamer.cpp:214
virtual void emitCFILsda(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:589
MCContext & getContext() const
Definition: MCStreamer.h:300
SMLoc getStartTokLoc() const
Definition: MCStreamer.h:292
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:122
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
Definition: MCStreamer.h:366
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:206
virtual void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)
Emits a COFF section relative relocation.
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
Definition: MCStreamer.cpp:897
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:120
virtual void emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:754
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:179
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:183
bool checkCVLocSection(unsigned FuncId, unsigned FileNo, SMLoc Loc)
Returns true if the .cv_loc directive is in the right section.
Definition: MCStreamer.cpp:330
virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)
Emit the debug line start label.
virtual void emitCFIEscape(StringRef Values, SMLoc Loc={})
Definition: MCStreamer.cpp:638
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:420
virtual void emitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
virtual void emitCFIRememberState(SMLoc Loc)
Definition: MCStreamer.cpp:597
virtual void reset()
State management.
Definition: MCStreamer.cpp:101
virtual void emitCFILabelDirective(SMLoc Loc, StringRef Name)
Definition: MCStreamer.cpp:722
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
Definition: MCStreamer.cpp:352
virtual void emitTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (64-bit TP relative) value.
Definition: MCStreamer.cpp:202
virtual void emitCFISections(bool EH, bool Debug)
Definition: MCStreamer.cpp:442
MCTargetStreamer * getTargetStreamer()
Definition: MCStreamer.h:309
MCStreamer(MCContext &Ctx)
Definition: MCStreamer.cpp:93
MCFragment * CurFrag
Definition: MCStreamer.h:255
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:483
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:133
unsigned getNumFrameInfos()
Definition: MCStreamer.cpp:115
virtual void emitWinCFISaveReg(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:960
virtual void emitWinCFIEndChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:814
virtual void emitWinCFIEndProlog(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndProc(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:772
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:480
virtual void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
Set the DescValue for the Symbol.
virtual void emitCFIDefCfaRegister(int64_t Register, SMLoc Loc={})
Definition: MCStreamer.cpp:537
virtual void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment)
Emit a local common (.lcomm) symbol.
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
Definition: MCStreamer.cpp:276
virtual void emitCFIRegister(int64_t Register1, int64_t Register2, SMLoc Loc={})
Definition: MCStreamer.cpp:675
virtual void emitCOFFSafeSEH(MCSymbol const *Symbol)
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:790
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 emitPseudoProbe(uint64_t Guid, uint64_t Index, uint64_t Type, uint64_t Attr, uint64_t Discriminator, const MCPseudoProbeInlineStack &InlineStack, MCSymbol *FnSym)
Emit the a pseudo probe into the current section.
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
Definition: MCStreamer.cpp:853
virtual void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc={})
Definition: MCStreamer.cpp:527
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:161
virtual void emitULEB128Value(const MCExpr *Value)
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
Definition: MCStreamer.cpp:116
virtual void emitCFIRelOffset(int64_t Register, int64_t Offset, SMLoc Loc)
Definition: MCStreamer.cpp:570
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, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
virtual void emitExplicitComments()
Emit added explicit comments.
Definition: MCStreamer.cpp:123
WinEH::FrameInfo * EnsureValidWinFrameInfo(SMLoc Loc)
Retrieve the current frame info if one is available and it is not yet closed.
Definition: MCStreamer.cpp:739
virtual void emitThumbFunc(MCSymbol *Func)
Note in the output that the specified Func is a Thumb mode function (ARM target only).
virtual void emitCFIRestoreState(SMLoc Loc)
Definition: MCStreamer.cpp:607
virtual void emitXCOFFRefDirective(const MCSymbol *Symbol)
Emit a XCOFF .ref directive which creates R_REF type entry in the relocation table for one or more sy...
virtual void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol)
Definition: MCStreamer.cpp:412
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:374
void emitInt32(uint64_t Value)
Definition: MCStreamer.h:721
virtual void emitCFIOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
Definition: MCStreamer.cpp:560
virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:921
void maybeEmitDwarf64Mark()
Emit a special value of 0xffffffff if producing 64-bit debugging info.
virtual void emitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
Definition: MCStreamer.cpp:198
virtual void emitCFIDefCfaOffset(int64_t Offset, SMLoc Loc={})
Definition: MCStreamer.cpp:517
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:325
virtual void emitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:943
virtual void emitFileDirective(StringRef Filename)
Switch to a new logical file.
virtual void emitSLEB128Value(const MCExpr *Value)
virtual void emitCFIValOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
Definition: MCStreamer.cpp:729
virtual void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name, bool KeepOriginalSym)
Emit an ELF .symver directive.
virtual void emitXCOFFCInfoSym(StringRef Name, StringRef Metadata)
Emit a C_INFO symbol with XCOFF embedded metadata to the .info section.
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:400
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 ....
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:171
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:311
virtual void emitCFISignalFrame()
Definition: MCStreamer.cpp:658
virtual void emitVersionMin(MCVersionMinType Type, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Specify the Mach-O minimum deployment target version.
Definition: MCStreamer.h:473
virtual void emitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
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:439
virtual void emitWinCFIStartChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:801
virtual void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment=Align(1))
Emit a thread local bss (.tbss) symbol.
virtual void emitCFIRestore(int64_t Register, SMLoc Loc={})
Definition: MCStreamer.cpp:628
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:356
void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
Definition: MCStreamer.cpp:220
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 ...
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:479
virtual void changeSection(MCSection *, uint32_t)
This is called by popSection and switchSection, if the current section changes.
virtual void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset, int64_t AddressSpace, SMLoc Loc={})
Definition: MCStreamer.cpp:548
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:398
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
Target specific streamer interface.
Definition: MCStreamer.h:94
virtual void emitDwarfFileDirective(StringRef Directive)
Definition: MCStreamer.cpp:67
virtual void emitValue(const MCExpr *Value)
Definition: MCStreamer.cpp:71
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:91
virtual void emitRawBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition: MCStreamer.cpp:79
MCStreamer & Streamer
Definition: MCStreamer.h:96
MCTargetStreamer(MCStreamer &S)
Definition: MCStreamer.cpp:46
virtual void changeSection(const MCSection *CurSection, MCSection *Section, uint32_t SubSection, raw_ostream &OS)
Update streamer for a new active section.
Definition: MCStreamer.cpp:59
virtual void emitLabel(MCSymbol *Symbol)
Definition: MCStreamer.cpp:53
virtual void emitConstantPools()
Definition: MCStreamer.cpp:57
Root of the metadata hierarchy.
Definition: Metadata.h:62
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:254
size_t size() const
Definition: SmallVector.h:78
void resize(size_type N)
Definition: SmallVector.h:638
void push_back(const T &Elt)
Definition: SmallVector.h:413
pointer data()
Return a pointer to the vector's buffer, even if empty().
Definition: SmallVector.h:286
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
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:532
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:5061
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:29
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
Definition: VersionTuple.h:66
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:691
StringRef str() const
Return a StringRef for the vector contents.
Definition: raw_ostream.h:720
This class represents a function that is read from a sample profile.
Definition: FunctionId.h:36
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_SCN_LNK_COMDAT
Definition: COFF.h:308
@ IMAGE_COMDAT_SELECT_ANY
Definition: COFF.h:455
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
PlatformType
Definition: MachO.h:500
StorageClass
Definition: XCOFF.h:170
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
Definition: CodeView.h:48
@ 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:1071
@ 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:44
static const bool IsLittleEndianHost
Definition: SwapByteOrder.h:29
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
@ Length
Definition: DWP.cpp:480
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:3024
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:255
std::pair< MCSection *, uint32_t > MCSectionSubPair
Definition: MCStreamer.h:67
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
MCVersionMinType
Definition: MCDirectives.h:69
@ MCVM_WatchOSVersionMin
.watchos_version_min
Definition: MCDirectives.h:73
@ MCVM_OSXVersionMin
.macosx_version_min
Definition: MCDirectives.h:71
@ MCVM_TvOSVersionMin
.tvos_version_min
Definition: MCDirectives.h:72
@ MCVM_IOSVersionMin
.ios_version_min
Definition: MCDirectives.h:70
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:167
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
MCAssemblerFlag
Definition: MCDirectives.h:53
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:260
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:764
unsigned PersonalityEncoding
Definition: MCDwarf.h:768
std::vector< MCCFIInstruction > Instructions
Definition: MCDwarf.h:766
unsigned LsdaEncoding
Definition: MCDwarf.h:769
const MCSymbol * Lsda
Definition: MCDwarf.h:765
unsigned CurrentCfaRegister
Definition: MCDwarf.h:767
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