LLVM 21.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 switchSectionNoPrint(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();
812}
813
816 if (!CurFrame)
817 return;
818 if (!CurFrame->ChainedParent)
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
1018 if (!CurFrame)
1019 return;
1020
1021 if (!CurFrame->PrologEnd)
1022 return getContext().reportError(
1023 Loc, "starting epilogue (.seh_startepilogue) before prologue has ended "
1024 "(.seh_endprologue) in " +
1025 CurFrame->Function->getName());
1026
1027 InEpilogCFI = true;
1029}
1030
1033 if (!CurFrame)
1034 return;
1035
1036 if (!InEpilogCFI)
1037 return getContext().reportError(Loc, "Stray .seh_endepilogue in " +
1038 CurFrame->Function->getName());
1039
1040 InEpilogCFI = false;
1041 MCSymbol *Label = emitCFILabel();
1042 CurFrame->EpilogMap[CurrentEpilog].End = Label;
1043 CurrentEpilog = nullptr;
1044}
1045
1047
1049
1051
1053
1054void MCStreamer::emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) {}
1055
1057
1059
1060/// EmitRawText - If this file is backed by an assembly streamer, this dumps
1061/// the specified string in the output .s file. This capability is
1062/// indicated by the hasRawTextSupport() predicate.
1064 // This is not llvm_unreachable for the sake of out of tree backend
1065 // developers who may not have assembly streamers and should serve as a
1066 // reminder to not accidentally call EmitRawText in the absence of such.
1067 report_fatal_error("EmitRawText called on an MCStreamer that doesn't support "
1068 "it (target backend is likely missing an AsmStreamer "
1069 "implementation)");
1070}
1071
1073 SmallString<128> Str;
1074 emitRawTextImpl(T.toStringRef(Str));
1075}
1076
1078
1080
1082 if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) ||
1083 (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
1084 getContext().reportError(EndLoc, "Unfinished frame!");
1085 return;
1086 }
1087
1089 if (TS)
1090 TS->finish();
1091
1092 finishImpl();
1093}
1094
1096 if (Context.getDwarfFormat() != dwarf::DWARF64)
1097 return;
1098 AddComment("DWARF64 Mark");
1100}
1101
1103 assert(Context.getDwarfFormat() == dwarf::DWARF64 ||
1106 AddComment(Comment);
1108}
1109
1111 const Twine &Comment) {
1113 AddComment(Comment);
1114 MCSymbol *Lo = Context.createTempSymbol(Prefix + "_start");
1115 MCSymbol *Hi = Context.createTempSymbol(Prefix + "_end");
1116
1119 // emit the begin symbol after we generate the length field.
1120 emitLabel(Lo);
1121 // Return the Hi symbol to the caller.
1122 return Hi;
1123}
1124
1126 // Set the value of the symbol, as we are at the start of the line table.
1127 emitLabel(StartSym);
1128}
1129
1132 Symbol->setVariableValue(Value);
1133
1135 if (TS)
1136 TS->emitAssignment(Symbol, Value);
1137}
1138
1140 uint64_t Address, const MCInst &Inst,
1141 const MCSubtargetInfo &STI,
1142 raw_ostream &OS) {
1143 InstPrinter.printInst(&Inst, Address, "", STI, OS);
1144}
1145
1147}
1148
1150 switch (Expr.getKind()) {
1151 case MCExpr::Target:
1152 cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
1153 break;
1154
1155 case MCExpr::Constant:
1156 break;
1157
1158 case MCExpr::Binary: {
1159 const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
1160 visitUsedExpr(*BE.getLHS());
1161 visitUsedExpr(*BE.getRHS());
1162 break;
1163 }
1164
1165 case MCExpr::SymbolRef:
1166 visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
1167 break;
1168
1169 case MCExpr::Unary:
1170 visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
1171 break;
1172 }
1173}
1174
1176 // Scan for values.
1177 for (unsigned i = Inst.getNumOperands(); i--;)
1178 if (Inst.getOperand(i).isExpr())
1179 visitUsedExpr(*Inst.getOperand(i).getExpr());
1180}
1181
1183 uint64_t Attr, uint64_t Discriminator,
1184 const MCPseudoProbeInlineStack &InlineStack,
1185 MCSymbol *FnSym) {
1186 auto &Context = getContext();
1187
1188 // Create a symbol at in the current section for use in the probe.
1189 MCSymbol *ProbeSym = Context.createTempSymbol();
1190
1191 // Set the value of the symbol to use for the MCPseudoProbe.
1192 emitLabel(ProbeSym);
1193
1194 // Create a (local) probe entry with the symbol.
1195 MCPseudoProbe Probe(ProbeSym, Guid, Index, Type, Attr, Discriminator);
1196
1197 // Add the probe entry to this section's entries.
1199 FnSym, Probe, InlineStack);
1200}
1201
1203 unsigned Size) {
1204 // Get the Hi-Lo expression.
1205 const MCExpr *Diff =
1207 MCSymbolRefExpr::create(Lo, Context), Context);
1208
1209 const MCAsmInfo *MAI = Context.getAsmInfo();
1210 if (!MAI->doesSetDirectiveSuppressReloc()) {
1211 emitValue(Diff, Size);
1212 return;
1213 }
1214
1215 // Otherwise, emit with .set (aka assignment).
1216 MCSymbol *SetLabel = Context.createTempSymbol("set");
1217 emitAssignment(SetLabel, Diff);
1218 emitSymbolValue(SetLabel, Size);
1219}
1220
1222 const MCSymbol *Lo) {
1223 // Get the Hi-Lo expression.
1224 const MCExpr *Diff =
1226 MCSymbolRefExpr::create(Lo, Context), Context);
1227
1228 emitULEB128Value(Diff);
1229}
1230
1233void MCStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
1235 llvm_unreachable("this directive only supported on COFF targets");
1236}
1238 llvm_unreachable("this directive only supported on COFF targets");
1239}
1242 StringRef CompilerVersion,
1243 StringRef TimeStamp, StringRef Description) {
1244}
1246 llvm_unreachable("this directive only supported on COFF targets");
1247}
1249 llvm_unreachable("this directive only supported on COFF targets");
1250}
1252 MCSymbol *CsectSym,
1253 Align Alignment) {
1254 llvm_unreachable("this directive only supported on XCOFF targets");
1255}
1256
1258 MCSymbolAttr Linkage,
1259 MCSymbolAttr Visibility) {
1260 llvm_unreachable("emitXCOFFSymbolLinkageWithVisibility is only supported on "
1261 "XCOFF targets");
1262}
1263
1265 StringRef Rename) {}
1266
1268 llvm_unreachable("emitXCOFFRefDirective is only supported on XCOFF targets");
1269}
1270
1272 const MCSymbol *Trap,
1273 unsigned Lang, unsigned Reason,
1274 unsigned FunctionSize,
1275 bool hasDebug) {
1276 report_fatal_error("emitXCOFFExceptDirective is only supported on "
1277 "XCOFF targets");
1278}
1279
1281 llvm_unreachable("emitXCOFFCInfoSym is only supported on"
1282 "XCOFF targets");
1283}
1284
1287 StringRef Name, bool KeepOriginalSym) {}
1289 Align ByteAlignment) {}
1291 uint64_t Size, Align ByteAlignment) {}
1293 CurFrag = &Section->getDummyFragment();
1294}
1298void MCStreamer::emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) {
1300}
1303void MCStreamer::emitFill(const MCExpr &NumBytes, uint64_t Value, SMLoc Loc) {}
1304void MCStreamer::emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
1305 SMLoc Loc) {}
1307 unsigned ValueSize,
1308 unsigned MaxBytesToEmit) {}
1310 unsigned MaxBytesToEmit) {}
1312 SMLoc Loc) {}
1314void MCStreamer::emitBundleLock(bool AlignToEnd) {}
1317
1319 if (SectionStack.size() <= 1)
1320 return false;
1321 auto I = SectionStack.end();
1322 --I;
1323 MCSectionSubPair OldSec = I->first;
1324 --I;
1325 MCSectionSubPair NewSec = I->first;
1326
1327 if (NewSec.first && OldSec != NewSec)
1328 changeSection(NewSec.first, NewSec.second);
1329 SectionStack.pop_back();
1330 return true;
1331}
1332
1334 assert(Section && "Cannot switch to a null section!");
1335 MCSectionSubPair curSection = SectionStack.back().first;
1336 SectionStack.back().second = curSection;
1337 if (MCSectionSubPair(Section, Subsection) != curSection) {
1338 changeSection(Section, Subsection);
1339 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
1340 assert(!Section->hasEnded() && "Section already ended");
1341 MCSymbol *Sym = Section->getBeginSymbol();
1342 if (Sym && !Sym->isInSection())
1343 emitLabel(Sym);
1344 }
1345}
1346
1347bool MCStreamer::switchSection(MCSection *Section, const MCExpr *SubsecExpr) {
1348 int64_t Subsec = 0;
1349 if (SubsecExpr) {
1350 if (!SubsecExpr->evaluateAsAbsolute(Subsec, getAssemblerPtr())) {
1351 getContext().reportError(SubsecExpr->getLoc(),
1352 "cannot evaluate subsection number");
1353 return true;
1354 }
1355 if (!isUInt<31>(Subsec)) {
1356 getContext().reportError(SubsecExpr->getLoc(),
1357 "subsection number " + Twine(Subsec) +
1358 " is not within [0,2147483647]");
1359 return true;
1360 }
1361 }
1362 switchSection(Section, Subsec);
1363 return false;
1364}
1365
1367 SectionStack.back().second = SectionStack.back().first;
1368 SectionStack.back().first = MCSectionSubPair(Section, 0);
1369 changeSection(Section, 0);
1370 MCSymbol *Sym = Section->getBeginSymbol();
1371 if (Sym && !Sym->isInSection())
1372 emitLabel(Sym);
1373}
1374
1376 // TODO: keep track of the last subsection so that this symbol appears in the
1377 // correct place.
1378 MCSymbol *Sym = Section->getEndSymbol(Context);
1379 if (Sym->isInSection())
1380 return Sym;
1381
1382 switchSection(Section);
1383 emitLabel(Sym);
1384 return Sym;
1385}
1386
1387static VersionTuple
1389 VersionTuple TargetVersion) {
1390 VersionTuple Min = Target.getMinimumSupportedOSVersion();
1391 return !Min.empty() && Min > TargetVersion ? Min : TargetVersion;
1392}
1393
1394static MCVersionMinType
1396 assert(Target.isOSDarwin() && "expected a darwin OS");
1397 switch (Target.getOS()) {
1398 case Triple::MacOSX:
1399 case Triple::Darwin:
1400 return MCVM_OSXVersionMin;
1401 case Triple::IOS:
1402 assert(!Target.isMacCatalystEnvironment() &&
1403 "mac Catalyst should use LC_BUILD_VERSION");
1404 return MCVM_IOSVersionMin;
1405 case Triple::TvOS:
1406 return MCVM_TvOSVersionMin;
1407 case Triple::WatchOS:
1409 default:
1410 break;
1411 }
1412 llvm_unreachable("unexpected OS type");
1413}
1414
1416 assert(Target.isOSDarwin() && "expected a darwin OS");
1417 switch (Target.getOS()) {
1418 case Triple::MacOSX:
1419 case Triple::Darwin:
1420 return VersionTuple(10, 14);
1421 case Triple::IOS:
1422 // Mac Catalyst always uses the build version load command.
1423 if (Target.isMacCatalystEnvironment())
1424 return VersionTuple();
1425 [[fallthrough]];
1426 case Triple::TvOS:
1427 return VersionTuple(12);
1428 case Triple::WatchOS:
1429 return VersionTuple(5);
1430 case Triple::DriverKit:
1431 // DriverKit always uses the build version load command.
1432 return VersionTuple();
1433 case Triple::XROS:
1434 // XROS always uses the build version load command.
1435 return VersionTuple();
1436 default:
1437 break;
1438 }
1439 llvm_unreachable("unexpected OS type");
1440}
1441
1444 assert(Target.isOSDarwin() && "expected a darwin OS");
1445 switch (Target.getOS()) {
1446 case Triple::MacOSX:
1447 case Triple::Darwin:
1448 return MachO::PLATFORM_MACOS;
1449 case Triple::IOS:
1450 if (Target.isMacCatalystEnvironment())
1451 return MachO::PLATFORM_MACCATALYST;
1452 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_IOSSIMULATOR
1453 : MachO::PLATFORM_IOS;
1454 case Triple::TvOS:
1455 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_TVOSSIMULATOR
1456 : MachO::PLATFORM_TVOS;
1457 case Triple::WatchOS:
1458 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_WATCHOSSIMULATOR
1459 : MachO::PLATFORM_WATCHOS;
1460 case Triple::DriverKit:
1461 return MachO::PLATFORM_DRIVERKIT;
1462 case Triple::XROS:
1463 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_XROS_SIMULATOR
1464 : MachO::PLATFORM_XROS;
1465 default:
1466 break;
1467 }
1468 llvm_unreachable("unexpected OS type");
1469}
1470
1472 const Triple &Target, const VersionTuple &SDKVersion,
1473 const Triple *DarwinTargetVariantTriple,
1474 const VersionTuple &DarwinTargetVariantSDKVersion) {
1475 if (!Target.isOSBinFormatMachO() || !Target.isOSDarwin())
1476 return;
1477 // Do we even know the version?
1478 if (Target.getOSMajorVersion() == 0)
1479 return;
1480
1482 switch (Target.getOS()) {
1483 case Triple::MacOSX:
1484 case Triple::Darwin:
1485 Target.getMacOSXVersion(Version);
1486 break;
1487 case Triple::IOS:
1488 case Triple::TvOS:
1489 Version = Target.getiOSVersion();
1490 break;
1491 case Triple::WatchOS:
1492 Version = Target.getWatchOSVersion();
1493 break;
1494 case Triple::DriverKit:
1495 Version = Target.getDriverKitVersion();
1496 break;
1497 case Triple::XROS:
1498 Version = Target.getOSVersion();
1499 break;
1500 default:
1501 llvm_unreachable("unexpected OS type");
1502 }
1503 assert(Version.getMajor() != 0 && "A non-zero major version is expected");
1504 auto LinkedTargetVersion =
1506 auto BuildVersionOSVersion = getMachoBuildVersionSupportedOS(Target);
1507 bool ShouldEmitBuildVersion = false;
1508 if (BuildVersionOSVersion.empty() ||
1509 LinkedTargetVersion >= BuildVersionOSVersion) {
1510 if (Target.isMacCatalystEnvironment() && DarwinTargetVariantTriple &&
1511 DarwinTargetVariantTriple->isMacOSX()) {
1512 emitVersionForTarget(*DarwinTargetVariantTriple,
1513 DarwinTargetVariantSDKVersion,
1514 /*DarwinTargetVariantTriple=*/nullptr,
1515 /*DarwinTargetVariantSDKVersion=*/VersionTuple());
1518 LinkedTargetVersion.getMajor(),
1519 LinkedTargetVersion.getMinor().value_or(0),
1520 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1521 return;
1522 }
1524 LinkedTargetVersion.getMajor(),
1525 LinkedTargetVersion.getMinor().value_or(0),
1526 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1527 ShouldEmitBuildVersion = true;
1528 }
1529
1530 if (const Triple *TVT = DarwinTargetVariantTriple) {
1531 if (Target.isMacOSX() && TVT->isMacCatalystEnvironment()) {
1532 auto TVLinkedTargetVersion =
1533 targetVersionOrMinimumSupportedOSVersion(*TVT, TVT->getiOSVersion());
1536 TVLinkedTargetVersion.getMajor(),
1537 TVLinkedTargetVersion.getMinor().value_or(0),
1538 TVLinkedTargetVersion.getSubminor().value_or(0),
1539 DarwinTargetVariantSDKVersion);
1540 }
1541 }
1542
1543 if (ShouldEmitBuildVersion)
1544 return;
1545
1547 LinkedTargetVersion.getMajor(),
1548 LinkedTargetVersion.getMinor().value_or(0),
1549 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1550}
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:42
MCCVFunctionInfo * getCVFunctionInfo(unsigned FuncId)
Retreive the function info if this is a valid function id, or nullptr.
Definition: MCCodeView.cpp:74
bool recordFunctionId(unsigned FuncId)
Records the function id of a normal function.
Definition: MCCodeView.cpp:82
bool recordInlinedCallSiteId(unsigned FuncId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol)
Records the function id of an inlined call site.
Definition: MCCodeView.cpp:95
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:230
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:549
bool hasCOFFAssociativeComdats() const
Definition: MCAsmInfo.h:527
bool isLittleEndian() const
True if the target is little endian.
Definition: MCAsmInfo.h:458
const std::vector< MCCFIInstruction > & getInitialFrameState() const
Definition: MCAsmInfo.h:689
const char * getData8bitsDirective() const
Definition: MCAsmInfo.h:467
bool doesSetDirectiveSuppressReloc() const
Definition: MCAsmInfo.h:600
bool usesWindowsCFI() const
Definition: MCAsmInfo.h:661
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
virtual 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 emitWinCFIEndEpilogue(SMLoc Loc=SMLoc())
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:310
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:293
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 emitCOFFSecNumber(MCSymbol const *Symbol)
Emits the physical number of the section containing the given symbol as assigned during object writin...
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:306
SMLoc getStartTokLoc() const
Definition: MCStreamer.h:298
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:376
virtual void emitWinCFIBeginEpilogue(SMLoc Loc=SMLoc())
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
MCSymbol * CurrentEpilog
Definition: MCStreamer.h:259
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
virtual void emitCOFFSecOffset(MCSymbol const *Symbol)
Emits the offset of the symbol from the beginning of the section during object writing (i....
MCTargetStreamer * getTargetStreamer()
Definition: MCStreamer.h:315
MCStreamer(MCContext &Ctx)
Definition: MCStreamer.cpp:93
MCFragment * CurFrag
Definition: MCStreamer.h:261
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:493
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:739
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:410
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:483
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:489
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
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:205
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:547
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:256
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:261
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
MapVector< MCSymbol *, Epilog > EpilogMap
Definition: MCWinEH.h:64
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