LLVM  10.0.0svn
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 
9 #include "llvm/MC/MCStreamer.h"
10 #include "llvm/ADT/Optional.h"
11 #include "llvm/ADT/SmallString.h"
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/ADT/Twine.h"
14 #include "llvm/BinaryFormat/COFF.h"
15 #include "llvm/MC/MCAsmBackend.h"
16 #include "llvm/MC/MCAsmInfo.h"
17 #include "llvm/MC/MCCodeView.h"
18 #include "llvm/MC/MCContext.h"
19 #include "llvm/MC/MCDwarf.h"
20 #include "llvm/MC/MCExpr.h"
21 #include "llvm/MC/MCInst.h"
22 #include "llvm/MC/MCInstPrinter.h"
24 #include "llvm/MC/MCSection.h"
25 #include "llvm/MC/MCSectionCOFF.h"
26 #include "llvm/MC/MCSymbol.h"
27 #include "llvm/MC/MCWin64EH.h"
28 #include "llvm/MC/MCWinEH.h"
29 #include "llvm/Support/Casting.h"
31 #include "llvm/Support/LEB128.h"
34 #include <cassert>
35 #include <cstdint>
36 #include <cstdlib>
37 #include <utility>
38 
39 using namespace llvm;
40 
42  S.setTargetStreamer(this);
43 }
44 
45 // Pin the vtables to this file.
47 
49 
51 
54  const MCExpr *Subsection,
55  raw_ostream &OS) {
56  Section->PrintSwitchToSection(
59  Subsection);
60 }
61 
63  Streamer.EmitRawText(Directive);
64 }
65 
67  SmallString<128> Str;
68  raw_svector_ostream OS(Str);
69 
70  Value->print(OS, Streamer.getContext().getAsmInfo());
71  Streamer.EmitRawText(OS.str());
72 }
73 
75  const MCAsmInfo *MAI = Streamer.getContext().getAsmInfo();
76  const char *Directive = MAI->getData8bitsDirective();
77  for (const unsigned char C : Data.bytes()) {
78  SmallString<128> Str;
79  raw_svector_ostream OS(Str);
80 
81  OS << Directive << (unsigned)C;
82  Streamer.EmitRawText(OS.str());
83  }
84 }
85 
87 
89  : Context(Ctx), CurrentWinFrameInfo(nullptr),
90  UseAssemblerInfoForParsing(false) {
91  SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
92 }
93 
95 
97  DwarfFrameInfos.clear();
98  CurrentWinFrameInfo = nullptr;
99  WinFrameInfos.clear();
100  SymbolOrdering.clear();
101  SectionStack.clear();
102  SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
103 }
104 
106  // By default, discard comments.
107  return nulls();
108 }
109 
110 unsigned MCStreamer::getNumFrameInfos() { return DwarfFrameInfos.size(); }
112  return DwarfFrameInfos;
113 }
114 
115 void MCStreamer::emitRawComment(const Twine &T, bool TabPrefix) {}
116 
119 
121  for (auto &FI : DwarfFrameInfos)
122  FI.CompactUnwindEncoding =
123  (MAB ? MAB->generateCompactUnwindEncoding(FI.Instructions) : 0);
124 }
125 
126 /// EmitIntValue - Special case of EmitValue that avoids the client having to
127 /// pass in a MCExpr for constant integers.
128 void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
129  assert(1 <= Size && Size <= 8 && "Invalid size");
130  assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
131  "Invalid size");
132  char buf[8];
133  const bool isLittleEndian = Context.getAsmInfo()->isLittleEndian();
134  for (unsigned i = 0; i != Size; ++i) {
135  unsigned index = isLittleEndian ? i : (Size - i - 1);
136  buf[i] = uint8_t(Value >> (index * 8));
137  }
138  EmitBytes(StringRef(buf, Size));
139 }
140 
141 /// EmitULEB128IntValue - Special case of EmitULEB128Value that avoids the
142 /// client having to pass in a MCExpr for constant integers.
143 void MCStreamer::EmitULEB128IntValue(uint64_t Value, unsigned PadTo) {
144  SmallString<128> Tmp;
145  raw_svector_ostream OSE(Tmp);
146  encodeULEB128(Value, OSE, PadTo);
147  EmitBytes(OSE.str());
148 }
149 
150 /// EmitSLEB128IntValue - Special case of EmitSLEB128Value that avoids the
151 /// client having to pass in a MCExpr for constant integers.
153  SmallString<128> Tmp;
154  raw_svector_ostream OSE(Tmp);
155  encodeSLEB128(Value, OSE);
156  EmitBytes(OSE.str());
157 }
158 
159 void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc) {
160  EmitValueImpl(Value, Size, Loc);
161 }
162 
163 void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
164  bool IsSectionRelative) {
165  assert((!IsSectionRelative || Size == 4) &&
166  "SectionRelative value requires 4-bytes");
167 
168  if (!IsSectionRelative)
170  else
171  EmitCOFFSecRel32(Sym, /*Offset=*/0);
172 }
173 
175  report_fatal_error("unsupported directive in streamer");
176 }
177 
179  report_fatal_error("unsupported directive in streamer");
180 }
181 
183  report_fatal_error("unsupported directive in streamer");
184 }
185 
187  report_fatal_error("unsupported directive in streamer");
188 }
189 
191  report_fatal_error("unsupported directive in streamer");
192 }
193 
195  report_fatal_error("unsupported directive in streamer");
196 }
197 
198 /// Emit NumBytes bytes worth of the value specified by FillValue.
199 /// This implements directives such as '.space'.
200 void MCStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
201  emitFill(*MCConstantExpr::create(NumBytes, getContext()), FillValue);
202 }
203 
204 /// The implementation in this class just redirects to emitFill.
205 void MCStreamer::EmitZeros(uint64_t NumBytes) {
206  emitFill(NumBytes, 0);
207 }
208 
211  StringRef Filename,
212  Optional<MD5::MD5Result> Checksum,
214  unsigned CUID) {
215  return getContext().getDwarfFile(Directory, Filename, FileNo, Checksum,
216  Source, CUID);
217 }
218 
220  StringRef Filename,
221  Optional<MD5::MD5Result> Checksum,
223  unsigned CUID) {
224  getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
225  Source);
226 }
227 
229  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
230  if (!CurFrame)
231  return;
232  CurFrame->IsBKeyFrame = true;
233 }
234 
235 void MCStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
236  unsigned Column, unsigned Flags,
237  unsigned Isa,
238  unsigned Discriminator,
239  StringRef FileName) {
240  getContext().setCurrentDwarfLoc(FileNo, Line, Column, Flags, Isa,
241  Discriminator);
242 }
243 
246  if (!Table.getLabel()) {
248  Table.setLabel(
249  Context.getOrCreateSymbol(Prefix + "line_table_start" + Twine(CUID)));
250  }
251  return Table.getLabel();
252 }
253 
255  return !DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End;
256 }
257 
258 MCDwarfFrameInfo *MCStreamer::getCurrentDwarfFrameInfo() {
260  getContext().reportError(SMLoc(), "this directive must appear between "
261  ".cfi_startproc and .cfi_endproc "
262  "directives");
263  return nullptr;
264  }
265  return &DwarfFrameInfos.back();
266 }
267 
268 bool MCStreamer::EmitCVFileDirective(unsigned FileNo, StringRef Filename,
269  ArrayRef<uint8_t> Checksum,
270  unsigned ChecksumKind) {
271  return getContext().getCVContext().addFile(*this, FileNo, Filename, Checksum,
272  ChecksumKind);
273 }
274 
275 bool MCStreamer::EmitCVFuncIdDirective(unsigned FunctionId) {
276  return getContext().getCVContext().recordFunctionId(FunctionId);
277 }
278 
280  unsigned IAFunc, unsigned IAFile,
281  unsigned IALine, unsigned IACol,
282  SMLoc Loc) {
283  if (getContext().getCVContext().getCVFunctionInfo(IAFunc) == nullptr) {
284  getContext().reportError(Loc, "parent function id not introduced by "
285  ".cv_func_id or .cv_inline_site_id");
286  return true;
287  }
288 
290  FunctionId, IAFunc, IAFile, IALine, IACol);
291 }
292 
293 void MCStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
294  unsigned Line, unsigned Column,
295  bool PrologueEnd, bool IsStmt,
296  StringRef FileName, SMLoc Loc) {}
297 
298 bool MCStreamer::checkCVLocSection(unsigned FuncId, unsigned FileNo,
299  SMLoc Loc) {
301  MCCVFunctionInfo *FI = CVC.getCVFunctionInfo(FuncId);
302  if (!FI) {
304  Loc, "function id not introduced by .cv_func_id or .cv_inline_site_id");
305  return false;
306  }
307 
308  // Track the section
309  if (FI->Section == nullptr)
311  else if (FI->Section != getCurrentSectionOnly()) {
313  Loc,
314  "all .cv_loc directives for a function must be in the same section");
315  return false;
316  }
317  return true;
318 }
319 
320 void MCStreamer::EmitCVLinetableDirective(unsigned FunctionId,
321  const MCSymbol *Begin,
322  const MCSymbol *End) {}
323 
324 void MCStreamer::EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
325  unsigned SourceFileId,
326  unsigned SourceLineNum,
327  const MCSymbol *FnStartSym,
328  const MCSymbol *FnEndSym) {}
329 
330 /// Only call this on endian-specific types like ulittle16_t and little32_t, or
331 /// structs composed of them.
332 template <typename T>
333 static void copyBytesForDefRange(SmallString<20> &BytePrefix,
334  codeview::SymbolKind SymKind,
335  const T &DefRangeHeader) {
336  BytePrefix.resize(2 + sizeof(T));
337  codeview::ulittle16_t SymKindLE = codeview::ulittle16_t(SymKind);
338  memcpy(&BytePrefix[0], &SymKindLE, 2);
339  memcpy(&BytePrefix[2], &DefRangeHeader, sizeof(T));
340 }
341 
343  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
344  StringRef FixedSizePortion) {}
345 
347  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
349  SmallString<20> BytePrefix;
350  copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_REGISTER_REL, DRHdr);
351  EmitCVDefRangeDirective(Ranges, BytePrefix);
352 }
353 
355  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
357  SmallString<20> BytePrefix;
358  copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_SUBFIELD_REGISTER,
359  DRHdr);
360  EmitCVDefRangeDirective(Ranges, BytePrefix);
361 }
362 
364  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
366  SmallString<20> BytePrefix;
367  copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_REGISTER, DRHdr);
368  EmitCVDefRangeDirective(Ranges, BytePrefix);
369 }
370 
372  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
374  SmallString<20> BytePrefix;
375  copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_FRAMEPOINTER_REL,
376  DRHdr);
377  EmitCVDefRangeDirective(Ranges, BytePrefix);
378 }
379 
381  MCSymbol *EHSymbol) {
382 }
383 
384 void MCStreamer::InitSections(bool NoExecStack) {
385  SwitchSection(getContext().getObjectFileInfo()->getTextSection());
386 }
387 
389  assert(Fragment);
390  Symbol->setFragment(Fragment);
391 
392  // As we emit symbols into a section, track the order so that they can
393  // be sorted upon later. Zero is reserved to mean 'unemitted'.
394  SymbolOrdering[Symbol] = 1 + SymbolOrdering.size();
395 }
396 
398  Symbol->redefineIfPossible();
399 
400  if (!Symbol->isUndefined() || Symbol->isVariable())
401  return getContext().reportError(Loc, "invalid symbol redefinition");
402 
403  assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
404  assert(getCurrentSectionOnly() && "Cannot emit before setting section!");
405  assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
406  assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
407 
408  Symbol->setFragment(&getCurrentSectionOnly()->getDummyFragment());
409 
411  if (TS)
412  TS->emitLabel(Symbol);
413 }
414 
415 void MCStreamer::EmitCFISections(bool EH, bool Debug) {
416  assert(EH || Debug);
417 }
418 
419 void MCStreamer::EmitCFIStartProc(bool IsSimple, SMLoc Loc) {
421  return getContext().reportError(
422  Loc, "starting new .cfi frame before finishing the previous one");
423 
424  MCDwarfFrameInfo Frame;
425  Frame.IsSimple = IsSimple;
426  EmitCFIStartProcImpl(Frame);
427 
428  const MCAsmInfo* MAI = Context.getAsmInfo();
429  if (MAI) {
430  for (const MCCFIInstruction& Inst : MAI->getInitialFrameState()) {
431  if (Inst.getOperation() == MCCFIInstruction::OpDefCfa ||
432  Inst.getOperation() == MCCFIInstruction::OpDefCfaRegister) {
433  Frame.CurrentCfaRegister = Inst.getRegister();
434  }
435  }
436  }
437 
438  DwarfFrameInfos.push_back(Frame);
439 }
440 
442 }
443 
445  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
446  if (!CurFrame)
447  return;
448  EmitCFIEndProcImpl(*CurFrame);
449 }
450 
452  // Put a dummy non-null value in Frame.End to mark that this frame has been
453  // closed.
454  Frame.End = (MCSymbol *)1;
455 }
456 
458  // Return a dummy non-null value so that label fields appear filled in when
459  // generating textual assembly.
460  return (MCSymbol *)1;
461 }
462 
463 void MCStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
464  MCSymbol *Label = EmitCFILabel();
466  MCCFIInstruction::createDefCfa(Label, Register, Offset);
467  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
468  if (!CurFrame)
469  return;
470  CurFrame->Instructions.push_back(Instruction);
471  CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
472 }
473 
475  MCSymbol *Label = EmitCFILabel();
478  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
479  if (!CurFrame)
480  return;
481  CurFrame->Instructions.push_back(Instruction);
482 }
483 
484 void MCStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
485  MCSymbol *Label = EmitCFILabel();
487  MCCFIInstruction::createAdjustCfaOffset(Label, Adjustment);
488  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
489  if (!CurFrame)
490  return;
491  CurFrame->Instructions.push_back(Instruction);
492 }
493 
495  MCSymbol *Label = EmitCFILabel();
498  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
499  if (!CurFrame)
500  return;
501  CurFrame->Instructions.push_back(Instruction);
502  CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
503 }
504 
505 void MCStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
506  MCSymbol *Label = EmitCFILabel();
508  MCCFIInstruction::createOffset(Label, Register, Offset);
509  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
510  if (!CurFrame)
511  return;
512  CurFrame->Instructions.push_back(Instruction);
513 }
514 
516  MCSymbol *Label = EmitCFILabel();
518  MCCFIInstruction::createRelOffset(Label, Register, Offset);
519  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
520  if (!CurFrame)
521  return;
522  CurFrame->Instructions.push_back(Instruction);
523 }
524 
526  unsigned Encoding) {
527  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
528  if (!CurFrame)
529  return;
530  CurFrame->Personality = Sym;
531  CurFrame->PersonalityEncoding = Encoding;
532 }
533 
534 void MCStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
535  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
536  if (!CurFrame)
537  return;
538  CurFrame->Lsda = Sym;
539  CurFrame->LsdaEncoding = Encoding;
540 }
541 
543  MCSymbol *Label = EmitCFILabel();
545  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
546  if (!CurFrame)
547  return;
548  CurFrame->Instructions.push_back(Instruction);
549 }
550 
552  // FIXME: Error if there is no matching cfi_remember_state.
553  MCSymbol *Label = EmitCFILabel();
555  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
556  if (!CurFrame)
557  return;
558  CurFrame->Instructions.push_back(Instruction);
559 }
560 
562  MCSymbol *Label = EmitCFILabel();
564  MCCFIInstruction::createSameValue(Label, Register);
565  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
566  if (!CurFrame)
567  return;
568  CurFrame->Instructions.push_back(Instruction);
569 }
570 
572  MCSymbol *Label = EmitCFILabel();
574  MCCFIInstruction::createRestore(Label, Register);
575  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
576  if (!CurFrame)
577  return;
578  CurFrame->Instructions.push_back(Instruction);
579 }
580 
582  MCSymbol *Label = EmitCFILabel();
584  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
585  if (!CurFrame)
586  return;
587  CurFrame->Instructions.push_back(Instruction);
588 }
589 
591  MCSymbol *Label = EmitCFILabel();
594  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
595  if (!CurFrame)
596  return;
597  CurFrame->Instructions.push_back(Instruction);
598 }
599 
601  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
602  if (!CurFrame)
603  return;
604  CurFrame->IsSignalFrame = true;
605 }
606 
608  MCSymbol *Label = EmitCFILabel();
610  MCCFIInstruction::createUndefined(Label, Register);
611  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
612  if (!CurFrame)
613  return;
614  CurFrame->Instructions.push_back(Instruction);
615 }
616 
617 void MCStreamer::EmitCFIRegister(int64_t Register1, int64_t Register2) {
618  MCSymbol *Label = EmitCFILabel();
620  MCCFIInstruction::createRegister(Label, Register1, Register2);
621  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
622  if (!CurFrame)
623  return;
624  CurFrame->Instructions.push_back(Instruction);
625 }
626 
628  MCSymbol *Label = EmitCFILabel();
631  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
632  if (!CurFrame)
633  return;
634  CurFrame->Instructions.push_back(Instruction);
635 }
636 
638  MCSymbol *Label = EmitCFILabel();
640  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
641  if (!CurFrame)
642  return;
643  CurFrame->Instructions.push_back(Instruction);
644 }
645 
647  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
648  if (!CurFrame)
649  return;
650  CurFrame->RAReg = Register;
651 }
652 
654  const MCAsmInfo *MAI = Context.getAsmInfo();
655  if (!MAI->usesWindowsCFI()) {
657  Loc, ".seh_* directives are not supported on this target");
658  return nullptr;
659  }
660  if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End) {
662  Loc, ".seh_ directive must appear within an active frame");
663  return nullptr;
664  }
665  return CurrentWinFrameInfo;
666 }
667 
669  const MCAsmInfo *MAI = Context.getAsmInfo();
670  if (!MAI->usesWindowsCFI())
671  return getContext().reportError(
672  Loc, ".seh_* directives are not supported on this target");
673  if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End)
675  Loc, "Starting a function before ending the previous one!");
676 
677  MCSymbol *StartProc = EmitCFILabel();
678 
679  WinFrameInfos.emplace_back(
680  std::make_unique<WinEH::FrameInfo>(Symbol, StartProc));
681  CurrentWinFrameInfo = WinFrameInfos.back().get();
682  CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
683 }
684 
686  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
687  if (!CurFrame)
688  return;
689  if (CurFrame->ChainedParent)
690  getContext().reportError(Loc, "Not all chained regions terminated!");
691 
692  MCSymbol *Label = EmitCFILabel();
693  CurFrame->End = Label;
694 }
695 
697  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
698  if (!CurFrame)
699  return;
700  if (CurFrame->ChainedParent)
701  getContext().reportError(Loc, "Not all chained regions terminated!");
702 
703  MCSymbol *Label = EmitCFILabel();
704  CurFrame->FuncletOrFuncEnd = Label;
705 }
706 
708  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
709  if (!CurFrame)
710  return;
711 
712  MCSymbol *StartProc = EmitCFILabel();
713 
714  WinFrameInfos.emplace_back(std::make_unique<WinEH::FrameInfo>(
715  CurFrame->Function, StartProc, CurFrame));
716  CurrentWinFrameInfo = WinFrameInfos.back().get();
717  CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
718 }
719 
721  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
722  if (!CurFrame)
723  return;
724  if (!CurFrame->ChainedParent)
725  return getContext().reportError(
726  Loc, "End of a chained region outside a chained region!");
727 
728  MCSymbol *Label = EmitCFILabel();
729 
730  CurFrame->End = Label;
731  CurrentWinFrameInfo = const_cast<WinEH::FrameInfo *>(CurFrame->ChainedParent);
732 }
733 
734 void MCStreamer::EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except,
735  SMLoc Loc) {
736  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
737  if (!CurFrame)
738  return;
739  if (CurFrame->ChainedParent)
740  return getContext().reportError(
741  Loc, "Chained unwind areas can't have handlers!");
742  CurFrame->ExceptionHandler = Sym;
743  if (!Except && !Unwind)
744  getContext().reportError(Loc, "Don't know what kind of handler this is!");
745  if (Unwind)
746  CurFrame->HandlesUnwind = true;
747  if (Except)
748  CurFrame->HandlesExceptions = true;
749 }
750 
752  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
753  if (!CurFrame)
754  return;
755  if (CurFrame->ChainedParent)
756  getContext().reportError(Loc, "Chained unwind areas can't have handlers!");
757 }
758 
760  const MCSymbolRefExpr *To, uint64_t Count) {
761 }
762 
763 static MCSection *getWinCFISection(MCContext &Context, unsigned *NextWinCFIID,
764  MCSection *MainCFISec,
765  const MCSection *TextSec) {
766  // If this is the main .text section, use the main unwind info section.
767  if (TextSec == Context.getObjectFileInfo()->getTextSection())
768  return MainCFISec;
769 
770  const auto *TextSecCOFF = cast<MCSectionCOFF>(TextSec);
771  auto *MainCFISecCOFF = cast<MCSectionCOFF>(MainCFISec);
772  unsigned UniqueID = TextSecCOFF->getOrAssignWinCFISectionID(NextWinCFIID);
773 
774  // If this section is COMDAT, this unwind section should be COMDAT associative
775  // with its group.
776  const MCSymbol *KeySym = nullptr;
777  if (TextSecCOFF->getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) {
778  KeySym = TextSecCOFF->getCOMDATSymbol();
779 
780  // In a GNU environment, we can't use associative comdats. Instead, do what
781  // GCC does, which is to make plain comdat selectany section named like
782  // ".[px]data$_Z3foov".
783  if (!Context.getAsmInfo()->hasCOFFAssociativeComdats()) {
784  std::string SectionName =
785  (MainCFISecCOFF->getSectionName() + "$" +
786  TextSecCOFF->getSectionName().split('$').second)
787  .str();
788  return Context.getCOFFSection(
789  SectionName,
790  MainCFISecCOFF->getCharacteristics() | COFF::IMAGE_SCN_LNK_COMDAT,
791  MainCFISecCOFF->getKind(), "", COFF::IMAGE_COMDAT_SELECT_ANY);
792  }
793  }
794 
795  return Context.getAssociativeCOFFSection(MainCFISecCOFF, KeySym, UniqueID);
796 }
797 
799  return getWinCFISection(getContext(), &NextWinCFIID,
800  getContext().getObjectFileInfo()->getPDataSection(),
801  TextSec);
802 }
803 
805  return getWinCFISection(getContext(), &NextWinCFIID,
806  getContext().getObjectFileInfo()->getXDataSection(),
807  TextSec);
808 }
809 
811 
813  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
814  if (!CurFrame)
815  return;
816 
817  MCSymbol *Label = EmitCFILabel();
818 
820  CurFrame->Instructions.push_back(Inst);
821 }
822 
824  SMLoc Loc) {
825  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
826  if (!CurFrame)
827  return;
828  if (CurFrame->LastFrameInst >= 0)
829  return getContext().reportError(
830  Loc, "frame register and offset can be set at most once");
831  if (Offset & 0x0F)
832  return getContext().reportError(Loc, "offset is not a multiple of 16");
833  if (Offset > 240)
834  return getContext().reportError(
835  Loc, "frame offset must be less than or equal to 240");
836 
837  MCSymbol *Label = EmitCFILabel();
838 
839  WinEH::Instruction Inst =
840  Win64EH::Instruction::SetFPReg(Label, Register, Offset);
841  CurFrame->LastFrameInst = CurFrame->Instructions.size();
842  CurFrame->Instructions.push_back(Inst);
843 }
844 
846  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
847  if (!CurFrame)
848  return;
849  if (Size == 0)
850  return getContext().reportError(Loc,
851  "stack allocation size must be non-zero");
852  if (Size & 7)
853  return getContext().reportError(
854  Loc, "stack allocation size is not a multiple of 8");
855 
856  MCSymbol *Label = EmitCFILabel();
857 
859  CurFrame->Instructions.push_back(Inst);
860 }
861 
863  SMLoc Loc) {
864  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
865  if (!CurFrame)
866  return;
867 
868  if (Offset & 7)
869  return getContext().reportError(
870  Loc, "register save offset is not 8 byte aligned");
871 
872  MCSymbol *Label = EmitCFILabel();
873 
874  WinEH::Instruction Inst =
875  Win64EH::Instruction::SaveNonVol(Label, Register, Offset);
876  CurFrame->Instructions.push_back(Inst);
877 }
878 
880  SMLoc Loc) {
881  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
882  if (!CurFrame)
883  return;
884  if (Offset & 0x0F)
885  return getContext().reportError(Loc, "offset is not a multiple of 16");
886 
887  MCSymbol *Label = EmitCFILabel();
888 
889  WinEH::Instruction Inst =
890  Win64EH::Instruction::SaveXMM(Label, Register, Offset);
891  CurFrame->Instructions.push_back(Inst);
892 }
893 
895  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
896  if (!CurFrame)
897  return;
898  if (!CurFrame->Instructions.empty())
899  return getContext().reportError(
900  Loc, "If present, PushMachFrame must be the first UOP");
901 
902  MCSymbol *Label = EmitCFILabel();
903 
905  CurFrame->Instructions.push_back(Inst);
906 }
907 
909  WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
910  if (!CurFrame)
911  return;
912 
913  MCSymbol *Label = EmitCFILabel();
914 
915  CurFrame->PrologEnd = Label;
916 }
917 
919 
921 
923 
925 
927 
928 /// EmitRawText - If this file is backed by an assembly streamer, this dumps
929 /// the specified string in the output .s file. This capability is
930 /// indicated by the hasRawTextSupport() predicate.
932  // This is not llvm_unreachable for the sake of out of tree backend
933  // developers who may not have assembly streamers and should serve as a
934  // reminder to not accidentally call EmitRawText in the absence of such.
935  report_fatal_error("EmitRawText called on an MCStreamer that doesn't support "
936  "it (target backend is likely missing an AsmStreamer "
937  "implementation)");
938 }
939 
941  SmallString<128> Str;
943 }
944 
946 }
947 
949  if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) ||
950  (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
951  getContext().reportError(SMLoc(), "Unfinished frame!");
952  return;
953  }
954 
956  if (TS)
957  TS->finish();
958 
959  FinishImpl();
960 }
961 
963  visitUsedExpr(*Value);
964  Symbol->setVariableValue(Value);
965 
967  if (TS)
968  TS->emitAssignment(Symbol, Value);
969 }
970 
972  raw_ostream &OS, const MCInst &Inst,
973  const MCSubtargetInfo &STI) {
974  InstPrinter.printInst(&Inst, OS, "", STI);
975 }
976 
978 }
979 
981  switch (Expr.getKind()) {
982  case MCExpr::Target:
983  cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
984  break;
985 
986  case MCExpr::Constant:
987  break;
988 
989  case MCExpr::Binary: {
990  const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
991  visitUsedExpr(*BE.getLHS());
992  visitUsedExpr(*BE.getRHS());
993  break;
994  }
995 
996  case MCExpr::SymbolRef:
997  visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
998  break;
999 
1000  case MCExpr::Unary:
1001  visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
1002  break;
1003  }
1004 }
1005 
1007  // Scan for values.
1008  for (unsigned i = Inst.getNumOperands(); i--;)
1009  if (Inst.getOperand(i).isExpr())
1010  visitUsedExpr(*Inst.getOperand(i).getExpr());
1011 }
1012 
1014  unsigned Size) {
1015  // Get the Hi-Lo expression.
1016  const MCExpr *Diff =
1018  MCSymbolRefExpr::create(Lo, Context), Context);
1019 
1020  const MCAsmInfo *MAI = Context.getAsmInfo();
1021  if (!MAI->doesSetDirectiveSuppressReloc()) {
1022  EmitValue(Diff, Size);
1023  return;
1024  }
1025 
1026  // Otherwise, emit with .set (aka assignment).
1027  MCSymbol *SetLabel = Context.createTempSymbol("set", true);
1028  EmitAssignment(SetLabel, Diff);
1029  EmitSymbolValue(SetLabel, Size);
1030 }
1031 
1033  const MCSymbol *Lo) {
1034  // Get the Hi-Lo expression.
1035  const MCExpr *Diff =
1037  MCSymbolRefExpr::create(Lo, Context), Context);
1038 
1039  EmitULEB128Value(Diff);
1040 }
1041 
1044 void MCStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
1046  llvm_unreachable("this directive only supported on COFF targets");
1047 }
1049  llvm_unreachable("this directive only supported on COFF targets");
1050 }
1053  llvm_unreachable("this directive only supported on COFF targets");
1054 }
1056  llvm_unreachable("this directive only supported on COFF targets");
1057 }
1059  unsigned ByteAlign) {
1060  llvm_unreachable("this directive only supported on XCOFF targets");
1061 }
1064  const MCSymbol *Aliasee) {}
1066  unsigned ByteAlignment) {}
1068  uint64_t Size, unsigned ByteAlignment) {}
1073 void MCStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) {
1074  visitUsedExpr(*Value);
1075 }
1078 void MCStreamer::emitFill(const MCExpr &NumBytes, uint64_t Value, SMLoc Loc) {}
1079 void MCStreamer::emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
1080  SMLoc Loc) {}
1082  unsigned ValueSize,
1083  unsigned MaxBytesToEmit) {}
1085  unsigned MaxBytesToEmit) {}
1087  SMLoc Loc) {}
1088 void MCStreamer::EmitBundleAlignMode(unsigned AlignPow2) {}
1089 void MCStreamer::EmitBundleLock(bool AlignToEnd) {}
1092 
1094  assert(Section && "Cannot switch to a null section!");
1095  MCSectionSubPair curSection = SectionStack.back().first;
1096  SectionStack.back().second = curSection;
1097  if (MCSectionSubPair(Section, Subsection) != curSection) {
1098  ChangeSection(Section, Subsection);
1099  SectionStack.back().first = MCSectionSubPair(Section, Subsection);
1100  assert(!Section->hasEnded() && "Section already ended");
1101  MCSymbol *Sym = Section->getBeginSymbol();
1102  if (Sym && !Sym->isInSection())
1103  EmitLabel(Sym);
1104  }
1105 }
1106 
1108  // TODO: keep track of the last subsection so that this symbol appears in the
1109  // correct place.
1110  MCSymbol *Sym = Section->getEndSymbol(Context);
1111  if (Sym->isInSection())
1112  return Sym;
1113 
1114  SwitchSection(Section);
1115  EmitLabel(Sym);
1116  return Sym;
1117 }
1118 
1120  const VersionTuple &SDKVersion) {
1121  if (!Target.isOSBinFormatMachO() || !Target.isOSDarwin())
1122  return;
1123  // Do we even know the version?
1124  if (Target.getOSMajorVersion() == 0)
1125  return;
1126 
1127  unsigned Major;
1128  unsigned Minor;
1129  unsigned Update;
1130  if (Target.isMacCatalystEnvironment()) {
1131  // Mac Catalyst always uses the build version load command.
1132  Target.getiOSVersion(Major, Minor, Update);
1133  assert(Major && "A non-zero major version is expected");
1134  EmitBuildVersion(MachO::PLATFORM_MACCATALYST, Major, Minor, Update,
1135  SDKVersion);
1136  return;
1137  }
1138 
1139  MCVersionMinType VersionType;
1140  if (Target.isWatchOS()) {
1141  VersionType = MCVM_WatchOSVersionMin;
1142  Target.getWatchOSVersion(Major, Minor, Update);
1143  } else if (Target.isTvOS()) {
1144  VersionType = MCVM_TvOSVersionMin;
1145  Target.getiOSVersion(Major, Minor, Update);
1146  } else if (Target.isMacOSX()) {
1147  VersionType = MCVM_OSXVersionMin;
1148  if (!Target.getMacOSXVersion(Major, Minor, Update))
1149  Major = 0;
1150  } else {
1151  VersionType = MCVM_IOSVersionMin;
1152  Target.getiOSVersion(Major, Minor, Update);
1153  }
1154  if (Major != 0)
1155  EmitVersionMin(VersionType, Major, Minor, Update, SDKVersion);
1156 }
virtual void EmitBundleUnlock()
Ends a bundle-locked group.
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag)
Note in the output the specified Flag.
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:318
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName)
This implements the DWARF2 &#39;.loc fileno lineno ...&#39; assembler directive.
Definition: MCStreamer.cpp:235
uint64_t CallInst * C
virtual void EmitBundleAlignMode(unsigned AlignPow2)
Set the bundle alignment mode from now on in the section.
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
Definition: Triple.h:481
Profile::FuncID FuncId
Definition: Profile.cpp:321
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:38
bool doesSetDirectiveSuppressReloc() const
Definition: MCAsmInfo.h:538
void getiOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getiOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1114
MCStreamer(MCContext &Ctx)
Definition: MCStreamer.cpp:88
bool usesWindowsCFI() const
Definition: MCAsmInfo.h:598
virtual void EmitCFISameValue(int64_t Register)
Definition: MCStreamer.cpp:561
virtual void EmitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol *>> Ranges, StringRef FixedSizePortion)
This implements the CodeView &#39;.cv_def_range&#39; assembler directive.
Definition: MCStreamer.cpp:342
virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:525
virtual void EmitWinCFIPushReg(unsigned Register, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:812
virtual void EmitSLEB128Value(const MCExpr *Value)
virtual void EmitCFIGnuArgsSize(int64_t Size)
Definition: MCStreamer.cpp:590
LLVMContext & Context
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:940
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:327
void EmitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:152
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:139
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool isVariable() const
isVariable - Check if this is a variable symbol.
Definition: MCSymbol.h:297
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:163
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
Definition: Triple.h:453
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.
virtual void emitELFSymverDirective(StringRef AliasName, const MCSymbol *Aliasee)
Emit an ELF .symver directive.
virtual void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot, const MCSubtargetInfo &STI)=0
Print the specified MCInst to the specified raw_ostream.
virtual void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment=0)
Emit a thread local bss (.tbss) symbol.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
void redefineIfPossible()
Prepare this symbol to be redefined.
Definition: MCSymbol.h:231
virtual void EmitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:668
virtual void EndCOFFSymbolDef()
Marks the end of the symbol definition.
virtual void EmitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Emit/Specify Mach-O build version command.
Definition: MCStreamer.h:459
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:111
const MCSymbol * End
Definition: MCWinEH.h:33
.watchos_version_min
Definition: MCDirectives.h:68
virtual void EmitULEB128Value(const MCExpr *Value)
static MCCFIInstruction createRememberState(MCSymbol *L)
.cfi_remember_state Save all current rules for all registers.
Definition: MCDwarf.h:557
virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol)
Emit an weak reference from Alias to Symbol.
void push_back(const T &Elt)
Definition: SmallVector.h:211
static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition: MCWin64EH.h:36
virtual void EmitWinCFISaveXMM(unsigned Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:879
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition: MCDwarf.h:507
Target specific streamer interface.
Definition: MCStreamer.h:84
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
Definition: Twine.h:455
.ios_version_min
Definition: MCDirectives.h:65
virtual void reset()
State management.
Definition: MCStreamer.cpp:96
unsigned CurrentCfaRegister
Definition: MCDwarf.h:614
virtual void EmitWindowsUnwindTables()
Definition: MCStreamer.cpp:945
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol)
Start emitting COFF symbol definition.
virtual Expected< unsigned > tryEmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, Optional< MD5::MD5Result > Checksum=None, Optional< StringRef > Source=None, unsigned CUID=0)
Associate a filename with a specified logical file number.
Definition: MCStreamer.cpp:210
virtual void EmitDTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
Definition: MCStreamer.cpp:174
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition: Triple.h:472
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition: MCExpr.h:568
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:530
virtual void EmitCFIRegister(int64_t Register1, int64_t Register2)
Definition: MCStreamer.cpp:617
virtual void emitExplicitComments()
Emit added explicit comments.
Definition: MCStreamer.cpp:118
virtual void emitValue(const MCExpr *Value)
Definition: MCStreamer.cpp:66
.macosx_version_min
Definition: MCDirectives.h:66
virtual void emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo)
Emit the absolute difference between two symbols encoded with ULEB128.
detail::packed_endian_specific_integral< uint16_t, little, unaligned > ulittle16_t
Definition: Endian.h:272
virtual void EmitCFIDefCfaOffset(int64_t Offset)
Definition: MCStreamer.cpp:474
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
Definition: MCStreamer.cpp:244
StringRef getPrivateGlobalPrefix() const
Definition: MCAsmInfo.h:501
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
Definition: MCDwarf.h:494
COFF::SymbolStorageClass StorageClass
Definition: COFFYAML.cpp:356
virtual void EmitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
std::vector< Instruction > Instructions
Definition: MCWinEH.h:46
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.
unsigned LsdaEncoding
Definition: MCDwarf.h:616
virtual void EmitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset)
Emits a COFF image relative relocation.
Definition: MCStreamer.cpp:926
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment)
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
Definition: MCDwarf.h:501
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
bool addFile(MCStreamer &OS, unsigned FileNumber, StringRef Filename, ArrayRef< uint8_t > ChecksumBytes, uint8_t ChecksumKind)
Definition: MCCodeView.cpp:46
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
Definition: MCContext.cpp:434
virtual void addExplicitComment(const Twine &T)
Add explicit comment T.
Definition: MCStreamer.cpp:117
virtual void EmitCFISections(bool EH, bool Debug)
Definition: MCStreamer.cpp:415
virtual void EmitGPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
Definition: MCStreamer.cpp:194
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:474
std::vector< MCCFIInstruction > Instructions
Definition: MCDwarf.h:613
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register)
.cfi_undefined From now on the previous value of Register can&#39;t be restored anymore.
Definition: MCDwarf.h:546
virtual void EmitCFIRememberState()
Definition: MCStreamer.cpp:542
MCContext & getContext() const
Definition: MCStreamer.h:251
unsigned getNumFrameInfos()
Definition: MCStreamer.cpp:110
virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:534
virtual void EmitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
Definition: MCStreamer.cpp:190
void AssignFragment(MCSymbol *Symbol, MCFragment *Fragment)
Sets the symbol&#39;s section.
Definition: MCStreamer.cpp:388
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
virtual void EmitWinCFIEndProc(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:685
virtual void EmitCFIEscape(StringRef Values)
Definition: MCStreamer.cpp:581
bool isMacCatalystEnvironment() const
Definition: Triple.h:489
virtual void EmitCOFFSymbolType(int Type)
Emit the type of the symbol.
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
Definition: MCSymbol.h:253
virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:734
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:169
const MCSymbol * Lsda
Definition: MCDwarf.h:612
void setFragment(MCFragment *F) const
Mark the symbol as defined in the fragment F.
Definition: MCSymbol.h:274
iterator_range< const unsigned char * > bytes() const
Definition: StringRef.h:111
virtual uint32_t generateCompactUnwindEncoding(ArrayRef< MCCFIInstruction >) const
Generate the compact unwind encoding for the CFI instructions.
Definition: MCAsmBackend.h:179
Tagged union holding either a T or a Error.
Definition: yaml2obj.h:21
virtual void emitLabel(MCSymbol *Symbol)
Definition: MCStreamer.cpp:48
virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
Definition: MCStreamer.cpp:441
virtual ~MCStreamer()
Definition: MCStreamer.cpp:94
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:558
MCSymbol * getEndSymbol(MCContext &Ctx)
Definition: MCSection.cpp:28
virtual void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc)
This implements the CodeView &#39;.cv_loc&#39; assembler directive.
Definition: MCStreamer.cpp:293
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Definition: MCStreamer.cpp:962
virtual void EmitWinCFIStartChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:707
Context object for machine code objects.
Definition: MCContext.h:65
Expected< unsigned > getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
Definition: MCContext.cpp:647
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&#39;s checksum info...
Definition: MCStreamer.cpp:268
static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg)
Definition: MCWin64EH.h:26
bool hasEnded() const
Definition: MCSection.cpp:34
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:550
virtual void finish()
Definition: MCStreamer.cpp:50
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition: MCExpr.h:571
virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
Definition: MCStreamer.cpp:451
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
Definition: MCStreamer.cpp:111
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
virtual void EmitTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (64-bit TP relative) value.
Definition: MCStreamer.cpp:182
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:115
virtual void EmitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
const MCExpr * getExpr() const
Definition: MCInst.h:95
virtual void EmitCFIRestoreState()
Definition: MCStreamer.cpp:551
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:128
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:159
Unary expressions.
Definition: MCExpr.h:41
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:158
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
Definition: MCExpr.cpp:169
virtual void EmitCFIRestore(int64_t Register)
Definition: MCStreamer.cpp:571
const char * getData8bitsDirective() const
Definition: MCAsmInfo.h:418
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:131
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
virtual void EmitBundleLock(bool AlignToEnd)
The following instructions are a bundle-locked group.
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)
Emit a local common (.lcomm) symbol.
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register)
.cfi_same_value Current value of Register is the same as in the previous frame.
Definition: MCDwarf.h:552
virtual raw_ostream & GetCommentOS()
Return a raw_ostream that comments can be written to.
Definition: MCStreamer.cpp:105
void EmitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Definition: MCStreamer.cpp:205
static MCCFIInstruction createNegateRAState(MCSymbol *L)
.cfi_negate_ra_state AArch64 negate RA state.
Definition: MCDwarf.h:533
Streaming machine code generation interface.
Definition: MCStreamer.h:189
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:696
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:225
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
Definition: MCExpr.cpp:42
const FrameInfo * ChainedParent
Definition: MCWinEH.h:45
MCTargetStreamer * getTargetStreamer()
Definition: MCStreamer.h:258
static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it...
Definition: MCDwarf.h:480
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
virtual void EmitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView &#39;.cv_linetable&#39; assembler directive.
Definition: MCStreamer.cpp:320
.tvos_version_min
Definition: MCDirectives.h:67
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
Definition: MCDwarf.h:487
static MCCFIInstruction createWindowSave(MCSymbol *L)
.cfi_window_save SPARC register window is saved.
Definition: MCDwarf.h:528
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size)
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
Definition: MCDwarf.h:573
static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code)
Definition: MCWin64EH.h:33
MCSection * getAssociatedPDataSection(const MCSection *TextSec)
Get the .pdata section used for the given section.
Definition: MCStreamer.cpp:798
virtual void EmitSyntaxDirective()
Definition: MCStreamer.cpp:810
virtual void EmitXCOFFLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)
Emits an lcomm directive with XCOFF csect information.
virtual void EmitCFIDefCfaRegister(int64_t Register)
Definition: MCStreamer.cpp:494
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
void getWatchOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getWatchOSVersion - Parse the version number as with getOSVersion.
Definition: Triple.cpp:1140
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:322
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:687
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register...
Definition: MCDwarf.h:515
bool isExpr() const
Definition: MCInst.h:60
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register)
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
Definition: MCDwarf.h:540
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:931
virtual void EmitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:751
unsigned getNumOperands() const
Definition: MCInst.h:181
unsigned size() const
Definition: DenseMap.h:125
virtual void EmitCFIUndefined(int64_t Register)
Definition: MCStreamer.cpp:607
virtual void EmitCFINegateRAState()
Definition: MCStreamer.cpp:637
unsigned PersonalityEncoding
Definition: MCDwarf.h:615
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:633
static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off)
Definition: MCWin64EH.h:48
void Finish()
Finish emission of machine code.
Definition: MCStreamer.cpp:948
virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol)
Definition: MCStreamer.cpp:380
virtual void EmitWinCFIEndChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:720
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:397
static MCCFIInstruction createRestoreState(MCSymbol *L)
.cfi_restore_state Restore the previously saved state.
Definition: MCDwarf.h:562
Binary assembler expressions.
Definition: MCExpr.h:421
virtual void emitDwarfFile0Directive(StringRef Directory, StringRef Filename, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, unsigned CUID=0)
Specify the "root" file of the compilation, using the ".file 0" extension.
Definition: MCStreamer.cpp:219
virtual void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, raw_ostream &OS, const MCExpr *Subsection) const =0
unsigned getOSMajorVersion() const
getOSMajorVersion - Return just the major version number, this is specialized because it is a common ...
Definition: Triple.h:338
virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol)
Definition: MCStreamer.cpp:918
virtual void EmitWinCFISetFrame(unsigned Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:823
void generateCompactUnwindEncodings(MCAsmBackend *MAB)
Definition: MCStreamer.cpp:120
MCCVFunctionInfo * getCVFunctionInfo(unsigned FuncId)
Retreive the function info if this is a valid function id, or nullptr.
Definition: MCCodeView.cpp:78
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
static MCSection * getWinCFISection(MCContext &Context, unsigned *NextWinCFIID, MCSection *MainCFISec, const MCSection *TextSec)
Definition: MCStreamer.cpp:763
virtual void EmitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:894
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:333
const std::vector< MCCFIInstruction > & getInitialFrameState() const
Definition: MCAsmInfo.h:617
static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition: MCWin64EH.h:42
virtual void EmitTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (32-bit TP relative) value.
Definition: MCStreamer.cpp:186
const MCSymbol * PrologEnd
Definition: MCWinEH.h:37
virtual void InitSections(bool NoExecStack)
Create the default sections and set the initial one.
Definition: MCStreamer.cpp:384
virtual void EmitCFIReturnColumn(int64_t Register)
Definition: MCStreamer.cpp:646
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
Definition: MCStreamer.h:57
BlockVerifier::State From
bool getMacOSXVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getMacOSXVersion - Parse the version number as with getOSVersion and then translate generic "darwin" ...
Definition: Triple.cpp:1073
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
virtual void EmitCOFFSymbolIndex(MCSymbol const *Symbol)
Emits the symbol table index of a Symbol into the current section.
Definition: MCStreamer.cpp:920
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
ExprKind getKind() const
Definition: MCExpr.h:68
virtual void EmitCFIOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:505
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
Definition: MCSymbol.h:258
MCFragment * getFragment(bool SetUsed=true) const
Definition: MCSymbol.h:396
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
const MCSection * TextSection
Definition: MCWinEH.h:39
virtual void EmitWinCFIEndProlog(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:908
static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size)
Definition: MCWin64EH.h:29
virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
const MCOperand & getOperand(unsigned i) const
Definition: MCInst.h:179
virtual void EmitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:845
virtual void EmitVersionMin(MCVersionMinType Type, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Specify the Mach-O minimum deployment target version.
Definition: MCStreamer.h:453
MCStreamer & Streamer
Definition: MCStreamer.h:86
Promote Memory to Register
Definition: Mem2Reg.cpp:109
virtual void EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView &#39;.cv_inline_linetable&#39; assembler directive.
Definition: MCStreamer.cpp:324
MCSymbol * getBeginSymbol()
Definition: MCSection.h:109
const Triple & getTargetTriple() const
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS, const MCInst &Inst, const MCSubtargetInfo &STI)
Definition: MCStreamer.cpp:971
StringRef str()
Return a StringRef for the vector contents.
Definition: raw_ostream.h:555
void 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:143
virtual void ChangeSection(MCSection *, const MCExpr *)
Update streamer for a new active section.
void setVariableValue(const MCExpr *Value)
Definition: MCSymbol.cpp:48
bool hasUnfinishedDwarfFrameInfo()
Definition: MCStreamer.cpp:254
virtual void changeSection(const MCSection *CurSection, MCSection *Section, const MCExpr *SubSection, raw_ostream &OS)
Update streamer for a new active section.
Definition: MCStreamer.cpp:52
const MCSymbol * Function
Definition: MCWinEH.h:36
Target - Wrapper for Target specific information.
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:344
void visitUsedExpr(const MCExpr &Expr)
Definition: MCStreamer.cpp:980
bool checkCVLocSection(unsigned FuncId, unsigned FileNo, SMLoc Loc)
Returns true if the the .cv_loc directive is in the right section.
Definition: MCStreamer.cpp:298
MCTargetStreamer(MCStreamer &S)
Definition: MCStreamer.cpp:41
virtual MCSymbol * EmitCFILabel()
When emitting an object file, create and emit a real label.
Definition: MCStreamer.cpp:457
bool recordFunctionId(unsigned FuncId)
Records the function id of a normal function.
Definition: MCCodeView.cpp:86
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:39
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:26
virtual void EmitThumbFunc(MCSymbol *Func)
Note in the output that the specified Func is a Thumb mode function (ARM target only).
const MCSymbol * FuncletOrFuncEnd
Definition: MCWinEH.h:34
virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:862
virtual void EmitCFISignalFrame()
Definition: MCStreamer.cpp:600
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:129
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:515
const MCSymbol * Personality
Definition: MCDwarf.h:611
MCAssemblerFlag
Definition: MCDirectives.h:48
bool recordInlinedCallSiteId(unsigned FuncId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol)
Records the function id of an inlined call site.
Definition: MCCodeView.cpp:99
bool hasCOFFAssociativeComdats() const
Definition: MCAsmInfo.h:479
virtual void EmitFileDirective(StringRef Filename)
Switch to a new logical file.
virtual void EmitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
Definition: MCStreamer.cpp:178
Generic base class for all target subtargets.
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
References to labels and assigned expressions.
Definition: MCExpr.h:40
uint32_t Size
Definition: Profile.cpp:46
bool isLittleEndian() const
True if the target is little endian.
Definition: MCAsmInfo.h:409
void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
Definition: MCStreamer.cpp:200
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
Definition: CodeView.h:47
virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:463
MCSymbol * endSection(MCSection *Section)
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:601
CodeViewContext & getCVContext()
Definition: MCContext.cpp:677
WinEH::FrameInfo * EnsureValidWinFrameInfo(SMLoc Loc)
Retreive the current frame info if one is available and it is not yet closed.
Definition: MCStreamer.cpp:653
virtual void emitRawBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition: MCStreamer.cpp:74
MCSymbol * getLabel() const
Definition: MCDwarf.h:346
MCSection * getTextSection() const
virtual void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)
Emits a COFF section relative relocation.
Definition: MCStreamer.cpp:924
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual void FinishImpl()
Streamer specific finalization.
void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir, StringRef Filename, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
Specifies the "root" file and directory of the compilation unit.
Definition: MCContext.h:584
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:279
bool isTvOS() const
Is this an Apple tvOS triple.
Definition: Triple.h:467
MCVersionMinType
Definition: MCDirectives.h:64
LLVM Value Representation.
Definition: Value.h:73
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:41
static cl::opt< bool, true > Debug("debug", cl::desc("Enable debug output"), cl::Hidden, cl::location(DebugFlag))
Constant expressions.
Definition: MCExpr.h:39
Binary expressions.
Definition: MCExpr.h:38
virtual bool EmitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
Definition: MCStreamer.cpp:275
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
virtual void EmitCFIBKeyFrame()
Definition: MCStreamer.cpp:228
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:397
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
Definition: MCStreamer.cpp:759
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Target specific expression.
Definition: MCExpr.h:42
Information describing a function or inlined call site introduced by .cv_func_id or ...
Definition: MCCodeView.h:91
virtual void visitUsedSymbol(const MCSymbol &Sym)
Definition: MCStreamer.cpp:977
virtual void emitDwarfFileDirective(StringRef Directive)
Definition: MCStreamer.cpp:62
Represents a location in source code.
Definition: SMLoc.h:23
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals)
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Definition: MCDwarf.h:568
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:392
const MCSymbol * ExceptionHandler
Definition: MCWinEH.h:35
void EmitVersionForTarget(const Triple &Target, const VersionTuple &SDKVersion)
void setTargetStreamer(MCTargetStreamer *TS)
Definition: MCStreamer.h:243
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Definition: MCStreamer.cpp:86
virtual void EmitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
Definition: MCStreamer.cpp:922
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment)
Definition: MCStreamer.cpp:484
void setLabel(MCSymbol *Label)
Definition: MCDwarf.h:350
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.
Definition: MCDwarf.h:522
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
Set the DescValue for the Symbol.
void EmitCFIStartProc(bool IsSimple, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:419
virtual void EmitCFIWindowSave()
Definition: MCStreamer.cpp:627
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
Definition: MCStreamer.cpp:804
void resize(size_type N)
Definition: SmallVector.h:344
Holds state from .cv_file and .cv_loc directives for later emission.
Definition: MCCodeView.h:137