LLVM 17.0.0git
MCStreamer.cpp
Go to the documentation of this file.
1//===- lib/MC/MCStreamer.cpp - Streaming Machine Code Output --------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11#include "llvm/ADT/StringRef.h"
12#include "llvm/ADT/Twine.h"
17#include "llvm/MC/MCAsmInfo.h"
18#include "llvm/MC/MCCodeView.h"
19#include "llvm/MC/MCContext.h"
20#include "llvm/MC/MCDwarf.h"
21#include "llvm/MC/MCExpr.h"
22#include "llvm/MC/MCInst.h"
26#include "llvm/MC/MCRegister.h"
28#include "llvm/MC/MCSection.h"
30#include "llvm/MC/MCSymbol.h"
31#include "llvm/MC/MCWin64EH.h"
32#include "llvm/MC/MCWinEH.h"
35#include "llvm/Support/LEB128.h"
38#include <cassert>
39#include <cstdint>
40#include <cstdlib>
41#include <optional>
42#include <utility>
43
44using namespace llvm;
45
47 S.setTargetStreamer(this);
48}
49
50// Pin the vtables to this file.
52
54
56
58
60 MCSection *Section,
61 const MCExpr *Subsection,
62 raw_ostream &OS) {
63 Section->printSwitchToSection(*Streamer.getContext().getAsmInfo(),
65 Subsection);
66}
67
70}
71
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();
140 Value, IsLittleEndian ? support::little : support::big);
141 unsigned Index = IsLittleEndian ? 0 : 8 - Size;
142 emitBytes(StringRef(reinterpret_cast<char *>(&Swapped) + Index, Size));
143}
145 if (Value.getNumWords() == 1) {
146 emitIntValue(Value.getLimitedValue(), Value.getBitWidth() / 8);
147 return;
148 }
149
150 const bool IsLittleEndianTarget = Context.getAsmInfo()->isLittleEndian();
151 const bool ShouldSwap = sys::IsLittleEndianHost != IsLittleEndianTarget;
152 const APInt Swapped = ShouldSwap ? Value.byteSwap() : Value;
153 const unsigned Size = Value.getBitWidth() / 8;
154 SmallString<10> Tmp;
155 Tmp.resize(Size);
156 StoreIntToMemory(Swapped, reinterpret_cast<uint8_t *>(Tmp.data()), Size);
157 emitBytes(Tmp.str());
158}
159
160/// EmitULEB128IntValue - Special case of EmitULEB128Value that avoids the
161/// client having to pass in a MCExpr for constant integers.
164 raw_svector_ostream OSE(Tmp);
165 encodeULEB128(Value, OSE, PadTo);
166 emitBytes(OSE.str());
167 return Tmp.size();
168}
169
170/// EmitSLEB128IntValue - Special case of EmitSLEB128Value that avoids the
171/// client having to pass in a MCExpr for constant integers.
174 raw_svector_ostream OSE(Tmp);
175 encodeSLEB128(Value, OSE);
176 emitBytes(OSE.str());
177 return Tmp.size();
178}
179
180void MCStreamer::emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc) {
181 emitValueImpl(Value, Size, Loc);
182}
183
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
302bool MCStreamer::emitCVFuncIdDirective(unsigned FunctionId) {
303 return getContext().getCVContext().recordFunctionId(FunctionId);
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
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) {
518 MCSymbol *Label = emitCFILabel();
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) {
540 MCSymbol *Label = emitCFILabel();
542 Label, Register, Offset, AddressSpace);
543 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
544 if (!CurFrame)
545 return;
546 CurFrame->Instructions.push_back(Instruction);
547 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
548}
549
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();
590 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
591 if (!CurFrame)
592 return;
593 CurFrame->Instructions.push_back(Instruction);
594}
595
597 // FIXME: Error if there is no matching cfi_remember_state.
598 MCSymbol *Label = emitCFILabel();
600 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
601 if (!CurFrame)
602 return;
603 CurFrame->Instructions.push_back(Instruction);
604}
605
607 MCSymbol *Label = emitCFILabel();
610 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
611 if (!CurFrame)
612 return;
613 CurFrame->Instructions.push_back(Instruction);
614}
615
617 MCSymbol *Label = emitCFILabel();
620 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
621 if (!CurFrame)
622 return;
623 CurFrame->Instructions.push_back(Instruction);
624}
625
627 MCSymbol *Label = emitCFILabel();
629 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
630 if (!CurFrame)
631 return;
632 CurFrame->Instructions.push_back(Instruction);
633}
634
636 MCSymbol *Label = emitCFILabel();
639 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
640 if (!CurFrame)
641 return;
642 CurFrame->Instructions.push_back(Instruction);
643}
644
646 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
647 if (!CurFrame)
648 return;
649 CurFrame->IsSignalFrame = true;
650}
651
653 MCSymbol *Label = emitCFILabel();
656 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
657 if (!CurFrame)
658 return;
659 CurFrame->Instructions.push_back(Instruction);
660}
661
662void MCStreamer::emitCFIRegister(int64_t Register1, int64_t Register2) {
663 MCSymbol *Label = emitCFILabel();
665 MCCFIInstruction::createRegister(Label, Register1, Register2);
666 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
667 if (!CurFrame)
668 return;
669 CurFrame->Instructions.push_back(Instruction);
670}
671
673 MCSymbol *Label = emitCFILabel();
676 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
677 if (!CurFrame)
678 return;
679 CurFrame->Instructions.push_back(Instruction);
680}
681
683 MCSymbol *Label = emitCFILabel();
685 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
686 if (!CurFrame)
687 return;
688 CurFrame->Instructions.push_back(Instruction);
689}
690
692 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
693 if (!CurFrame)
694 return;
695 CurFrame->RAReg = Register;
696}
697
699 const MCAsmInfo *MAI = Context.getAsmInfo();
700 if (!MAI->usesWindowsCFI()) {
702 Loc, ".seh_* directives are not supported on this target");
703 return nullptr;
704 }
705 if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End) {
707 Loc, ".seh_ directive must appear within an active frame");
708 return nullptr;
709 }
710 return CurrentWinFrameInfo;
711}
712
714 const MCAsmInfo *MAI = Context.getAsmInfo();
715 if (!MAI->usesWindowsCFI())
716 return getContext().reportError(
717 Loc, ".seh_* directives are not supported on this target");
718 if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End)
720 Loc, "Starting a function before ending the previous one!");
721
722 MCSymbol *StartProc = emitCFILabel();
723
724 CurrentProcWinFrameInfoStartIndex = WinFrameInfos.size();
725 WinFrameInfos.emplace_back(
726 std::make_unique<WinEH::FrameInfo>(Symbol, StartProc));
727 CurrentWinFrameInfo = WinFrameInfos.back().get();
728 CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
729}
730
733 if (!CurFrame)
734 return;
735 if (CurFrame->ChainedParent)
736 getContext().reportError(Loc, "Not all chained regions terminated!");
737
738 MCSymbol *Label = emitCFILabel();
739 CurFrame->End = Label;
740 if (!CurFrame->FuncletOrFuncEnd)
741 CurFrame->FuncletOrFuncEnd = CurFrame->End;
742
743 for (size_t I = CurrentProcWinFrameInfoStartIndex, E = WinFrameInfos.size();
744 I != E; ++I)
745 emitWindowsUnwindTables(WinFrameInfos[I].get());
746 switchSection(CurFrame->TextSection);
747}
748
751 if (!CurFrame)
752 return;
753 if (CurFrame->ChainedParent)
754 getContext().reportError(Loc, "Not all chained regions terminated!");
755
756 MCSymbol *Label = emitCFILabel();
757 CurFrame->FuncletOrFuncEnd = Label;
758}
759
762 if (!CurFrame)
763 return;
764
765 MCSymbol *StartProc = emitCFILabel();
766
767 WinFrameInfos.emplace_back(std::make_unique<WinEH::FrameInfo>(
768 CurFrame->Function, StartProc, CurFrame));
769 CurrentWinFrameInfo = WinFrameInfos.back().get();
770 CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
771}
772
775 if (!CurFrame)
776 return;
777 if (!CurFrame->ChainedParent)
778 return getContext().reportError(
779 Loc, "End of a chained region outside a chained region!");
780
781 MCSymbol *Label = emitCFILabel();
782
783 CurFrame->End = Label;
784 CurrentWinFrameInfo = const_cast<WinEH::FrameInfo *>(CurFrame->ChainedParent);
785}
786
787void MCStreamer::emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except,
788 SMLoc Loc) {
790 if (!CurFrame)
791 return;
792 if (CurFrame->ChainedParent)
793 return getContext().reportError(
794 Loc, "Chained unwind areas can't have handlers!");
795 CurFrame->ExceptionHandler = Sym;
796 if (!Except && !Unwind)
797 getContext().reportError(Loc, "Don't know what kind of handler this is!");
798 if (Unwind)
799 CurFrame->HandlesUnwind = true;
800 if (Except)
801 CurFrame->HandlesExceptions = true;
802}
803
806 if (!CurFrame)
807 return;
808 if (CurFrame->ChainedParent)
809 getContext().reportError(Loc, "Chained unwind areas can't have handlers!");
810}
811
813 const MCSymbolRefExpr *To, uint64_t Count) {
814}
815
816static MCSection *getWinCFISection(MCContext &Context, unsigned *NextWinCFIID,
817 MCSection *MainCFISec,
818 const MCSection *TextSec) {
819 // If this is the main .text section, use the main unwind info section.
820 if (TextSec == Context.getObjectFileInfo()->getTextSection())
821 return MainCFISec;
822
823 const auto *TextSecCOFF = cast<MCSectionCOFF>(TextSec);
824 auto *MainCFISecCOFF = cast<MCSectionCOFF>(MainCFISec);
825 unsigned UniqueID = TextSecCOFF->getOrAssignWinCFISectionID(NextWinCFIID);
826
827 // If this section is COMDAT, this unwind section should be COMDAT associative
828 // with its group.
829 const MCSymbol *KeySym = nullptr;
830 if (TextSecCOFF->getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) {
831 KeySym = TextSecCOFF->getCOMDATSymbol();
832
833 // In a GNU environment, we can't use associative comdats. Instead, do what
834 // GCC does, which is to make plain comdat selectany section named like
835 // ".[px]data$_Z3foov".
836 if (!Context.getAsmInfo()->hasCOFFAssociativeComdats()) {
837 std::string SectionName = (MainCFISecCOFF->getName() + "$" +
838 TextSecCOFF->getName().split('$').second)
839 .str();
840 return Context.getCOFFSection(
842 MainCFISecCOFF->getCharacteristics() | COFF::IMAGE_SCN_LNK_COMDAT,
843 MainCFISecCOFF->getKind(), "", COFF::IMAGE_COMDAT_SELECT_ANY);
844 }
845 }
846
847 return Context.getAssociativeCOFFSection(MainCFISecCOFF, KeySym, UniqueID);
848}
849
851 return getWinCFISection(getContext(), &NextWinCFIID,
852 getContext().getObjectFileInfo()->getPDataSection(),
853 TextSec);
854}
855
857 return getWinCFISection(getContext(), &NextWinCFIID,
858 getContext().getObjectFileInfo()->getXDataSection(),
859 TextSec);
860}
861
863
864static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg) {
865 return Ctx.getRegisterInfo()->getSEHRegNum(Reg);
866}
867
870 if (!CurFrame)
871 return;
872
873 MCSymbol *Label = emitCFILabel();
874
877 CurFrame->Instructions.push_back(Inst);
878}
879
881 SMLoc Loc) {
883 if (!CurFrame)
884 return;
885 if (CurFrame->LastFrameInst >= 0)
886 return getContext().reportError(
887 Loc, "frame register and offset can be set at most once");
888 if (Offset & 0x0F)
889 return getContext().reportError(Loc, "offset is not a multiple of 16");
890 if (Offset > 240)
891 return getContext().reportError(
892 Loc, "frame offset must be less than or equal to 240");
893
894 MCSymbol *Label = emitCFILabel();
895
898 CurFrame->LastFrameInst = CurFrame->Instructions.size();
899 CurFrame->Instructions.push_back(Inst);
900}
901
904 if (!CurFrame)
905 return;
906 if (Size == 0)
907 return getContext().reportError(Loc,
908 "stack allocation size must be non-zero");
909 if (Size & 7)
910 return getContext().reportError(
911 Loc, "stack allocation size is not a multiple of 8");
912
913 MCSymbol *Label = emitCFILabel();
914
916 CurFrame->Instructions.push_back(Inst);
917}
918
920 SMLoc Loc) {
922 if (!CurFrame)
923 return;
924
925 if (Offset & 7)
926 return getContext().reportError(
927 Loc, "register save offset is not 8 byte aligned");
928
929 MCSymbol *Label = emitCFILabel();
930
933 CurFrame->Instructions.push_back(Inst);
934}
935
937 SMLoc Loc) {
939 if (!CurFrame)
940 return;
941 if (Offset & 0x0F)
942 return getContext().reportError(Loc, "offset is not a multiple of 16");
943
944 MCSymbol *Label = emitCFILabel();
945
948 CurFrame->Instructions.push_back(Inst);
949}
950
953 if (!CurFrame)
954 return;
955 if (!CurFrame->Instructions.empty())
956 return getContext().reportError(
957 Loc, "If present, PushMachFrame must be the first UOP");
958
959 MCSymbol *Label = emitCFILabel();
960
962 CurFrame->Instructions.push_back(Inst);
963}
964
967 if (!CurFrame)
968 return;
969
970 MCSymbol *Label = emitCFILabel();
971
972 CurFrame->PrologEnd = Label;
973}
974
976
978
980
982
983void MCStreamer::emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) {}
984
985/// EmitRawText - If this file is backed by an assembly streamer, this dumps
986/// the specified string in the output .s file. This capability is
987/// indicated by the hasRawTextSupport() predicate.
989 // This is not llvm_unreachable for the sake of out of tree backend
990 // developers who may not have assembly streamers and should serve as a
991 // reminder to not accidentally call EmitRawText in the absence of such.
992 report_fatal_error("EmitRawText called on an MCStreamer that doesn't support "
993 "it (target backend is likely missing an AsmStreamer "
994 "implementation)");
995}
996
999 emitRawTextImpl(T.toStringRef(Str));
1000}
1001
1003
1005
1007 if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) ||
1008 (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
1009 getContext().reportError(EndLoc, "Unfinished frame!");
1010 return;
1011 }
1012
1014 if (TS)
1015 TS->finish();
1016
1017 finishImpl();
1018}
1019
1021 if (Context.getDwarfFormat() != dwarf::DWARF64)
1022 return;
1023 AddComment("DWARF64 Mark");
1025}
1026
1028 assert(Context.getDwarfFormat() == dwarf::DWARF64 ||
1031 AddComment(Comment);
1033}
1034
1036 const Twine &Comment) {
1038 AddComment(Comment);
1039 MCSymbol *Lo = Context.createTempSymbol(Prefix + "_start");
1040 MCSymbol *Hi = Context.createTempSymbol(Prefix + "_end");
1041
1043 Hi, Lo, dwarf::getDwarfOffsetByteSize(Context.getDwarfFormat()));
1044 // emit the begin symbol after we generate the length field.
1045 emitLabel(Lo);
1046 // Return the Hi symbol to the caller.
1047 return Hi;
1048}
1049
1051 // Set the value of the symbol, as we are at the start of the line table.
1052 emitLabel(StartSym);
1053}
1054
1057 Symbol->setVariableValue(Value);
1058
1060 if (TS)
1061 TS->emitAssignment(Symbol, Value);
1062}
1063
1065 uint64_t Address, const MCInst &Inst,
1066 const MCSubtargetInfo &STI,
1067 raw_ostream &OS) {
1068 InstPrinter.printInst(&Inst, Address, "", STI, OS);
1069}
1070
1072}
1073
1075 switch (Expr.getKind()) {
1076 case MCExpr::Target:
1077 cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
1078 break;
1079
1080 case MCExpr::Constant:
1081 break;
1082
1083 case MCExpr::Binary: {
1084 const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
1085 visitUsedExpr(*BE.getLHS());
1086 visitUsedExpr(*BE.getRHS());
1087 break;
1088 }
1089
1090 case MCExpr::SymbolRef:
1091 visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
1092 break;
1093
1094 case MCExpr::Unary:
1095 visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
1096 break;
1097 }
1098}
1099
1101 // Scan for values.
1102 for (unsigned i = Inst.getNumOperands(); i--;)
1103 if (Inst.getOperand(i).isExpr())
1104 visitUsedExpr(*Inst.getOperand(i).getExpr());
1105}
1106
1108 uint64_t Attr, uint64_t Discriminator,
1109 const MCPseudoProbeInlineStack &InlineStack,
1110 MCSymbol *FnSym) {
1111 auto &Context = getContext();
1112
1113 // Create a symbol at in the current section for use in the probe.
1114 MCSymbol *ProbeSym = Context.createTempSymbol();
1115
1116 // Set the value of the symbol to use for the MCPseudoProbe.
1117 emitLabel(ProbeSym);
1118
1119 // Create a (local) probe entry with the symbol.
1120 MCPseudoProbe Probe(ProbeSym, Guid, Index, Type, Attr, Discriminator);
1121
1122 // Add the probe entry to this section's entries.
1123 Context.getMCPseudoProbeTable().getProbeSections().addPseudoProbe(
1124 FnSym, Probe, InlineStack);
1125}
1126
1128 unsigned Size) {
1129 // Get the Hi-Lo expression.
1130 const MCExpr *Diff =
1133
1134 const MCAsmInfo *MAI = Context.getAsmInfo();
1135 if (!MAI->doesSetDirectiveSuppressReloc()) {
1136 emitValue(Diff, Size);
1137 return;
1138 }
1139
1140 // Otherwise, emit with .set (aka assignment).
1141 MCSymbol *SetLabel = Context.createTempSymbol("set");
1142 emitAssignment(SetLabel, Diff);
1143 emitSymbolValue(SetLabel, Size);
1144}
1145
1147 const MCSymbol *Lo) {
1148 // Get the Hi-Lo expression.
1149 const MCExpr *Diff =
1152
1153 emitULEB128Value(Diff);
1154}
1155
1158void MCStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
1160 llvm_unreachable("this directive only supported on COFF targets");
1161}
1163 llvm_unreachable("this directive only supported on COFF targets");
1164}
1167 StringRef TimeStamp, StringRef Description) {
1168}
1170 llvm_unreachable("this directive only supported on COFF targets");
1171}
1173 llvm_unreachable("this directive only supported on COFF targets");
1174}
1176 MCSymbol *CsectSym,
1177 Align Alignment) {
1178 llvm_unreachable("this directive only supported on XCOFF targets");
1179}
1180
1182 MCSymbolAttr Linkage,
1183 MCSymbolAttr Visibility) {
1184 llvm_unreachable("emitXCOFFSymbolLinkageWithVisibility is only supported on "
1185 "XCOFF targets");
1186}
1187
1189 StringRef Rename) {
1190 llvm_unreachable("emitXCOFFRenameDirective is only supported on "
1191 "XCOFF targets");
1192}
1193
1195 llvm_unreachable("emitXCOFFRefDirective is only supported on XCOFF targets");
1196}
1197
1199 const MCSymbol *Trap,
1200 unsigned Lang, unsigned Reason,
1201 unsigned FunctionSize,
1202 bool hasDebug) {
1203 report_fatal_error("emitXCOFFExceptDirective is only supported on "
1204 "XCOFF targets");
1205}
1206
1209 StringRef Name, bool KeepOriginalSym) {}
1211 Align ByteAlignment) {}
1213 uint64_t Size, Align ByteAlignment) {}
1218void MCStreamer::emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) {
1220}
1223void MCStreamer::emitFill(const MCExpr &NumBytes, uint64_t Value, SMLoc Loc) {}
1224void MCStreamer::emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
1225 SMLoc Loc) {}
1227 unsigned ValueSize,
1228 unsigned MaxBytesToEmit) {}
1230 unsigned MaxBytesToEmit) {}
1232 SMLoc Loc) {}
1234void MCStreamer::emitBundleLock(bool AlignToEnd) {}
1237
1238void MCStreamer::switchSection(MCSection *Section, const MCExpr *Subsection) {
1239 assert(Section && "Cannot switch to a null section!");
1240 MCSectionSubPair curSection = SectionStack.back().first;
1241 SectionStack.back().second = curSection;
1242 if (MCSectionSubPair(Section, Subsection) != curSection) {
1243 changeSection(Section, Subsection);
1244 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
1245 assert(!Section->hasEnded() && "Section already ended");
1246 MCSymbol *Sym = Section->getBeginSymbol();
1247 if (Sym && !Sym->isInSection())
1248 emitLabel(Sym);
1249 }
1250}
1251
1253 // TODO: keep track of the last subsection so that this symbol appears in the
1254 // correct place.
1255 MCSymbol *Sym = Section->getEndSymbol(Context);
1256 if (Sym->isInSection())
1257 return Sym;
1258
1259 switchSection(Section);
1260 emitLabel(Sym);
1261 return Sym;
1262}
1263
1264static VersionTuple
1266 VersionTuple TargetVersion) {
1267 VersionTuple Min = Target.getMinimumSupportedOSVersion();
1268 return !Min.empty() && Min > TargetVersion ? Min : TargetVersion;
1269}
1270
1271static MCVersionMinType
1273 assert(Target.isOSDarwin() && "expected a darwin OS");
1274 switch (Target.getOS()) {
1275 case Triple::MacOSX:
1276 case Triple::Darwin:
1277 return MCVM_OSXVersionMin;
1278 case Triple::IOS:
1279 assert(!Target.isMacCatalystEnvironment() &&
1280 "mac Catalyst should use LC_BUILD_VERSION");
1281 return MCVM_IOSVersionMin;
1282 case Triple::TvOS:
1283 return MCVM_TvOSVersionMin;
1284 case Triple::WatchOS:
1286 default:
1287 break;
1288 }
1289 llvm_unreachable("unexpected OS type");
1290}
1291
1293 assert(Target.isOSDarwin() && "expected a darwin OS");
1294 switch (Target.getOS()) {
1295 case Triple::MacOSX:
1296 case Triple::Darwin:
1297 return VersionTuple(10, 14);
1298 case Triple::IOS:
1299 // Mac Catalyst always uses the build version load command.
1300 if (Target.isMacCatalystEnvironment())
1301 return VersionTuple();
1302 [[fallthrough]];
1303 case Triple::TvOS:
1304 return VersionTuple(12);
1305 case Triple::WatchOS:
1306 return VersionTuple(5);
1307 case Triple::DriverKit:
1308 // DriverKit always uses the build version load command.
1309 return VersionTuple();
1310 default:
1311 break;
1312 }
1313 llvm_unreachable("unexpected OS type");
1314}
1315
1318 assert(Target.isOSDarwin() && "expected a darwin OS");
1319 switch (Target.getOS()) {
1320 case Triple::MacOSX:
1321 case Triple::Darwin:
1322 return MachO::PLATFORM_MACOS;
1323 case Triple::IOS:
1324 if (Target.isMacCatalystEnvironment())
1326 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_IOSSIMULATOR
1328 case Triple::TvOS:
1329 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_TVOSSIMULATOR
1331 case Triple::WatchOS:
1332 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_WATCHOSSIMULATOR
1334 case Triple::DriverKit:
1336 default:
1337 break;
1338 }
1339 llvm_unreachable("unexpected OS type");
1340}
1341
1343 const Triple &Target, const VersionTuple &SDKVersion,
1344 const Triple *DarwinTargetVariantTriple,
1345 const VersionTuple &DarwinTargetVariantSDKVersion) {
1346 if (!Target.isOSBinFormatMachO() || !Target.isOSDarwin())
1347 return;
1348 // Do we even know the version?
1349 if (Target.getOSMajorVersion() == 0)
1350 return;
1351
1352 VersionTuple Version;
1353 switch (Target.getOS()) {
1354 case Triple::MacOSX:
1355 case Triple::Darwin:
1356 Target.getMacOSXVersion(Version);
1357 break;
1358 case Triple::IOS:
1359 case Triple::TvOS:
1360 Version = Target.getiOSVersion();
1361 break;
1362 case Triple::WatchOS:
1363 Version = Target.getWatchOSVersion();
1364 break;
1365 case Triple::DriverKit:
1366 Version = Target.getDriverKitVersion();
1367 break;
1368 default:
1369 llvm_unreachable("unexpected OS type");
1370 }
1371 assert(Version.getMajor() != 0 && "A non-zero major version is expected");
1372 auto LinkedTargetVersion =
1374 auto BuildVersionOSVersion = getMachoBuildVersionSupportedOS(Target);
1375 bool ShouldEmitBuildVersion = false;
1376 if (BuildVersionOSVersion.empty() ||
1377 LinkedTargetVersion >= BuildVersionOSVersion) {
1378 if (Target.isMacCatalystEnvironment() && DarwinTargetVariantTriple &&
1379 DarwinTargetVariantTriple->isMacOSX()) {
1380 emitVersionForTarget(*DarwinTargetVariantTriple,
1381 DarwinTargetVariantSDKVersion,
1382 /*DarwinTargetVariantTriple=*/nullptr,
1383 /*DarwinTargetVariantSDKVersion=*/VersionTuple());
1386 LinkedTargetVersion.getMajor(),
1387 LinkedTargetVersion.getMinor().value_or(0),
1388 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1389 return;
1390 }
1392 LinkedTargetVersion.getMajor(),
1393 LinkedTargetVersion.getMinor().value_or(0),
1394 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1395 ShouldEmitBuildVersion = true;
1396 }
1397
1398 if (const Triple *TVT = DarwinTargetVariantTriple) {
1399 if (Target.isMacOSX() && TVT->isMacCatalystEnvironment()) {
1400 auto TVLinkedTargetVersion =
1401 targetVersionOrMinimumSupportedOSVersion(*TVT, TVT->getiOSVersion());
1404 TVLinkedTargetVersion.getMajor(),
1405 TVLinkedTargetVersion.getMinor().value_or(0),
1406 TVLinkedTargetVersion.getSubminor().value_or(0),
1407 DarwinTargetVariantSDKVersion);
1408 }
1409 }
1410
1411 if (ShouldEmitBuildVersion)
1412 return;
1413
1415 LinkedTargetVersion.getMajor(),
1416 LinkedTargetVersion.getMinor().value_or(0),
1417 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1418}
BlockVerifier::State From
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::string Name
uint64_t Size
bool End
Definition: ELF_riscv.cpp:464
Symbol * Sym
Definition: ELF_riscv.cpp:463
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:816
static MachO::PlatformType getMachoBuildVersionPlatformType(const Triple &Target)
static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg)
Definition: MCStreamer.cpp:864
#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.
@ Flags
Definition: TextStubV5.cpp:93
Class for arbitrary precision integers.
Definition: APInt.h:75
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Holds state from .cv_file and .cv_loc directives for later emission.
Definition: MCCodeView.h:144
bool addFile(MCStreamer &OS, unsigned FileNumber, StringRef Filename, ArrayRef< uint8_t > ChecksumBytes, uint8_t ChecksumKind)
Definition: MCCodeView.cpp:47
MCCVFunctionInfo * getCVFunctionInfo(unsigned FuncId)
Retreive the function info if this is a valid function id, or nullptr.
Definition: MCCodeView.cpp:79
bool recordFunctionId(unsigned FuncId)
Records the function id of a normal function.
Definition: MCCodeView.cpp:87
bool recordInlinedCallSiteId(unsigned FuncId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol)
Records the function id of an inlined call site.
Definition: MCCodeView.cpp:100
unsigned size() const
Definition: DenseMap.h:99
Tagged union holding either a T or a Error.
Definition: Error.h:470
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:42
virtual uint32_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI, const MCContext *Ctxt) const
Generate the compact unwind encoding for the CFI instructions.
Definition: MCAsmBackend.h:214
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
StringRef getPrivateGlobalPrefix() const
Definition: MCAsmInfo.h:668
bool isLittleEndian() const
True if the target is little endian.
Definition: MCAsmInfo.h:559
const std::vector< MCCFIInstruction > & getInitialFrameState() const
Definition: MCAsmInfo.h:833
const char * getData8bitsDirective() const
Definition: MCAsmInfo.h:568
bool doesSetDirectiveSuppressReloc() const
Definition: MCAsmInfo.h:728
bool usesWindowsCFI() const
Definition: MCAsmInfo.h:799
Binary assembler expressions.
Definition: MCExpr.h:481
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition: MCExpr.h:628
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition: MCExpr.h:631
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:610
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
Definition: MCDwarf.h:547
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register)
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
Definition: MCDwarf.h:604
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register)
.cfi_same_value Current value of Register is the same as in the previous frame.
Definition: MCDwarf.h:616
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size)
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
Definition: MCDwarf.h:638
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
Definition: MCDwarf.h:540
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register)
.cfi_undefined From now on the previous value of Register can't be restored anymore.
Definition: MCDwarf.h:610
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment)
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
Definition: MCDwarf.h:554
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition: MCDwarf.h:533
static MCCFIInstruction createRememberState(MCSymbol *L)
.cfi_remember_state Save all current rules for all registers.
Definition: MCDwarf.h:621
static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register, int Offset, unsigned AddressSpace)
.cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to be the result of evaluating the DW...
Definition: MCDwarf.h:562
static MCCFIInstruction createWindowSave(MCSymbol *L)
.cfi_window_save SPARC register window is saved.
Definition: MCDwarf.h:592
static MCCFIInstruction createRestoreState(MCSymbol *L)
.cfi_restore_state Restore the previously saved state.
Definition: MCDwarf.h:626
static MCCFIInstruction createNegateRAState(MCSymbol *L)
.cfi_negate_ra_state AArch64 negate RA state.
Definition: MCDwarf.h:597
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Definition: MCDwarf.h:632
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition: MCDwarf.h:571
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register.
Definition: MCDwarf.h:579
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.
Definition: MCDwarf.h:586
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:194
Context object for machine code objects.
Definition: MCContext.h:76
Expected< unsigned > getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
Definition: MCContext.cpp:972
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:729
CodeViewContext & getCVContext()
Definition: MCContext.cpp:1000
const MCRegisterInfo * getRegisterInfo() const
Definition: MCContext.h:448
void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator)
Saves the information from the currently parsed dwarf .loc directive and sets DwarfLocSeen.
Definition: MCContext.h:770
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:446
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1055
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:201
void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir, StringRef Filename, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
Specifies the "root" file and directory of the compilation unit.
Definition: MCContext.h:753
const Triple & getTargetTriple() const
Definition: MCContext.h:434
void setLabel(MCSymbol *Label)
Definition: MCDwarf.h:401
MCSymbol * getLabel() const
Definition: MCDwarf.h:397
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
@ Unary
Unary expressions.
Definition: MCExpr.h:41
@ Constant
Constant expressions.
Definition: MCExpr.h:39
@ SymbolRef
References to labels and assigned expressions.
Definition: MCExpr.h:40
@ Target
Target specific expression.
Definition: MCExpr.h:42
@ Binary
Binary expressions.
Definition: MCExpr.h:38
ExprKind getKind() const
Definition: MCExpr.h:81
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:44
virtual void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS)=0
Print the specified MCInst to the specified raw_ostream.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
unsigned getNumOperands() const
Definition: MCInst.h:208
const MCOperand & getOperand(unsigned i) const
Definition: MCInst.h:206
const MCExpr * getExpr() const
Definition: MCInst.h:114
bool isExpr() const
Definition: MCInst.h:65
Instances of this class represent a pseudo probe instance for a pseudo probe table entry,...
int getSEHRegNum(MCRegister RegNum) const
Map a target register to an equivalent SEH register number.
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:24
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
Streaming machine code generation interface.
Definition: MCStreamer.h:212
virtual void emitNops(int64_t NumBytes, int64_t ControlledNopLength, SMLoc Loc, const MCSubtargetInfo &STI)
Definition: MCStreamer.cpp:226
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void visitUsedSymbol(const MCSymbol &Sym)
void emitCFIStartProc(bool IsSimple, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp: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 emitCFIDefCfaOffset(int64_t Offset)
Definition: MCStreamer.cpp:507
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:862
virtual void emitWinCFIPushReg(MCRegister Register, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:868
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 emitCFIGnuArgsSize(int64_t Size)
Definition: MCStreamer.cpp:635
virtual void emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:787
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:850
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 emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset, int64_t AddressSpace)
Definition: MCStreamer.cpp:538
virtual void emitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
Definition: MCStreamer.cpp:211
virtual void emitCFIRegister(int64_t Register1, int64_t Register2)
Definition: MCStreamer.cpp:662
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:691
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 emitCOFFSymbolIndex(MCSymbol const *Symbol)
Emits the symbol table index of a Symbol into the current section.
Definition: MCStreamer.cpp:977
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:983
virtual void endCOFFSymbolDef()
Marks the end of the symbol definition.
virtual void emitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:951
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:804
virtual void emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo)
Emit the absolute difference between two symbols encoded with ULEB128.
virtual void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol, MCSymbolAttr Linkage, MCSymbolAttr Visibility)
Emit a symbol's linkage and visibility with a linkage directive for XCOFF.
void setTargetStreamer(MCTargetStreamer *TS)
Definition: MCStreamer.h:284
virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:936
virtual void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
Definition: MCStreamer.cpp:473
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
virtual void emitCFIRememberState()
Definition: MCStreamer.cpp:587
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:981
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
Definition: MCStreamer.cpp:856
virtual void emitCFIOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:550
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:713
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:180
void emitSymbolValue(const MCSymbol *Sym, unsigned Size, bool IsSectionRelative=false)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
Definition: MCStreamer.cpp:184
bool checkCVLocSection(unsigned FuncId, unsigned FileNo, SMLoc Loc)
Returns true if the the .cv_loc directive is in the right section.
Definition: MCStreamer.cpp:325
virtual void emitCFIWindowSave()
Definition: MCStreamer.cpp:672
virtual void emitCFIRestoreState()
Definition: MCStreamer.cpp:596
virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)
Emit the debug line start label.
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
virtual void emitXCOFFExceptDirective(const MCSymbol *Symbol, const MCSymbol *Trap, unsigned Lang, unsigned Reason, unsigned FunctionSize, bool hasDebug)
Emit an XCOFF .except directive which adds information about a trap instruction to the object file ex...
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:424
virtual void emitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
Definition: MCStreamer.cpp:979
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 emitCFIRestore(int64_t Register)
Definition: MCStreamer.cpp:616
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:919
virtual void emitWinCFIEndChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:773
virtual void emitWinCFIEndProlog(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:965
virtual void emitWinCFIEndProc(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:731
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 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 emitCOFFSafeSEH(MCSymbol const *Symbol)
Definition: MCStreamer.cpp:975
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:749
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 emitCFIUndefined(int64_t Register)
Definition: MCStreamer.cpp:652
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
Definition: MCStreamer.cpp:812
virtual void emitCFIDefCfaRegister(int64_t Register)
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:162
virtual void emitULEB128Value(const MCExpr *Value)
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
Definition: MCStreamer.cpp:117
virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc)
Emit some number of copies of Value until the byte offset Offset is reached.
MCSymbol * endSection(MCSection *Section)
virtual void switchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
virtual void emitExplicitComments()
Emit added explicit comments.
Definition: MCStreamer.cpp:124
WinEH::FrameInfo * EnsureValidWinFrameInfo(SMLoc Loc)
Retrieve the current frame info if one is available and it is not yet closed.
Definition: MCStreamer.cpp:698
virtual void emitThumbFunc(MCSymbol *Func)
Note in the output that the specified Func is a Thumb mode function (ARM target only).
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:748
virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:880
virtual void emitCFINegateRAState()
Definition: MCStreamer.cpp:682
void maybeEmitDwarf64Mark()
Emit a special value of 0xffffffff if producing 64-bit debugging info.
virtual void emitCFIAdjustCfaOffset(int64_t Adjustment)
Definition: MCStreamer.cpp:517
virtual void emitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
Definition: MCStreamer.cpp:199
virtual void emitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc)
This implements the CodeView '.cv_loc' assembler directive.
Definition: MCStreamer.cpp:320
virtual void emitCFISameValue(int64_t Register)
Definition: MCStreamer.cpp:606
virtual void emitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:902
virtual void emitFileDirective(StringRef Filename)
Switch to a new logical file.
virtual void emitSLEB128Value(const MCExpr *Value)
virtual void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name, bool KeepOriginalSym)
Emit an ELF .symver directive.
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:393
virtual void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
void emitRawText(const Twine &String)
If this file is backed by a assembly streamer, this dumps the specified string in the output ....
Definition: MCStreamer.cpp:997
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:645
virtual void emitCFIDefCfa(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:496
virtual void emitVersionMin(MCVersionMinType Type, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Specify the Mach-O minimum deployment target version.
Definition: MCStreamer.h:506
virtual void emitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
virtual void emitCFIRelOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:560
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:760
virtual void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment=Align(1))
Emit a thread local bss (.tbss) symbol.
virtual void emitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView '.cv_inline_linetable' assembler directive.
Definition: MCStreamer.cpp: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:988
virtual void emitCFIEscape(StringRef Values)
Definition: MCStreamer.cpp:626
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
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:192
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:386
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
Target specific streamer interface.
Definition: MCStreamer.h:93
virtual void emitDwarfFileDirective(StringRef Directive)
Definition: MCStreamer.cpp:68
virtual void emitValue(const MCExpr *Value)
Definition: MCStreamer.cpp:72
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, uint64_t Address, const MCInst &Inst, const MCSubtargetInfo &STI, raw_ostream &OS)
virtual void finish()
Definition: MCStreamer.cpp:55
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Definition: MCStreamer.cpp:92
virtual void emitRawBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition: MCStreamer.cpp:80
MCStreamer & Streamer
Definition: MCStreamer.h:95
MCTargetStreamer(MCStreamer &S)
Definition: MCStreamer.cpp:46
virtual void emitLabel(MCSymbol *Symbol)
Definition: MCStreamer.cpp:53
virtual void changeSection(const MCSection *CurSection, MCSection *Section, const MCExpr *SubSection, raw_ostream &OS)
Update streamer for a new active section.
Definition: MCStreamer.cpp:59
virtual void emitConstantPools()
Definition: MCStreamer.cpp:57
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
Represents a location in source code.
Definition: SMLoc.h:23
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:261
size_t size() const
Definition: SmallVector.h:91
void resize(size_type N)
Definition: SmallVector.h:642
void push_back(const T &Elt)
Definition: SmallVector.h:416
pointer data()
Return a pointer to the vector's buffer, even if empty().
Definition: SmallVector.h:289
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
bool isMacOSX() const
Is this a Mac OS X triple.
Definition: Triple.h:487
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:74
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
Definition: AsmWriter.cpp:4695
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:31
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
Definition: VersionTuple.h:68
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:672
StringRef str() const
Return a StringRef for the vector contents.
Definition: raw_ostream.h:697
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_SCN_LNK_COMDAT
Definition: COFF.h:304
@ IMAGE_COMDAT_SELECT_ANY
Definition: COFF.h:418
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
PlatformType
Definition: MachO.h:499
@ PLATFORM_MACCATALYST
Definition: MachO.h:506
@ PLATFORM_DRIVERKIT
Definition: MachO.h:510
@ PLATFORM_WATCHOS
Definition: MachO.h:504
@ PLATFORM_WATCHOSSIMULATOR
Definition: MachO.h:509
@ PLATFORM_IOS
Definition: MachO.h:502
@ PLATFORM_TVOS
Definition: MachO.h:503
@ PLATFORM_TVOSSIMULATOR
Definition: MachO.h:508
@ PLATFORM_MACOS
Definition: MachO.h:501
@ PLATFORM_IOSSIMULATOR
Definition: MachO.h:507
StorageClass
Definition: XCOFF.h:169
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
Definition: CodeView.h:47
@ DWARF64
Definition: Dwarf.h:91
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:718
@ DW_LENGTH_lo_reserved
Special values for an initial length field.
Definition: Dwarf.h:54
@ DW_LENGTH_DWARF64
Indicator of 64-bit DWARF format.
Definition: Dwarf.h:55
value_type byte_swap(value_type value, endianness endian)
Definition: Endian.h:49
static const bool IsLittleEndianHost
Definition: SwapByteOrder.h:57
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:440
@ Length
Definition: DWP.cpp:440
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:3019
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:256
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:145
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
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
Definition: MCStreamer.h:66
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
Definition: LEB128.h:23
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
Definition: LEB128.h:80
MCSymbolAttr
Definition: MCDirectives.h:18
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Information describing a function or inlined call site introduced by .cv_func_id or ....
Definition: MCCodeView.h:98
MCSection * Section
The section of the first .cv_loc directive used for this function, or null if none has been seen yet.
Definition: MCCodeView.h:118
const MCSymbol * Personality
Definition: MCDwarf.h:687
unsigned PersonalityEncoding
Definition: MCDwarf.h:691
std::vector< MCCFIInstruction > Instructions
Definition: MCDwarf.h:689
unsigned LsdaEncoding
Definition: MCDwarf.h:692
const MCSymbol * Lsda
Definition: MCDwarf.h:688
unsigned CurrentCfaRegister
Definition: MCDwarf.h:690
static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition: MCWin64EH.h:42
static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg)
Definition: MCWin64EH.h:26
static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code)
Definition: MCWin64EH.h:33
static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition: MCWin64EH.h:36
static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size)
Definition: MCWin64EH.h:29
static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off)
Definition: MCWin64EH.h:48
std::vector< Instruction > Instructions
Definition: MCWinEH.h:58
const MCSymbol * Function
Definition: MCWinEH.h:44
MCSection * TextSection
Definition: MCWinEH.h:47
const MCSymbol * PrologEnd
Definition: MCWinEH.h:45
const MCSymbol * FuncletOrFuncEnd
Definition: MCWinEH.h:42
const MCSymbol * End
Definition: MCWinEH.h:41
const FrameInfo * ChainedParent
Definition: MCWinEH.h:57
const MCSymbol * ExceptionHandler
Definition: MCWinEH.h:43