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