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