LLVM  4.0.0
MCStreamer.cpp
Go to the documentation of this file.
1 //===- lib/MC/MCStreamer.cpp - Streaming Machine Code Output --------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "llvm/MC/MCStreamer.h"
11 #include "llvm/ADT/SmallString.h"
12 #include "llvm/ADT/Twine.h"
13 #include "llvm/MC/MCAsmBackend.h"
14 #include "llvm/MC/MCAsmInfo.h"
15 #include "llvm/MC/MCCodeView.h"
16 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCExpr.h"
18 #include "llvm/MC/MCInst.h"
19 #include "llvm/MC/MCInstPrinter.h"
21 #include "llvm/MC/MCObjectWriter.h"
22 #include "llvm/MC/MCSection.h"
23 #include "llvm/MC/MCSectionCOFF.h"
24 #include "llvm/MC/MCSymbol.h"
25 #include "llvm/MC/MCWin64EH.h"
26 #include "llvm/Support/COFF.h"
28 #include "llvm/Support/LEB128.h"
30 #include <cstdlib>
31 using namespace llvm;
32 
33 // Pin the vtables to this file.
35 
37  S.setTargetStreamer(this);
38 }
39 
41 
43 
45 
46 MCStreamer::MCStreamer(MCContext &Ctx)
47  : Context(Ctx), CurrentWinFrameInfo(nullptr) {
48  SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
49 }
50 
52  for (unsigned i = 0; i < getNumWinFrameInfos(); ++i)
53  delete WinFrameInfos[i];
54 }
55 
57  DwarfFrameInfos.clear();
58  for (unsigned i = 0; i < getNumWinFrameInfos(); ++i)
59  delete WinFrameInfos[i];
60  WinFrameInfos.clear();
61  CurrentWinFrameInfo = nullptr;
62  SymbolOrdering.clear();
63  SectionStack.clear();
64  SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
65 }
66 
68  // By default, discard comments.
69  return nulls();
70 }
71 
72 void MCStreamer::emitRawComment(const Twine &T, bool TabPrefix) {}
73 
76 
78  for (auto &FI : DwarfFrameInfos)
79  FI.CompactUnwindEncoding =
80  (MAB ? MAB->generateCompactUnwindEncoding(FI.Instructions) : 0);
81 }
82 
83 /// EmitIntValue - Special case of EmitValue that avoids the client having to
84 /// pass in a MCExpr for constant integers.
85 void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
86  assert(1 <= Size && Size <= 8 && "Invalid size");
87  assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
88  "Invalid size");
89  char buf[8];
90  const bool isLittleEndian = Context.getAsmInfo()->isLittleEndian();
91  for (unsigned i = 0; i != Size; ++i) {
92  unsigned index = isLittleEndian ? i : (Size - i - 1);
93  buf[i] = uint8_t(Value >> (index * 8));
94  }
95  EmitBytes(StringRef(buf, Size));
96 }
97 
98 /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the
99 /// client having to pass in a MCExpr for constant integers.
100 void MCStreamer::EmitULEB128IntValue(uint64_t Value, unsigned Padding) {
101  SmallString<128> Tmp;
102  raw_svector_ostream OSE(Tmp);
103  encodeULEB128(Value, OSE, Padding);
104  EmitBytes(OSE.str());
105 }
106 
107 /// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the
108 /// client having to pass in a MCExpr for constant integers.
110  SmallString<128> Tmp;
111  raw_svector_ostream OSE(Tmp);
112  encodeSLEB128(Value, OSE);
113  EmitBytes(OSE.str());
114 }
115 
116 void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc) {
117  EmitValueImpl(Value, Size, Loc);
118 }
119 
120 void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
121  bool IsSectionRelative) {
122  assert((!IsSectionRelative || Size == 4) &&
123  "SectionRelative value requires 4-bytes");
124 
125  if (!IsSectionRelative)
127  else
128  EmitCOFFSecRel32(Sym, /*Offset=*/0);
129 }
130 
132  report_fatal_error("unsupported directive in streamer");
133 }
134 
136  report_fatal_error("unsupported directive in streamer");
137 }
138 
140  report_fatal_error("unsupported directive in streamer");
141 }
142 
144  report_fatal_error("unsupported directive in streamer");
145 }
146 
148  report_fatal_error("unsupported directive in streamer");
149 }
150 
152  report_fatal_error("unsupported directive in streamer");
153 }
154 
155 /// Emit NumBytes bytes worth of the value specified by FillValue.
156 /// This implements directives such as '.space'.
157 void MCStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
158  for (uint64_t i = 0, e = NumBytes; i != e; ++i)
159  EmitIntValue(FillValue, 1);
160 }
161 
162 void MCStreamer::emitFill(uint64_t NumValues, int64_t Size, int64_t Expr) {
163  int64_t NonZeroSize = Size > 4 ? 4 : Size;
164  Expr &= ~0ULL >> (64 - NonZeroSize * 8);
165  for (uint64_t i = 0, e = NumValues; i != e; ++i) {
166  EmitIntValue(Expr, NonZeroSize);
167  if (NonZeroSize < Size)
168  EmitIntValue(0, Size - NonZeroSize);
169  }
170 }
171 
172 /// The implementation in this class just redirects to emitFill.
173 void MCStreamer::EmitZeros(uint64_t NumBytes) {
174  emitFill(NumBytes, 0);
175 }
176 
177 unsigned MCStreamer::EmitDwarfFileDirective(unsigned FileNo,
178  StringRef Directory,
179  StringRef Filename, unsigned CUID) {
180  return getContext().getDwarfFile(Directory, Filename, FileNo, CUID);
181 }
182 
183 void MCStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
184  unsigned Column, unsigned Flags,
185  unsigned Isa,
186  unsigned Discriminator,
187  StringRef FileName) {
188  getContext().setCurrentDwarfLoc(FileNo, Line, Column, Flags, Isa,
189  Discriminator);
190 }
191 
194  if (!Table.getLabel()) {
195  StringRef Prefix = Context.getAsmInfo()->getPrivateGlobalPrefix();
196  Table.setLabel(
197  Context.getOrCreateSymbol(Prefix + "line_table_start" + Twine(CUID)));
198  }
199  return Table.getLabel();
200 }
201 
202 MCDwarfFrameInfo *MCStreamer::getCurrentDwarfFrameInfo() {
203  if (DwarfFrameInfos.empty())
204  return nullptr;
205  return &DwarfFrameInfos.back();
206 }
207 
209  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
210  return CurFrame && !CurFrame->End;
211 }
212 
213 void MCStreamer::EnsureValidDwarfFrame() {
214  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
215  if (!CurFrame || CurFrame->End)
216  report_fatal_error("No open frame");
217 }
218 
219 bool MCStreamer::EmitCVFileDirective(unsigned FileNo, StringRef Filename) {
220  return getContext().getCVContext().addFile(FileNo, Filename);
221 }
222 
223 bool MCStreamer::EmitCVFuncIdDirective(unsigned FunctionId) {
224  return getContext().getCVContext().recordFunctionId(FunctionId);
225 }
226 
228  unsigned IAFunc, unsigned IAFile,
229  unsigned IALine, unsigned IACol,
230  SMLoc Loc) {
231  if (getContext().getCVContext().getCVFunctionInfo(IAFunc) == nullptr) {
232  getContext().reportError(Loc, "parent function id not introduced by "
233  ".cv_func_id or .cv_inline_site_id");
234  return true;
235  }
236 
238  FunctionId, IAFunc, IAFile, IALine, IACol);
239 }
240 
241 void MCStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
242  unsigned Line, unsigned Column,
243  bool PrologueEnd, bool IsStmt,
244  StringRef FileName, SMLoc Loc) {
246  MCCVFunctionInfo *FI = CVC.getCVFunctionInfo(FunctionId);
247  if (!FI)
248  return getContext().reportError(
249  Loc, "function id not introduced by .cv_func_id or .cv_inline_site_id");
250 
251  // Track the section
252  if (FI->Section == nullptr)
254  else if (FI->Section != getCurrentSectionOnly())
255  return getContext().reportError(
256  Loc,
257  "all .cv_loc directives for a function must be in the same section");
258 
259  CVC.setCurrentCVLoc(FunctionId, FileNo, Line, Column, PrologueEnd, IsStmt);
260 }
261 
262 void MCStreamer::EmitCVLinetableDirective(unsigned FunctionId,
263  const MCSymbol *Begin,
264  const MCSymbol *End) {}
265 
266 void MCStreamer::EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
267  unsigned SourceFileId,
268  unsigned SourceLineNum,
269  const MCSymbol *FnStartSym,
270  const MCSymbol *FnEndSym) {}
271 
273  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
274  StringRef FixedSizePortion) {}
275 
277  MCSymbol *EHSymbol) {
278 }
279 
280 void MCStreamer::InitSections(bool NoExecStack) {
281  SwitchSection(getContext().getObjectFileInfo()->getTextSection());
282 }
283 
285  assert(Fragment);
286  Symbol->setFragment(Fragment);
287 
288  // As we emit symbols into a section, track the order so that they can
289  // be sorted upon later. Zero is reserved to mean 'unemitted'.
290  SymbolOrdering[Symbol] = 1 + SymbolOrdering.size();
291 }
292 
294  assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
295  assert(getCurrentSectionOnly() && "Cannot emit before setting section!");
296  assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
297  Symbol->setFragment(&getCurrentSectionOnly()->getDummyFragment());
298 
300  if (TS)
301  TS->emitLabel(Symbol);
302 }
303 
304 void MCStreamer::EmitCFISections(bool EH, bool Debug) {
305  assert(EH || Debug);
306 }
307 
308 void MCStreamer::EmitCFIStartProc(bool IsSimple) {
310  report_fatal_error("Starting a frame before finishing the previous one!");
311 
312  MCDwarfFrameInfo Frame;
313  Frame.IsSimple = IsSimple;
314  EmitCFIStartProcImpl(Frame);
315 
316  const MCAsmInfo* MAI = Context.getAsmInfo();
317  if (MAI) {
318  for (const MCCFIInstruction& Inst : MAI->getInitialFrameState()) {
319  if (Inst.getOperation() == MCCFIInstruction::OpDefCfa ||
320  Inst.getOperation() == MCCFIInstruction::OpDefCfaRegister) {
321  Frame.CurrentCfaRegister = Inst.getRegister();
322  }
323  }
324  }
325 
326  DwarfFrameInfos.push_back(Frame);
327 }
328 
330 }
331 
333  EnsureValidDwarfFrame();
334  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
335  EmitCFIEndProcImpl(*CurFrame);
336 }
337 
339  // Put a dummy non-null value in Frame.End to mark that this frame has been
340  // closed.
341  Frame.End = (MCSymbol *) 1;
342 }
343 
344 MCSymbol *MCStreamer::EmitCFILabel() {
345  MCSymbol *Label = getContext().createTempSymbol("cfi", true);
346  EmitLabel(Label);
347  return Label;
348 }
349 
350 MCSymbol *MCStreamer::EmitCFICommon() {
351  EnsureValidDwarfFrame();
352  return EmitCFILabel();
353 }
354 
355 void MCStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
356  MCSymbol *Label = EmitCFICommon();
358  MCCFIInstruction::createDefCfa(Label, Register, Offset);
359  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
360  CurFrame->Instructions.push_back(Instruction);
361  CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
362 }
363 
365  MCSymbol *Label = EmitCFICommon();
368  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
369  CurFrame->Instructions.push_back(Instruction);
370 }
371 
372 void MCStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
373  MCSymbol *Label = EmitCFICommon();
375  MCCFIInstruction::createAdjustCfaOffset(Label, Adjustment);
376  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
377  CurFrame->Instructions.push_back(Instruction);
378 }
379 
381  MCSymbol *Label = EmitCFICommon();
384  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
385  CurFrame->Instructions.push_back(Instruction);
386  CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
387 }
388 
389 void MCStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
390  MCSymbol *Label = EmitCFICommon();
392  MCCFIInstruction::createOffset(Label, Register, Offset);
393  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
394  CurFrame->Instructions.push_back(Instruction);
395 }
396 
398  MCSymbol *Label = EmitCFICommon();
400  MCCFIInstruction::createRelOffset(Label, Register, Offset);
401  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
402  CurFrame->Instructions.push_back(Instruction);
403 }
404 
406  unsigned Encoding) {
407  EnsureValidDwarfFrame();
408  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
409  CurFrame->Personality = Sym;
410  CurFrame->PersonalityEncoding = Encoding;
411 }
412 
413 void MCStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
414  EnsureValidDwarfFrame();
415  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
416  CurFrame->Lsda = Sym;
417  CurFrame->LsdaEncoding = Encoding;
418 }
419 
421  MCSymbol *Label = EmitCFICommon();
423  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
424  CurFrame->Instructions.push_back(Instruction);
425 }
426 
428  // FIXME: Error if there is no matching cfi_remember_state.
429  MCSymbol *Label = EmitCFICommon();
431  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
432  CurFrame->Instructions.push_back(Instruction);
433 }
434 
436  MCSymbol *Label = EmitCFICommon();
438  MCCFIInstruction::createSameValue(Label, Register);
439  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
440  CurFrame->Instructions.push_back(Instruction);
441 }
442 
444  MCSymbol *Label = EmitCFICommon();
446  MCCFIInstruction::createRestore(Label, Register);
447  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
448  CurFrame->Instructions.push_back(Instruction);
449 }
450 
452  MCSymbol *Label = EmitCFICommon();
454  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
455  CurFrame->Instructions.push_back(Instruction);
456 }
457 
458 void MCStreamer::EmitCFIGnuArgsSize(int64_t Size) {
459  MCSymbol *Label = EmitCFICommon();
462  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
463  CurFrame->Instructions.push_back(Instruction);
464 }
465 
467  EnsureValidDwarfFrame();
468  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
469  CurFrame->IsSignalFrame = true;
470 }
471 
473  MCSymbol *Label = EmitCFICommon();
475  MCCFIInstruction::createUndefined(Label, Register);
476  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
477  CurFrame->Instructions.push_back(Instruction);
478 }
479 
480 void MCStreamer::EmitCFIRegister(int64_t Register1, int64_t Register2) {
481  MCSymbol *Label = EmitCFICommon();
483  MCCFIInstruction::createRegister(Label, Register1, Register2);
484  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
485  CurFrame->Instructions.push_back(Instruction);
486 }
487 
489  MCSymbol *Label = EmitCFICommon();
492  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
493  CurFrame->Instructions.push_back(Instruction);
494 }
495 
496 void MCStreamer::EnsureValidWinFrameInfo() {
497  const MCAsmInfo *MAI = Context.getAsmInfo();
498  if (!MAI->usesWindowsCFI())
499  report_fatal_error(".seh_* directives are not supported on this target");
500  if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End)
501  report_fatal_error("No open Win64 EH frame function!");
502 }
503 
505  const MCAsmInfo *MAI = Context.getAsmInfo();
506  if (!MAI->usesWindowsCFI())
507  report_fatal_error(".seh_* directives are not supported on this target");
508  if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End)
509  report_fatal_error("Starting a function before ending the previous one!");
510 
511  MCSymbol *StartProc = EmitCFILabel();
512 
513  WinFrameInfos.push_back(new WinEH::FrameInfo(Symbol, StartProc));
514  CurrentWinFrameInfo = WinFrameInfos.back();
515  CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
516 }
517 
519  EnsureValidWinFrameInfo();
520  if (CurrentWinFrameInfo->ChainedParent)
521  report_fatal_error("Not all chained regions terminated!");
522 
523  MCSymbol *Label = EmitCFILabel();
524  CurrentWinFrameInfo->End = Label;
525 }
526 
528  EnsureValidWinFrameInfo();
529 
530  MCSymbol *StartProc = EmitCFILabel();
531 
532  WinFrameInfos.push_back(new WinEH::FrameInfo(CurrentWinFrameInfo->Function,
533  StartProc, CurrentWinFrameInfo));
534  CurrentWinFrameInfo = WinFrameInfos.back();
535  CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
536 }
537 
539  EnsureValidWinFrameInfo();
540  if (!CurrentWinFrameInfo->ChainedParent)
541  report_fatal_error("End of a chained region outside a chained region!");
542 
543  MCSymbol *Label = EmitCFILabel();
544 
545  CurrentWinFrameInfo->End = Label;
546  CurrentWinFrameInfo =
547  const_cast<WinEH::FrameInfo *>(CurrentWinFrameInfo->ChainedParent);
548 }
549 
550 void MCStreamer::EmitWinEHHandler(const MCSymbol *Sym, bool Unwind,
551  bool Except) {
552  EnsureValidWinFrameInfo();
553  if (CurrentWinFrameInfo->ChainedParent)
554  report_fatal_error("Chained unwind areas can't have handlers!");
555  CurrentWinFrameInfo->ExceptionHandler = Sym;
556  if (!Except && !Unwind)
557  report_fatal_error("Don't know what kind of handler this is!");
558  if (Unwind)
559  CurrentWinFrameInfo->HandlesUnwind = true;
560  if (Except)
561  CurrentWinFrameInfo->HandlesExceptions = true;
562 }
563 
565  EnsureValidWinFrameInfo();
566  if (CurrentWinFrameInfo->ChainedParent)
567  report_fatal_error("Chained unwind areas can't have handlers!");
568 }
569 
570 static MCSection *getWinCFISection(MCContext &Context, unsigned *NextWinCFIID,
571  MCSection *MainCFISec,
572  const MCSection *TextSec) {
573  // If this is the main .text section, use the main unwind info section.
574  if (TextSec == Context.getObjectFileInfo()->getTextSection())
575  return MainCFISec;
576 
577  const auto *TextSecCOFF = cast<MCSectionCOFF>(TextSec);
578  unsigned UniqueID = TextSecCOFF->getOrAssignWinCFISectionID(NextWinCFIID);
579 
580  // If this section is COMDAT, this unwind section should be COMDAT associative
581  // with its group.
582  const MCSymbol *KeySym = nullptr;
583  if (TextSecCOFF->getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT)
584  KeySym = TextSecCOFF->getCOMDATSymbol();
585 
586  return Context.getAssociativeCOFFSection(cast<MCSectionCOFF>(MainCFISec),
587  KeySym, UniqueID);
588 }
589 
591  return getWinCFISection(getContext(), &NextWinCFIID,
592  getContext().getObjectFileInfo()->getPDataSection(),
593  TextSec);
594 }
595 
597  return getWinCFISection(getContext(), &NextWinCFIID,
598  getContext().getObjectFileInfo()->getXDataSection(),
599  TextSec);
600 }
601 
603 
605  EnsureValidWinFrameInfo();
606 
607  MCSymbol *Label = EmitCFILabel();
608 
610  CurrentWinFrameInfo->Instructions.push_back(Inst);
611 }
612 
614  EnsureValidWinFrameInfo();
615  if (CurrentWinFrameInfo->LastFrameInst >= 0)
616  report_fatal_error("Frame register and offset already specified!");
617  if (Offset & 0x0F)
618  report_fatal_error("Misaligned frame pointer offset!");
619  if (Offset > 240)
620  report_fatal_error("Frame offset must be less than or equal to 240!");
621 
622  MCSymbol *Label = EmitCFILabel();
623 
624  WinEH::Instruction Inst =
625  Win64EH::Instruction::SetFPReg(Label, Register, Offset);
626  CurrentWinFrameInfo->LastFrameInst = CurrentWinFrameInfo->Instructions.size();
627  CurrentWinFrameInfo->Instructions.push_back(Inst);
628 }
629 
630 void MCStreamer::EmitWinCFIAllocStack(unsigned Size) {
631  EnsureValidWinFrameInfo();
632  if (Size == 0)
633  report_fatal_error("Allocation size must be non-zero!");
634  if (Size & 7)
635  report_fatal_error("Misaligned stack allocation!");
636 
637  MCSymbol *Label = EmitCFILabel();
638 
640  CurrentWinFrameInfo->Instructions.push_back(Inst);
641 }
642 
644  EnsureValidWinFrameInfo();
645  if (Offset & 7)
646  report_fatal_error("Misaligned saved register offset!");
647 
648  MCSymbol *Label = EmitCFILabel();
649 
650  WinEH::Instruction Inst =
651  Win64EH::Instruction::SaveNonVol(Label, Register, Offset);
652  CurrentWinFrameInfo->Instructions.push_back(Inst);
653 }
654 
656  EnsureValidWinFrameInfo();
657  if (Offset & 0x0F)
658  report_fatal_error("Misaligned saved vector register offset!");
659 
660  MCSymbol *Label = EmitCFILabel();
661 
662  WinEH::Instruction Inst =
663  Win64EH::Instruction::SaveXMM(Label, Register, Offset);
664  CurrentWinFrameInfo->Instructions.push_back(Inst);
665 }
666 
668  EnsureValidWinFrameInfo();
669  if (CurrentWinFrameInfo->Instructions.size() > 0)
670  report_fatal_error("If present, PushMachFrame must be the first UOP");
671 
672  MCSymbol *Label = EmitCFILabel();
673 
675  CurrentWinFrameInfo->Instructions.push_back(Inst);
676 }
677 
679  EnsureValidWinFrameInfo();
680 
681  MCSymbol *Label = EmitCFILabel();
682 
683  CurrentWinFrameInfo->PrologEnd = Label;
684 }
685 
687 }
688 
690 }
691 
693 
694 /// EmitRawText - If this file is backed by an assembly streamer, this dumps
695 /// the specified string in the output .s file. This capability is
696 /// indicated by the hasRawTextSupport() predicate.
698  errs() << "EmitRawText called on an MCStreamer that doesn't support it, "
699  " something must not be fully mc'ized\n";
700  abort();
701 }
702 
704  SmallString<128> Str;
706 }
707 
709 }
710 
712  if (!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End)
713  report_fatal_error("Unfinished frame!");
714 
716  if (TS)
717  TS->finish();
718 
719  FinishImpl();
720 }
721 
723  visitUsedExpr(*Value);
724  Symbol->setVariableValue(Value);
725 
727  if (TS)
728  TS->emitAssignment(Symbol, Value);
729 }
730 
732  const MCInst &Inst, const MCSubtargetInfo &STI) {
733  InstPrinter.printInst(&Inst, OS, "", STI);
734 }
735 
737 }
738 
740  switch (Expr.getKind()) {
741  case MCExpr::Target:
742  cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
743  break;
744 
745  case MCExpr::Constant:
746  break;
747 
748  case MCExpr::Binary: {
749  const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
750  visitUsedExpr(*BE.getLHS());
751  visitUsedExpr(*BE.getRHS());
752  break;
753  }
754 
755  case MCExpr::SymbolRef:
756  visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
757  break;
758 
759  case MCExpr::Unary:
760  visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
761  break;
762  }
763 }
764 
766  const MCSubtargetInfo &STI) {
767  // Scan for values.
768  for (unsigned i = Inst.getNumOperands(); i--;)
769  if (Inst.getOperand(i).isExpr())
770  visitUsedExpr(*Inst.getOperand(i).getExpr());
771 }
772 
774  unsigned Size) {
775  // Get the Hi-Lo expression.
776  const MCExpr *Diff =
779 
780  const MCAsmInfo *MAI = Context.getAsmInfo();
781  if (!MAI->doesSetDirectiveSuppressReloc()) {
782  EmitValue(Diff, Size);
783  return;
784  }
785 
786  // Otherwise, emit with .set (aka assignment).
787  MCSymbol *SetLabel = Context.createTempSymbol("set", true);
788  EmitAssignment(SetLabel, Diff);
789  EmitSymbolValue(SetLabel, Size);
790 }
791 
794 void MCStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
802  unsigned ByteAlignment) {}
804  uint64_t Size, unsigned ByteAlignment) {}
809 void MCStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) {
810  visitUsedExpr(*Value);
811 }
814 void MCStreamer::emitFill(const MCExpr &NumBytes, uint64_t Value, SMLoc Loc) {}
815 void MCStreamer::emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
816  SMLoc Loc) {}
818  unsigned ValueSize,
819  unsigned MaxBytesToEmit) {}
821  unsigned MaxBytesToEmit) {}
823  SMLoc Loc) {}
824 void MCStreamer::EmitBundleAlignMode(unsigned AlignPow2) {}
825 void MCStreamer::EmitBundleLock(bool AlignToEnd) {}
828 
830  assert(Section && "Cannot switch to a null section!");
831  MCSectionSubPair curSection = SectionStack.back().first;
832  SectionStack.back().second = curSection;
833  if (MCSectionSubPair(Section, Subsection) != curSection) {
834  ChangeSection(Section, Subsection);
835  SectionStack.back().first = MCSectionSubPair(Section, Subsection);
836  assert(!Section->hasEnded() && "Section already ended");
837  MCSymbol *Sym = Section->getBeginSymbol();
838  if (Sym && !Sym->isInSection())
839  EmitLabel(Sym);
840  }
841 }
842 
844  // TODO: keep track of the last subsection so that this symbol appears in the
845  // correct place.
846  MCSymbol *Sym = Section->getEndSymbol(Context);
847  if (Sym->isInSection())
848  return Sym;
849 
850  SwitchSection(Section);
851  EmitLabel(Sym);
852  return Sym;
853 }
virtual void EmitBundleUnlock()
Ends a bundle-locked group.
Definition: MCStreamer.cpp:827
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag)
Note in the output the specified Flag.
Definition: MCStreamer.cpp:792
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:183
virtual void EmitBundleAlignMode(unsigned AlignPow2)
Set the bundle alignment mode from now on in the section.
Definition: MCStreamer.cpp:824
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:40
void push_back(const T &Elt)
Definition: SmallVector.h:211
virtual void EmitCFISameValue(int64_t Register)
Definition: MCStreamer.cpp:435
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:405
virtual void EmitSLEB128Value(const MCExpr *Value)
Definition: MCStreamer.cpp:813
virtual void EmitCFIGnuArgsSize(int64_t Size)
Definition: MCStreamer.cpp:458
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:703
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:298
virtual void EmitWinCFIEndProlog()
Definition: MCStreamer.cpp:678
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:109
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
size_t i
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:120
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.
Definition: MCStreamer.cpp:822
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.
Definition: MCStreamer.cpp:803
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
bool hasEnded() const
Definition: MCSection.cpp:32
virtual void EndCOFFSymbolDef()
Marks the end of the symbol definition.
Definition: MCStreamer.cpp:796
virtual ~MCTargetStreamer()
Definition: MCStreamer.cpp:34
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:132
const MCSymbol * End
Definition: MCWinEH.h:33
virtual void EmitULEB128Value(const MCExpr *Value)
Definition: MCStreamer.cpp:812
static MCCFIInstruction createRememberState(MCSymbol *L)
.cfi_remember_state Save all current rules for all registers.
Definition: MCDwarf.h:441
virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol)
Emit an weak reference from Alias to Symbol.
Definition: MCStreamer.cpp:806
static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition: MCWin64EH.h:37
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition: MCStreamer.cpp:807
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:396
MCSymbol * getLabel() const
Definition: MCDwarf.h:239
Target specific streamer interface.
Definition: MCStreamer.h:73
ExprKind getKind() const
Definition: MCExpr.h:70
virtual void reset()
State management.
Definition: MCStreamer.cpp:56
unsigned CurrentCfaRegister
Definition: MCDwarf.h:501
virtual void EmitWindowsUnwindTables()
Definition: MCStreamer.cpp:708
void EmitCFIStartProc(bool IsSimple)
Definition: MCStreamer.cpp:308
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol)
Start emitting COFF symbol definition.
Definition: MCStreamer.cpp:795
virtual void EmitDTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
Definition: MCStreamer.cpp:131
virtual unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, unsigned CUID=0)
Associate a filename with a specified logical file number.
Definition: MCStreamer.cpp:177
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:490
virtual void EmitCFIRegister(int64_t Register1, int64_t Register2)
Definition: MCStreamer.cpp:480
virtual void emitExplicitComments()
Emit added explicit comments.
Definition: MCStreamer.cpp:75
virtual void EmitCFIDefCfaOffset(int64_t Offset)
Definition: MCStreamer.cpp:364
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
Definition: MCStreamer.cpp:192
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
Definition: MCDwarf.h:383
COFF::SymbolStorageClass StorageClass
Definition: COFFYAML.cpp:296
virtual void EmitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
Definition: MCStreamer.cpp:798
std::vector< Instruction > Instructions
Definition: MCWinEH.h:45
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.
Definition: MCStreamer.cpp:809
unsigned LsdaEncoding
Definition: MCDwarf.h:503
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:390
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
Definition: MCStreamer.cpp:765
virtual void addExplicitComment(const Twine &T)
Add explicit comment T.
Definition: MCStreamer.cpp:74
virtual void EmitCFISections(bool EH, bool Debug)
Definition: MCStreamer.cpp:304
virtual void EmitGPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
Definition: MCStreamer.cpp:151
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:444
std::vector< MCCFIInstruction > Instructions
Definition: MCDwarf.h:500
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register)
.cfi_undefined From now on the previous value of Register can't be restored anymore.
Definition: MCDwarf.h:430
virtual void EmitWinEHHandlerData()
Definition: MCStreamer.cpp:564
virtual void EmitCFIRememberState()
Definition: MCStreamer.cpp:420
virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:413
virtual void EmitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
Definition: MCStreamer.cpp:147
void AssignFragment(MCSymbol *Symbol, MCFragment *Fragment)
Sets the symbol's section.
Definition: MCStreamer.cpp:284
struct fuzzer::@269 Flags
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
virtual void EmitCFIEscape(StringRef Values)
Definition: MCStreamer.cpp:451
virtual void EmitCOFFSymbolType(int Type)
Emit the type of the symbol.
Definition: MCStreamer.cpp:799
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:302
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
const std::vector< MCCFIInstruction > & getInitialFrameState() const
Definition: MCAsmInfo.h:569
const MCSymbol * Lsda
Definition: MCDwarf.h:499
virtual void emitLabel(MCSymbol *Symbol)
Definition: MCStreamer.cpp:40
virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
Definition: MCStreamer.cpp:329
unsigned getNumWinFrameInfos()
Definition: MCStreamer.h:234
virtual ~MCStreamer()
Definition: MCStreamer.cpp:51
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:453
MCContext & getContext() const
Definition: MCStreamer.h:221
MCSymbol * getEndSymbol(MCContext &Ctx)
Definition: MCSection.cpp:26
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:241
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Definition: MCStreamer.cpp:722
Context object for machine code objects.
Definition: MCContext.h:51
void setCurrentCVLoc(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt)
Saves the information from the currently parsed .cv_loc directive and sets CVLocSeen.
Definition: MCCodeView.h:192
static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg)
Definition: MCWin64EH.h:27
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:497
virtual void finish()
Definition: MCStreamer.cpp:42
virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
Definition: MCStreamer.cpp:338
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
Definition: MCStreamer.h:44
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
virtual void EmitTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (64-bit TP relative) value.
Definition: MCStreamer.cpp:139
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:72
virtual void EmitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
Definition: MCStreamer.cpp:808
virtual void EmitCFIRestoreState()
Definition: MCStreamer.cpp:427
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:85
Expected< const typename ELFT::Sym * > getSymbol(typename ELFT::SymRange Symbols, uint32_t Index)
Definition: Object/ELF.h:236
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:116
Unary expressions.
Definition: MCExpr.h:40
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
virtual void EmitCFIRestore(int64_t Register)
Definition: MCStreamer.cpp:443
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:121
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:57
void setFragment(MCFragment *F) const
Mark the symbol as defined in the fragment F.
Definition: MCSymbol.h:270
virtual void EmitBundleLock(bool AlignToEnd)
The following instructions are a bundle-locked group.
Definition: MCStreamer.cpp:825
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)
Emit a local common (.lcomm) symbol.
Definition: MCStreamer.cpp:801
const MCExpr * getExpr() const
Definition: MCInst.h:93
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:436
virtual raw_ostream & GetCommentOS()
Return a raw_ostream that comments can be written to.
Definition: MCStreamer.cpp:67
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition: MCExpr.h:514
bool addFile(unsigned FileNumber, StringRef Filename)
Definition: MCCodeView.cpp:47
void EmitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Definition: MCStreamer.cpp:173
Streaming machine code generation interface.
Definition: MCStreamer.h:161
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:218
const FrameInfo * ChainedParent
Definition: MCWinEH.h:44
MCTargetStreamer * getTargetStreamer()
Definition: MCStreamer.h:223
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:369
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 '.cv_linetable' assembler directive.
Definition: MCStreamer.cpp:262
MCCVFunctionInfo * getCVFunctionInfo(unsigned FuncId)
Retreive the function info if this is a valid function id, or nullptr.
Definition: MCCodeView.h:180
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
Definition: MCDwarf.h:376
virtual void EmitWinCFIPushReg(unsigned Register)
Definition: MCStreamer.cpp:604
static MCCFIInstruction createWindowSave(MCSymbol *L)
.cfi_window_save SPARC register window is saved.
Definition: MCDwarf.h:417
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Definition: MCStreamer.cpp:829
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size)
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
Definition: MCDwarf.h:457
static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code)
Definition: MCWin64EH.h:34
MCSection * getAssociatedPDataSection(const MCSection *TextSec)
Get the .pdata section used for the given section.
Definition: MCStreamer.cpp:590
virtual void EmitSyntaxDirective()
Definition: MCStreamer.cpp:602
virtual void EmitCFIDefCfaRegister(int64_t Register)
Definition: MCStreamer.cpp:380
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.
Definition: MCStreamer.cpp:817
bool isExpr() const
Definition: MCInst.h:59
uint32_t Offset
static const unsigned End
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:510
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:404
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:424
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:697
virtual void EmitWinCFIEndChained()
Definition: MCStreamer.cpp:538
virtual void EmitWinCFIEndProc()
Definition: MCStreamer.cpp:518
MCSection * getTextSection() const
virtual void EmitCFIUndefined(int64_t Register)
Definition: MCStreamer.cpp:472
unsigned PersonalityEncoding
Definition: MCDwarf.h:502
static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off)
Definition: MCWin64EH.h:49
void Finish()
Finish emission of machine code.
Definition: MCStreamer.cpp:711
virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol)
Definition: MCStreamer.cpp:276
bool isInSection(bool SetUsed=true) const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
Definition: MCSymbol.h:251
bool isIntN(unsigned N, int64_t x)
isIntN - Checks if an signed integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:366
static MCCFIInstruction createRestoreState(MCSymbol *L)
.cfi_restore_state Restore the previously saved state.
Definition: MCDwarf.h:446
virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except)
Definition: MCStreamer.cpp:550
Binary assembler expressions.
Definition: MCExpr.h:388
virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol)
Definition: MCStreamer.cpp:686
void generateCompactUnwindEncodings(MCAsmBackend *MAB)
Definition: MCStreamer.cpp:77
virtual bool EmitCVFileDirective(unsigned FileNo, StringRef Filename)
Associate a filename with a specified logical file number.
Definition: MCStreamer.cpp:219
static MCSection * getWinCFISection(MCContext &Context, unsigned *NextWinCFIID, MCSection *MainCFISec, const MCSection *TextSec)
Definition: MCStreamer.cpp:570
static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition: MCWin64EH.h:43
virtual void EmitTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (32-bit TP relative) value.
Definition: MCStreamer.cpp:143
const MCSymbol * PrologEnd
Definition: MCWinEH.h:36
virtual void EmitWinCFIStartChained()
Definition: MCStreamer.cpp:527
virtual void InitSections(bool NoExecStack)
Create the default sections and set the initial one.
Definition: MCStreamer.cpp:280
bool doesSetDirectiveSuppressReloc() const
Definition: MCAsmInfo.h:503
virtual void EmitLabel(MCSymbol *Symbol)
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:293
virtual void EmitWinCFISaveXMM(unsigned Register, unsigned Offset)
Definition: MCStreamer.cpp:655
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
Definition: MCStreamer.cpp:773
virtual void EmitCFIOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:389
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
Definition: Twine.h:463
const MCSection * TextSection
Definition: MCWinEH.h:38
static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size)
Definition: MCWin64EH.h:30
virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
Definition: MCStreamer.cpp:820
Promote Memory to Register
Definition: Mem2Reg.cpp:100
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:266
MCSymbol * getBeginSymbol()
Definition: MCSection.h:106
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS, const MCInst &Inst, const MCSubtargetInfo &STI)
Definition: MCStreamer.cpp:731
StringRef str()
Return a StringRef for the vector contents.
Definition: raw_ostream.h:515
virtual void EmitWinCFIAllocStack(unsigned Size)
Definition: MCStreamer.cpp:630
virtual void ChangeSection(MCSection *, const MCExpr *)
Update streamer for a new active section.
Definition: MCStreamer.cpp:805
void setVariableValue(const MCExpr *Value)
Definition: MCSymbol.cpp:42
bool hasUnfinishedDwarfFrameInfo()
Definition: MCStreamer.cpp:208
void encodeSLEB128(int64_t Value, raw_ostream &OS)
Utility function to encode a SLEB128 value to an output stream.
Definition: LEB128.h:23
const MCSymbol * Function
Definition: MCWinEH.h:35
void visitUsedExpr(const MCExpr &Expr)
Definition: MCStreamer.cpp:739
MCTargetStreamer(MCStreamer &S)
Definition: MCStreamer.cpp:36
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition: MCExpr.h:517
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:272
bool recordFunctionId(unsigned FuncId)
Records the function id of a normal function.
Definition: MCCodeView.cpp:68
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:41
virtual void EmitThumbFunc(MCSymbol *Func)
Note in the output that the specified Func is a Thumb mode function (ARM target only).
Definition: MCStreamer.cpp:793
unsigned size() const
Definition: DenseMap.h:83
virtual void EmitCFISignalFrame()
Definition: MCStreamer.cpp:466
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:397
const MCSymbol * Personality
Definition: MCDwarf.h:498
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:81
unsigned getNumOperands() const
Definition: MCInst.h:166
virtual void EmitFileDirective(StringRef Filename)
Switch to a new logical file.
Definition: MCStreamer.cpp:797
virtual void EmitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
Definition: MCStreamer.cpp:135
MCSubtargetInfo - Generic base class for all target subtargets.
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
Definition: MCStreamer.cpp:800
virtual uint32_t generateCompactUnwindEncoding(ArrayRef< MCCFIInstruction >) const
Generate the compact unwind encoding for the CFI instructions.
Definition: MCAsmBackend.h:134
References to labels and assigned expressions.
Definition: MCExpr.h:39
virtual void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
Definition: MCStreamer.cpp:157
virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:355
void EmitULEB128IntValue(uint64_t Value, unsigned Padding=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:100
MCSymbol * endSection(MCSection *Section)
Definition: MCStreamer.cpp:843
bool isVariable() const
isVariable - Check if this is a variable symbol.
Definition: MCSymbol.h:289
MCFragment * getFragment(bool SetUsed=true) const
Definition: MCSymbol.h:377
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:488
CodeViewContext & getCVContext()
Definition: MCContext.cpp:500
virtual void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)
Emits a COFF section relative relocation.
Definition: MCStreamer.cpp:692
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual void FinishImpl()
Streamer specific finalization.
Definition: MCStreamer.cpp:826
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:227
LLVM Value Representation.
Definition: Value.h:71
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:36
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:247
unsigned getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
Definition: MCContext.cpp:477
static cl::opt< bool, true > Debug("debug", cl::desc("Enable debug output"), cl::Hidden, cl::location(DebugFlag))
Constant expressions.
Definition: MCExpr.h:38
Binary expressions.
Definition: MCExpr.h:37
virtual bool EmitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
Definition: MCStreamer.cpp:223
virtual void EmitWinCFIStartProc(const MCSymbol *Symbol)
Definition: MCStreamer.cpp:504
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
static TraceState * TS
void encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned Padding=0)
Utility function to encode a ULEB128 value to an output stream.
Definition: LEB128.h:38
virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset)
Definition: MCStreamer.cpp:643
virtual void EmitWinCFIPushFrame(bool Code)
Definition: MCStreamer.cpp:667
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
Target specific expression.
Definition: MCExpr.h:41
Information describing a function or inlined call site introduced by .cv_func_id or ...
Definition: MCCodeView.h:112
virtual void visitUsedSymbol(const MCSymbol &Sym)
Definition: MCStreamer.cpp:736
isLittleEndian(LE)
Represents a location in source code.
Definition: SMLoc.h:24
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals)
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Definition: MCDwarf.h:452
bool isUIntN(unsigned N, uint64_t x)
isUIntN - Checks if an unsigned integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:360
const MCSymbol * ExceptionHandler
Definition: MCWinEH.h:34
void setTargetStreamer(MCTargetStreamer *TS)
Definition: MCStreamer.h:213
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Definition: MCStreamer.cpp:44
virtual void EmitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
Definition: MCStreamer.cpp:689
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment)
Definition: MCStreamer.cpp:372
void setLabel(MCSymbol *Label)
Definition: MCDwarf.h:243
const MCOperand & getOperand(unsigned i) const
Definition: MCInst.h:164
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.
Definition: MCDwarf.h:411
virtual void EmitWinCFISetFrame(unsigned Register, unsigned Offset)
Definition: MCStreamer.cpp:613
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
Set the DescValue for the Symbol.
Definition: MCStreamer.cpp:794
virtual void EmitCFIWindowSave()
Definition: MCStreamer.cpp:488
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
Definition: MCStreamer.cpp:596
bool usesWindowsCFI() const
Definition: MCAsmInfo.h:552
Holds state from .cv_file and .cv_loc directives for later emission.
Definition: MCCodeView.h:158