LLVM  4.0.0
MCStreamer.h
Go to the documentation of this file.
1 //===- MCStreamer.h - High-level Streaming Machine Code Output --*- C++ -*-===//
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 // This file declares the MCStreamer class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_MC_MCSTREAMER_H
15 #define LLVM_MC_MCSTREAMER_H
16 
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/MC/MCDirectives.h"
20 #include "llvm/MC/MCDwarf.h"
22 #include "llvm/MC/MCSymbol.h"
23 #include "llvm/MC/MCWinEH.h"
24 #include "llvm/Support/DataTypes.h"
25 #include "llvm/Support/SMLoc.h"
26 #include <string>
27 
28 namespace llvm {
29 class MCAsmBackend;
30 class MCCodeEmitter;
31 class MCContext;
32 class MCExpr;
33 class MCInst;
34 class MCInstPrinter;
35 class MCSection;
36 class MCStreamer;
37 class MCSymbolELF;
38 class MCSymbolRefExpr;
39 class MCSubtargetInfo;
40 class StringRef;
41 class Twine;
42 class raw_ostream;
43 class formatted_raw_ostream;
45 
46 typedef std::pair<MCSection *, const MCExpr *> MCSectionSubPair;
47 
48 /// Target specific streamer interface. This is used so that targets can
49 /// implement support for target specific assembly directives.
50 ///
51 /// If target foo wants to use this, it should implement 3 classes:
52 /// * FooTargetStreamer : public MCTargetStreamer
53 /// * FooTargetAsmStreamer : public FooTargetStreamer
54 /// * FooTargetELFStreamer : public FooTargetStreamer
55 ///
56 /// FooTargetStreamer should have a pure virtual method for each directive. For
57 /// example, for a ".bar symbol_name" directive, it should have
58 /// virtual emitBar(const MCSymbol &Symbol) = 0;
59 ///
60 /// The FooTargetAsmStreamer and FooTargetELFStreamer classes implement the
61 /// method. The assembly streamer just prints ".bar symbol_name". The object
62 /// streamer does whatever is needed to implement .bar in the object file.
63 ///
64 /// In the assembly printer and parser the target streamer can be used by
65 /// calling getTargetStreamer and casting it to FooTargetStreamer:
66 ///
67 /// MCTargetStreamer &TS = OutStreamer.getTargetStreamer();
68 /// FooTargetStreamer &ATS = static_cast<FooTargetStreamer &>(TS);
69 ///
70 /// The base classes FooTargetAsmStreamer and FooTargetELFStreamer should
71 /// *never* be treated differently. Callers should always talk to a
72 /// FooTargetStreamer.
74 protected:
76 
77 public:
79  virtual ~MCTargetStreamer();
80 
82 
83  // Allow a target to add behavior to the EmitLabel of MCStreamer.
84  virtual void emitLabel(MCSymbol *Symbol);
85  // Allow a target to add behavior to the emitAssignment of MCStreamer.
86  virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value);
87 
88  virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS,
89  const MCInst &Inst, const MCSubtargetInfo &STI);
90 
91  virtual void finish();
92 };
93 
94 // FIXME: declared here because it is used from
95 // lib/CodeGen/AsmPrinter/ARMException.cpp.
97 public:
99  ~ARMTargetStreamer() override;
100 
101  virtual void emitFnStart();
102  virtual void emitFnEnd();
103  virtual void emitCantUnwind();
104  virtual void emitPersonality(const MCSymbol *Personality);
105  virtual void emitPersonalityIndex(unsigned Index);
106  virtual void emitHandlerData();
107  virtual void emitSetFP(unsigned FpReg, unsigned SpReg,
108  int64_t Offset = 0);
109  virtual void emitMovSP(unsigned Reg, int64_t Offset = 0);
110  virtual void emitPad(int64_t Offset);
111  virtual void emitRegSave(const SmallVectorImpl<unsigned> &RegList,
112  bool isVector);
113  virtual void emitUnwindRaw(int64_t StackOffset,
114  const SmallVectorImpl<uint8_t> &Opcodes);
115 
116  virtual void switchVendor(StringRef Vendor);
117  virtual void emitAttribute(unsigned Attribute, unsigned Value);
118  virtual void emitTextAttribute(unsigned Attribute, StringRef String);
119  virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
120  StringRef StringValue = "");
121  virtual void emitFPU(unsigned FPU);
122  virtual void emitArch(unsigned Arch);
123  virtual void emitArchExtension(unsigned ArchExt);
124  virtual void emitObjectArch(unsigned Arch);
125  virtual void finishAttributeSection();
126  virtual void emitInst(uint32_t Inst, char Suffix = '\0');
127 
128  virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE);
129 
130  virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value);
131 
132  void finish() override;
133 
134  /// Reset any state between object emissions, i.e. the equivalent of
135  /// MCStreamer's reset method.
136  virtual void reset();
137 
138  /// Callback used to implement the ldr= pseudo.
139  /// Add a new entry to the constant pool for the current section and return an
140  /// MCExpr that can be used to refer to the constant pool location.
141  const MCExpr *addConstantPoolEntry(const MCExpr *, SMLoc Loc);
142 
143  /// Callback used to implemnt the .ltorg directive.
144  /// Emit contents of constant pool for the current section.
146 
147 private:
148  std::unique_ptr<AssemblerConstantPools> ConstantPools;
149 };
150 
151 /// \brief Streaming machine code generation interface.
152 ///
153 /// This interface is intended to provide a programatic interface that is very
154 /// similar to the level that an assembler .s file provides. It has callbacks
155 /// to emit bytes, handle directives, etc. The implementation of this interface
156 /// retains state to know what the current section is etc.
157 ///
158 /// There are multiple implementations of this interface: one for writing out
159 /// a .s file, and implementations that write out .o files of various formats.
160 ///
161 class MCStreamer {
162  MCContext &Context;
163  std::unique_ptr<MCTargetStreamer> TargetStreamer;
164 
165  MCStreamer(const MCStreamer &) = delete;
166  MCStreamer &operator=(const MCStreamer &) = delete;
167 
168  std::vector<MCDwarfFrameInfo> DwarfFrameInfos;
169  MCDwarfFrameInfo *getCurrentDwarfFrameInfo();
170  void EnsureValidDwarfFrame();
171 
172  MCSymbol *EmitCFILabel();
173  MCSymbol *EmitCFICommon();
174 
175  std::vector<WinEH::FrameInfo *> WinFrameInfos;
176  WinEH::FrameInfo *CurrentWinFrameInfo;
177  void EnsureValidWinFrameInfo();
178 
179  /// \brief Tracks an index to represent the order a symbol was emitted in.
180  /// Zero means we did not emit that symbol.
182 
183  /// \brief This is stack of current and previous section values saved by
184  /// PushSection.
186 
187  /// The next unique ID to use when creating a WinCFI-related section (.pdata
188  /// or .xdata). This ID ensures that we have a one-to-one mapping from
189  /// code section to unwind info section, which MSVC's incremental linker
190  /// requires.
191  unsigned NextWinCFIID = 0;
192 
193 protected:
194  MCStreamer(MCContext &Ctx);
195 
196  virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
197  virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
198 
200  return CurrentWinFrameInfo;
201  }
202 
203  virtual void EmitWindowsUnwindTables();
204 
205  virtual void EmitRawTextImpl(StringRef String);
206 
207 public:
208  virtual ~MCStreamer();
209 
210  void visitUsedExpr(const MCExpr &Expr);
211  virtual void visitUsedSymbol(const MCSymbol &Sym);
212 
214  TargetStreamer.reset(TS);
215  }
216 
217  /// State management
218  ///
219  virtual void reset();
220 
221  MCContext &getContext() const { return Context; }
222 
224  return TargetStreamer.get();
225  }
226 
227  unsigned getNumFrameInfos() { return DwarfFrameInfos.size(); }
229  return DwarfFrameInfos;
230  }
231 
233 
234  unsigned getNumWinFrameInfos() { return WinFrameInfos.size(); }
236  return WinFrameInfos;
237  }
238 
240 
241  /// \name Assembly File Formatting.
242  /// @{
243 
244  /// \brief Return true if this streamer supports verbose assembly and if it is
245  /// enabled.
246  virtual bool isVerboseAsm() const { return false; }
247 
248  /// \brief Return true if this asm streamer supports emitting unformatted text
249  /// to the .s file with EmitRawText.
250  virtual bool hasRawTextSupport() const { return false; }
251 
252  /// \brief Is the integrated assembler required for this streamer to function
253  /// correctly?
254  virtual bool isIntegratedAssemblerRequired() const { return false; }
255 
256  /// \brief Add a textual comment.
257  ///
258  /// Typically for comments that can be emitted to the generated .s
259  /// file if applicable as a QoI issue to make the output of the compiler
260  /// more readable. This only affects the MCAsmStreamer, and only when
261  /// verbose assembly output is enabled.
262  ///
263  /// If the comment includes embedded \n's, they will each get the comment
264  /// prefix as appropriate. The added comment should not end with a \n.
265  /// By default, each comment is terminated with an end of line, i.e. the
266  /// EOL param is set to true by default. If one prefers not to end the
267  /// comment with a new line then the EOL param should be passed
268  /// with a false value.
269  virtual void AddComment(const Twine &T, bool EOL = true) {}
270 
271  /// \brief Return a raw_ostream that comments can be written to. Unlike
272  /// AddComment, you are required to terminate comments with \n if you use this
273  /// method.
274  virtual raw_ostream &GetCommentOS();
275 
276  /// \brief Print T and prefix it with the comment string (normally #) and
277  /// optionally a tab. This prints the comment immediately, not at the end of
278  /// the current line. It is basically a safe version of EmitRawText: since it
279  /// only prints comments, the object streamer ignores it instead of asserting.
280  virtual void emitRawComment(const Twine &T, bool TabPrefix = true);
281 
282  /// \brief Add explicit comment T. T is required to be a valid
283  /// comment in the output and does not need to be escaped.
284  virtual void addExplicitComment(const Twine &T);
285  /// \brief Emit added explicit comments.
286  virtual void emitExplicitComments();
287 
288  /// AddBlankLine - Emit a blank line to a .s file to pretty it up.
289  virtual void AddBlankLine() {}
290 
291  /// @}
292 
293  /// \name Symbol & Section Management
294  /// @{
295 
296  /// \brief Return the current section that the streamer is emitting code to.
298  if (!SectionStack.empty())
299  return SectionStack.back().first;
300  return MCSectionSubPair();
301  }
302  MCSection *getCurrentSectionOnly() const { return getCurrentSection().first; }
303 
304  /// \brief Return the previous section that the streamer is emitting code to.
306  if (!SectionStack.empty())
307  return SectionStack.back().second;
308  return MCSectionSubPair();
309  }
310 
311  /// \brief Returns an index to represent the order a symbol was emitted in.
312  /// (zero if we did not emit that symbol)
313  unsigned GetSymbolOrder(const MCSymbol *Sym) const {
314  return SymbolOrdering.lookup(Sym);
315  }
316 
317  /// \brief Update streamer for a new active section.
318  ///
319  /// This is called by PopSection and SwitchSection, if the current
320  /// section changes.
321  virtual void ChangeSection(MCSection *, const MCExpr *);
322 
323  /// \brief Save the current and previous section on the section stack.
324  void PushSection() {
325  SectionStack.push_back(
326  std::make_pair(getCurrentSection(), getPreviousSection()));
327  }
328 
329  /// \brief Restore the current and previous section from the section stack.
330  /// Calls ChangeSection as needed.
331  ///
332  /// Returns false if the stack was empty.
333  bool PopSection() {
334  if (SectionStack.size() <= 1)
335  return false;
336  auto I = SectionStack.end();
337  --I;
338  MCSectionSubPair OldSection = I->first;
339  --I;
340  MCSectionSubPair NewSection = I->first;
341 
342  if (OldSection != NewSection)
343  ChangeSection(NewSection.first, NewSection.second);
344  SectionStack.pop_back();
345  return true;
346  }
347 
348  bool SubSection(const MCExpr *Subsection) {
349  if (SectionStack.empty())
350  return false;
351 
352  SwitchSection(SectionStack.back().first.first, Subsection);
353  return true;
354  }
355 
356  /// Set the current section where code is being emitted to \p Section. This
357  /// is required to update CurSection.
358  ///
359  /// This corresponds to assembler directives like .section, .text, etc.
360  virtual void SwitchSection(MCSection *Section,
361  const MCExpr *Subsection = nullptr);
362 
363  /// \brief Set the current section where code is being emitted to \p Section.
364  /// This is required to update CurSection. This version does not call
365  /// ChangeSection.
367  const MCExpr *Subsection = nullptr) {
368  assert(Section && "Cannot switch to a null section!");
369  MCSectionSubPair curSection = SectionStack.back().first;
370  SectionStack.back().second = curSection;
371  if (MCSectionSubPair(Section, Subsection) != curSection)
372  SectionStack.back().first = MCSectionSubPair(Section, Subsection);
373  }
374 
375  /// \brief Create the default sections and set the initial one.
376  virtual void InitSections(bool NoExecStack);
377 
379 
380  /// \brief Sets the symbol's section.
381  ///
382  /// Each emitted symbol will be tracked in the ordering table,
383  /// so we can sort on them later.
384  void AssignFragment(MCSymbol *Symbol, MCFragment *Fragment);
385 
386  /// \brief Emit a label for \p Symbol into the current section.
387  ///
388  /// This corresponds to an assembler statement such as:
389  /// foo:
390  ///
391  /// \param Symbol - The symbol to emit. A given symbol should only be
392  /// emitted as a label once, and symbols emitted as a label should never be
393  /// used in an assignment.
394  // FIXME: These emission are non-const because we mutate the symbol to
395  // add the section we're emitting it to later.
396  virtual void EmitLabel(MCSymbol *Symbol);
397 
398  virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol);
399 
400  /// \brief Note in the output the specified \p Flag.
401  virtual void EmitAssemblerFlag(MCAssemblerFlag Flag);
402 
403  /// \brief Emit the given list \p Options of strings as linker
404  /// options into the output.
406 
407  /// \brief Note in the output the specified region \p Kind.
409 
410  /// \brief Specify the MachO minimum deployment target version.
411  virtual void EmitVersionMin(MCVersionMinType, unsigned Major, unsigned Minor,
412  unsigned Update) {}
413 
414  /// \brief Note in the output that the specified \p Func is a Thumb mode
415  /// function (ARM target only).
416  virtual void EmitThumbFunc(MCSymbol *Func);
417 
418  /// \brief Emit an assignment of \p Value to \p Symbol.
419  ///
420  /// This corresponds to an assembler statement such as:
421  /// symbol = value
422  ///
423  /// The assignment generates no code, but has the side effect of binding the
424  /// value in the current context. For the assembly streamer, this prints the
425  /// binding into the .s file.
426  ///
427  /// \param Symbol - The symbol being assigned to.
428  /// \param Value - The value for the symbol.
429  virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value);
430 
431  /// \brief Emit an weak reference from \p Alias to \p Symbol.
432  ///
433  /// This corresponds to an assembler statement such as:
434  /// .weakref alias, symbol
435  ///
436  /// \param Alias - The alias that is being created.
437  /// \param Symbol - The symbol being aliased.
438  virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol);
439 
440  /// \brief Add the given \p Attribute to \p Symbol.
441  virtual bool EmitSymbolAttribute(MCSymbol *Symbol,
442  MCSymbolAttr Attribute) = 0;
443 
444  /// \brief Set the \p DescValue for the \p Symbol.
445  ///
446  /// \param Symbol - The symbol to have its n_desc field set.
447  /// \param DescValue - The value to set into the n_desc field.
448  virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
449 
450  /// \brief Start emitting COFF symbol definition
451  ///
452  /// \param Symbol - The symbol to have its External & Type fields set.
453  virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol);
454 
455  /// \brief Emit the storage class of the symbol.
456  ///
457  /// \param StorageClass - The storage class the symbol should have.
458  virtual void EmitCOFFSymbolStorageClass(int StorageClass);
459 
460  /// \brief Emit the type of the symbol.
461  ///
462  /// \param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h)
463  virtual void EmitCOFFSymbolType(int Type);
464 
465  /// \brief Marks the end of the symbol definition.
466  virtual void EndCOFFSymbolDef();
467 
468  virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol);
469 
470  /// \brief Emits a COFF section index.
471  ///
472  /// \param Symbol - Symbol the section number relocation should point to.
473  virtual void EmitCOFFSectionIndex(MCSymbol const *Symbol);
474 
475  /// \brief Emits a COFF section relative relocation.
476  ///
477  /// \param Symbol - Symbol the section relative relocation should point to.
478  virtual void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset);
479 
480  /// \brief Emit an ELF .size directive.
481  ///
482  /// This corresponds to an assembler statement such as:
483  /// .size symbol, expression
484  virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value);
485 
486  /// \brief Emit a Linker Optimization Hint (LOH) directive.
487  /// \param Args - Arguments of the LOH.
488  virtual void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {}
489 
490  /// \brief Emit a common symbol.
491  ///
492  /// \param Symbol - The common symbol to emit.
493  /// \param Size - The size of the common symbol.
494  /// \param ByteAlignment - The alignment of the symbol if
495  /// non-zero. This must be a power of 2.
496  virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
497  unsigned ByteAlignment) = 0;
498 
499  /// \brief Emit a local common (.lcomm) symbol.
500  ///
501  /// \param Symbol - The common symbol to emit.
502  /// \param Size - The size of the common symbol.
503  /// \param ByteAlignment - The alignment of the common symbol in bytes.
504  virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
505  unsigned ByteAlignment);
506 
507  /// \brief Emit the zerofill section and an optional symbol.
508  ///
509  /// \param Section - The zerofill section to create and or to put the symbol
510  /// \param Symbol - The zerofill symbol to emit, if non-NULL.
511  /// \param Size - The size of the zerofill symbol.
512  /// \param ByteAlignment - The alignment of the zerofill symbol if
513  /// non-zero. This must be a power of 2 on some targets.
514  virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
515  uint64_t Size = 0, unsigned ByteAlignment = 0) = 0;
516 
517  /// \brief Emit a thread local bss (.tbss) symbol.
518  ///
519  /// \param Section - The thread local common section.
520  /// \param Symbol - The thread local common symbol to emit.
521  /// \param Size - The size of the symbol.
522  /// \param ByteAlignment - The alignment of the thread local common symbol
523  /// if non-zero. This must be a power of 2 on some targets.
525  uint64_t Size, unsigned ByteAlignment = 0);
526 
527  /// @}
528  /// \name Generating Data
529  /// @{
530 
531  /// \brief Emit the bytes in \p Data into the output.
532  ///
533  /// This is used to implement assembler directives such as .byte, .ascii,
534  /// etc.
535  virtual void EmitBytes(StringRef Data);
536 
537  /// Functionally identical to EmitBytes. When emitting textual assembly, this
538  /// method uses .byte directives instead of .ascii or .asciz for readability.
539  virtual void EmitBinaryData(StringRef Data);
540 
541  /// \brief Emit the expression \p Value into the output as a native
542  /// integer of the given \p Size bytes.
543  ///
544  /// This is used to implement assembler directives such as .word, .quad,
545  /// etc.
546  ///
547  /// \param Value - The value to emit.
548  /// \param Size - The size of the integer (in bytes) to emit. This must
549  /// match a native machine width.
550  /// \param Loc - The location of the expression for error reporting.
551  virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
552  SMLoc Loc = SMLoc());
553 
554  void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc());
555 
556  /// \brief Special case of EmitValue that avoids the client having
557  /// to pass in a MCExpr for constant integers.
558  virtual void EmitIntValue(uint64_t Value, unsigned Size);
559 
560  virtual void EmitULEB128Value(const MCExpr *Value);
561 
562  virtual void EmitSLEB128Value(const MCExpr *Value);
563 
564  /// \brief Special case of EmitULEB128Value that avoids the client having to
565  /// pass in a MCExpr for constant integers.
566  void EmitULEB128IntValue(uint64_t Value, unsigned Padding = 0);
567 
568  /// \brief Special case of EmitSLEB128Value that avoids the client having to
569  /// pass in a MCExpr for constant integers.
570  void EmitSLEB128IntValue(int64_t Value);
571 
572  /// \brief Special case of EmitValue that avoids the client having to pass in
573  /// a MCExpr for MCSymbols.
574  void EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
575  bool IsSectionRelative = false);
576 
577  /// \brief Emit the expression \p Value into the output as a dtprel
578  /// (64-bit DTP relative) value.
579  ///
580  /// This is used to implement assembler directives such as .dtpreldword on
581  /// targets that support them.
582  virtual void EmitDTPRel64Value(const MCExpr *Value);
583 
584  /// \brief Emit the expression \p Value into the output as a dtprel
585  /// (32-bit DTP relative) value.
586  ///
587  /// This is used to implement assembler directives such as .dtprelword on
588  /// targets that support them.
589  virtual void EmitDTPRel32Value(const MCExpr *Value);
590 
591  /// \brief Emit the expression \p Value into the output as a tprel
592  /// (64-bit TP relative) value.
593  ///
594  /// This is used to implement assembler directives such as .tpreldword on
595  /// targets that support them.
596  virtual void EmitTPRel64Value(const MCExpr *Value);
597 
598  /// \brief Emit the expression \p Value into the output as a tprel
599  /// (32-bit TP relative) value.
600  ///
601  /// This is used to implement assembler directives such as .tprelword on
602  /// targets that support them.
603  virtual void EmitTPRel32Value(const MCExpr *Value);
604 
605  /// \brief Emit the expression \p Value into the output as a gprel64 (64-bit
606  /// GP relative) value.
607  ///
608  /// This is used to implement assembler directives such as .gpdword on
609  /// targets that support them.
610  virtual void EmitGPRel64Value(const MCExpr *Value);
611 
612  /// \brief Emit the expression \p Value into the output as a gprel32 (32-bit
613  /// GP relative) value.
614  ///
615  /// This is used to implement assembler directives such as .gprel32 on
616  /// targets that support them.
617  virtual void EmitGPRel32Value(const MCExpr *Value);
618 
619  /// \brief Emit NumBytes bytes worth of the value specified by FillValue.
620  /// This implements directives such as '.space'.
621  virtual void emitFill(uint64_t NumBytes, uint8_t FillValue);
622 
623  /// \brief Emit \p Size bytes worth of the value specified by \p FillValue.
624  ///
625  /// This is used to implement assembler directives such as .space or .skip.
626  ///
627  /// \param NumBytes - The number of bytes to emit.
628  /// \param FillValue - The value to use when filling bytes.
629  /// \param Loc - The location of the expression for error reporting.
630  virtual void emitFill(const MCExpr &NumBytes, uint64_t FillValue,
631  SMLoc Loc = SMLoc());
632 
633  /// \brief Emit \p NumValues copies of \p Size bytes. Each \p Size bytes is
634  /// taken from the lowest order 4 bytes of \p Expr expression.
635  ///
636  /// This is used to implement assembler directives such as .fill.
637  ///
638  /// \param NumValues - The number of copies of \p Size bytes to emit.
639  /// \param Size - The size (in bytes) of each repeated value.
640  /// \param Expr - The expression from which \p Size bytes are used.
641  virtual void emitFill(uint64_t NumValues, int64_t Size, int64_t Expr);
642  virtual void emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
643  SMLoc Loc = SMLoc());
644 
645  /// \brief Emit NumBytes worth of zeros.
646  /// This function properly handles data in virtual sections.
647  void EmitZeros(uint64_t NumBytes);
648 
649  /// \brief Emit some number of copies of \p Value until the byte alignment \p
650  /// ByteAlignment is reached.
651  ///
652  /// If the number of bytes need to emit for the alignment is not a multiple
653  /// of \p ValueSize, then the contents of the emitted fill bytes is
654  /// undefined.
655  ///
656  /// This used to implement the .align assembler directive.
657  ///
658  /// \param ByteAlignment - The alignment to reach. This must be a power of
659  /// two on some targets.
660  /// \param Value - The value to use when filling bytes.
661  /// \param ValueSize - The size of the integer (in bytes) to emit for
662  /// \p Value. This must match a native machine width.
663  /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
664  /// the alignment cannot be reached in this many bytes, no bytes are
665  /// emitted.
666  virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
667  unsigned ValueSize = 1,
668  unsigned MaxBytesToEmit = 0);
669 
670  /// \brief Emit nops until the byte alignment \p ByteAlignment is reached.
671  ///
672  /// This used to align code where the alignment bytes may be executed. This
673  /// can emit different bytes for different sizes to optimize execution.
674  ///
675  /// \param ByteAlignment - The alignment to reach. This must be a power of
676  /// two on some targets.
677  /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
678  /// the alignment cannot be reached in this many bytes, no bytes are
679  /// emitted.
680  virtual void EmitCodeAlignment(unsigned ByteAlignment,
681  unsigned MaxBytesToEmit = 0);
682 
683  /// \brief Emit some number of copies of \p Value until the byte offset \p
684  /// Offset is reached.
685  ///
686  /// This is used to implement assembler directives such as .org.
687  ///
688  /// \param Offset - The offset to reach. This may be an expression, but the
689  /// expression must be associated with the current section.
690  /// \param Value - The value to use when filling bytes.
691  virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value,
692  SMLoc Loc);
693 
694  /// @}
695 
696  /// \brief Switch to a new logical file. This is used to implement the '.file
697  /// "foo.c"' assembler directive.
698  virtual void EmitFileDirective(StringRef Filename);
699 
700  /// \brief Emit the "identifiers" directive. This implements the
701  /// '.ident "version foo"' assembler directive.
702  virtual void EmitIdent(StringRef IdentString) {}
703 
704  /// \brief Associate a filename with a specified logical file number. This
705  /// implements the DWARF2 '.file 4 "foo.c"' assembler directive.
706  virtual unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
707  StringRef Filename,
708  unsigned CUID = 0);
709 
710  /// \brief This implements the DWARF2 '.loc fileno lineno ...' assembler
711  /// directive.
712  virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
713  unsigned Column, unsigned Flags,
714  unsigned Isa, unsigned Discriminator,
715  StringRef FileName);
716 
717  /// \brief Associate a filename with a specified logical file number. This
718  /// implements the '.cv_file 4 "foo.c"' assembler directive. Returns true on
719  /// success.
720  virtual bool EmitCVFileDirective(unsigned FileNo, StringRef Filename);
721 
722  /// \brief Introduces a function id for use with .cv_loc.
723  virtual bool EmitCVFuncIdDirective(unsigned FunctionId);
724 
725  /// \brief Introduces an inline call site id for use with .cv_loc. Includes
726  /// extra information for inline line table generation.
727  virtual bool EmitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc,
728  unsigned IAFile, unsigned IALine,
729  unsigned IACol, SMLoc Loc);
730 
731  /// \brief This implements the CodeView '.cv_loc' assembler directive.
732  virtual void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
733  unsigned Line, unsigned Column,
734  bool PrologueEnd, bool IsStmt,
735  StringRef FileName, SMLoc Loc);
736 
737  /// \brief This implements the CodeView '.cv_linetable' assembler directive.
738  virtual void EmitCVLinetableDirective(unsigned FunctionId,
739  const MCSymbol *FnStart,
740  const MCSymbol *FnEnd);
741 
742  /// \brief This implements the CodeView '.cv_inline_linetable' assembler
743  /// directive.
744  virtual void EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
745  unsigned SourceFileId,
746  unsigned SourceLineNum,
747  const MCSymbol *FnStartSym,
748  const MCSymbol *FnEndSym);
749 
750  /// \brief This implements the CodeView '.cv_def_range' assembler
751  /// directive.
752  virtual void EmitCVDefRangeDirective(
753  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
754  StringRef FixedSizePortion);
755 
756  /// \brief This implements the CodeView '.cv_stringtable' assembler directive.
757  virtual void EmitCVStringTableDirective() {}
758 
759  /// \brief This implements the CodeView '.cv_filechecksums' assembler directive.
761 
762  /// Emit the absolute difference between two symbols.
763  ///
764  /// \pre Offset of \c Hi is greater than the offset \c Lo.
765  virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo,
766  unsigned Size);
767 
768  virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID);
769  virtual void EmitCFISections(bool EH, bool Debug);
770  void EmitCFIStartProc(bool IsSimple);
771  void EmitCFIEndProc();
772  virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset);
773  virtual void EmitCFIDefCfaOffset(int64_t Offset);
774  virtual void EmitCFIDefCfaRegister(int64_t Register);
775  virtual void EmitCFIOffset(int64_t Register, int64_t Offset);
776  virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
777  virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
778  virtual void EmitCFIRememberState();
779  virtual void EmitCFIRestoreState();
780  virtual void EmitCFISameValue(int64_t Register);
781  virtual void EmitCFIRestore(int64_t Register);
782  virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
783  virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
784  virtual void EmitCFIEscape(StringRef Values);
785  virtual void EmitCFIGnuArgsSize(int64_t Size);
786  virtual void EmitCFISignalFrame();
787  virtual void EmitCFIUndefined(int64_t Register);
788  virtual void EmitCFIRegister(int64_t Register1, int64_t Register2);
789  virtual void EmitCFIWindowSave();
790 
791  virtual void EmitWinCFIStartProc(const MCSymbol *Symbol);
792  virtual void EmitWinCFIEndProc();
793  virtual void EmitWinCFIStartChained();
794  virtual void EmitWinCFIEndChained();
795  virtual void EmitWinCFIPushReg(unsigned Register);
796  virtual void EmitWinCFISetFrame(unsigned Register, unsigned Offset);
797  virtual void EmitWinCFIAllocStack(unsigned Size);
798  virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset);
799  virtual void EmitWinCFISaveXMM(unsigned Register, unsigned Offset);
800  virtual void EmitWinCFIPushFrame(bool Code);
801  virtual void EmitWinCFIEndProlog();
802 
803  virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except);
804  virtual void EmitWinEHHandlerData();
805 
806  /// Get the .pdata section used for the given section. Typically the given
807  /// section is either the main .text section or some other COMDAT .text
808  /// section, but it may be any section containing code.
810 
811  /// Get the .xdata section used for the given section.
813 
814  virtual void EmitSyntaxDirective();
815 
816  /// \brief Emit a .reloc directive.
817  /// Returns true if the relocation could not be emitted because Name is not
818  /// known.
820  const MCExpr *Expr, SMLoc Loc) {
821  return true;
822  }
823 
824  /// \brief Emit the given \p Instruction into the current section.
825  virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);
826 
827  /// \brief Set the bundle alignment mode from now on in the section.
828  /// The argument is the power of 2 to which the alignment is set. The
829  /// value 0 means turn the bundle alignment off.
830  virtual void EmitBundleAlignMode(unsigned AlignPow2);
831 
832  /// \brief The following instructions are a bundle-locked group.
833  ///
834  /// \param AlignToEnd - If true, the bundle-locked group will be aligned to
835  /// the end of a bundle.
836  virtual void EmitBundleLock(bool AlignToEnd);
837 
838  /// \brief Ends a bundle-locked group.
839  virtual void EmitBundleUnlock();
840 
841  /// \brief If this file is backed by a assembly streamer, this dumps the
842  /// specified string in the output .s file. This capability is indicated by
843  /// the hasRawTextSupport() predicate. By default this aborts.
844  void EmitRawText(const Twine &String);
845 
846  /// \brief Streamer specific finalization.
847  virtual void FinishImpl();
848  /// \brief Finish emission of machine code.
849  void Finish();
850 
851  virtual bool mayHaveInstructions(MCSection &Sec) const { return true; }
852 };
853 
854 /// Create a dummy machine code streamer, which does nothing. This is useful for
855 /// timing the assembler front end.
856 MCStreamer *createNullStreamer(MCContext &Ctx);
857 
858 /// Create a machine code streamer which will print out assembly for the native
859 /// target, suitable for compiling with a native assembler.
860 ///
861 /// \param InstPrint - If given, the instruction printer to use. If not given
862 /// the MCInst representation will be printed. This method takes ownership of
863 /// InstPrint.
864 ///
865 /// \param CE - If given, a code emitter to use to show the instruction
866 /// encoding inline with the assembly. This method takes ownership of \p CE.
867 ///
868 /// \param TAB - If given, a target asm backend to use to show the fixup
869 /// information in conjunction with encoding information. This method takes
870 /// ownership of \p TAB.
871 ///
872 /// \param ShowInst - Whether to show the MCInst representation inline with
873 /// the assembly.
874 MCStreamer *createAsmStreamer(MCContext &Ctx,
875  std::unique_ptr<formatted_raw_ostream> OS,
876  bool isVerboseAsm, bool useDwarfDirectory,
877  MCInstPrinter *InstPrint, MCCodeEmitter *CE,
878  MCAsmBackend *TAB, bool ShowInst);
879 } // end namespace llvm
880 
881 #endif
virtual void EmitBundleUnlock()
Ends a bundle-locked group.
Definition: MCStreamer.cpp:827
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag)
Note in the output the specified Flag.
Definition: MCStreamer.cpp:792
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName)
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
Definition: MCStreamer.cpp:183
virtual void EmitBundleAlignMode(unsigned AlignPow2)
Set the bundle alignment mode from now on in the section.
Definition: MCStreamer.cpp:824
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:40
void push_back(const T &Elt)
Definition: SmallVector.h:211
virtual void emitInst(uint32_t Inst, char Suffix= '\0')
virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE)
virtual void EmitCFISameValue(int64_t Register)
Definition: MCStreamer.cpp:435
virtual void emitFPU(unsigned FPU)
MCSectionSubPair getPreviousSection() const
Return the previous section that the streamer is emitting code to.
Definition: MCStreamer.h:305
virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:405
virtual void EmitCVStringTableDirective()
This implements the CodeView '.cv_stringtable' assembler directive.
Definition: MCStreamer.h:757
virtual void EmitSLEB128Value(const MCExpr *Value)
Definition: MCStreamer.cpp:813
virtual void EmitCFIGnuArgsSize(int64_t Size)
Definition: MCStreamer.cpp:458
void EmitRawText(const Twine &String)
If this file is backed by a assembly streamer, this dumps the specified string in the output ...
Definition: MCStreamer.cpp:703
virtual void EmitWinCFIEndProlog()
Definition: MCStreamer.cpp:678
void EmitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:109
void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, bool IsSectionRelative=false)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
Definition: MCStreamer.cpp:120
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:162
virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc)
Emit some number of copies of Value until the byte offset Offset is reached.
Definition: MCStreamer.cpp:822
virtual void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment=0)
Emit a thread local bss (.tbss) symbol.
Definition: MCStreamer.cpp:803
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
virtual void EndCOFFSymbolDef()
Marks the end of the symbol definition.
Definition: MCStreamer.cpp:796
virtual void AddBlankLine()
AddBlankLine - Emit a blank line to a .s file to pretty it up.
Definition: MCStreamer.h:289
virtual ~MCTargetStreamer()
Definition: MCStreamer.cpp:34
virtual void EmitULEB128Value(const MCExpr *Value)
Definition: MCStreamer.cpp:812
virtual void emitArchExtension(unsigned ArchExt)
virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol)
Emit an weak reference from Alias to Symbol.
Definition: MCStreamer.cpp:806
void SwitchSectionNoChange(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Definition: MCStreamer.h:366
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition: MCStreamer.cpp:807
Target specific streamer interface.
Definition: MCStreamer.h:73
virtual void emitPad(int64_t Offset)
virtual void reset()
State management.
Definition: MCStreamer.cpp:56
MCStreamer * createNullStreamer(MCContext &Ctx)
Create a dummy machine code streamer, which does nothing.
virtual void EmitWindowsUnwindTables()
Definition: MCStreamer.cpp:708
void EmitCFIStartProc(bool IsSimple)
Definition: MCStreamer.cpp:308
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol)
Start emitting COFF symbol definition.
Definition: MCStreamer.cpp:795
virtual void EmitDTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
Definition: MCStreamer.cpp:131
virtual unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, unsigned CUID=0)
Associate a filename with a specified logical file number.
Definition: MCStreamer.cpp:177
virtual bool hasRawTextSupport() const
Return true if this asm streamer supports emitting unformatted text to the .s file with EmitRawText...
Definition: MCStreamer.h:250
ArrayRef< WinEH::FrameInfo * > getWinFrameInfos() const
Definition: MCStreamer.h:235
void PushSection()
Save the current and previous section on the section stack.
Definition: MCStreamer.h:324
virtual void EmitCFIRegister(int64_t Register1, int64_t Register2)
Definition: MCStreamer.cpp:480
virtual void finishAttributeSection()
virtual void emitExplicitComments()
Emit added explicit comments.
Definition: MCStreamer.cpp:75
MCDataRegionType
Definition: MCDirectives.h:56
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
Definition: MCStreamer.h:228
virtual void EmitCFIDefCfaOffset(int64_t Offset)
Definition: MCStreamer.cpp:364
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
Definition: MCStreamer.cpp:192
COFF::SymbolStorageClass StorageClass
Definition: COFFYAML.cpp:296
virtual void EmitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
Definition: MCStreamer.cpp:798
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
Definition: MCStreamer.cpp:809
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
Definition: MCStreamer.cpp:765
virtual void emitPersonality(const MCSymbol *Personality)
virtual void reset()
Reset any state between object emissions, i.e.
virtual void emitPersonalityIndex(unsigned Index)
virtual void addExplicitComment(const Twine &T)
Add explicit comment T.
Definition: MCStreamer.cpp:74
virtual void EmitCFISections(bool EH, bool Debug)
Definition: MCStreamer.cpp:304
virtual void EmitGPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
Definition: MCStreamer.cpp:151
virtual void EmitWinEHHandlerData()
Definition: MCStreamer.cpp:564
virtual void EmitCFIRememberState()
Definition: MCStreamer.cpp:420
void emitCurrentConstantPool()
Callback used to implemnt the .ltorg directive.
virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:413
virtual void EmitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
Definition: MCStreamer.cpp:147
void AssignFragment(MCSymbol *Symbol, MCFragment *Fragment)
Sets the symbol's section.
Definition: MCStreamer.cpp:284
struct fuzzer::@269 Flags
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
virtual void EmitCFIEscape(StringRef Values)
Definition: MCStreamer.cpp:451
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
Definition: MCStreamer.h:297
virtual void EmitCOFFSymbolType(int Type)
Emit the type of the symbol.
Definition: MCStreamer.cpp:799
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:302
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
Reg
All possible values of the reg field in the ModR/M byte.
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:161
virtual void emitLabel(MCSymbol *Symbol)
Definition: MCStreamer.cpp:40
virtual bool isVerboseAsm() const
Return true if this streamer supports verbose assembly and if it is enabled.
Definition: MCStreamer.h:246
virtual bool mayHaveInstructions(MCSection &Sec) const
Definition: MCStreamer.h:851
virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
Definition: MCStreamer.cpp:329
unsigned getNumWinFrameInfos()
Definition: MCStreamer.h:234
virtual ~MCStreamer()
Definition: MCStreamer.cpp:51
MCContext & getContext() const
Definition: MCStreamer.h:221
virtual void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc)
This implements the CodeView '.cv_loc' assembler directive.
Definition: MCStreamer.cpp:241
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:60
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Definition: MCStreamer.cpp:722
Context object for machine code objects.
Definition: MCContext.h:51
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
Definition: MCStreamer.h:269
virtual void EmitCVFileChecksumsDirective()
This implements the CodeView '.cv_filechecksums' assembler directive.
Definition: MCStreamer.h:760
virtual void finish()
Definition: MCStreamer.cpp:42
virtual bool isIntegratedAssemblerRequired() const
Is the integrated assembler required for this streamer to function correctly?
Definition: MCStreamer.h:254
virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
Definition: MCStreamer.cpp:338
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
Definition: MCStreamer.h:44
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
virtual void EmitTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (64-bit TP relative) value.
Definition: MCStreamer.cpp:139
virtual void emitMovSP(unsigned Reg, int64_t Offset=0)
virtual void emitRawComment(const Twine &T, bool TabPrefix=true)
Print T and prefix it with the comment string (normally #) and optionally a tab.
Definition: MCStreamer.cpp:72
virtual void EmitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
Definition: MCStreamer.cpp:808
virtual void EmitCFIRestoreState()
Definition: MCStreamer.cpp:427
ARMTargetStreamer(MCStreamer &S)
virtual void EmitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers...
Definition: MCStreamer.cpp:85
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:116
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
virtual void EmitCFIRestore(int64_t Register)
Definition: MCStreamer.cpp:443
virtual void emitAttribute(unsigned Attribute, unsigned Value)
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:121
virtual void EmitBundleLock(bool AlignToEnd)
The following instructions are a bundle-locked group.
Definition: MCStreamer.cpp:825
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)
Emit a local common (.lcomm) symbol.
Definition: MCStreamer.cpp:801
virtual raw_ostream & GetCommentOS()
Return a raw_ostream that comments can be written to.
Definition: MCStreamer.cpp:67
virtual void EmitVersionMin(MCVersionMinType, unsigned Major, unsigned Minor, unsigned Update)
Specify the MachO minimum deployment target version.
Definition: MCStreamer.h:411
void EmitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Definition: MCStreamer.cpp:173
Streaming machine code generation interface.
Definition: MCStreamer.h:161
virtual void emitRegSave(const SmallVectorImpl< unsigned > &RegList, bool isVector)
WinEH::FrameInfo * getCurrentWinFrameInfo()
Definition: MCStreamer.h:199
MCTargetStreamer * getTargetStreamer()
Definition: MCStreamer.h:223
virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol=nullptr, uint64_t Size=0, unsigned ByteAlignment=0)=0
Emit the zerofill section and an optional symbol.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
virtual void EmitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
Definition: MCStreamer.cpp:262
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool isVerboseAsm, bool useDwarfDirectory, MCInstPrinter *InstPrint, MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst)
Create a machine code streamer which will print out assembly for the native target, suitable for compiling with a native assembler.
virtual void EmitWinCFIPushReg(unsigned Register)
Definition: MCStreamer.cpp:604
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Definition: MCStreamer.cpp:829
virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value)
virtual void emitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset=0)
virtual void emitObjectArch(unsigned Arch)
MCSection * getAssociatedPDataSection(const MCSection *TextSec)
Get the .pdata section used for the given section.
Definition: MCStreamer.cpp:590
virtual void EmitSyntaxDirective()
Definition: MCStreamer.cpp:602
virtual void EmitCFIDefCfaRegister(int64_t Register)
Definition: MCStreamer.cpp:380
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
Definition: MCStreamer.cpp:817
MCLOHType
Linker Optimization Hint Type.
virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
uint32_t Offset
virtual void emitUnwindRaw(int64_t StackOffset, const SmallVectorImpl< uint8_t > &Opcodes)
virtual void EmitRawTextImpl(StringRef String)
EmitRawText - If this file is backed by an assembly streamer, this dumps the specified string in the ...
Definition: MCStreamer.cpp:697
virtual void EmitWinCFIEndChained()
Definition: MCStreamer.cpp:538
virtual void EmitWinCFIEndProc()
Definition: MCStreamer.cpp:518
virtual void EmitCFIUndefined(int64_t Register)
Definition: MCStreamer.cpp:472
virtual void EmitIdent(StringRef IdentString)
Emit the "identifiers" directive.
Definition: MCStreamer.h:702
void Finish()
Finish emission of machine code.
Definition: MCStreamer.cpp:711
virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol)
Definition: MCStreamer.cpp:276
virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except)
Definition: MCStreamer.cpp:550
virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol)
Definition: MCStreamer.cpp:686
void generateCompactUnwindEncodings(MCAsmBackend *MAB)
Definition: MCStreamer.cpp:77
bool SubSection(const MCExpr *Subsection)
Definition: MCStreamer.h:348
virtual void EmitDataRegion(MCDataRegionType Kind)
Note in the output the specified region Kind.
Definition: MCStreamer.h:408
virtual bool EmitCVFileDirective(unsigned FileNo, StringRef Filename)
Associate a filename with a specified logical file number.
Definition: MCStreamer.cpp:219
virtual void EmitTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (32-bit TP relative) value.
Definition: MCStreamer.cpp:143
virtual void EmitWinCFIStartChained()
Definition: MCStreamer.cpp:527
virtual void InitSections(bool NoExecStack)
Create the default sections and set the initial one.
Definition: MCStreamer.cpp:280
MCStreamer & getStreamer()
Definition: MCStreamer.h:81
virtual void EmitLabel(MCSymbol *Symbol)
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:293
virtual void EmitWinCFISaveXMM(unsigned Register, unsigned Offset)
Definition: MCStreamer.cpp:655
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
Definition: MCStreamer.cpp:773
virtual void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args)
Emit a Linker Optimization Hint (LOH) directive.
Definition: MCStreamer.h:488
virtual void EmitCFIOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:389
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:843
virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
Definition: MCStreamer.cpp:820
bool isVector(MCInstrInfo const &MCII, MCInst const &MCI)
MCStreamer & Streamer
Definition: MCStreamer.h:75
Promote Memory to Register
Definition: Mem2Reg.cpp:100
virtual void EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView '.cv_inline_linetable' assembler directive.
Definition: MCStreamer.cpp:266
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS, const MCInst &Inst, const MCSubtargetInfo &STI)
Definition: MCStreamer.cpp:731
virtual void EmitWinCFIAllocStack(unsigned Size)
Definition: MCStreamer.cpp:630
virtual void ChangeSection(MCSection *, const MCExpr *)
Update streamer for a new active section.
Definition: MCStreamer.cpp:805
bool hasUnfinishedDwarfFrameInfo()
Definition: MCStreamer.cpp:208
MCSymbolAttr
Definition: MCDirectives.h:19
const MCExpr * addConstantPoolEntry(const MCExpr *, SMLoc Loc)
Callback used to implement the ldr= pseudo.
void visitUsedExpr(const MCExpr &Expr)
Definition: MCStreamer.cpp:739
MCTargetStreamer(MCStreamer &S)
Definition: MCStreamer.cpp:36
virtual void EmitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * >> Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
Definition: MCStreamer.cpp:272
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
Definition: SmallVector.h:119
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:41
virtual void EmitThumbFunc(MCSymbol *Func)
Note in the output that the specified Func is a Thumb mode function (ARM target only).
Definition: MCStreamer.cpp:793
unsigned getNumFrameInfos()
Definition: MCStreamer.h:227
virtual bool EmitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc)
Emit a .reloc directive.
Definition: MCStreamer.h:819
virtual void EmitLinkerOptions(ArrayRef< std::string > Kind)
Emit the given list Options of strings as linker options into the output.
Definition: MCStreamer.h:405
virtual void EmitCFISignalFrame()
Definition: MCStreamer.cpp:466
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:397
MCAssemblerFlag
Definition: MCDirectives.h:48
virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue, StringRef StringValue="")
#define I(x, y, z)
Definition: MD5.cpp:54
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Definition: SmallVector.h:135
virtual void EmitFileDirective(StringRef Filename)
Switch to a new logical file.
Definition: MCStreamer.cpp:797
virtual void EmitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
Definition: MCStreamer.cpp:135
MCSubtargetInfo - Generic base class for all target subtargets.
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
Definition: MCStreamer.cpp:800
virtual void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
Definition: MCStreamer.cpp:157
virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:355
void EmitULEB128IntValue(uint64_t Value, unsigned Padding=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:100
MCSymbol * endSection(MCSection *Section)
Definition: MCStreamer.cpp:843
const unsigned Kind
virtual void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)
Emits a COFF section relative relocation.
Definition: MCStreamer.cpp:692
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)=0
Emit a common symbol.
virtual void FinishImpl()
Streamer specific finalization.
Definition: MCStreamer.cpp:826
bool PopSection()
Restore the current and previous section from the section stack.
Definition: MCStreamer.h:333
virtual bool EmitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol, SMLoc Loc)
Introduces an inline call site id for use with .cv_loc.
Definition: MCStreamer.cpp:227
MCVersionMinType
Definition: MCDirectives.h:64
LLVM Value Representation.
Definition: Value.h:71
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:36
static cl::opt< bool, true > Debug("debug", cl::desc("Enable debug output"), cl::Hidden, cl::location(DebugFlag))
virtual bool EmitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
Definition: MCStreamer.cpp:223
virtual void EmitWinCFIStartProc(const MCSymbol *Symbol)
Definition: MCStreamer.cpp:504
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
static TraceState * TS
virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset)
Definition: MCStreamer.cpp:643
virtual void EmitWinCFIPushFrame(bool Code)
Definition: MCStreamer.cpp:667
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
virtual void emitArch(unsigned Arch)
virtual void visitUsedSymbol(const MCSymbol &Sym)
Definition: MCStreamer.cpp:736
Represents a location in source code.
Definition: SMLoc.h:24
void setTargetStreamer(MCTargetStreamer *TS)
Definition: MCStreamer.h:213
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Definition: MCStreamer.cpp:44
virtual void EmitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
Definition: MCStreamer.cpp:689
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment)
Definition: MCStreamer.cpp:372
unsigned GetSymbolOrder(const MCSymbol *Sym) const
Returns an index to represent the order a symbol was emitted in.
Definition: MCStreamer.h:313
virtual void EmitWinCFISetFrame(unsigned Register, unsigned Offset)
Definition: MCStreamer.cpp:613
virtual void switchVendor(StringRef Vendor)
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
Set the DescValue for the Symbol.
Definition: MCStreamer.cpp:794
virtual void EmitCFIWindowSave()
Definition: MCStreamer.cpp:488
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
Definition: MCStreamer.cpp:596
virtual void emitTextAttribute(unsigned Attribute, StringRef String)