LLVM  13.0.0git
AsmPrinter.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/AsmPrinter.h - AsmPrinter Framework ---------*- 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 contains a class to be used as the base class for target specific
10 // asm writers. This class primarily handles common functionality used by
11 // all asm writers.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CODEGEN_ASMPRINTER_H
16 #define LLVM_CODEGEN_ASMPRINTER_H
17 
18 #include "llvm/ADT/MapVector.h"
19 #include "llvm/ADT/SmallVector.h"
23 #include "llvm/IR/InlineAsm.h"
24 #include "llvm/IR/LLVMContext.h"
26 #include "llvm/Support/SourceMgr.h"
27 #include <cstdint>
28 #include <memory>
29 #include <utility>
30 #include <vector>
31 
32 namespace llvm {
33 
34 class BasicBlock;
35 class BlockAddress;
36 class Constant;
37 class ConstantArray;
38 class DataLayout;
39 class DIE;
40 class DIEAbbrev;
41 class DwarfDebug;
42 class GCMetadataPrinter;
43 class GCStrategy;
44 class GlobalIndirectSymbol;
45 class GlobalObject;
46 class GlobalValue;
47 class GlobalVariable;
48 class MachineBasicBlock;
49 class MachineConstantPoolValue;
50 class MachineDominatorTree;
51 class MachineFunction;
52 class MachineInstr;
53 class MachineJumpTableInfo;
54 class MachineLoopInfo;
55 class MachineModuleInfo;
56 class MachineOptimizationRemarkEmitter;
57 class MCAsmInfo;
58 class MCCFIInstruction;
59 class MCContext;
60 class MCExpr;
61 class MCInst;
62 class MCSection;
63 class MCStreamer;
64 class MCSubtargetInfo;
65 class MCSymbol;
66 class MCTargetOptions;
67 class MDNode;
68 class Module;
69 class PseudoProbeHandler;
70 class raw_ostream;
71 class StackMaps;
72 class StringRef;
73 class TargetLoweringObjectFile;
74 class TargetMachine;
75 class Twine;
76 
77 namespace remarks {
78 class RemarkStreamer;
79 }
80 
81 /// This class is intended to be used as a driving class for all asm writers.
83 public:
84  /// Target machine description.
86 
87  /// Target Asm Printer information.
88  const MCAsmInfo *MAI;
89 
90  /// This is the context for the output file that we are streaming. This owns
91  /// all of the global MC-related objects for the generated translation unit.
93 
94  /// This is the MCStreamer object for the file we are generating. This
95  /// contains the transient state for the current translation unit that we are
96  /// generating (such as the current section etc).
97  std::unique_ptr<MCStreamer> OutStreamer;
98 
99  /// The current machine function.
100  MachineFunction *MF = nullptr;
101 
102  /// This is a pointer to the current MachineModuleInfo.
103  MachineModuleInfo *MMI = nullptr;
104 
105  /// This is a pointer to the current MachineDominatorTree.
107 
108  /// This is a pointer to the current MachineLoopInfo.
109  MachineLoopInfo *MLI = nullptr;
110 
111  /// Optimization remark emitter.
113 
114  /// The symbol for the entry in __patchable_function_entires.
116 
117  /// The symbol for the current function. This is recalculated at the beginning
118  /// of each call to runOnMachineFunction().
119  MCSymbol *CurrentFnSym = nullptr;
120 
121  /// The symbol for the current function descriptor on AIX. This is created
122  /// at the beginning of each call to SetupMachineFunction().
124 
125  /// The symbol used to represent the start of the current function for the
126  /// purpose of calculating its size (e.g. using the .size directive). By
127  /// default, this is equal to CurrentFnSym.
129 
130  /// Map a basic block section ID to the begin and end symbols of that section
131  /// which determine the section's range.
134  };
135 
137 
138  /// Map global GOT equivalent MCSymbols to GlobalVariables and keep track of
139  /// its number of uses by other globals.
140  using GOTEquivUsePair = std::pair<const GlobalVariable *, unsigned>;
142 
143  /// struct HandlerInfo and Handlers permit users or target extended
144  /// AsmPrinter to add their own handlers.
145  struct HandlerInfo {
146  std::unique_ptr<AsmPrinterHandler> Handler;
147  const char *TimerName;
148  const char *TimerDescription;
149  const char *TimerGroupName;
151 
152  HandlerInfo(std::unique_ptr<AsmPrinterHandler> Handler,
153  const char *TimerName, const char *TimerDescription,
154  const char *TimerGroupName, const char *TimerGroupDescription)
158  };
159 
160 private:
161  MCSymbol *CurrentFnEnd = nullptr;
162 
163  /// Map a basic block section ID to the exception symbol associated with that
164  /// section. Map entries are assigned and looked up via
165  /// AsmPrinter::getMBBExceptionSym.
166  DenseMap<unsigned, MCSymbol *> MBBSectionExceptionSyms;
167 
168  // The symbol used to represent the start of the current BB section of the
169  // function. This is used to calculate the size of the BB section.
170  MCSymbol *CurrentSectionBeginSym = nullptr;
171 
172  // The garbage collection metadata printer table.
173  void *GCMetadataPrinters = nullptr; // Really a DenseMap.
174 
175  /// Emit comments in assembly output if this is true.
176  bool VerboseAsm;
177 
178  static char ID;
179 
180 protected:
182 
183  /// A vector of all debug/EH info emitters we should use. This vector
184  /// maintains ownership of the emitters.
185  std::vector<HandlerInfo> Handlers;
186  size_t NumUserHandlers = 0;
187 
188 public:
189  struct SrcMgrDiagInfo {
191  std::vector<const MDNode *> LocInfos;
193  void *DiagContext;
194  };
195 
196 private:
197  /// If generated on the fly this own the instance.
198  std::unique_ptr<MachineDominatorTree> OwnedMDT;
199 
200  /// If generated on the fly this own the instance.
201  std::unique_ptr<MachineLoopInfo> OwnedMLI;
202 
203  /// Structure for generating diagnostics for inline assembly. Only initialised
204  /// when necessary.
205  mutable std::unique_ptr<SrcMgrDiagInfo> DiagInfo;
206 
207  /// If the target supports dwarf debug info, this pointer is non-null.
208  DwarfDebug *DD = nullptr;
209 
210  /// A handler that supports pseudo probe emission with embedded inline
211  /// context.
212  PseudoProbeHandler *PP = nullptr;
213 
214  /// If the current module uses dwarf CFI annotations strictly for debugging.
215  bool isCFIMoveForDebugging = false;
216 
217 protected:
218  explicit AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer);
219 
220 public:
221  ~AsmPrinter() override;
222 
223  DwarfDebug *getDwarfDebug() { return DD; }
224  DwarfDebug *getDwarfDebug() const { return DD; }
225 
226  uint16_t getDwarfVersion() const;
228 
229  bool isDwarf64() const;
230 
231  /// Returns 4 for DWARF32 and 8 for DWARF64.
232  unsigned int getDwarfOffsetByteSize() const;
233 
234  /// Returns 4 for DWARF32 and 12 for DWARF64.
235  unsigned int getUnitLengthFieldByteSize() const;
236 
237  bool isPositionIndependent() const;
238 
239  /// Return true if assembly output should contain comments.
240  bool isVerbose() const { return VerboseAsm; }
241 
242  /// Return a unique ID for the current function.
243  unsigned getFunctionNumber() const;
244 
245  /// Return symbol for the function pseudo stack if the stack frame is not a
246  /// register based.
247  virtual const MCSymbol *getFunctionFrameSymbol() const { return nullptr; }
248 
250  MCSymbol *getFunctionEnd() const { return CurrentFnEnd; }
251 
252  // Return the exception symbol associated with the MBB section containing a
253  // given basic block.
255 
256  /// Return information about object file lowering.
258 
259  /// Return information about data layout.
260  const DataLayout &getDataLayout() const;
261 
262  /// Return the pointer size from the TargetMachine
263  unsigned getPointerSize() const;
264 
265  /// Return information about subtarget.
266  const MCSubtargetInfo &getSubtargetInfo() const;
267 
268  void EmitToStreamer(MCStreamer &S, const MCInst &Inst);
269 
270  /// Emits inital debug location directive.
272 
273  /// Return the current section we are emitting to.
274  const MCSection *getCurrentSection() const;
275 
277  const GlobalValue *GV) const;
278 
279  MCSymbol *getSymbol(const GlobalValue *GV) const;
280 
281  /// Similar to getSymbol() but preferred for references. On ELF, this uses a
282  /// local symbol if a reference to GV is guaranteed to be resolved to the
283  /// definition in the same module.
284  MCSymbol *getSymbolPreferLocal(const GlobalValue &GV) const;
285 
286  //===------------------------------------------------------------------===//
287  // XRay instrumentation implementation.
288  //===------------------------------------------------------------------===//
289 public:
290  // This describes the kind of sled we're storing in the XRay table.
291  enum class SledKind : uint8_t {
292  FUNCTION_ENTER = 0,
293  FUNCTION_EXIT = 1,
294  TAIL_CALL = 2,
295  LOG_ARGS_ENTER = 3,
296  CUSTOM_EVENT = 4,
297  TYPED_EVENT = 5,
298  };
299 
300  // The table will contain these structs that point to the sled, the function
301  // containing the sled, and what kind of sled (and whether they should always
302  // be instrumented). We also use a version identifier that the runtime can use
303  // to decide what to do with the sled, depending on the version of the sled.
305  const MCSymbol *Sled;
309  const class Function *Fn;
310  uint8_t Version;
311 
312  void emit(int, MCStreamer *) const;
313  };
314 
315  // All the sleds to be emitted.
317 
318  // Helper function to record a given XRay sled.
319  void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind,
320  uint8_t Version = 0);
321 
322  /// Emit a table with all XRay instrumentation points.
323  void emitXRayTable();
324 
326 
327  //===------------------------------------------------------------------===//
328  // MachineFunctionPass Implementation.
329  //===------------------------------------------------------------------===//
330 
331  /// Record analysis usage.
332  void getAnalysisUsage(AnalysisUsage &AU) const override;
333 
334  /// Set up the AsmPrinter when we are working on a new module. If your pass
335  /// overrides this, it must make sure to explicitly call this implementation.
336  bool doInitialization(Module &M) override;
337 
338  /// Shut down the asmprinter. If you override this in your pass, you must make
339  /// sure to call it explicitly.
340  bool doFinalization(Module &M) override;
341 
342  /// Emit the specified function out to the OutStreamer.
346  return false;
347  }
348 
349  //===------------------------------------------------------------------===//
350  // Coarse grained IR lowering routines.
351  //===------------------------------------------------------------------===//
352 
353  /// This should be called when a new MachineFunction is being processed from
354  /// runOnMachineFunction.
355  virtual void SetupMachineFunction(MachineFunction &MF);
356 
357  /// This method emits the body and trailer for a function.
358  void emitFunctionBody();
359 
360  void emitCFIInstruction(const MachineInstr &MI);
361 
362  void emitFrameAlloc(const MachineInstr &MI);
363 
365 
367 
368  void emitPseudoProbe(const MachineInstr &MI);
369 
371 
373  CFIMoveType needsCFIMoves() const;
374 
375  /// Returns false if needsCFIMoves() == CFI_M_EH for any function
376  /// in the module.
377  bool needsOnlyDebugCFIMoves() const { return isCFIMoveForDebugging; }
378 
379  bool needsSEHMoves();
380 
381  /// Print to the current output stream assembly representations of the
382  /// constants in the constant pool MCP. This is used to print out constants
383  /// which have been "spilled to memory" by the code generator.
384  virtual void emitConstantPool();
385 
386  /// Print assembly representations of the jump tables used by the current
387  /// function to the current output stream.
388  virtual void emitJumpTableInfo();
389 
390  /// Emit the specified global variable to the .s file.
391  virtual void emitGlobalVariable(const GlobalVariable *GV);
392 
393  /// Check to see if the specified global is a special global used by LLVM. If
394  /// so, emit it and return true, otherwise do nothing and return false.
395  bool emitSpecialLLVMGlobal(const GlobalVariable *GV);
396 
397  /// `llvm.global_ctors` and `llvm.global_dtors` are arrays of Structor
398  /// structs.
399  ///
400  /// Priority - init priority
401  /// Func - global initialization or global clean-up function
402  /// ComdatKey - associated data
403  struct Structor {
404  int Priority = 0;
405  Constant *Func = nullptr;
406  GlobalValue *ComdatKey = nullptr;
407 
408  Structor() = default;
409  };
410 
411  /// This method gathers an array of Structors and then sorts them out by
412  /// Priority.
413  /// @param List The initializer of `llvm.global_ctors` or `llvm.global_dtors`
414  /// array.
415  /// @param[out] Structors Sorted Structor structs by Priority.
416  void preprocessXXStructorList(const DataLayout &DL, const Constant *List,
417  SmallVector<Structor, 8> &Structors);
418 
419  /// This method emits `llvm.global_ctors` or `llvm.global_dtors` list.
420  virtual void emitXXStructorList(const DataLayout &DL, const Constant *List,
421  bool IsCtor);
422 
423  /// Emit an alignment directive to the specified power of two boundary. If a
424  /// global value is specified, and if that global has an explicit alignment
425  /// requested, it will override the alignment request if required for
426  /// correctness.
427  void emitAlignment(Align Alignment, const GlobalObject *GV = nullptr) const;
428 
429  /// Lower the specified LLVM Constant to an MCExpr.
430  virtual const MCExpr *lowerConstant(const Constant *CV);
431 
432  /// Print a general LLVM constant to the .s file.
433  void emitGlobalConstant(const DataLayout &DL, const Constant *CV);
434 
435  /// Unnamed constant global variables solely contaning a pointer to
436  /// another globals variable act like a global variable "proxy", or GOT
437  /// equivalents, i.e., it's only used to hold the address of the latter. One
438  /// optimization is to replace accesses to these proxies by using the GOT
439  /// entry for the final global instead. Hence, we select GOT equivalent
440  /// candidates among all the module global variables, avoid emitting them
441  /// unnecessarily and finally replace references to them by pc relative
442  /// accesses to GOT entries.
444 
445  /// Constant expressions using GOT equivalent globals may not be
446  /// eligible for PC relative GOT entry conversion, in such cases we need to
447  /// emit the proxies we previously omitted in EmitGlobalVariable.
448  void emitGlobalGOTEquivs();
449 
450  /// Emit the stack maps.
451  void emitStackMaps(StackMaps &SM);
452 
453  //===------------------------------------------------------------------===//
454  // Overridable Hooks
455  //===------------------------------------------------------------------===//
456 
458  Handlers.insert(Handlers.begin(), std::move(Handler));
459  NumUserHandlers++;
460  }
461 
462  // Targets can, or in the case of EmitInstruction, must implement these to
463  // customize output.
464 
465  /// This virtual method can be overridden by targets that want to emit
466  /// something at the start of their file.
467  virtual void emitStartOfAsmFile(Module &) {}
468 
469  /// This virtual method can be overridden by targets that want to emit
470  /// something at the end of their file.
471  virtual void emitEndOfAsmFile(Module &) {}
472 
473  /// Targets can override this to emit stuff before the first basic block in
474  /// the function.
475  virtual void emitFunctionBodyStart() {}
476 
477  /// Targets can override this to emit stuff after the last basic block in the
478  /// function.
479  virtual void emitFunctionBodyEnd() {}
480 
481  /// Targets can override this to emit stuff at the start of a basic block.
482  /// By default, this method prints the label for the specified
483  /// MachineBasicBlock, an alignment (if present) and a comment describing it
484  /// if appropriate.
485  virtual void emitBasicBlockStart(const MachineBasicBlock &MBB);
486 
487  /// Targets can override this to emit stuff at the end of a basic block.
488  virtual void emitBasicBlockEnd(const MachineBasicBlock &MBB);
489 
490  /// Targets should implement this to emit instructions.
491  virtual void emitInstruction(const MachineInstr *) {
492  llvm_unreachable("EmitInstruction not implemented");
493  }
494 
495  /// Return the symbol for the specified constant pool entry.
496  virtual MCSymbol *GetCPISymbol(unsigned CPID) const;
497 
498  virtual void emitFunctionEntryLabel();
499 
500  virtual void emitFunctionDescriptor() {
501  llvm_unreachable("Function descriptor is target-specific.");
502  }
503 
505 
506  /// Targets can override this to change how global constants that are part of
507  /// a C++ static/global constructor list are emitted.
508  virtual void emitXXStructor(const DataLayout &DL, const Constant *CV) {
509  emitGlobalConstant(DL, CV);
510  }
511 
512  /// Return true if the basic block has exactly one predecessor and the control
513  /// transfer mechanism between the predecessor and this block is a
514  /// fall-through.
515  virtual bool
517 
518  /// Targets can override this to customize the output of IMPLICIT_DEF
519  /// instructions in verbose mode.
520  virtual void emitImplicitDef(const MachineInstr *MI) const;
521 
522  /// Emit N NOP instructions.
523  void emitNops(unsigned N);
524 
525  //===------------------------------------------------------------------===//
526  // Symbol Lowering Routines.
527  //===------------------------------------------------------------------===//
528 
529  MCSymbol *createTempSymbol(const Twine &Name) const;
530 
531  /// Return the MCSymbol for a private symbol with global value name as its
532  /// base, with the specified suffix.
534  StringRef Suffix) const;
535 
536  /// Return the MCSymbol for the specified ExternalSymbol.
538 
539  /// Return the symbol for the specified jump table entry.
540  MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
541 
542  /// Return the symbol for the specified jump table .set
543  /// FIXME: privatize to AsmPrinter.
544  MCSymbol *GetJTSetSymbol(unsigned UID, unsigned MBBID) const;
545 
546  /// Return the MCSymbol used to satisfy BlockAddress uses of the specified
547  /// basic block.
548  MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA) const;
550 
551  //===------------------------------------------------------------------===//
552  // Emission Helper Routines.
553  //===------------------------------------------------------------------===//
554 
555  /// This is just convenient handler for printing offsets.
556  void printOffset(int64_t Offset, raw_ostream &OS) const;
557 
558  /// Emit a byte directive and value.
559  void emitInt8(int Value) const;
560 
561  /// Emit a short directive and value.
562  void emitInt16(int Value) const;
563 
564  /// Emit a long directive and value.
565  void emitInt32(int Value) const;
566 
567  /// Emit a long long directive and value.
568  void emitInt64(uint64_t Value) const;
569 
570  /// Emit something like ".long Hi-Lo" where the size in bytes of the directive
571  /// is specified by Size and Hi/Lo specify the labels. This implicitly uses
572  /// .set if it is available.
573  void emitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
574  unsigned Size) const;
575 
576  /// Emit something like ".uleb128 Hi-Lo".
578  const MCSymbol *Lo) const;
579 
580  /// Emit something like ".long Label+Offset" where the size in bytes of the
581  /// directive is specified by Size and Label specifies the label. This
582  /// implicitly uses .set if it is available.
583  void emitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
584  unsigned Size, bool IsSectionRelative = false) const;
585 
586  /// Emit something like ".long Label" where the size in bytes of the directive
587  /// is specified by Size and Label specifies the label.
588  void emitLabelReference(const MCSymbol *Label, unsigned Size,
589  bool IsSectionRelative = false) const {
590  emitLabelPlusOffset(Label, 0, Size, IsSectionRelative);
591  }
592 
593  //===------------------------------------------------------------------===//
594  // Dwarf Emission Helper Routines
595  //===------------------------------------------------------------------===//
596 
597  /// Emit the specified signed leb128 value.
598  void emitSLEB128(int64_t Value, const char *Desc = nullptr) const;
599 
600  /// Emit the specified unsigned leb128 value.
601  void emitULEB128(uint64_t Value, const char *Desc = nullptr,
602  unsigned PadTo = 0) const;
603 
604  /// Emit a .byte 42 directive that corresponds to an encoding. If verbose
605  /// assembly output is enabled, we output comments describing the encoding.
606  /// Desc is a string saying what the encoding is specifying (e.g. "LSDA").
607  void emitEncodingByte(unsigned Val, const char *Desc = nullptr) const;
608 
609  /// Return the size of the encoding in bytes.
610  unsigned GetSizeOfEncodedValue(unsigned Encoding) const;
611 
612  /// Emit reference to a ttype global with a specified encoding.
613  virtual void emitTTypeReference(const GlobalValue *GV, unsigned Encoding);
614 
615  /// Emit a reference to a symbol for use in dwarf. Different object formats
616  /// represent this in different ways. Some use a relocation others encode
617  /// the label offset in its section.
618  void emitDwarfSymbolReference(const MCSymbol *Label,
619  bool ForceOffset = false) const;
620 
621  /// Emit the 4- or 8-byte offset of a string from the start of its section.
622  ///
623  /// When possible, emit a DwarfStringPool section offset without any
624  /// relocations, and without using the symbol. Otherwise, defers to \a
625  /// emitDwarfSymbolReference().
626  ///
627  /// The length of the emitted value depends on the DWARF format.
629 
630  /// Emit the 4-or 8-byte offset of a string from the start of its section.
632  emitDwarfStringOffset(S.getEntry());
633  }
634 
635  /// Emit something like ".long Label + Offset" or ".quad Label + Offset"
636  /// depending on the DWARF format.
637  void emitDwarfOffset(const MCSymbol *Label, uint64_t Offset) const;
638 
639  /// Emit 32- or 64-bit value depending on the DWARF format.
640  void emitDwarfLengthOrOffset(uint64_t Value) const;
641 
642  /// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
643  /// according to the settings.
644  void emitDwarfUnitLength(uint64_t Length, const Twine &Comment) const;
645 
646  /// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
647  /// according to the settings.
648  /// Return the end symbol generated inside, the caller needs to emit it.
650  const Twine &Comment) const;
651 
652  /// Emit reference to a call site with a specified encoding
653  void emitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo,
654  unsigned Encoding) const;
655  /// Emit an integer value corresponding to the call site encoding
656  void emitCallSiteValue(uint64_t Value, unsigned Encoding) const;
657 
658  /// Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
659  virtual unsigned getISAEncoding() { return 0; }
660 
661  /// Emit the directive and value for debug thread local expression
662  ///
663  /// \p Value - The value to emit.
664  /// \p Size - The size of the integer (in bytes) to emit.
665  virtual void emitDebugValue(const MCExpr *Value, unsigned Size) const;
666 
667  //===------------------------------------------------------------------===//
668  // Dwarf Lowering Routines
669  //===------------------------------------------------------------------===//
670 
671  /// Emit frame instruction to describe the layout of the frame.
672  void emitCFIInstruction(const MCCFIInstruction &Inst) const;
673 
674  /// Emit Dwarf abbreviation table.
675  template <typename T> void emitDwarfAbbrevs(const T &Abbrevs) const {
676  // For each abbreviation.
677  for (const auto &Abbrev : Abbrevs)
678  emitDwarfAbbrev(*Abbrev);
679 
680  // Mark end of abbreviations.
681  emitULEB128(0, "EOM(3)");
682  }
683 
684  void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const;
685 
686  /// Recursively emit Dwarf DIE tree.
687  void emitDwarfDIE(const DIE &Die) const;
688 
689  //===------------------------------------------------------------------===//
690  // Inline Asm Support
691  //===------------------------------------------------------------------===//
692 
693  // These are hooks that targets can override to implement inline asm
694  // support. These should probably be moved out of AsmPrinter someday.
695 
696  /// Print information related to the specified machine instr that is
697  /// independent of the operand, and may be independent of the instr itself.
698  /// This can be useful for portably encoding the comment character or other
699  /// bits of target-specific knowledge into the asmstrings. The syntax used is
700  /// ${:comment}. Targets can override this to add support for their own
701  /// strange codes.
702  virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
703  const char *Code) const;
704 
705  /// Print the MachineOperand as a symbol. Targets with complex handling of
706  /// symbol references should override the base implementation.
707  virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS);
708 
709  /// Print the specified operand of MI, an INLINEASM instruction, using the
710  /// specified assembler variant. Targets should override this to format as
711  /// appropriate. This method can return true if the operand is erroneous.
712  virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
713  const char *ExtraCode, raw_ostream &OS);
714 
715  /// Print the specified operand of MI, an INLINEASM instruction, using the
716  /// specified assembler variant as an address. Targets should override this to
717  /// format as appropriate. This method can return true if the operand is
718  /// erroneous.
719  virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
720  const char *ExtraCode, raw_ostream &OS);
721 
722  /// Let the target do anything it needs to do before emitting inlineasm.
723  /// \p StartInfo - the subtarget info before parsing inline asm
724  virtual void emitInlineAsmStart() const;
725 
726  /// Let the target do anything it needs to do after emitting inlineasm.
727  /// This callback can be used restore the original mode in case the
728  /// inlineasm contains directives to switch modes.
729  /// \p StartInfo - the original subtarget info before inline asm
730  /// \p EndInfo - the final subtarget info after parsing the inline asm,
731  /// or NULL if the value is unknown.
732  virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
733  const MCSubtargetInfo *EndInfo) const;
734 
735  /// This emits visibility information about symbol, if this is supported by
736  /// the target.
737  void emitVisibility(MCSymbol *Sym, unsigned Visibility,
738  bool IsDefinition = true) const;
739 
740  /// This emits linkage information about \p GVSym based on \p GV, if this is
741  /// supported by the target.
742  virtual void emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const;
743 
744  /// Return the alignment for the specified \p GV.
745  static Align getGVAlignment(const GlobalObject *GV, const DataLayout &DL,
746  Align InAlign = Align(1));
747 
748 private:
749  /// Private state for PrintSpecial()
750  // Assign a unique ID to this machine instruction.
751  mutable const MachineInstr *LastMI = nullptr;
752  mutable unsigned LastFn = 0;
753  mutable unsigned Counter = ~0U;
754 
755  /// This method emits the header for the current function.
756  virtual void emitFunctionHeader();
757 
758  /// This method emits a comment next to header for the current function.
759  virtual void emitFunctionHeaderComment();
760 
761  /// Emit a blob of inline asm to the output streamer.
762  void
763  emitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
764  const MCTargetOptions &MCOptions,
765  const MDNode *LocMDNode = nullptr,
767 
768  /// This method formats and emits the specified machine instruction that is an
769  /// inline asm.
770  void emitInlineAsm(const MachineInstr *MI) const;
771 
772  /// Add inline assembly info to the diagnostics machinery, so we can
773  /// emit file and position info. Returns SrcMgr memory buffer position.
774  unsigned addInlineAsmDiagBuffer(StringRef AsmStr,
775  const MDNode *LocMDNode) const;
776 
777  //===------------------------------------------------------------------===//
778  // Internal Implementation Details
779  //===------------------------------------------------------------------===//
780 
781  void emitJumpTableEntry(const MachineJumpTableInfo *MJTI,
782  const MachineBasicBlock *MBB, unsigned uid) const;
783  void emitLLVMUsedList(const ConstantArray *InitList);
784  /// Emit llvm.ident metadata in an '.ident' directive.
785  void emitModuleIdents(Module &M);
786  /// Emit bytes for llvm.commandline metadata.
787  void emitModuleCommandLines(Module &M);
788 
789  GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy &S);
790  /// Emit GlobalAlias or GlobalIFunc.
791  void emitGlobalIndirectSymbol(Module &M, const GlobalIndirectSymbol &GIS);
792 
793  /// This method decides whether the specified basic block requires a label.
794  bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const;
795 };
796 
797 } // end namespace llvm
798 
799 #endif // LLVM_CODEGEN_ASMPRINTER_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::EngineKind::Kind
Kind
Definition: ExecutionEngine.h:524
llvm::AsmPrinter::emitLabelDifference
void emitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
Emit something like ".long Hi-Lo" where the size in bytes of the directive is specified by Size and H...
Definition: AsmPrinter.cpp:2315
llvm::AsmPrinter::isPositionIndependent
bool isPositionIndependent() const
Definition: AsmPrinter.cpp:213
llvm::AsmPrinter::NumUserHandlers
size_t NumUserHandlers
Definition: AsmPrinter.h:186
llvm::AsmPrinter::emitLabelDifferenceAsULEB128
void emitLabelDifferenceAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo) const
Emit something like ".uleb128 Hi-Lo".
Definition: AsmPrinterDwarf.cpp:56
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:100
llvm::AsmPrinter::GlobalGOTEquivs
MapVector< const MCSymbol *, GOTEquivUsePair > GlobalGOTEquivs
Definition: AsmPrinter.h:141
llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:23
llvm::AsmPrinter::getFunctionEnd
MCSymbol * getFunctionEnd() const
Definition: AsmPrinter.h:250
llvm::InlineAsm::AsmDialect
AsmDialect
Definition: InlineAsm.h:33
llvm::AsmPrinter::printOffset
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
Definition: AsmPrinter.cpp:2988
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::AsmPrinter::SrcMgrDiagInfo::DiagHandler
LLVMContext::InlineAsmDiagHandlerTy DiagHandler
Definition: AsmPrinter.h:192
llvm::AsmPrinter::MBBSectionRange::BeginLabel
MCSymbol * BeginLabel
Definition: AsmPrinter.h:133
AsmDialect
AsmDialect
Definition: SystemZMCAsmInfo.cpp:15
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:111
llvm::AsmPrinter::emitXXStructor
virtual void emitXXStructor(const DataLayout &DL, const Constant *CV)
Targets can override this to change how global constants that are part of a C++ static/global constru...
Definition: AsmPrinter.h:508
llvm::AsmPrinter::emitBasicBlockEnd
virtual void emitBasicBlockEnd(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the end of a basic block.
Definition: AsmPrinter.cpp:3218
llvm::remarks::RemarkStreamer
Definition: RemarkStreamer.h:42
llvm::AsmPrinter::lowerConstant
virtual const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
Definition: AsmPrinter.cpp:2365
llvm::GCStrategy
GCStrategy describes a garbage collector algorithm's code generation requirements,...
Definition: GCStrategy.h:66
llvm::AsmPrinter::emitULEB128
void emitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
Definition: AsmPrinterDwarf.cpp:47
llvm::AsmPrinter::recordSled
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind, uint8_t Version=0)
Definition: AsmPrinter.cpp:3447
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:161
llvm::AsmPrinter::CurrentFnSymForSize
MCSymbol * CurrentFnSymForSize
The symbol used to represent the start of the current function for the purpose of calculating its siz...
Definition: AsmPrinter.h:128
llvm::AsmPrinter::createTempSymbol
MCSymbol * createTempSymbol(const Twine &Name) const
Definition: AsmPrinter.cpp:3006
llvm::AsmPrinter::getDwarfDebug
DwarfDebug * getDwarfDebug()
Definition: AsmPrinter.h:223
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:68
llvm::Function
Definition: Function.h:61
llvm::AsmPrinter::SledKind::CUSTOM_EVENT
@ CUSTOM_EVENT
llvm::AsmPrinter::MBBSectionRange
Map a basic block section ID to the begin and end symbols of that section which determine the section...
Definition: AsmPrinter.h:132
llvm::AsmPrinter::emitInlineAsmEnd
virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, const MCSubtargetInfo *EndInfo) const
Let the target do anything it needs to do after emitting inlineasm.
Definition: AsmPrinterInlineAsm.cpp:694
llvm::InlineAsm::AD_ATT
@ AD_ATT
Definition: InlineAsm.h:34
llvm::AsmPrinter::MAI
const MCAsmInfo * MAI
Target Asm Printer information.
Definition: AsmPrinter.h:88
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
llvm::AsmPrinter::emitGlobalConstant
void emitGlobalConstant(const DataLayout &DL, const Constant *CV)
Print a general LLVM constant to the .s file.
Definition: AsmPrinter.cpp:2972
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
InlineAsm.h
llvm::AsmPrinter::emitPatchableFunctionEntries
void emitPatchableFunctionEntries()
Definition: AsmPrinter.cpp:3460
llvm::MipsISD::Lo
@ Lo
Definition: MipsISelLowering.h:79
llvm::AsmPrinter::Structor::Priority
int Priority
Definition: AsmPrinter.h:404
ErrorHandling.h
llvm::AsmPrinter::emitSLEB128
void emitSLEB128(int64_t Value, const char *Desc=nullptr) const
Emit the specified signed leb128 value.
Definition: AsmPrinterDwarf.cpp:40
llvm::GlobalIndirectSymbol
Definition: GlobalIndirectSymbol.h:28
MapVector.h
llvm::GlobalVariable
Definition: GlobalVariable.h:40
llvm::AsmPrinter::XRayFunctionEntry::Function
const MCSymbol * Function
Definition: AsmPrinter.h:306
llvm::MachineOptimizationRemarkEmitter
The optimization diagnostic interface.
Definition: MachineOptimizationRemarkEmitter.h:144
llvm::AsmPrinter::XRayFunctionEntry::Sled
const MCSymbol * Sled
Definition: AsmPrinter.h:305
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition: MachineFunctionPass.h:30
llvm::AsmPrinter::getNameWithPrefix
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
Definition: AsmPrinter.cpp:467
llvm::AsmPrinter::HandlerInfo::TimerDescription
const char * TimerDescription
Definition: AsmPrinter.h:148
llvm::AsmPrinter::doFinalization
bool doFinalization(Module &M) override
Shut down the asmprinter.
Definition: AsmPrinter.cpp:1616
llvm::AsmPrinter::emitStackMaps
void emitStackMaps(StackMaps &SM)
Emit the stack maps.
Definition: AsmPrinter.cpp:3328
llvm::MachineConstantPoolValue
Abstract base class for all machine specific constantpool value subclasses.
Definition: MachineConstantPool.h:35
llvm::AsmPrinter::PrintSymbolOperand
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
Definition: AsmPrinterInlineAsm.cpp:634
llvm::AsmPrinter::getDwarfOffsetByteSize
unsigned int getDwarfOffsetByteSize() const
Returns 4 for DWARF32 and 8 for DWARF64.
Definition: AsmPrinter.cpp:3507
llvm::AsmPrinter::setDwarfVersion
void setDwarfVersion(uint16_t Version)
Definition: AsmPrinter.cpp:3499
llvm::AsmPrinter::Structor::ComdatKey
GlobalValue * ComdatKey
Definition: AsmPrinter.h:406
llvm::AsmPrinter::Structor::Func
Constant * Func
Definition: AsmPrinter.h:405
AsmPrinterHandler.h
llvm::AsmPrinter::SledKind
SledKind
Definition: AsmPrinter.h:291
llvm::AsmPrinter::emitDwarfOffset
void emitDwarfOffset(const MCSymbol *Label, uint64_t Offset) const
Emit something like ".long Label + Offset" or ".quad Label + Offset" depending on the DWARF format.
Definition: AsmPrinterDwarf.cpp:192
llvm::AsmPrinter::Structor
llvm.global_ctors and llvm.global_dtors are arrays of Structor structs.
Definition: AsmPrinter.h:403
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::MapVector
This class implements a map that also provides access to all stored values in a deterministic order.
Definition: MapVector.h:37
llvm::DIE
A structured debug information entry.
Definition: DIE.h:739
llvm::AsmPrinter::CFIMoveType
CFIMoveType
Definition: AsmPrinter.h:372
llvm::AsmPrinter::emitLabelReference
void emitLabelReference(const MCSymbol *Label, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label" where the size in bytes of the directive is specified by Size and L...
Definition: AsmPrinter.h:588
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:194
llvm::GCMetadataPrinter
GCMetadataPrinter - Emits GC metadata as assembly code.
Definition: GCMetadataPrinter.h:39
llvm::AsmPrinter::HandlerInfo::TimerGroupDescription
const char * TimerGroupDescription
Definition: AsmPrinter.h:150
llvm::AsmPrinter::ORE
MachineOptimizationRemarkEmitter * ORE
Optimization remark emitter.
Definition: AsmPrinter.h:112
llvm::AsmPrinter::XRayFunctionEntry::Fn
const class Function * Fn
Definition: AsmPrinter.h:309
llvm::AsmPrinter::CurrentFnDescSym
MCSymbol * CurrentFnDescSym
The symbol for the current function descriptor on AIX.
Definition: AsmPrinter.h:123
llvm::AsmPrinter::emitCallSiteOffset
void emitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Encoding) const
Emit reference to a call site with a specified encoding.
Definition: AsmPrinterDwarf.cpp:211
llvm::StackMaps
Definition: StackMaps.h:251
llvm::DwarfStringPoolEntryRef
String pool entry reference.
Definition: DwarfStringPoolEntry.h:31
llvm::AsmPrinter::emitBBAddrMapSection
void emitBBAddrMapSection(const MachineFunction &MF)
Definition: AsmPrinter.cpp:1085
llvm::AsmPrinter::emitGlobalVariable
virtual void emitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
Definition: AsmPrinter.cpp:494
llvm::MachineLoopInfo
Definition: MachineLoopInfo.h:90
llvm::AsmPrinter::EmitToStreamer
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
Definition: AsmPrinter.cpp:241
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::MipsISD::Hi
@ Hi
Definition: MipsISelLowering.h:75
llvm::AsmPrinter::emitDwarfStringOffset
void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const
Emit the 4-or 8-byte offset of a string from the start of its section.
Definition: AsmPrinter.h:631
llvm::TargetLoweringObjectFile
Definition: TargetLoweringObjectFile.h:43
llvm::AsmPrinter::GOTEquivUsePair
std::pair< const GlobalVariable *, unsigned > GOTEquivUsePair
Map global GOT equivalent MCSymbols to GlobalVariables and keep track of its number of uses by other ...
Definition: AsmPrinter.h:140
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:197
llvm::DIEAbbrev
Dwarf abbreviation, describes the organization of a debug information object.
Definition: DIE.h:79
llvm::AsmPrinter::emitDwarfAbbrev
void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const
Definition: AsmPrinterDwarf.cpp:314
llvm::AsmPrinter::CFI_M_None
@ CFI_M_None
Definition: AsmPrinter.h:372
llvm::AsmPrinter::emitLinkage
virtual void emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const
This emits linkage information about GVSym based on GV, if this is supported by the target.
Definition: AsmPrinter.cpp:427
llvm::AsmPrinter::SrcMgrDiagInfo
Definition: AsmPrinter.h:189
llvm::ISD::Constant
@ Constant
Definition: ISDOpcodes.h:69
llvm::AsmPrinter::XRayFunctionEntry::Version
uint8_t Version
Definition: AsmPrinter.h:310
llvm::AsmPrinter::needsCFIMoves
CFIMoveType needsCFIMoves() const
Definition: AsmPrinter.cpp:1020
llvm::AsmPrinter::OutStreamer
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:97
llvm::AsmPrinter::PrintAsmMemoryOperand
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
Definition: AsmPrinterInlineAsm.cpp:686
llvm::AsmPrinter::addAsmPrinterHandler
void addAsmPrinterHandler(HandlerInfo Handler)
Definition: AsmPrinter.h:457
llvm::GlobalObject
Definition: GlobalObject.h:30
llvm::AsmPrinter::SrcMgrDiagInfo::LocInfos
std::vector< const MDNode * > LocInfos
Definition: AsmPrinter.h:191
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::AsmPrinter::SetupMachineFunction
virtual void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
Definition: AsmPrinter.cpp:1865
llvm::AsmPrinter::emitFunctionEntryLabel
virtual void emitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
Definition: AsmPrinter.cpp:819
llvm::AsmPrinter::Structor::Structor
Structor()=default
llvm::AsmPrinter::emitStartOfAsmFile
virtual void emitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
Definition: AsmPrinter.h:467
llvm::AsmPrinter::isBlockOnlyReachableByFallthrough
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
Definition: AsmPrinter.cpp:3266
remarks
annotation remarks
Definition: AnnotationRemarks.cpp:149
llvm::AsmPrinter::HandlerInfo::HandlerInfo
HandlerInfo(std::unique_ptr< AsmPrinterHandler > Handler, const char *TimerName, const char *TimerDescription, const char *TimerGroupName, const char *TimerGroupDescription)
Definition: AsmPrinter.h:152
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:49
llvm::ConstantArray
ConstantArray - Constant Array Declarations.
Definition: Constants.h:424
llvm::MachineModuleInfo
This class contains meta information specific to a module.
Definition: MachineModuleInfo.h:78
llvm::AsmPrinter::emitInstruction
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
Definition: AsmPrinter.h:491
llvm::AsmPrinter::MLI
MachineLoopInfo * MLI
This is a pointer to the current MachineLoopInfo.
Definition: AsmPrinter.h:109
llvm::AsmPrinter::getDwarfDebug
DwarfDebug * getDwarfDebug() const
Definition: AsmPrinter.h:224
llvm::AsmPrinter::CurrentFnSym
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition: AsmPrinter.h:119
llvm::AsmPrinter::emitAlignment
void emitAlignment(Align Alignment, const GlobalObject *GV=nullptr) const
Emit an alignment directive to the specified power of two boundary.
Definition: AsmPrinter.cpp:2348
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
llvm::AsmPrinter::emitEndOfAsmFile
virtual void emitEndOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the end of their file...
Definition: AsmPrinter.h:471
llvm::AsmPrinter::CFI_M_Debug
@ CFI_M_Debug
Definition: AsmPrinter.h:372
DwarfStringPoolEntry.h
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:991
llvm::AsmPrinter::XRayFunctionEntry::AlwaysInstrument
bool AlwaysInstrument
Definition: AsmPrinter.h:308
llvm::AsmPrinter::emitFunctionBodyStart
virtual void emitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
Definition: AsmPrinter.h:475
llvm::AsmPrinter::emitDwarfAbbrevs
void emitDwarfAbbrevs(const T &Abbrevs) const
Emit Dwarf abbreviation table.
Definition: AsmPrinter.h:675
llvm::AsmPrinter::emitDwarfSymbolReference
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
Definition: AsmPrinterDwarf.cpp:158
llvm::AsmPrinter::CurrentPatchableFunctionEntrySym
MCSymbol * CurrentPatchableFunctionEntrySym
The symbol for the entry in __patchable_function_entires.
Definition: AsmPrinter.h:115
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::AsmPrinter::emitInt8
void emitInt8(int Value) const
Emit a byte directive and value.
Definition: AsmPrinter.cpp:2299
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::AsmPrinter::PrintSpecial
virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS, const char *Code) const
Print information related to the specified machine instr that is independent of the operand,...
Definition: AsmPrinterInlineAsm.cpp:607
llvm::AsmPrinter::getFunctionBegin
MCSymbol * getFunctionBegin() const
Definition: AsmPrinter.h:249
llvm::AsmPrinter::emitBasicBlockStart
virtual void emitBasicBlockStart(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the start of a basic block.
Definition: AsmPrinter.cpp:3138
llvm::MCCFIInstruction
Definition: MCDwarf.h:441
SourceMgr.h
llvm::AsmPrinter::getPointerSize
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
Definition: AsmPrinter.cpp:232
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::AsmPrinter::XRayFunctionEntry::Kind
SledKind Kind
Definition: AsmPrinter.h:307
llvm::AsmPrinter::HandlerInfo::Handler
std::unique_ptr< AsmPrinterHandler > Handler
Definition: AsmPrinter.h:146
llvm::AsmPrinter::Handlers
std::vector< HandlerInfo > Handlers
A vector of all debug/EH info emitters we should use.
Definition: AsmPrinter.h:185
llvm::ISD::BlockAddress
@ BlockAddress
Definition: ISDOpcodes.h:77
llvm::AsmPrinter::AsmPrinter
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
Definition: AsmPrinter.cpp:195
llvm::AsmPrinter::emitMachineConstantPoolValue
virtual void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV)
Definition: AsmPrinter.cpp:2983
llvm::PseudoProbeHandler
Definition: PseudoProbePrinter.h:26
llvm::AsmPrinter::emitFrameAlloc
void emitFrameAlloc(const MachineInstr &MI)
Definition: AsmPrinter.cpp:1060
llvm::AsmPrinter::GetJTSetSymbol
MCSymbol * GetJTSetSymbol(unsigned UID, unsigned MBBID) const
Return the symbol for the specified jump table .set FIXME: privatize to AsmPrinter.
Definition: AsmPrinter.cpp:3053
llvm::AsmPrinter::emitInt64
void emitInt64(uint64_t Value) const
Emit a long long directive and value.
Definition: AsmPrinter.cpp:2308
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::DwarfStringPoolEntry
Data for a string pool entry.
Definition: DwarfStringPoolEntry.h:20
llvm::AsmPrinter::GetCPISymbol
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
Definition: AsmPrinter.cpp:3019
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:62
llvm::DwarfDebug
Collects and handles dwarf debug information.
Definition: DwarfDebug.h:295
llvm::AsmPrinter::emitLabelPlusOffset
void emitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label+Offset" where the size in bytes of the directive is specified by Siz...
Definition: AsmPrinter.cpp:2323
llvm::AsmPrinter::SrcMgrDiagInfo::SrcMgr
SourceMgr SrcMgr
Definition: AsmPrinter.h:190
llvm::AsmPrinter::GetSizeOfEncodedValue
unsigned GetSizeOfEncodedValue(unsigned Encoding) const
Return the size of the encoding in bytes.
Definition: AsmPrinterDwarf.cpp:129
llvm::AsmPrinter::GetBlockAddressSymbol
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
Definition: AsmPrinter.cpp:3010
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::AsmPrinter::getSymbolPreferLocal
MCSymbol * getSymbolPreferLocal(const GlobalValue &GV) const
Similar to getSymbol() but preferred for references.
Definition: AsmPrinter.cpp:476
llvm::DenseMap
Definition: DenseMap.h:714
llvm::AsmPrinter::needsSEHMoves
bool needsSEHMoves()
Definition: AsmPrinter.cpp:1031
MachineFunctionPass.h
llvm::AsmPrinter::emitJumpTableInfo
virtual void emitJumpTableInfo()
Print assembly representations of the jump tables used by the current function to the current output ...
Definition: AsmPrinter.cpp:1998
llvm::AsmPrinter::getFunctionFrameSymbol
virtual const MCSymbol * getFunctionFrameSymbol() const
Return symbol for the function pseudo stack if the stack frame is not a register based.
Definition: AsmPrinter.h:247
llvm::AsmPrinter::getSymbol
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: AsmPrinter.cpp:472
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
llvm::AsmPrinter::emitDwarfUnitLength
void emitDwarfUnitLength(uint64_t Length, const Twine &Comment) const
Emit a unit length field.
Definition: AsmPrinterDwarf.cpp:201
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1556
llvm::AsmPrinter::getMBBExceptionSym
MCSymbol * getMBBExceptionSym(const MachineBasicBlock &MBB)
Definition: AsmPrinter.cpp:1858
llvm::AsmPrinter::MF
MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:100
llvm::AsmPrinter::OutContext
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition: AsmPrinter.h:92
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:64
llvm::AsmPrinter::emitRemarksSection
void emitRemarksSection(remarks::RemarkStreamer &RS)
Definition: AsmPrinter.cpp:1588
llvm::AsmPrinter::emitImplicitDef
virtual void emitImplicitDef(const MachineInstr *MI) const
Targets can override this to customize the output of IMPLICIT_DEF instructions in verbose mode.
Definition: AsmPrinter.cpp:877
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:886
llvm::MCTargetOptions
Definition: MCTargetOptions.h:36
llvm::LLVMContext::InlineAsmDiagHandlerTy
void(*)(const SMDiagnostic &, void *Context, unsigned LocCookie) InlineAsmDiagHandlerTy
Definition: LLVMContext.h:157
llvm::AsmPrinter::emitSpecialLLVMGlobal
bool emitSpecialLLVMGlobal(const GlobalVariable *GV)
Check to see if the specified global is a special global used by LLVM.
Definition: AsmPrinter.cpp:2140
llvm::AsmPrinter::emitDwarfLengthOrOffset
void emitDwarfLengthOrOffset(uint64_t Value) const
Emit 32- or 64-bit value depending on the DWARF format.
Definition: AsmPrinterDwarf.cpp:196
llvm::AsmPrinter::XRayFunctionEntry
Definition: AsmPrinter.h:304
llvm::AsmPrinter::computeGlobalGOTEquivs
void computeGlobalGOTEquivs(Module &M)
Unnamed constant global variables solely contaning a pointer to another globals variable act like a g...
Definition: AsmPrinter.cpp:1482
llvm::AsmPrinter::MDT
MachineDominatorTree * MDT
This is a pointer to the current MachineDominatorTree.
Definition: AsmPrinter.h:106
llvm::MachineFunction
Definition: MachineFunction.h:227
llvm::AsmPrinter::emitCFIInstruction
void emitCFIInstruction(const MachineInstr &MI)
Definition: AsmPrinter.cpp:1035
llvm::AsmPrinter::emitDebugValue
virtual void emitDebugValue(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
Definition: AsmPrinter.cpp:692
llvm::AsmPrinter::runOnMachineFunction
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
Definition: AsmPrinter.h:343
llvm::BlockAddress
The address of a basic block.
Definition: Constants.h:851
llvm::AsmPrinter::GetExternalSymbolSymbol
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
Definition: AsmPrinter.cpp:3066
llvm::AsmPrinter::CFI_M_EH
@ CFI_M_EH
Definition: AsmPrinter.h:372
llvm::AsmPrinter::emitGlobalGOTEquivs
void emitGlobalGOTEquivs()
Constant expressions using GOT equivalent globals may not be eligible for PC relative GOT entry conve...
Definition: AsmPrinter.cpp:1499
llvm::AsmPrinter::SledKind::TYPED_EVENT
@ TYPED_EVENT
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::AsmPrinter::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
Definition: AsmPrinter.cpp:258
llvm::AsmPrinter::GetJTISymbol
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
Definition: AsmPrinter.cpp:3047
llvm::AsmPrinter::HandlerInfo::TimerName
const char * TimerName
Definition: AsmPrinter.h:147
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::AsmPrinter::SledKind::FUNCTION_EXIT
@ FUNCTION_EXIT
llvm::SourceMgr
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition: SourceMgr.h:31
llvm::AsmPrinter::preprocessXXStructorList
void preprocessXXStructorList(const DataLayout &DL, const Constant *List, SmallVector< Structor, 8 > &Structors)
This method gathers an array of Structors and then sorts them out by Priority.
Definition: AsmPrinter.cpp:2185
llvm::AsmPrinter::SledKind::LOG_ARGS_ENTER
@ LOG_ARGS_ENTER
llvm::AsmPrinter::Sleds
SmallVector< XRayFunctionEntry, 4 > Sleds
Definition: AsmPrinter.h:316
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::AsmPrinter::getISAEncoding
virtual unsigned getISAEncoding()
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
Definition: AsmPrinter.h:659
llvm::AsmPrinter::getUnitLengthFieldByteSize
unsigned int getUnitLengthFieldByteSize() const
Returns 4 for DWARF32 and 12 for DWARF64.
Definition: AsmPrinter.cpp:3512
llvm::AsmPrinter::MMI
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Definition: AsmPrinter.h:103
llvm::AsmPrinter::SledKind::TAIL_CALL
@ TAIL_CALL
llvm::AsmPrinter::getGVAlignment
static Align getGVAlignment(const GlobalObject *GV, const DataLayout &DL, Align InAlign=Align(1))
Return the alignment for the specified GV.
Definition: AsmPrinter.cpp:171
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::AsmPrinter::emitPseudoProbe
void emitPseudoProbe(const MachineInstr &MI)
Definition: AsmPrinter.cpp:1111
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
std
Definition: BitVector.h:941
llvm::AsmPrinter::HandlerInfo::TimerGroupName
const char * TimerGroupName
Definition: AsmPrinter.h:149
uint16_t
llvm::AsmPrinter::emitNops
void emitNops(unsigned N)
Emit N NOP instructions.
Definition: AsmPrinter.cpp:2995
llvm::AsmPrinter::needsOnlyDebugCFIMoves
bool needsOnlyDebugCFIMoves() const
Returns false if needsCFIMoves() == CFI_M_EH for any function in the module.
Definition: AsmPrinter.h:377
llvm::AsmPrinter::getSubtargetInfo
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
Definition: AsmPrinter.cpp:236
llvm::AsmPrinter::HandlerInfo
struct HandlerInfo and Handlers permit users or target extended AsmPrinter to add their own handlers.
Definition: AsmPrinter.h:145
llvm::AsmPrinter::isDwarf64
bool isDwarf64() const
Definition: AsmPrinter.cpp:3503
llvm::AsmPrinter::emitInlineAsmStart
virtual void emitInlineAsmStart() const
Let the target do anything it needs to do before emitting inlineasm.
Definition: AsmPrinterInlineAsm.cpp:692
llvm::AsmPrinter::emitStackSizeSection
void emitStackSizeSection(const MachineFunction &MF)
Definition: AsmPrinter.cpp:1120
llvm::AsmPrinter::getDwarfVersion
uint16_t getDwarfVersion() const
Definition: AsmPrinter.cpp:3495
llvm::AsmPrinter
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:82
llvm::AsmPrinter::emitVisibility
void emitVisibility(MCSymbol *Sym, unsigned Visibility, bool IsDefinition=true) const
This emits visibility information about symbol, if this is supported by the target.
Definition: AsmPrinter.cpp:3226
llvm::AsmPrinter::emitInt32
void emitInt32(int Value) const
Emit a long directive and value.
Definition: AsmPrinter.cpp:2305
llvm::AsmPrinter::emitTTypeReference
virtual void emitTTypeReference(const GlobalValue *GV, unsigned Encoding)
Emit reference to a ttype global with a specified encoding.
Definition: AsmPrinterDwarf.cpp:147
llvm::AsmPrinter::MBBSectionRanges
MapVector< unsigned, MBBSectionRange > MBBSectionRanges
Definition: AsmPrinter.h:136
llvm::AsmPrinter::SrcMgrDiagInfo::DiagContext
void * DiagContext
Definition: AsmPrinter.h:193
llvm::AsmPrinter::TM
TargetMachine & TM
Target machine description.
Definition: AsmPrinter.h:85
SmallVector.h
llvm::AsmPrinter::getSymbolWithGlobalValueBase
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
Definition: AsmPrinter.cpp:3060
llvm::AsmPrinter::getObjFileLowering
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Definition: AsmPrinter.cpp:222
N
#define N
llvm::AsmPrinter::emitFunctionBody
void emitFunctionBody()
This method emits the body and trailer for a function.
Definition: AsmPrinter.cpp:1160
llvm::AsmPrinter::emitFunctionDescriptor
virtual void emitFunctionDescriptor()
Definition: AsmPrinter.h:500
llvm::AsmPrinter::CurrentFnBegin
MCSymbol * CurrentFnBegin
Definition: AsmPrinter.h:181
llvm::AsmPrinter::~AsmPrinter
~AsmPrinter() override
Definition: AsmPrinter.cpp:201
llvm::AsmPrinter::getDataLayout
const DataLayout & getDataLayout() const
Return information about data layout.
Definition: AsmPrinter.cpp:226
llvm::AsmPrinter::emitDwarfStringOffset
void emitDwarfStringOffset(DwarfStringPoolEntry S) const
Emit the 4- or 8-byte offset of a string from the start of its section.
Definition: AsmPrinterDwarf.cpp:181
llvm::AsmPrinter::SledKind::FUNCTION_ENTER
@ FUNCTION_ENTER
llvm::SmallVectorImpl< char >
llvm::AsmPrinter::MBBSectionRange::EndLabel
MCSymbol * EndLabel
Definition: AsmPrinter.h:133
llvm::AsmPrinter::getCurrentSection
const MCSection * getCurrentSection() const
Return the current section we are emitting to.
Definition: AsmPrinter.cpp:254
llvm::AsmPrinter::emitDwarfDIE
void emitDwarfDIE(const DIE &Die) const
Recursively emit Dwarf DIE tree.
Definition: AsmPrinterDwarf.cpp:279
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::AsmPrinter::emitInitialRawDwarfLocDirective
void emitInitialRawDwarfLocDirective(const MachineFunction &MF)
Emits inital debug location directive.
Definition: AsmPrinter.cpp:245
llvm::AsmPrinter::emitXRayTable
void emitXRayTable()
Emit a table with all XRay instrumentation points.
Definition: AsmPrinter.cpp:3368
llvm::AsmPrinter::emitCallSiteValue
void emitCallSiteValue(uint64_t Value, unsigned Encoding) const
Emit an integer value corresponding to the call site encoding.
Definition: AsmPrinterDwarf.cpp:220
LLVMContext.h
llvm::MachineJumpTableInfo
Definition: MachineJumpTableInfo.h:42
llvm::AsmPrinter::isVerbose
bool isVerbose() const
Return true if assembly output should contain comments.
Definition: AsmPrinter.h:240
llvm::AsmPrinter::emitFunctionBodyEnd
virtual void emitFunctionBodyEnd()
Targets can override this to emit stuff after the last basic block in the function.
Definition: AsmPrinter.h:479
llvm::MachineDominatorTree
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Definition: MachineDominators.h:45
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75
llvm::AsmPrinter::getFunctionNumber
unsigned getFunctionNumber() const
Return a unique ID for the current function.
Definition: AsmPrinter.cpp:218
llvm::AsmPrinter::emitEncodingByte
void emitEncodingByte(unsigned Val, const char *Desc=nullptr) const
Emit a .byte 42 directive that corresponds to an encoding.
Definition: AsmPrinterDwarf.cpp:116
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::AsmPrinter::emitInt16
void emitInt16(int Value) const
Emit a short directive and value.
Definition: AsmPrinter.cpp:2302
llvm::AsmPrinter::emitXXStructorList
virtual void emitXXStructorList(const DataLayout &DL, const Constant *List, bool IsCtor)
This method emits llvm.global_ctors or llvm.global_dtors list.
Definition: AsmPrinter.cpp:2222
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
llvm::AsmPrinter::PrintAsmOperand
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
Definition: AsmPrinterInlineAsm.cpp:644
llvm::AsmPrinter::XRayFunctionEntry::emit
void emit(int, MCStreamer *) const
Definition: AsmPrinter.cpp:3357
llvm::AsmPrinter::emitConstantPool
virtual void emitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
Definition: AsmPrinter.cpp:1921
llvm::ISD::MCSymbol
@ MCSymbol
Definition: ISDOpcodes.h:165
llvm::AsmPrinter::doInitialization
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
Definition: AsmPrinter.cpp:265