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