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