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