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