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  for (unsigned i = 0; i < getNumWinFrameInfos(); ++i)
61  delete WinFrameInfos[i];
62 }
63 
65  DwarfFrameInfos.clear();
66  for (unsigned i = 0; i < getNumWinFrameInfos(); ++i)
67  delete WinFrameInfos[i];
68  WinFrameInfos.clear();
69  CurrentWinFrameInfo = nullptr;
70  SymbolOrdering.clear();
71  SectionStack.clear();
72  SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
73 }
74 
76  // By default, discard comments.
77  return nulls();
78 }
79 
80 void MCStreamer::emitRawComment(const Twine &T, bool TabPrefix) {}
81 
84 
86  for (auto &FI : DwarfFrameInfos)
87  FI.CompactUnwindEncoding =
88  (MAB ? MAB->generateCompactUnwindEncoding(FI.Instructions) : 0);
89 }
90 
91 /// EmitIntValue - Special case of EmitValue that avoids the client having to
92 /// pass in a MCExpr for constant integers.
93 void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
94  assert(1 <= Size && Size <= 8 && "Invalid size");
95  assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
96  "Invalid size");
97  char buf[8];
98  const bool isLittleEndian = Context.getAsmInfo()->isLittleEndian();
99  for (unsigned i = 0; i != Size; ++i) {
100  unsigned index = isLittleEndian ? i : (Size - i - 1);
101  buf[i] = uint8_t(Value >> (index * 8));
102  }
103  EmitBytes(StringRef(buf, Size));
104 }
105 
106 /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the
107 /// client having to pass in a MCExpr for constant integers.
108 void MCStreamer::EmitULEB128IntValue(uint64_t Value, unsigned Padding) {
109  SmallString<128> Tmp;
110  raw_svector_ostream OSE(Tmp);
111  encodeULEB128(Value, OSE, Padding);
112  EmitBytes(OSE.str());
113 }
114 
115 /// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the
116 /// client having to pass in a MCExpr for constant integers.
118  SmallString<128> Tmp;
119  raw_svector_ostream OSE(Tmp);
120  encodeSLEB128(Value, OSE);
121  EmitBytes(OSE.str());
122 }
123 
124 void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc) {
125  EmitValueImpl(Value, Size, Loc);
126 }
127 
128 void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
129  bool IsSectionRelative) {
130  assert((!IsSectionRelative || Size == 4) &&
131  "SectionRelative value requires 4-bytes");
132 
133  if (!IsSectionRelative)
135  else
136  EmitCOFFSecRel32(Sym, /*Offset=*/0);
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 
156  report_fatal_error("unsupported directive in streamer");
157 }
158 
160  report_fatal_error("unsupported directive in streamer");
161 }
162 
163 /// Emit NumBytes bytes worth of the value specified by FillValue.
164 /// This implements directives such as '.space'.
165 void MCStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
166  for (uint64_t i = 0, e = NumBytes; i != e; ++i)
167  EmitIntValue(FillValue, 1);
168 }
169 
170 void MCStreamer::emitFill(uint64_t NumValues, int64_t Size, int64_t Expr) {
171  int64_t NonZeroSize = Size > 4 ? 4 : Size;
172  Expr &= ~0ULL >> (64 - NonZeroSize * 8);
173  for (uint64_t i = 0, e = NumValues; i != e; ++i) {
174  EmitIntValue(Expr, NonZeroSize);
175  if (NonZeroSize < Size)
176  EmitIntValue(0, Size - NonZeroSize);
177  }
178 }
179 
180 /// The implementation in this class just redirects to emitFill.
181 void MCStreamer::EmitZeros(uint64_t NumBytes) {
182  emitFill(NumBytes, 0);
183 }
184 
185 unsigned MCStreamer::EmitDwarfFileDirective(unsigned FileNo,
186  StringRef Directory,
187  StringRef Filename, unsigned CUID) {
188  return getContext().getDwarfFile(Directory, Filename, FileNo, CUID);
189 }
190 
191 void MCStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
192  unsigned Column, unsigned Flags,
193  unsigned Isa,
194  unsigned Discriminator,
195  StringRef FileName) {
196  getContext().setCurrentDwarfLoc(FileNo, Line, Column, Flags, Isa,
197  Discriminator);
198 }
199 
202  if (!Table.getLabel()) {
204  Table.setLabel(
205  Context.getOrCreateSymbol(Prefix + "line_table_start" + Twine(CUID)));
206  }
207  return Table.getLabel();
208 }
209 
210 MCDwarfFrameInfo *MCStreamer::getCurrentDwarfFrameInfo() {
211  if (DwarfFrameInfos.empty())
212  return nullptr;
213  return &DwarfFrameInfos.back();
214 }
215 
217  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
218  return CurFrame && !CurFrame->End;
219 }
220 
221 void MCStreamer::EnsureValidDwarfFrame() {
222  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
223  if (!CurFrame || CurFrame->End)
224  report_fatal_error("No open frame");
225 }
226 
227 bool MCStreamer::EmitCVFileDirective(unsigned FileNo, StringRef Filename) {
228  return getContext().getCVContext().addFile(FileNo, Filename);
229 }
230 
231 bool MCStreamer::EmitCVFuncIdDirective(unsigned FunctionId) {
232  return getContext().getCVContext().recordFunctionId(FunctionId);
233 }
234 
236  unsigned IAFunc, unsigned IAFile,
237  unsigned IALine, unsigned IACol,
238  SMLoc Loc) {
239  if (getContext().getCVContext().getCVFunctionInfo(IAFunc) == nullptr) {
240  getContext().reportError(Loc, "parent function id not introduced by "
241  ".cv_func_id or .cv_inline_site_id");
242  return true;
243  }
244 
246  FunctionId, IAFunc, IAFile, IALine, IACol);
247 }
248 
249 void MCStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
250  unsigned Line, unsigned Column,
251  bool PrologueEnd, bool IsStmt,
252  StringRef FileName, SMLoc Loc) {
254  MCCVFunctionInfo *FI = CVC.getCVFunctionInfo(FunctionId);
255  if (!FI)
256  return getContext().reportError(
257  Loc, "function id not introduced by .cv_func_id or .cv_inline_site_id");
258 
259  // Track the section
260  if (FI->Section == nullptr)
262  else if (FI->Section != getCurrentSectionOnly())
263  return getContext().reportError(
264  Loc,
265  "all .cv_loc directives for a function must be in the same section");
266 
267  CVC.setCurrentCVLoc(FunctionId, FileNo, Line, Column, PrologueEnd, IsStmt);
268 }
269 
270 void MCStreamer::EmitCVLinetableDirective(unsigned FunctionId,
271  const MCSymbol *Begin,
272  const MCSymbol *End) {}
273 
274 void MCStreamer::EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
275  unsigned SourceFileId,
276  unsigned SourceLineNum,
277  const MCSymbol *FnStartSym,
278  const MCSymbol *FnEndSym) {}
279 
281  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
282  StringRef FixedSizePortion) {}
283 
285  MCSymbol *EHSymbol) {
286 }
287 
288 void MCStreamer::InitSections(bool NoExecStack) {
289  SwitchSection(getContext().getObjectFileInfo()->getTextSection());
290 }
291 
293  assert(Fragment);
294  Symbol->setFragment(Fragment);
295 
296  // As we emit symbols into a section, track the order so that they can
297  // be sorted upon later. Zero is reserved to mean 'unemitted'.
298  SymbolOrdering[Symbol] = 1 + SymbolOrdering.size();
299 }
300 
302  Symbol->redefineIfPossible();
303 
304  if (!Symbol->isUndefined() || Symbol->isVariable())
305  return getContext().reportError(Loc, "invalid symbol redefinition");
306 
307  assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
308  assert(getCurrentSectionOnly() && "Cannot emit before setting section!");
309  assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
310  assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
311 
312  Symbol->setFragment(&getCurrentSectionOnly()->getDummyFragment());
313 
315  if (TS)
316  TS->emitLabel(Symbol);
317 }
318 
319 void MCStreamer::EmitCFISections(bool EH, bool Debug) {
320  assert(EH || Debug);
321 }
322 
323 void MCStreamer::EmitCFIStartProc(bool IsSimple) {
325  report_fatal_error("Starting a 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  EnsureValidDwarfFrame();
349  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
350  EmitCFIEndProcImpl(*CurFrame);
351 }
352 
354  // Put a dummy non-null value in Frame.End to mark that this frame has been
355  // closed.
356  Frame.End = (MCSymbol *) 1;
357 }
358 
359 MCSymbol *MCStreamer::EmitCFILabel() {
360  MCSymbol *Label = getContext().createTempSymbol("cfi", true);
361  EmitLabel(Label);
362  return Label;
363 }
364 
365 MCSymbol *MCStreamer::EmitCFICommon() {
366  EnsureValidDwarfFrame();
367  return EmitCFILabel();
368 }
369 
370 void MCStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
371  MCSymbol *Label = EmitCFICommon();
373  MCCFIInstruction::createDefCfa(Label, Register, Offset);
374  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
375  CurFrame->Instructions.push_back(Instruction);
376  CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
377 }
378 
380  MCSymbol *Label = EmitCFICommon();
383  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
384  CurFrame->Instructions.push_back(Instruction);
385 }
386 
387 void MCStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
388  MCSymbol *Label = EmitCFICommon();
390  MCCFIInstruction::createAdjustCfaOffset(Label, Adjustment);
391  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
392  CurFrame->Instructions.push_back(Instruction);
393 }
394 
396  MCSymbol *Label = EmitCFICommon();
399  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
400  CurFrame->Instructions.push_back(Instruction);
401  CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
402 }
403 
404 void MCStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
405  MCSymbol *Label = EmitCFICommon();
407  MCCFIInstruction::createOffset(Label, Register, Offset);
408  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
409  CurFrame->Instructions.push_back(Instruction);
410 }
411 
413  MCSymbol *Label = EmitCFICommon();
415  MCCFIInstruction::createRelOffset(Label, Register, Offset);
416  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
417  CurFrame->Instructions.push_back(Instruction);
418 }
419 
421  unsigned Encoding) {
422  EnsureValidDwarfFrame();
423  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
424  CurFrame->Personality = Sym;
425  CurFrame->PersonalityEncoding = Encoding;
426 }
427 
428 void MCStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
429  EnsureValidDwarfFrame();
430  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
431  CurFrame->Lsda = Sym;
432  CurFrame->LsdaEncoding = Encoding;
433 }
434 
436  MCSymbol *Label = EmitCFICommon();
438  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
439  CurFrame->Instructions.push_back(Instruction);
440 }
441 
443  // FIXME: Error if there is no matching cfi_remember_state.
444  MCSymbol *Label = EmitCFICommon();
446  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
447  CurFrame->Instructions.push_back(Instruction);
448 }
449 
451  MCSymbol *Label = EmitCFICommon();
453  MCCFIInstruction::createSameValue(Label, Register);
454  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
455  CurFrame->Instructions.push_back(Instruction);
456 }
457 
459  MCSymbol *Label = EmitCFICommon();
461  MCCFIInstruction::createRestore(Label, Register);
462  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
463  CurFrame->Instructions.push_back(Instruction);
464 }
465 
467  MCSymbol *Label = EmitCFICommon();
469  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
470  CurFrame->Instructions.push_back(Instruction);
471 }
472 
474  MCSymbol *Label = EmitCFICommon();
477  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
478  CurFrame->Instructions.push_back(Instruction);
479 }
480 
482  EnsureValidDwarfFrame();
483  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
484  CurFrame->IsSignalFrame = true;
485 }
486 
488  MCSymbol *Label = EmitCFICommon();
490  MCCFIInstruction::createUndefined(Label, Register);
491  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
492  CurFrame->Instructions.push_back(Instruction);
493 }
494 
495 void MCStreamer::EmitCFIRegister(int64_t Register1, int64_t Register2) {
496  MCSymbol *Label = EmitCFICommon();
498  MCCFIInstruction::createRegister(Label, Register1, Register2);
499  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
500  CurFrame->Instructions.push_back(Instruction);
501 }
502 
504  MCSymbol *Label = EmitCFICommon();
507  MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
508  CurFrame->Instructions.push_back(Instruction);
509 }
510 
511 void MCStreamer::EnsureValidWinFrameInfo() {
512  const MCAsmInfo *MAI = Context.getAsmInfo();
513  if (!MAI->usesWindowsCFI())
514  report_fatal_error(".seh_* directives are not supported on this target");
515  if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End)
516  report_fatal_error("No open Win64 EH frame function!");
517 }
518 
520  const MCAsmInfo *MAI = Context.getAsmInfo();
521  if (!MAI->usesWindowsCFI())
522  report_fatal_error(".seh_* directives are not supported on this target");
523  if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End)
524  report_fatal_error("Starting a function before ending the previous one!");
525 
526  MCSymbol *StartProc = EmitCFILabel();
527 
528  WinFrameInfos.push_back(new WinEH::FrameInfo(Symbol, StartProc));
529  CurrentWinFrameInfo = WinFrameInfos.back();
530  CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
531 }
532 
534  EnsureValidWinFrameInfo();
535  if (CurrentWinFrameInfo->ChainedParent)
536  report_fatal_error("Not all chained regions terminated!");
537 
538  MCSymbol *Label = EmitCFILabel();
539  CurrentWinFrameInfo->End = Label;
540 }
541 
543  EnsureValidWinFrameInfo();
544 
545  MCSymbol *StartProc = EmitCFILabel();
546 
547  WinFrameInfos.push_back(new WinEH::FrameInfo(CurrentWinFrameInfo->Function,
548  StartProc, CurrentWinFrameInfo));
549  CurrentWinFrameInfo = WinFrameInfos.back();
550  CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
551 }
552 
554  EnsureValidWinFrameInfo();
555  if (!CurrentWinFrameInfo->ChainedParent)
556  report_fatal_error("End of a chained region outside a chained region!");
557 
558  MCSymbol *Label = EmitCFILabel();
559 
560  CurrentWinFrameInfo->End = Label;
561  CurrentWinFrameInfo =
562  const_cast<WinEH::FrameInfo *>(CurrentWinFrameInfo->ChainedParent);
563 }
564 
565 void MCStreamer::EmitWinEHHandler(const MCSymbol *Sym, bool Unwind,
566  bool Except) {
567  EnsureValidWinFrameInfo();
568  if (CurrentWinFrameInfo->ChainedParent)
569  report_fatal_error("Chained unwind areas can't have handlers!");
570  CurrentWinFrameInfo->ExceptionHandler = Sym;
571  if (!Except && !Unwind)
572  report_fatal_error("Don't know what kind of handler this is!");
573  if (Unwind)
574  CurrentWinFrameInfo->HandlesUnwind = true;
575  if (Except)
576  CurrentWinFrameInfo->HandlesExceptions = true;
577 }
578 
580  EnsureValidWinFrameInfo();
581  if (CurrentWinFrameInfo->ChainedParent)
582  report_fatal_error("Chained unwind areas can't have handlers!");
583 }
584 
585 static MCSection *getWinCFISection(MCContext &Context, unsigned *NextWinCFIID,
586  MCSection *MainCFISec,
587  const MCSection *TextSec) {
588  // If this is the main .text section, use the main unwind info section.
589  if (TextSec == Context.getObjectFileInfo()->getTextSection())
590  return MainCFISec;
591 
592  const auto *TextSecCOFF = cast<MCSectionCOFF>(TextSec);
593  unsigned UniqueID = TextSecCOFF->getOrAssignWinCFISectionID(NextWinCFIID);
594 
595  // If this section is COMDAT, this unwind section should be COMDAT associative
596  // with its group.
597  const MCSymbol *KeySym = nullptr;
598  if (TextSecCOFF->getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT)
599  KeySym = TextSecCOFF->getCOMDATSymbol();
600 
601  return Context.getAssociativeCOFFSection(cast<MCSectionCOFF>(MainCFISec),
602  KeySym, UniqueID);
603 }
604 
606  return getWinCFISection(getContext(), &NextWinCFIID,
607  getContext().getObjectFileInfo()->getPDataSection(),
608  TextSec);
609 }
610 
612  return getWinCFISection(getContext(), &NextWinCFIID,
613  getContext().getObjectFileInfo()->getXDataSection(),
614  TextSec);
615 }
616 
618 
620  EnsureValidWinFrameInfo();
621 
622  MCSymbol *Label = EmitCFILabel();
623 
625  CurrentWinFrameInfo->Instructions.push_back(Inst);
626 }
627 
629  EnsureValidWinFrameInfo();
630  if (CurrentWinFrameInfo->LastFrameInst >= 0)
631  report_fatal_error("Frame register and offset already specified!");
632  if (Offset & 0x0F)
633  report_fatal_error("Misaligned frame pointer offset!");
634  if (Offset > 240)
635  report_fatal_error("Frame offset must be less than or equal to 240!");
636 
637  MCSymbol *Label = EmitCFILabel();
638 
639  WinEH::Instruction Inst =
640  Win64EH::Instruction::SetFPReg(Label, Register, Offset);
641  CurrentWinFrameInfo->LastFrameInst = CurrentWinFrameInfo->Instructions.size();
642  CurrentWinFrameInfo->Instructions.push_back(Inst);
643 }
644 
646  EnsureValidWinFrameInfo();
647  if (Size == 0)
648  report_fatal_error("Allocation size must be non-zero!");
649  if (Size & 7)
650  report_fatal_error("Misaligned stack allocation!");
651 
652  MCSymbol *Label = EmitCFILabel();
653 
655  CurrentWinFrameInfo->Instructions.push_back(Inst);
656 }
657 
659  EnsureValidWinFrameInfo();
660  if (Offset & 7)
661  report_fatal_error("Misaligned saved register offset!");
662 
663  MCSymbol *Label = EmitCFILabel();
664 
665  WinEH::Instruction Inst =
666  Win64EH::Instruction::SaveNonVol(Label, Register, Offset);
667  CurrentWinFrameInfo->Instructions.push_back(Inst);
668 }
669 
671  EnsureValidWinFrameInfo();
672  if (Offset & 0x0F)
673  report_fatal_error("Misaligned saved vector register offset!");
674 
675  MCSymbol *Label = EmitCFILabel();
676 
677  WinEH::Instruction Inst =
678  Win64EH::Instruction::SaveXMM(Label, Register, Offset);
679  CurrentWinFrameInfo->Instructions.push_back(Inst);
680 }
681 
683  EnsureValidWinFrameInfo();
684  if (!CurrentWinFrameInfo->Instructions.empty())
685  report_fatal_error("If present, PushMachFrame must be the first UOP");
686 
687  MCSymbol *Label = EmitCFILabel();
688 
690  CurrentWinFrameInfo->Instructions.push_back(Inst);
691 }
692 
694  EnsureValidWinFrameInfo();
695 
696  MCSymbol *Label = EmitCFILabel();
697 
698  CurrentWinFrameInfo->PrologEnd = Label;
699 }
700 
702 }
703 
705 }
706 
708 
709 /// EmitRawText - If this file is backed by an assembly streamer, this dumps
710 /// the specified string in the output .s file. This capability is
711 /// indicated by the hasRawTextSupport() predicate.
713  errs() << "EmitRawText called on an MCStreamer that doesn't support it, "
714  " something must not be fully mc'ized\n";
715  abort();
716 }
717 
719  SmallString<128> Str;
721 }
722 
724 }
725 
727  if (!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End)
728  report_fatal_error("Unfinished frame!");
729 
731  if (TS)
732  TS->finish();
733 
734  FinishImpl();
735 }
736 
738  visitUsedExpr(*Value);
739  Symbol->setVariableValue(Value);
740 
742  if (TS)
743  TS->emitAssignment(Symbol, Value);
744 }
745 
747  const MCInst &Inst, const MCSubtargetInfo &STI) {
748  InstPrinter.printInst(&Inst, OS, "", STI);
749 }
750 
752 }
753 
755  switch (Expr.getKind()) {
756  case MCExpr::Target:
757  cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
758  break;
759 
760  case MCExpr::Constant:
761  break;
762 
763  case MCExpr::Binary: {
764  const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
765  visitUsedExpr(*BE.getLHS());
766  visitUsedExpr(*BE.getRHS());
767  break;
768  }
769 
770  case MCExpr::SymbolRef:
771  visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
772  break;
773 
774  case MCExpr::Unary:
775  visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
776  break;
777  }
778 }
779 
781  bool) {
782  // Scan for values.
783  for (unsigned i = Inst.getNumOperands(); i--;)
784  if (Inst.getOperand(i).isExpr())
785  visitUsedExpr(*Inst.getOperand(i).getExpr());
786 }
787 
789  unsigned Size) {
790  // Get the Hi-Lo expression.
791  const MCExpr *Diff =
793  MCSymbolRefExpr::create(Lo, Context), Context);
794 
795  const MCAsmInfo *MAI = Context.getAsmInfo();
796  if (!MAI->doesSetDirectiveSuppressReloc()) {
797  EmitValue(Diff, Size);
798  return;
799  }
800 
801  // Otherwise, emit with .set (aka assignment).
802  MCSymbol *SetLabel = Context.createTempSymbol("set", true);
803  EmitAssignment(SetLabel, Diff);
804  EmitSymbolValue(SetLabel, Size);
805 }
806 
809 void MCStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
811  llvm_unreachable("this directive only supported on COFF targets");
812 }
814  llvm_unreachable("this directive only supported on COFF targets");
815 }
818  llvm_unreachable("this directive only supported on COFF targets");
819 }
821  llvm_unreachable("this directive only supported on COFF targets");
822 }
825  const MCSymbol *Aliasee) {}
827  unsigned ByteAlignment) {}
829  uint64_t Size, unsigned ByteAlignment) {}
834 void MCStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) {
835  visitUsedExpr(*Value);
836 }
839 void MCStreamer::emitFill(const MCExpr &NumBytes, uint64_t Value, SMLoc Loc) {}
840 void MCStreamer::emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
841  SMLoc Loc) {}
843  unsigned ValueSize,
844  unsigned MaxBytesToEmit) {}
846  unsigned MaxBytesToEmit) {}
848  SMLoc Loc) {}
849 void MCStreamer::EmitBundleAlignMode(unsigned AlignPow2) {}
850 void MCStreamer::EmitBundleLock(bool AlignToEnd) {}
853 
855  assert(Section && "Cannot switch to a null section!");
856  MCSectionSubPair curSection = SectionStack.back().first;
857  SectionStack.back().second = curSection;
858  if (MCSectionSubPair(Section, Subsection) != curSection) {
859  ChangeSection(Section, Subsection);
860  SectionStack.back().first = MCSectionSubPair(Section, Subsection);
861  assert(!Section->hasEnded() && "Section already ended");
862  MCSymbol *Sym = Section->getBeginSymbol();
863  if (Sym && !Sym->isInSection())
864  EmitLabel(Sym);
865  }
866 }
867 
869  // TODO: keep track of the last subsection so that this symbol appears in the
870  // correct place.
871  MCSymbol *Sym = Section->getEndSymbol(Context);
872  if (Sym->isInSection())
873  return Sym;
874 
875  SwitchSection(Section);
876  EmitLabel(Sym);
877  return Sym;
878 }
virtual void EmitBundleUnlock()
Ends a bundle-locked group.
Definition: MCStreamer.cpp:852
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag)
Note in the output the specified Flag.
Definition: MCStreamer.cpp:807
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:191
virtual void EmitBundleAlignMode(unsigned AlignPow2)
Set the bundle alignment mode from now on in the section.
Definition: MCStreamer.cpp:849
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
bool usesWindowsCFI() const
Definition: MCAsmInfo.h:568
virtual void EmitCFISameValue(int64_t Register)
Definition: MCStreamer.cpp:450
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:280
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:420
virtual void EmitSLEB128Value(const MCExpr *Value)
Definition: MCStreamer.cpp:838
virtual void EmitCFIGnuArgsSize(int64_t Size)
Definition: MCStreamer.cpp:473
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:718
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:305
virtual void EmitWinCFIEndProlog()
Definition: MCStreamer.cpp:693
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:117
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:103
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:128
virtual void emitELFSymverDirective(MCSymbol *Alias, const MCSymbol *Aliasee)
Emit an ELF .symver directive.
Definition: MCStreamer.cpp:824
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:847
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:828
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 EndCOFFSymbolDef()
Marks the end of the symbol definition.
Definition: MCStreamer.cpp:813
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:837
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:831
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:832
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:78
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
virtual void reset()
State management.
Definition: MCStreamer.cpp:64
unsigned CurrentCfaRegister
Definition: MCDwarf.h:506
virtual void EmitWindowsUnwindTables()
Definition: MCStreamer.cpp:723
void EmitCFIStartProc(bool IsSimple)
Definition: MCStreamer.cpp:323
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol)
Start emitting COFF symbol definition.
Definition: MCStreamer.cpp:810
virtual void EmitDTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
Definition: MCStreamer.cpp:139
virtual unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, unsigned CUID=0)
Associate a filename with a specified logical file number.
Definition: MCStreamer.cpp:185
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:490
virtual void EmitCFIRegister(int64_t Register1, int64_t Register2)
Definition: MCStreamer.cpp:495
virtual void emitExplicitComments()
Emit added explicit comments.
Definition: MCStreamer.cpp:83
virtual void EmitCFIDefCfaOffset(int64_t Offset)
Definition: MCStreamer.cpp:379
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
Definition: MCStreamer.cpp:200
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:314
virtual void EmitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
Definition: MCStreamer.cpp:817
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:834
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
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, bool PrintSchedInfo=false)
Emit the given Instruction into the current section.
Definition: MCStreamer.cpp:780
virtual void addExplicitComment(const Twine &T)
Add explicit comment T.
Definition: MCStreamer.cpp:82
virtual void EmitCFISections(bool EH, bool Debug)
Definition: MCStreamer.cpp:319
virtual void EmitGPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
Definition: MCStreamer.cpp:159
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 EmitWinEHHandlerData()
Definition: MCStreamer.cpp:579
virtual void EmitCFIRememberState()
Definition: MCStreamer.cpp:435
MCContext & getContext() const
Definition: MCStreamer.h:226
virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:428
virtual void EmitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
Definition: MCStreamer.cpp:155
void AssignFragment(MCSymbol *Symbol, MCFragment *Fragment)
Sets the symbol&#39;s section.
Definition: MCStreamer.cpp:292
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:466
virtual void EmitCOFFSymbolType(int Type)
Emit the type of the symbol.
Definition: MCStreamer.cpp:820
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
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:132
virtual void emitLabel(MCSymbol *Symbol)
Definition: MCStreamer.cpp:48
virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
Definition: MCStreamer.cpp:344
unsigned getNumWinFrameInfos()
Definition: MCStreamer.h:239
virtual ~MCStreamer()
Definition: MCStreamer.cpp:59
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition: MCContext.h:526
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:249
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Definition: MCStreamer.cpp:737
Context object for machine code objects.
Definition: MCContext.h:59
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:353
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:147
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:80
virtual void EmitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
Definition: MCStreamer.cpp:833
const MCExpr * getExpr() const
Definition: MCInst.h:96
virtual void EmitCFIRestoreState()
Definition: MCStreamer.cpp:442
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:93
Expected< const typename ELFT::Sym * > getSymbol(typename ELFT::SymRange Symbols, uint32_t Index)
Definition: ELF.h:243
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:124
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:458
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:850
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)
Emit a local common (.lcomm) symbol.
Definition: MCStreamer.cpp:826
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:75
bool addFile(unsigned FileNumber, StringRef Filename)
Definition: MCCodeView.cpp:47
void EmitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Definition: MCStreamer.cpp:181
Streaming machine code generation interface.
Definition: MCStreamer.h:167
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:228
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:270
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
virtual void EmitWinCFIPushReg(unsigned Register)
Definition: MCStreamer.cpp:619
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:854
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:605
virtual void EmitSyntaxDirective()
Definition: MCStreamer.cpp:617
virtual void EmitCFIDefCfaRegister(int64_t Register)
Definition: MCStreamer.cpp:395
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:842
static const unsigned End
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:287
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:608
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:712
virtual void EmitWinCFIEndChained()
Definition: MCStreamer.cpp:553
virtual void EmitWinCFIEndProc()
Definition: MCStreamer.cpp:533
unsigned getNumOperands() const
Definition: MCInst.h:175
unsigned size() const
Definition: DenseMap.h:87
virtual void EmitCFIUndefined(int64_t Register)
Definition: MCStreamer.cpp:487
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:726
virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol)
Definition: MCStreamer.cpp:284
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
virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except)
Definition: MCStreamer.cpp:565
Binary assembler expressions.
Definition: MCExpr.h:399
virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol)
Definition: MCStreamer.cpp:701
void generateCompactUnwindEncodings(MCAsmBackend *MAB)
Definition: MCStreamer.cpp:85
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
virtual bool EmitCVFileDirective(unsigned FileNo, StringRef Filename)
Associate a filename with a specified logical file number.
Definition: MCStreamer.cpp:227
static MCSection * getWinCFISection(MCContext &Context, unsigned *NextWinCFIID, MCSection *MainCFISec, const MCSection *TextSec)
Definition: MCStreamer.cpp:585
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:151
const MCSymbol * PrologEnd
Definition: MCWinEH.h:36
virtual void EmitWinCFIStartChained()
Definition: MCStreamer.cpp:542
virtual void InitSections(bool NoExecStack)
Create the default sections and set the initial one.
Definition: MCStreamer.cpp:288
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
Definition: MCStreamer.h:51
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 EmitWinCFISaveXMM(unsigned Register, unsigned Offset)
Definition: MCStreamer.cpp:670
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
Definition: MCStreamer.cpp:788
ExprKind getKind() const
Definition: MCExpr.h:73
virtual void EmitCFIOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:404
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
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:845
const MCOperand & getOperand(unsigned i) const
Definition: MCInst.h:173
Promote Memory to Register
Definition: Mem2Reg.cpp:101
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:274
MCSymbol * getBeginSymbol()
Definition: MCSection.h:106
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS, const MCInst &Inst, const MCSubtargetInfo &STI)
Definition: MCStreamer.cpp:746
StringRef str()
Return a StringRef for the vector contents.
Definition: raw_ostream.h:515
virtual void EmitWinCFIAllocStack(unsigned Size)
Definition: MCStreamer.cpp:645
virtual void ChangeSection(MCSection *, const MCExpr *)
Update streamer for a new active section.
Definition: MCStreamer.cpp:830
void setVariableValue(const MCExpr *Value)
Definition: MCSymbol.cpp:48
bool hasUnfinishedDwarfFrameInfo()
Definition: MCStreamer.cpp:216
const MCSymbol * Function
Definition: MCWinEH.h:35
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:308
void visitUsedExpr(const MCExpr &Expr)
Definition: MCStreamer.cpp:754
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
MCTargetStreamer(MCStreamer &S)
Definition: MCStreamer.cpp:41
static std::vector< std::string > Flags
Definition: FlagsTest.cpp:8
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:808
virtual void EmitCFISignalFrame()
Definition: MCStreamer.cpp:481
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:412
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:81
virtual void EmitFileDirective(StringRef Filename)
Switch to a new logical file.
Definition: MCStreamer.cpp:816
virtual void EmitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
Definition: MCStreamer.cpp:143
MCSubtargetInfo - Generic base class for all target subtargets.
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
Definition: MCStreamer.cpp:823
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:165
virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:370
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:108
MCSymbol * endSection(MCSection *Section)
Definition: MCStreamer.cpp:868
void encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned Padding=0)
Utility function to encode a SLEB128 value to an output stream.
Definition: LEB128.h:23
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:565
CodeViewContext & getCVContext()
Definition: MCContext.cpp:598
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:707
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual void FinishImpl()
Streamer specific finalization.
Definition: MCStreamer.cpp:851
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:235
LLVM Value Representation.
Definition: Value.h:73
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:35
unsigned getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
Definition: MCContext.cpp:575
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:231
virtual void EmitWinCFIStartProc(const MCSymbol *Symbol)
Definition: MCStreamer.cpp:519
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:301
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
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:73
virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset)
Definition: MCStreamer.cpp:658
virtual void EmitWinCFIPushFrame(bool Code)
Definition: MCStreamer.cpp:682
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Target specific expression.
Definition: MCExpr.h:43
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:751
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:218
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:704
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 EmitWinCFISetFrame(unsigned Register, unsigned Offset)
Definition: MCStreamer.cpp:628
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
Set the DescValue for the Symbol.
Definition: MCStreamer.cpp:809
virtual void EmitCFIWindowSave()
Definition: MCStreamer.cpp:503
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
Definition: MCStreamer.cpp:611
Holds state from .cv_file and .cv_loc directives for later emission.
Definition: MCCodeView.h:158