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