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 SymbolOrdering.clear();
106 SectionStack.clear();
107 SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
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 assert(Fragment);
416 Symbol->setFragment(Fragment);
417
418 // As we emit symbols into a section, track the order so that they can
419 // be sorted upon later. Zero is reserved to mean 'unemitted'.
420 SymbolOrdering[Symbol] = 1 + SymbolOrdering.size();
421}
422
424 Symbol->redefineIfPossible();
425
426 if (!Symbol->isUndefined() || Symbol->isVariable())
427 return getContext().reportError(Loc, "symbol '" + Twine(Symbol->getName()) +
428 "' is already defined");
429
430 assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
431 assert(getCurrentSectionOnly() && "Cannot emit before setting section!");
432 assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
433 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
434
435 Symbol->setFragment(&getCurrentSectionOnly()->getDummyFragment());
436
438 if (TS)
439 TS->emitLabel(Symbol);
440}
441
443 const MCExpr *Value) {}
444
445void MCStreamer::emitCFISections(bool EH, bool Debug) {}
446
447void MCStreamer::emitCFIStartProc(bool IsSimple, SMLoc Loc) {
448 if (!FrameInfoStack.empty() &&
449 getCurrentSectionOnly() == FrameInfoStack.back().second)
450 return getContext().reportError(
451 Loc, "starting new .cfi frame before finishing the previous one");
452
453 MCDwarfFrameInfo Frame;
454 Frame.IsSimple = IsSimple;
456
457 const MCAsmInfo* MAI = Context.getAsmInfo();
458 if (MAI) {
459 for (const MCCFIInstruction& Inst : MAI->getInitialFrameState()) {
460 if (Inst.getOperation() == MCCFIInstruction::OpDefCfa ||
461 Inst.getOperation() == MCCFIInstruction::OpDefCfaRegister ||
462 Inst.getOperation() == MCCFIInstruction::OpLLVMDefAspaceCfa) {
463 Frame.CurrentCfaRegister = Inst.getRegister();
464 }
465 }
466 }
467
468 FrameInfoStack.emplace_back(DwarfFrameInfos.size(), getCurrentSectionOnly());
469 DwarfFrameInfos.push_back(Frame);
470}
471
473}
474
476 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
477 if (!CurFrame)
478 return;
479 emitCFIEndProcImpl(*CurFrame);
480 FrameInfoStack.pop_back();
481}
482
484 // Put a dummy non-null value in Frame.End to mark that this frame has been
485 // closed.
486 Frame.End = (MCSymbol *)1;
487}
488
490 // Return a dummy non-null value so that label fields appear filled in when
491 // generating textual assembly.
492 return (MCSymbol *)1;
493}
494
495void MCStreamer::emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc) {
496 MCSymbol *Label = emitCFILabel();
499 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
500 if (!CurFrame)
501 return;
502 CurFrame->Instructions.push_back(Instruction);
503 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
504}
505
507 MCSymbol *Label = emitCFILabel();
510 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
511 if (!CurFrame)
512 return;
513 CurFrame->Instructions.push_back(Instruction);
514}
515
516void MCStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc) {
517 MCSymbol *Label = emitCFILabel();
519 MCCFIInstruction::createAdjustCfaOffset(Label, Adjustment, Loc);
520 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
521 if (!CurFrame)
522 return;
523 CurFrame->Instructions.push_back(Instruction);
524}
525
527 MCSymbol *Label = emitCFILabel();
530 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
531 if (!CurFrame)
532 return;
533 CurFrame->Instructions.push_back(Instruction);
534 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
535}
536
538 int64_t AddressSpace, SMLoc Loc) {
539 MCSymbol *Label = emitCFILabel();
541 Label, Register, Offset, AddressSpace, Loc);
542 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
543 if (!CurFrame)
544 return;
545 CurFrame->Instructions.push_back(Instruction);
546 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
547}
548
549void MCStreamer::emitCFIOffset(int64_t Register, int64_t Offset, SMLoc Loc) {
550 MCSymbol *Label = emitCFILabel();
553 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
554 if (!CurFrame)
555 return;
556 CurFrame->Instructions.push_back(Instruction);
557}
558
560 MCSymbol *Label = emitCFILabel();
563 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
564 if (!CurFrame)
565 return;
566 CurFrame->Instructions.push_back(Instruction);
567}
568
570 unsigned Encoding) {
571 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
572 if (!CurFrame)
573 return;
574 CurFrame->Personality = Sym;
575 CurFrame->PersonalityEncoding = Encoding;
576}
577
578void MCStreamer::emitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
579 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
580 if (!CurFrame)
581 return;
582 CurFrame->Lsda = Sym;
583 CurFrame->LsdaEncoding = Encoding;
584}
585
587 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();
601 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
602 if (!CurFrame)
603 return;
604 CurFrame->Instructions.push_back(Instruction);
605}
606
608 MCSymbol *Label = emitCFILabel();
611 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
612 if (!CurFrame)
613 return;
614 CurFrame->Instructions.push_back(Instruction);
615}
616
618 MCSymbol *Label = emitCFILabel();
621 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
622 if (!CurFrame)
623 return;
624 CurFrame->Instructions.push_back(Instruction);
625}
626
628 MCSymbol *Label = emitCFILabel();
630 MCCFIInstruction::createEscape(Label, Values, Loc, "");
631 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
632 if (!CurFrame)
633 return;
634 CurFrame->Instructions.push_back(Instruction);
635}
636
638 MCSymbol *Label = emitCFILabel();
641 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
642 if (!CurFrame)
643 return;
644 CurFrame->Instructions.push_back(Instruction);
645}
646
648 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
649 if (!CurFrame)
650 return;
651 CurFrame->IsSignalFrame = true;
652}
653
655 MCSymbol *Label = emitCFILabel();
658 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
659 if (!CurFrame)
660 return;
661 CurFrame->Instructions.push_back(Instruction);
662}
663
664void MCStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
665 SMLoc Loc) {
666 MCSymbol *Label = emitCFILabel();
668 MCCFIInstruction::createRegister(Label, Register1, Register2, Loc);
669 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
670 if (!CurFrame)
671 return;
672 CurFrame->Instructions.push_back(Instruction);
673}
674
676 MCSymbol *Label = emitCFILabel();
678 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
679 if (!CurFrame)
680 return;
681 CurFrame->Instructions.push_back(Instruction);
682}
683
685 MCSymbol *Label = emitCFILabel();
688 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
689 if (!CurFrame)
690 return;
691 CurFrame->Instructions.push_back(Instruction);
692}
693
695 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
696 if (!CurFrame)
697 return;
698 CurFrame->RAReg = Register;
699}
700
702 const MCAsmInfo *MAI = Context.getAsmInfo();
703 if (!MAI->usesWindowsCFI()) {
705 Loc, ".seh_* directives are not supported on this target");
706 return nullptr;
707 }
708 if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End) {
710 Loc, ".seh_ directive must appear within an active frame");
711 return nullptr;
712 }
713 return CurrentWinFrameInfo;
714}
715
717 const MCAsmInfo *MAI = Context.getAsmInfo();
718 if (!MAI->usesWindowsCFI())
719 return getContext().reportError(
720 Loc, ".seh_* directives are not supported on this target");
721 if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End)
723 Loc, "Starting a function before ending the previous one!");
724
725 MCSymbol *StartProc = emitCFILabel();
726
727 CurrentProcWinFrameInfoStartIndex = WinFrameInfos.size();
728 WinFrameInfos.emplace_back(
729 std::make_unique<WinEH::FrameInfo>(Symbol, StartProc));
730 CurrentWinFrameInfo = WinFrameInfos.back().get();
731 CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
732}
733
736 if (!CurFrame)
737 return;
738 if (CurFrame->ChainedParent)
739 getContext().reportError(Loc, "Not all chained regions terminated!");
740
741 MCSymbol *Label = emitCFILabel();
742 CurFrame->End = Label;
743 if (!CurFrame->FuncletOrFuncEnd)
744 CurFrame->FuncletOrFuncEnd = CurFrame->End;
745
746 for (size_t I = CurrentProcWinFrameInfoStartIndex, E = WinFrameInfos.size();
747 I != E; ++I)
748 emitWindowsUnwindTables(WinFrameInfos[I].get());
749 switchSection(CurFrame->TextSection);
750}
751
754 if (!CurFrame)
755 return;
756 if (CurFrame->ChainedParent)
757 getContext().reportError(Loc, "Not all chained regions terminated!");
758
759 MCSymbol *Label = emitCFILabel();
760 CurFrame->FuncletOrFuncEnd = Label;
761}
762
765 if (!CurFrame)
766 return;
767
768 MCSymbol *StartProc = emitCFILabel();
769
770 WinFrameInfos.emplace_back(std::make_unique<WinEH::FrameInfo>(
771 CurFrame->Function, StartProc, CurFrame));
772 CurrentWinFrameInfo = WinFrameInfos.back().get();
773 CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
774}
775
778 if (!CurFrame)
779 return;
780 if (!CurFrame->ChainedParent)
781 return getContext().reportError(
782 Loc, "End of a chained region outside a chained region!");
783
784 MCSymbol *Label = emitCFILabel();
785
786 CurFrame->End = Label;
787 CurrentWinFrameInfo = const_cast<WinEH::FrameInfo *>(CurFrame->ChainedParent);
788}
789
790void MCStreamer::emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except,
791 SMLoc Loc) {
793 if (!CurFrame)
794 return;
795 if (CurFrame->ChainedParent)
796 return getContext().reportError(
797 Loc, "Chained unwind areas can't have handlers!");
798 CurFrame->ExceptionHandler = Sym;
799 if (!Except && !Unwind)
800 getContext().reportError(Loc, "Don't know what kind of handler this is!");
801 if (Unwind)
802 CurFrame->HandlesUnwind = true;
803 if (Except)
804 CurFrame->HandlesExceptions = true;
805}
806
809 if (!CurFrame)
810 return;
811 if (CurFrame->ChainedParent)
812 getContext().reportError(Loc, "Chained unwind areas can't have handlers!");
814
816 const MCSymbolRefExpr *To, uint64_t Count) {
817}
818
819static MCSection *getWinCFISection(MCContext &Context, unsigned *NextWinCFIID,
820 MCSection *MainCFISec,
821 const MCSection *TextSec) {
822 // If this is the main .text section, use the main unwind info section.
823 if (TextSec == Context.getObjectFileInfo()->getTextSection())
824 return MainCFISec;
825
826 const auto *TextSecCOFF = cast<MCSectionCOFF>(TextSec);
827 auto *MainCFISecCOFF = cast<MCSectionCOFF>(MainCFISec);
828 unsigned UniqueID = TextSecCOFF->getOrAssignWinCFISectionID(NextWinCFIID);
829
830 // If this section is COMDAT, this unwind section should be COMDAT associative
831 // with its group.
832 const MCSymbol *KeySym = nullptr;
833 if (TextSecCOFF->getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) {
834 KeySym = TextSecCOFF->getCOMDATSymbol();
835
836 // In a GNU environment, we can't use associative comdats. Instead, do what
837 // GCC does, which is to make plain comdat selectany section named like
838 // ".[px]data$_Z3foov".
839 if (!Context.getAsmInfo()->hasCOFFAssociativeComdats()) {
840 std::string SectionName = (MainCFISecCOFF->getName() + "$" +
841 TextSecCOFF->getName().split('$').second)
842 .str();
843 return Context.getCOFFSection(SectionName,
844 MainCFISecCOFF->getCharacteristics() |
847 }
848 }
849
850 return Context.getAssociativeCOFFSection(MainCFISecCOFF, KeySym, UniqueID);
851}
852
854 return getWinCFISection(getContext(), &NextWinCFIID,
855 getContext().getObjectFileInfo()->getPDataSection(),
856 TextSec);
857}
858
860 return getWinCFISection(getContext(), &NextWinCFIID,
861 getContext().getObjectFileInfo()->getXDataSection(),
862 TextSec);
863}
864
866
867static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg) {
868 return Ctx.getRegisterInfo()->getSEHRegNum(Reg);
869}
870
873 if (!CurFrame)
874 return;
875
876 MCSymbol *Label = emitCFILabel();
877
879 Label, encodeSEHRegNum(Context, Register));
880 CurFrame->Instructions.push_back(Inst);
881}
882
884 SMLoc Loc) {
886 if (!CurFrame)
887 return;
888 if (CurFrame->LastFrameInst >= 0)
889 return getContext().reportError(
890 Loc, "frame register and offset can be set at most once");
891 if (Offset & 0x0F)
892 return getContext().reportError(Loc, "offset is not a multiple of 16");
893 if (Offset > 240)
894 return getContext().reportError(
895 Loc, "frame offset must be less than or equal to 240");
896
897 MCSymbol *Label = emitCFILabel();
898
901 CurFrame->LastFrameInst = CurFrame->Instructions.size();
902 CurFrame->Instructions.push_back(Inst);
903}
904
907 if (!CurFrame)
908 return;
909 if (Size == 0)
910 return getContext().reportError(Loc,
911 "stack allocation size must be non-zero");
912 if (Size & 7)
913 return getContext().reportError(
914 Loc, "stack allocation size is not a multiple of 8");
915
916 MCSymbol *Label = emitCFILabel();
917
919 CurFrame->Instructions.push_back(Inst);
920}
921
923 SMLoc Loc) {
925 if (!CurFrame)
926 return;
927
928 if (Offset & 7)
929 return getContext().reportError(
930 Loc, "register save offset is not 8 byte aligned");
931
932 MCSymbol *Label = emitCFILabel();
933
935 Label, encodeSEHRegNum(Context, Register), Offset);
936 CurFrame->Instructions.push_back(Inst);
937}
938
940 SMLoc Loc) {
942 if (!CurFrame)
943 return;
944 if (Offset & 0x0F)
945 return getContext().reportError(Loc, "offset is not a multiple of 16");
946
947 MCSymbol *Label = emitCFILabel();
948
950 Label, encodeSEHRegNum(Context, Register), Offset);
951 CurFrame->Instructions.push_back(Inst);
952}
953
956 if (!CurFrame)
957 return;
958 if (!CurFrame->Instructions.empty())
959 return getContext().reportError(
960 Loc, "If present, PushMachFrame must be the first UOP");
961
962 MCSymbol *Label = emitCFILabel();
963
965 CurFrame->Instructions.push_back(Inst);
966}
967
970 if (!CurFrame)
971 return;
972
973 MCSymbol *Label = emitCFILabel();
974
975 CurFrame->PrologEnd = Label;
976}
977
979
981
983
985
986void MCStreamer::emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) {}
987
988/// EmitRawText - If this file is backed by an assembly streamer, this dumps
989/// the specified string in the output .s file. This capability is
990/// indicated by the hasRawTextSupport() predicate.
992 // This is not llvm_unreachable for the sake of out of tree backend
993 // developers who may not have assembly streamers and should serve as a
994 // reminder to not accidentally call EmitRawText in the absence of such.
995 report_fatal_error("EmitRawText called on an MCStreamer that doesn't support "
996 "it (target backend is likely missing an AsmStreamer "
997 "implementation)");
998}
999
1001 SmallString<128> Str;
1002 emitRawTextImpl(T.toStringRef(Str));
1003}
1004
1006
1008
1010 if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) ||
1011 (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
1012 getContext().reportError(EndLoc, "Unfinished frame!");
1013 return;
1014 }
1015
1017 if (TS)
1018 TS->finish();
1019
1020 finishImpl();
1021}
1022
1024 if (Context.getDwarfFormat() != dwarf::DWARF64)
1025 return;
1026 AddComment("DWARF64 Mark");
1028}
1029
1031 assert(Context.getDwarfFormat() == dwarf::DWARF64 ||
1034 AddComment(Comment);
1036}
1037
1039 const Twine &Comment) {
1041 AddComment(Comment);
1042 MCSymbol *Lo = Context.createTempSymbol(Prefix + "_start");
1043 MCSymbol *Hi = Context.createTempSymbol(Prefix + "_end");
1044
1047 // emit the begin symbol after we generate the length field.
1048 emitLabel(Lo);
1049 // Return the Hi symbol to the caller.
1050 return Hi;
1051}
1052
1054 // Set the value of the symbol, as we are at the start of the line table.
1055 emitLabel(StartSym);
1056}
1057
1060 Symbol->setVariableValue(Value);
1061
1063 if (TS)
1064 TS->emitAssignment(Symbol, Value);
1065}
1066
1068 uint64_t Address, const MCInst &Inst,
1069 const MCSubtargetInfo &STI,
1070 raw_ostream &OS) {
1071 InstPrinter.printInst(&Inst, Address, "", STI, OS);
1072}
1073
1075}
1076
1078 switch (Expr.getKind()) {
1079 case MCExpr::Target:
1080 cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
1081 break;
1082
1083 case MCExpr::Constant:
1084 break;
1085
1086 case MCExpr::Binary: {
1087 const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
1088 visitUsedExpr(*BE.getLHS());
1089 visitUsedExpr(*BE.getRHS());
1090 break;
1091 }
1092
1093 case MCExpr::SymbolRef:
1094 visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
1095 break;
1096
1097 case MCExpr::Unary:
1098 visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
1099 break;
1100 }
1101}
1102
1104 // Scan for values.
1105 for (unsigned i = Inst.getNumOperands(); i--;)
1106 if (Inst.getOperand(i).isExpr())
1107 visitUsedExpr(*Inst.getOperand(i).getExpr());
1108}
1109
1111 uint64_t Attr, uint64_t Discriminator,
1112 const MCPseudoProbeInlineStack &InlineStack,
1113 MCSymbol *FnSym) {
1114 auto &Context = getContext();
1115
1116 // Create a symbol at in the current section for use in the probe.
1117 MCSymbol *ProbeSym = Context.createTempSymbol();
1118
1119 // Set the value of the symbol to use for the MCPseudoProbe.
1120 emitLabel(ProbeSym);
1121
1122 // Create a (local) probe entry with the symbol.
1123 MCPseudoProbe Probe(ProbeSym, Guid, Index, Type, Attr, Discriminator);
1124
1125 // Add the probe entry to this section's entries.
1127 FnSym, Probe, InlineStack);
1128}
1129
1131 unsigned Size) {
1132 // Get the Hi-Lo expression.
1133 const MCExpr *Diff =
1135 MCSymbolRefExpr::create(Lo, Context), Context);
1136
1137 const MCAsmInfo *MAI = Context.getAsmInfo();
1138 if (!MAI->doesSetDirectiveSuppressReloc()) {
1139 emitValue(Diff, Size);
1140 return;
1141 }
1142
1143 // Otherwise, emit with .set (aka assignment).
1144 MCSymbol *SetLabel = Context.createTempSymbol("set");
1145 emitAssignment(SetLabel, Diff);
1146 emitSymbolValue(SetLabel, Size);
1147}
1148
1150 const MCSymbol *Lo) {
1151 // Get the Hi-Lo expression.
1152 const MCExpr *Diff =
1154 MCSymbolRefExpr::create(Lo, Context), Context);
1155
1156 emitULEB128Value(Diff);
1157}
1158
1161void MCStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
1163 llvm_unreachable("this directive only supported on COFF targets");
1164}
1166 llvm_unreachable("this directive only supported on COFF targets");
1167}
1170 StringRef CompilerVersion,
1171 StringRef TimeStamp, StringRef Description) {
1172}
1174 llvm_unreachable("this directive only supported on COFF targets");
1175}
1177 llvm_unreachable("this directive only supported on COFF targets");
1178}
1180 MCSymbol *CsectSym,
1181 Align Alignment) {
1182 llvm_unreachable("this directive only supported on XCOFF targets");
1183}
1184
1186 MCSymbolAttr Linkage,
1187 MCSymbolAttr Visibility) {
1188 llvm_unreachable("emitXCOFFSymbolLinkageWithVisibility is only supported on "
1189 "XCOFF targets");
1190}
1191
1193 StringRef Rename) {}
1194
1196 llvm_unreachable("emitXCOFFRefDirective is only supported on XCOFF targets");
1197}
1198
1200 const MCSymbol *Trap,
1201 unsigned Lang, unsigned Reason,
1202 unsigned FunctionSize,
1203 bool hasDebug) {
1204 report_fatal_error("emitXCOFFExceptDirective is only supported on "
1205 "XCOFF targets");
1206}
1207
1209 llvm_unreachable("emitXCOFFCInfoSym is only supported on"
1210 "XCOFF targets");
1211}
1212
1215 StringRef Name, bool KeepOriginalSym) {}
1217 Align ByteAlignment) {}
1219 uint64_t Size, Align ByteAlignment) {}
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 // TODO: keep track of the last subsection so that this symbol appears in the
1294 // correct place.
1295 MCSymbol *Sym = Section->getEndSymbol(Context);
1296 if (Sym->isInSection())
1297 return Sym;
1298
1299 switchSection(Section);
1300 emitLabel(Sym);
1301 return Sym;
1302}
1303
1304static VersionTuple
1306 VersionTuple TargetVersion) {
1307 VersionTuple Min = Target.getMinimumSupportedOSVersion();
1308 return !Min.empty() && Min > TargetVersion ? Min : TargetVersion;
1309}
1310
1311static MCVersionMinType
1313 assert(Target.isOSDarwin() && "expected a darwin OS");
1314 switch (Target.getOS()) {
1315 case Triple::MacOSX:
1316 case Triple::Darwin:
1317 return MCVM_OSXVersionMin;
1318 case Triple::IOS:
1319 assert(!Target.isMacCatalystEnvironment() &&
1320 "mac Catalyst should use LC_BUILD_VERSION");
1321 return MCVM_IOSVersionMin;
1322 case Triple::TvOS:
1323 return MCVM_TvOSVersionMin;
1324 case Triple::WatchOS:
1326 default:
1327 break;
1328 }
1329 llvm_unreachable("unexpected OS type");
1330}
1331
1333 assert(Target.isOSDarwin() && "expected a darwin OS");
1334 switch (Target.getOS()) {
1335 case Triple::MacOSX:
1336 case Triple::Darwin:
1337 return VersionTuple(10, 14);
1338 case Triple::IOS:
1339 // Mac Catalyst always uses the build version load command.
1340 if (Target.isMacCatalystEnvironment())
1341 return VersionTuple();
1342 [[fallthrough]];
1343 case Triple::TvOS:
1344 return VersionTuple(12);
1345 case Triple::WatchOS:
1346 return VersionTuple(5);
1347 case Triple::DriverKit:
1348 // DriverKit always uses the build version load command.
1349 return VersionTuple();
1350 case Triple::XROS:
1351 // XROS always uses the build version load command.
1352 return VersionTuple();
1353 default:
1354 break;
1355 }
1356 llvm_unreachable("unexpected OS type");
1357}
1358
1361 assert(Target.isOSDarwin() && "expected a darwin OS");
1362 switch (Target.getOS()) {
1363 case Triple::MacOSX:
1364 case Triple::Darwin:
1365 return MachO::PLATFORM_MACOS;
1366 case Triple::IOS:
1367 if (Target.isMacCatalystEnvironment())
1368 return MachO::PLATFORM_MACCATALYST;
1369 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_IOSSIMULATOR
1370 : MachO::PLATFORM_IOS;
1371 case Triple::TvOS:
1372 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_TVOSSIMULATOR
1373 : MachO::PLATFORM_TVOS;
1374 case Triple::WatchOS:
1375 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_WATCHOSSIMULATOR
1376 : MachO::PLATFORM_WATCHOS;
1377 case Triple::DriverKit:
1378 return MachO::PLATFORM_DRIVERKIT;
1379 case Triple::XROS:
1380 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_XROS_SIMULATOR
1381 : MachO::PLATFORM_XROS;
1382 default:
1383 break;
1384 }
1385 llvm_unreachable("unexpected OS type");
1386}
1387
1389 const Triple &Target, const VersionTuple &SDKVersion,
1390 const Triple *DarwinTargetVariantTriple,
1391 const VersionTuple &DarwinTargetVariantSDKVersion) {
1392 if (!Target.isOSBinFormatMachO() || !Target.isOSDarwin())
1393 return;
1394 // Do we even know the version?
1395 if (Target.getOSMajorVersion() == 0)
1396 return;
1397
1399 switch (Target.getOS()) {
1400 case Triple::MacOSX:
1401 case Triple::Darwin:
1402 Target.getMacOSXVersion(Version);
1403 break;
1404 case Triple::IOS:
1405 case Triple::TvOS:
1406 Version = Target.getiOSVersion();
1407 break;
1408 case Triple::WatchOS:
1409 Version = Target.getWatchOSVersion();
1410 break;
1411 case Triple::DriverKit:
1412 Version = Target.getDriverKitVersion();
1413 break;
1414 case Triple::XROS:
1415 Version = Target.getOSVersion();
1416 break;
1417 default:
1418 llvm_unreachable("unexpected OS type");
1419 }
1420 assert(Version.getMajor() != 0 && "A non-zero major version is expected");
1421 auto LinkedTargetVersion =
1423 auto BuildVersionOSVersion = getMachoBuildVersionSupportedOS(Target);
1424 bool ShouldEmitBuildVersion = false;
1425 if (BuildVersionOSVersion.empty() ||
1426 LinkedTargetVersion >= BuildVersionOSVersion) {
1427 if (Target.isMacCatalystEnvironment() && DarwinTargetVariantTriple &&
1428 DarwinTargetVariantTriple->isMacOSX()) {
1429 emitVersionForTarget(*DarwinTargetVariantTriple,
1430 DarwinTargetVariantSDKVersion,
1431 /*DarwinTargetVariantTriple=*/nullptr,
1432 /*DarwinTargetVariantSDKVersion=*/VersionTuple());
1435 LinkedTargetVersion.getMajor(),
1436 LinkedTargetVersion.getMinor().value_or(0),
1437 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1438 return;
1439 }
1441 LinkedTargetVersion.getMajor(),
1442 LinkedTargetVersion.getMinor().value_or(0),
1443 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1444 ShouldEmitBuildVersion = true;
1445 }
1446
1447 if (const Triple *TVT = DarwinTargetVariantTriple) {
1448 if (Target.isMacOSX() && TVT->isMacCatalystEnvironment()) {
1449 auto TVLinkedTargetVersion =
1450 targetVersionOrMinimumSupportedOSVersion(*TVT, TVT->getiOSVersion());
1453 TVLinkedTargetVersion.getMajor(),
1454 TVLinkedTargetVersion.getMinor().value_or(0),
1455 TVLinkedTargetVersion.getSubminor().value_or(0),
1456 DarwinTargetVariantSDKVersion);
1457 }
1458 }
1459
1460 if (ShouldEmitBuildVersion)
1461 return;
1462
1464 LinkedTargetVersion.getMajor(),
1465 LinkedTargetVersion.getMinor().value_or(0),
1466 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1467}
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:819
static MachO::PlatformType getMachoBuildVersionPlatformType(const Triple &Target)
static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg)
Definition: MCStreamer.cpp:867
#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:77
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:45
MCCVFunctionInfo * getCVFunctionInfo(unsigned FuncId)
Retreive the function info if this is a valid function id, or nullptr.
Definition: MCCodeView.cpp:77
bool recordFunctionId(unsigned FuncId)
Records the function id of a normal function.
Definition: MCCodeView.cpp:85
bool recordInlinedCallSiteId(unsigned FuncId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol)
Records the function id of an inlined call site.
Definition: MCCodeView.cpp:98
unsigned size() const
Definition: DenseMap.h:99
Tagged union holding either a T or a Error.
Definition: Error.h:481
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:43
virtual uint32_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI, const MCContext *Ctxt) const
Generate the compact unwind encoding for the CFI instructions.
Definition: MCAsmBackend.h:235
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
StringRef getPrivateGlobalPrefix() const
Definition: MCAsmInfo.h:664
bool hasCOFFAssociativeComdats() const
Definition: MCAsmInfo.h:629
bool isLittleEndian() const
True if the target is little endian.
Definition: MCAsmInfo.h:555
const std::vector< MCCFIInstruction > & getInitialFrameState() const
Definition: MCAsmInfo.h:833
const char * getData8bitsDirective() const
Definition: MCAsmInfo.h:564
bool doesSetDirectiveSuppressReloc() const
Definition: MCAsmInfo.h:727
bool usesWindowsCFI() const
Definition: MCAsmInfo.h:799
Binary assembler expressions.
Definition: MCExpr.h:492
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition: MCExpr.h:639
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition: MCExpr.h:642
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:621
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_def_cfa_register modifies a rule for computing CFA.
Definition: MCDwarf.h:548
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition: MCDwarf.h:583
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_undefined From now on the previous value of Register can't be restored anymore.
Definition: MCDwarf.h:623
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int Offset, SMLoc Loc={})
.cfi_def_cfa_offset modifies a rule for computing CFA.
Definition: MCDwarf.h:556
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int Offset, SMLoc Loc={})
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register.
Definition: MCDwarf.h:591
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
Definition: MCDwarf.h:616
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2, SMLoc Loc={})
.cfi_register Previous value of Register1 is saved in register Register2.
Definition: MCDwarf.h:598
static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register, int Offset, unsigned AddressSpace, SMLoc Loc)
.cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to be the result of evaluating the DW...
Definition: MCDwarf.h:573
static MCCFIInstruction createNegateRAState(MCSymbol *L, SMLoc Loc={})
.cfi_negate_ra_state AArch64 negate RA state.
Definition: MCDwarf.h:609
static MCCFIInstruction createRememberState(MCSymbol *L, SMLoc Loc={})
.cfi_remember_state Save all current rules for all registers.
Definition: MCDwarf.h:636
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition: MCDwarf.h:541
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment, SMLoc Loc={})
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
Definition: MCDwarf.h:564
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, SMLoc Loc={}, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Definition: MCDwarf.h:647
static MCCFIInstruction createWindowSave(MCSymbol *L, SMLoc Loc={})
.cfi_window_save SPARC register window is saved.
Definition: MCDwarf.h:604
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size, SMLoc Loc={})
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
Definition: MCDwarf.h:653
static MCCFIInstruction createRestoreState(MCSymbol *L, SMLoc Loc={})
.cfi_restore_state Restore the previously saved state.
Definition: MCDwarf.h:641
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_same_value Current value of Register is the same as in the previous frame.
Definition: MCDwarf.h:630
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:194
Context object for machine code objects.
Definition: MCContext.h:83
MCPseudoProbeTable & getMCPseudoProbeTable()
Definition: MCContext.h:850
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:413
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Definition: MCContext.cpp:345
Expected< unsigned > getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
Definition: MCContext.cpp:978
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:708
CodeViewContext & getCVContext()
Definition: MCContext.cpp:1006
const MCRegisterInfo * getRegisterInfo() const
Definition: MCContext.h:411
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:749
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
Definition: MCContext.cpp:681
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:409
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1061
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:212
dwarf::DwarfFormat getDwarfFormat() const
Definition: MCContext.h:805
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:718
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:732
const Triple & getTargetTriple() const
Definition: MCContext.h:397
void setLabel(MCSymbol *Label)
Definition: MCDwarf.h:406
MCSymbol * getLabel() const
Definition: MCDwarf.h:402
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
@ Unary
Unary expressions.
Definition: MCExpr.h:41
@ Constant
Constant expressions.
Definition: MCExpr.h:39
@ SymbolRef
References to labels and assigned expressions.
Definition: MCExpr.h:40
@ Target
Target specific expression.
Definition: MCExpr.h:42
@ Binary
Binary expressions.
Definition: MCExpr.h:38
ExprKind getKind() const
Definition: MCExpr.h:81
SMLoc getLoc() const
Definition: MCExpr.h:82
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:35
Streaming machine code generation interface.
Definition: MCStreamer.h:212
virtual void emitCFIGnuArgsSize(int64_t Size, SMLoc Loc={})
Definition: MCStreamer.cpp:637
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 emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc={})
Definition: MCStreamer.cpp:495
virtual void visitUsedSymbol(const MCSymbol &Sym)
void emitCFIStartProc(bool IsSimple, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:447
virtual bool emitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
Definition: MCStreamer.cpp:301
virtual void finishImpl()
Streamer specific finalization.
void assignFragment(MCSymbol *Symbol, MCFragment *Fragment)
Sets the symbol's section.
Definition: MCStreamer.cpp:414
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:865
virtual void emitWinCFIPushReg(MCRegister Register, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:871
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:489
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:790
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:853
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:607
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:694
virtual void emitCOFFSymbolType(int Type)
Emit the type of the symbol.
virtual void emitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:569
virtual void emitDwarfUnitLength(uint64_t Length, const Twine &Comment)
Emit a unit length field.
virtual void emitCFIWindowSave(SMLoc Loc={})
Definition: MCStreamer.cpp:675
virtual void emitCOFFSymbolIndex(MCSymbol const *Symbol)
Emits the symbol table index of a Symbol into the current section.
Definition: MCStreamer.cpp:980
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:986
virtual void endCOFFSymbolDef()
Marks the end of the symbol definition.
virtual void emitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:954
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:807
virtual MCAssembler * getAssemblerPtr()
Definition: MCStreamer.h:301
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:654
void setTargetStreamer(MCTargetStreamer *TS)
Definition: MCStreamer.h:284
virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:939
virtual void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
Definition: MCStreamer.cpp:472
virtual void emitCFINegateRAState(SMLoc Loc={})
Definition: MCStreamer.cpp:684
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:578
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: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:361
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:984
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
Definition: MCStreamer.cpp:859
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:716
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:627
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:423
virtual void emitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
Definition: MCStreamer.cpp:982
virtual void emitCFIRememberState(SMLoc Loc)
Definition: MCStreamer.cpp:586
virtual void reset()
State management.
Definition: MCStreamer.cpp:101
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:445
MCTargetStreamer * getTargetStreamer()
Definition: MCStreamer.h:306
MCStreamer(MCContext &Ctx)
Definition: MCStreamer.cpp:93
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:495
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:922
virtual void emitWinCFIEndChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:776
virtual void emitWinCFIEndProlog(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:968
virtual void emitWinCFIEndProc(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:734
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:483
virtual void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
Set the DescValue for the Symbol.
virtual void emitCFIDefCfaRegister(int64_t Register, SMLoc Loc={})
Definition: MCStreamer.cpp:526
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:664
virtual void emitCOFFSafeSEH(MCSymbol const *Symbol)
Definition: MCStreamer.cpp:978
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:752
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:815
virtual void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc={})
Definition: MCStreamer.cpp:516
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:559
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:701
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:596
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:733
virtual void emitCFIOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
Definition: MCStreamer.cpp:549
virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:883
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:506
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:905
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:395
virtual void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
void emitRawText(const Twine &String)
If this file is backed by a assembly streamer, this dumps the specified string in the output ....
void emitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Definition: MCStreamer.cpp:229
unsigned emitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:171
virtual bool emitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol, SMLoc Loc)
Introduces an inline call site id for use with .cv_loc.
Definition: MCStreamer.cpp:305
virtual void emitCFISignalFrame()
Definition: MCStreamer.cpp:647
virtual void emitVersionMin(MCVersionMinType Type, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Specify the Mach-O minimum deployment target version.
Definition: MCStreamer.h:485
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:442
virtual void emitWinCFIStartChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:763
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:617
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:991
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:491
virtual void changeSection(MCSection *, uint32_t)
Update streamer for a new active section.
virtual void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset, int64_t AddressSpace, SMLoc Loc={})
Definition: MCStreamer.cpp:537
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:192
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:397
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
Target specific streamer interface.
Definition: MCStreamer.h:93
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:95
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:456
@ Length
Definition: DWP.cpp:456
void StoreIntToMemory(const APInt &IntVal, uint8_t *Dst, unsigned StoreBytes)
StoreIntToMemory - Fills the StoreBytes bytes of memory starting from Dst with the integer held in In...
Definition: APInt.cpp:3020
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:239
AddressSpace
Definition: NVPTXBaseInfo.h:21
std::pair< MCSection *, uint32_t > MCSectionSubPair
Definition: MCStreamer.h:66
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:244
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
Definition: LEB128.h:23
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
Definition: LEB128.h:80
MCSymbolAttr
Definition: MCDirectives.h:18
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Information describing a function or inlined call site introduced by .cv_func_id or ....
Definition: MCCodeView.h:98
MCSection * Section
The section of the first .cv_loc directive used for this function, or null if none has been seen yet.
Definition: MCCodeView.h:118
const MCSymbol * Personality
Definition: MCDwarf.h:702
unsigned PersonalityEncoding
Definition: MCDwarf.h:706
std::vector< MCCFIInstruction > Instructions
Definition: MCDwarf.h:704
unsigned LsdaEncoding
Definition: MCDwarf.h:707
const MCSymbol * Lsda
Definition: MCDwarf.h:703
unsigned CurrentCfaRegister
Definition: MCDwarf.h:705
static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition: MCWin64EH.h:42
static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg)
Definition: MCWin64EH.h:26
static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code)
Definition: MCWin64EH.h:33
static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition: MCWin64EH.h:36
static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size)
Definition: MCWin64EH.h:29
static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off)
Definition: MCWin64EH.h:48
std::vector< Instruction > Instructions
Definition: MCWinEH.h:58
const MCSymbol * Function
Definition: MCWinEH.h:44
MCSection * TextSection
Definition: MCWinEH.h:47
const MCSymbol * PrologEnd
Definition: MCWinEH.h:45
const MCSymbol * FuncletOrFuncEnd
Definition: MCWinEH.h:42
const MCSymbol * End
Definition: MCWinEH.h:41
const FrameInfo * ChainedParent
Definition: MCWinEH.h:57
const MCSymbol * ExceptionHandler
Definition: MCWinEH.h:43