LLVM  3.7.0
AsmPrinter.h
Go to the documentation of this file.
1 //===-- llvm/CodeGen/AsmPrinter.h - AsmPrinter Framework --------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains a class to be used as the base class for target specific
11 // asm writers. This class primarily handles common functionality used by
12 // all asm writers.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CODEGEN_ASMPRINTER_H
17 #define LLVM_CODEGEN_ASMPRINTER_H
18 
19 #include "llvm/ADT/MapVector.h"
20 #include "llvm/ADT/Twine.h"
23 #include "llvm/IR/InlineAsm.h"
24 #include "llvm/Support/DataTypes.h"
26 
27 namespace llvm {
28 class AsmPrinterHandler;
29 class BlockAddress;
30 class ByteStreamer;
31 class GCStrategy;
32 class Constant;
33 class ConstantArray;
34 class DIE;
35 class DIEAbbrev;
36 class GCMetadataPrinter;
37 class GlobalValue;
38 class GlobalVariable;
39 class MachineBasicBlock;
40 class MachineFunction;
41 class MachineInstr;
42 class MachineLocation;
43 class MachineLoopInfo;
44 class MachineLoop;
45 class MachineConstantPoolValue;
46 class MachineJumpTableInfo;
47 class MachineModuleInfo;
48 class MCAsmInfo;
49 class MCCFIInstruction;
50 class MCContext;
51 class MCExpr;
52 class MCInst;
53 class MCSection;
54 class MCStreamer;
55 class MCSubtargetInfo;
56 class MCSymbol;
57 class MCTargetOptions;
58 class MDNode;
59 class DwarfDebug;
60 class Mangler;
61 class TargetLoweringObjectFile;
62 class DataLayout;
63 class TargetMachine;
64 
65 /// This class is intended to be used as a driving class for all asm writers.
67 public:
68  /// Target machine description.
69  ///
71 
72  /// Target Asm Printer information.
73  ///
74  const MCAsmInfo *MAI;
75 
76  /// This is the context for the output file that we are streaming. This owns
77  /// all of the global MC-related objects for the generated translation unit.
79 
80  /// This is the MCStreamer object for the file we are generating. This
81  /// contains the transient state for the current translation unit that we are
82  /// generating (such as the current section etc).
83  std::unique_ptr<MCStreamer> OutStreamer;
84 
85  /// The current machine function.
87 
88  /// This is a pointer to the current MachineModuleInfo.
90 
91  /// Name-mangler for global names.
92  ///
94 
95  /// The symbol for the current function. This is recalculated at the beginning
96  /// of each call to runOnMachineFunction().
97  ///
99 
100  /// The symbol used to represent the start of the current function for the
101  /// purpose of calculating its size (e.g. using the .size directive). By
102  /// default, this is equal to CurrentFnSym.
104 
105  /// Map global GOT equivalent MCSymbols to GlobalVariables and keep track of
106  /// its number of uses by other globals.
107  typedef std::pair<const GlobalVariable *, unsigned> GOTEquivUsePair;
109 
110 private:
111  MCSymbol *CurrentFnBegin;
112  MCSymbol *CurrentFnEnd;
113  MCSymbol *CurExceptionSym;
114 
115  // The garbage collection metadata printer table.
116  void *GCMetadataPrinters; // Really a DenseMap.
117 
118  /// Emit comments in assembly output if this is true.
119  ///
120  bool VerboseAsm;
121  static char ID;
122 
123  /// If VerboseAsm is set, a pointer to the loop info for this function.
124  MachineLoopInfo *LI;
125 
126  struct HandlerInfo {
127  AsmPrinterHandler *Handler;
128  const char *TimerName, *TimerGroupName;
129  HandlerInfo(AsmPrinterHandler *Handler, const char *TimerName,
130  const char *TimerGroupName)
131  : Handler(Handler), TimerName(TimerName),
132  TimerGroupName(TimerGroupName) {}
133  };
134  /// A vector of all debug/EH info emitters we should use. This vector
135  /// maintains ownership of the emitters.
137 
138  /// If the target supports dwarf debug info, this pointer is non-null.
139  DwarfDebug *DD;
140 
141 protected:
142  explicit AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer);
143 
144 public:
145  ~AsmPrinter() override;
146 
147  DwarfDebug *getDwarfDebug() { return DD; }
148  DwarfDebug *getDwarfDebug() const { return DD; }
149 
150  /// Return true if assembly output should contain comments.
151  ///
152  bool isVerbose() const { return VerboseAsm; }
153 
154  /// Return a unique ID for the current function.
155  ///
156  unsigned getFunctionNumber() const;
157 
158  MCSymbol *getFunctionBegin() const { return CurrentFnBegin; }
159  MCSymbol *getFunctionEnd() const { return CurrentFnEnd; }
161 
162  /// Return information about object file lowering.
164 
165  /// Return information about data layout.
166  const DataLayout &getDataLayout() const;
167 
168  /// Return information about subtarget.
169  const MCSubtargetInfo &getSubtargetInfo() const;
170 
171  void EmitToStreamer(MCStreamer &S, const MCInst &Inst);
172 
173  /// Return the target triple string.
174  StringRef getTargetTriple() const;
175 
176  /// Return the current section we are emitting to.
177  const MCSection *getCurrentSection() const;
178 
180  const GlobalValue *GV) const;
181 
182  MCSymbol *getSymbol(const GlobalValue *GV) const;
183 
184  //===------------------------------------------------------------------===//
185  // MachineFunctionPass Implementation.
186  //===------------------------------------------------------------------===//
187 
188  /// Record analysis usage.
189  ///
190  void getAnalysisUsage(AnalysisUsage &AU) const override;
191 
192  /// Set up the AsmPrinter when we are working on a new module. If your pass
193  /// overrides this, it must make sure to explicitly call this implementation.
194  bool doInitialization(Module &M) override;
195 
196  /// Shut down the asmprinter. If you override this in your pass, you must make
197  /// sure to call it explicitly.
198  bool doFinalization(Module &M) override;
199 
200  /// Emit the specified function out to the OutStreamer.
204  return false;
205  }
206 
207  //===------------------------------------------------------------------===//
208  // Coarse grained IR lowering routines.
209  //===------------------------------------------------------------------===//
210 
211  /// This should be called when a new MachineFunction is being processed from
212  /// runOnMachineFunction.
214 
215  /// This method emits the body and trailer for a function.
216  void EmitFunctionBody();
217 
218  void emitCFIInstruction(const MachineInstr &MI);
219 
220  void emitFrameAlloc(const MachineInstr &MI);
221 
224 
225  bool needsSEHMoves();
226 
227  /// Print to the current output stream assembly representations of the
228  /// constants in the constant pool MCP. This is used to print out constants
229  /// which have been "spilled to memory" by the code generator.
230  ///
231  virtual void EmitConstantPool();
232 
233  /// Print assembly representations of the jump tables used by the current
234  /// function to the current output stream.
235  ///
236  void EmitJumpTableInfo();
237 
238  /// Emit the specified global variable to the .s file.
239  virtual void EmitGlobalVariable(const GlobalVariable *GV);
240 
241  /// Check to see if the specified global is a special global used by LLVM. If
242  /// so, emit it and return true, otherwise do nothing and return false.
243  bool EmitSpecialLLVMGlobal(const GlobalVariable *GV);
244 
245  /// Emit an alignment directive to the specified power of two boundary. For
246  /// example, if you pass in 3 here, you will get an 8 byte alignment. If a
247  /// global value is specified, and if that global has an explicit alignment
248  /// requested, it will override the alignment request if required for
249  /// correctness.
250  ///
251  void EmitAlignment(unsigned NumBits, const GlobalObject *GO = nullptr) const;
252 
253  /// Lower the specified LLVM Constant to an MCExpr.
254  const MCExpr *lowerConstant(const Constant *CV);
255 
256  /// \brief Print a general LLVM constant to the .s file.
257  void EmitGlobalConstant(const Constant *CV);
258 
259  /// \brief Unnamed constant global variables solely contaning a pointer to
260  /// another globals variable act like a global variable "proxy", or GOT
261  /// equivalents, i.e., it's only used to hold the address of the latter. One
262  /// optimization is to replace accesses to these proxies by using the GOT
263  /// entry for the final global instead. Hence, we select GOT equivalent
264  /// candidates among all the module global variables, avoid emitting them
265  /// unnecessarily and finally replace references to them by pc relative
266  /// accesses to GOT entries.
268 
269  /// \brief Constant expressions using GOT equivalent globals may not be
270  /// eligible for PC relative GOT entry conversion, in such cases we need to
271  /// emit the proxies we previously omitted in EmitGlobalVariable.
272  void emitGlobalGOTEquivs();
273 
274  //===------------------------------------------------------------------===//
275  // Overridable Hooks
276  //===------------------------------------------------------------------===//
277 
278  // Targets can, or in the case of EmitInstruction, must implement these to
279  // customize output.
280 
281  /// This virtual method can be overridden by targets that want to emit
282  /// something at the start of their file.
283  virtual void EmitStartOfAsmFile(Module &) {}
284 
285  /// This virtual method can be overridden by targets that want to emit
286  /// something at the end of their file.
287  virtual void EmitEndOfAsmFile(Module &) {}
288 
289  /// Targets can override this to emit stuff before the first basic block in
290  /// the function.
291  virtual void EmitFunctionBodyStart() {}
292 
293  /// Targets can override this to emit stuff after the last basic block in the
294  /// function.
295  virtual void EmitFunctionBodyEnd() {}
296 
297  /// Targets can override this to emit stuff at the start of a basic block.
298  /// By default, this method prints the label for the specified
299  /// MachineBasicBlock, an alignment (if present) and a comment describing it
300  /// if appropriate.
301  virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB) const;
302 
303  /// Targets can override this to emit stuff at the end of a basic block.
304  virtual void EmitBasicBlockEnd(const MachineBasicBlock &MBB) {}
305 
306  /// Targets should implement this to emit instructions.
307  virtual void EmitInstruction(const MachineInstr *) {
308  llvm_unreachable("EmitInstruction not implemented");
309  }
310 
311  /// Return the symbol for the specified constant pool entry.
312  virtual MCSymbol *GetCPISymbol(unsigned CPID) const;
313 
314  virtual void EmitFunctionEntryLabel();
315 
317 
318  /// Targets can override this to change how global constants that are part of
319  /// a C++ static/global constructor list are emitted.
320  virtual void EmitXXStructor(const Constant *CV) { EmitGlobalConstant(CV); }
321 
322  /// Return true if the basic block has exactly one predecessor and the control
323  /// transfer mechanism between the predecessor and this block is a
324  /// fall-through.
325  virtual bool
327 
328  /// Targets can override this to customize the output of IMPLICIT_DEF
329  /// instructions in verbose mode.
330  virtual void emitImplicitDef(const MachineInstr *MI) const;
331 
332  //===------------------------------------------------------------------===//
333  // Symbol Lowering Routines.
334  //===------------------------------------------------------------------===//
335 public:
336  MCSymbol *createTempSymbol(const Twine &Name) const;
337 
338  /// Return the MCSymbol for a private symbol with global value name as its
339  /// base, with the specified suffix.
341  StringRef Suffix) const;
342 
343  /// Return the MCSymbol for the specified ExternalSymbol.
345 
346  /// Return the symbol for the specified jump table entry.
347  MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
348 
349  /// Return the symbol for the specified jump table .set
350  /// FIXME: privatize to AsmPrinter.
351  MCSymbol *GetJTSetSymbol(unsigned UID, unsigned MBBID) const;
352 
353  /// Return the MCSymbol used to satisfy BlockAddress uses of the specified
354  /// basic block.
355  MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA) const;
356  MCSymbol *GetBlockAddressSymbol(const BasicBlock *BB) const;
357 
358  //===------------------------------------------------------------------===//
359  // Emission Helper Routines.
360  //===------------------------------------------------------------------===//
361 public:
362  /// This is just convenient handler for printing offsets.
363  void printOffset(int64_t Offset, raw_ostream &OS) const;
364 
365  /// Emit a byte directive and value.
366  ///
367  void EmitInt8(int Value) const;
368 
369  /// Emit a short directive and value.
370  ///
371  void EmitInt16(int Value) const;
372 
373  /// Emit a long directive and value.
374  ///
375  void EmitInt32(int Value) const;
376 
377  /// Emit something like ".long Hi-Lo" where the size in bytes of the directive
378  /// is specified by Size and Hi/Lo specify the labels. This implicitly uses
379  /// .set if it is available.
380  void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
381  unsigned Size) const;
382 
383  /// Emit something like ".long Label+Offset" where the size in bytes of the
384  /// directive is specified by Size and Label specifies the label. This
385  /// implicitly uses .set if it is available.
386  void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
387  unsigned Size, bool IsSectionRelative = false) const;
388 
389  /// Emit something like ".long Label" where the size in bytes of the directive
390  /// is specified by Size and Label specifies the label.
391  void EmitLabelReference(const MCSymbol *Label, unsigned Size,
392  bool IsSectionRelative = false) const {
393  EmitLabelPlusOffset(Label, 0, Size, IsSectionRelative);
394  }
395 
396  //===------------------------------------------------------------------===//
397  // Dwarf Emission Helper Routines
398  //===------------------------------------------------------------------===//
399 
400  /// Emit the specified signed leb128 value.
401  void EmitSLEB128(int64_t Value, const char *Desc = nullptr) const;
402 
403  /// Emit the specified unsigned leb128 value.
404  void EmitULEB128(uint64_t Value, const char *Desc = nullptr,
405  unsigned PadTo = 0) const;
406 
407  /// Emit a .byte 42 directive for a DW_CFA_xxx value.
408  void EmitCFAByte(unsigned Val) const;
409 
410  /// Emit a .byte 42 directive that corresponds to an encoding. If verbose
411  /// assembly output is enabled, we output comments describing the encoding.
412  /// Desc is a string saying what the encoding is specifying (e.g. "LSDA").
413  void EmitEncodingByte(unsigned Val, const char *Desc = nullptr) const;
414 
415  /// Return the size of the encoding in bytes.
416  unsigned GetSizeOfEncodedValue(unsigned Encoding) const;
417 
418  /// Emit reference to a ttype global with a specified encoding.
419  void EmitTTypeReference(const GlobalValue *GV, unsigned Encoding) const;
420 
421  /// Emit a reference to a symbol for use in dwarf. Different object formats
422  /// represent this in different ways. Some use a relocation others encode
423  /// the label offset in its section.
425  bool ForceOffset = false) const;
426 
427  /// Emit the 4-byte offset of a string from the start of its section.
428  ///
429  /// When possible, emit a DwarfStringPool section offset without any
430  /// relocations, and without using the symbol. Otherwise, defers to \a
431  /// emitDwarfSymbolReference().
433 
434  /// Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
435  virtual unsigned getISAEncoding() { return 0; }
436 
437  /// EmitDwarfRegOp - Emit a dwarf register operation.
438  virtual void EmitDwarfRegOp(ByteStreamer &BS,
439  const MachineLocation &MLoc) const;
440 
441  //===------------------------------------------------------------------===//
442  // Dwarf Lowering Routines
443  //===------------------------------------------------------------------===//
444 
445  /// \brief Emit frame instruction to describe the layout of the frame.
446  void emitCFIInstruction(const MCCFIInstruction &Inst) const;
447 
448  /// \brief Emit Dwarf abbreviation table.
449  void emitDwarfAbbrevs(const std::vector<DIEAbbrev *>& Abbrevs) const;
450 
451  /// \brief Recursively emit Dwarf DIE tree.
452  void emitDwarfDIE(const DIE &Die) const;
453 
454  //===------------------------------------------------------------------===//
455  // Inline Asm Support
456  //===------------------------------------------------------------------===//
457 public:
458  // These are hooks that targets can override to implement inline asm
459  // support. These should probably be moved out of AsmPrinter someday.
460 
461  /// Print information related to the specified machine instr that is
462  /// independent of the operand, and may be independent of the instr itself.
463  /// This can be useful for portably encoding the comment character or other
464  /// bits of target-specific knowledge into the asmstrings. The syntax used is
465  /// ${:comment}. Targets can override this to add support for their own
466  /// strange codes.
467  virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
468  const char *Code) const;
469 
470  /// Print the specified operand of MI, an INLINEASM instruction, using the
471  /// specified assembler variant. Targets should override this to format as
472  /// appropriate. This method can return true if the operand is erroneous.
473  virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
474  unsigned AsmVariant, const char *ExtraCode,
475  raw_ostream &OS);
476 
477  /// Print the specified operand of MI, an INLINEASM instruction, using the
478  /// specified assembler variant as an address. Targets should override this to
479  /// format as appropriate. This method can return true if the operand is
480  /// erroneous.
481  virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
482  unsigned AsmVariant, const char *ExtraCode,
483  raw_ostream &OS);
484 
485  /// Let the target do anything it needs to do before emitting inlineasm.
486  /// \p StartInfo - the subtarget info before parsing inline asm
487  virtual void emitInlineAsmStart() const;
488 
489  /// Let the target do anything it needs to do after emitting inlineasm.
490  /// This callback can be used restore the original mode in case the
491  /// inlineasm contains directives to switch modes.
492  /// \p StartInfo - the original subtarget info before inline asm
493  /// \p EndInfo - the final subtarget info after parsing the inline asm,
494  /// or NULL if the value is unknown.
495  virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
496  const MCSubtargetInfo *EndInfo) const;
497 
498 private:
499  /// Private state for PrintSpecial()
500  // Assign a unique ID to this machine instruction.
501  mutable const MachineInstr *LastMI;
502  mutable unsigned LastFn;
503  mutable unsigned Counter;
504 
505  /// This method emits the header for the current function.
506  virtual void EmitFunctionHeader();
507 
508  /// Emit a blob of inline asm to the output streamer.
509  void
510  EmitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
511  const MCTargetOptions &MCOptions,
512  const MDNode *LocMDNode = nullptr,
513  InlineAsm::AsmDialect AsmDialect = InlineAsm::AD_ATT) const;
514 
515  /// This method formats and emits the specified machine instruction that is an
516  /// inline asm.
517  void EmitInlineAsm(const MachineInstr *MI) const;
518 
519  //===------------------------------------------------------------------===//
520  // Internal Implementation Details
521  //===------------------------------------------------------------------===//
522 
523  /// This emits visibility information about symbol, if this is suported by the
524  /// target.
525  void EmitVisibility(MCSymbol *Sym, unsigned Visibility,
526  bool IsDefinition = true) const;
527 
528  void EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const;
529 
530  void EmitJumpTableEntry(const MachineJumpTableInfo *MJTI,
531  const MachineBasicBlock *MBB, unsigned uid) const;
532  void EmitLLVMUsedList(const ConstantArray *InitList);
533  /// Emit llvm.ident metadata in an '.ident' directive.
534  void EmitModuleIdents(Module &M);
535  void EmitXXStructorList(const Constant *List, bool isCtor);
536  GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy &C);
537 };
538 }
539 
540 #endif
virtual void EmitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
Definition: AsmPrinter.cpp:344
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:48
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:283
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:104
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:83
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: AsmPrinter.cpp:339
virtual void EmitDwarfRegOp(ByteStreamer &BS, const MachineLocation &MLoc) const
EmitDwarfRegOp - Emit a dwarf register operation.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
const DataLayout & getDataLayout() const
Return information about data layout.
Definition: AsmPrinter.cpp:139
bool doFinalization(Module &M) override
Shut down the asmprinter.
void EmitInt8(int Value) const
Emit a byte directive and value.
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition: AsmPrinter.h:78
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...
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...
void EmitJumpTableInfo()
Print assembly representations of the jump tables used by the current function to the current output ...
Collects and handles AsmPrinter objects required to build debug or EH information.
Collects and handles dwarf debug information.
Definition: DwarfDebug.h:207
const MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:86
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...
virtual void EmitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
This class implements a map that also provides access to all stored values in a deterministic order...
Definition: MapVector.h:32
unsigned getFunctionNumber() const
Return a unique ID for the current function.
Definition: AsmPrinter.cpp:130
Metadata node.
Definition: Metadata.h:740
void EmitInt32(int Value) const
Emit a long directive and value.
ELFYAML::ELF_STV Visibility
Definition: ELFYAML.cpp:590
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:391
virtual void emitInlineAsmStart() const
Let the target do anything it needs to do before emitting inlineasm.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
Definition: AsmPrinter.cpp:143
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
Definition: AsmPrinter.cpp:334
BlockAddress - The address of a basic block.
Definition: Constants.h:802
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
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:287
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
void emitDwarfDIE(const DIE &Die) const
Recursively emit Dwarf DIE tree.
String pool entry reference.
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:33
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...
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
void EmitEncodingByte(unsigned Val, const char *Desc=nullptr) const
Emit a .byte 42 directive that corresponds to an encoding.
Context object for machine code objects.
Definition: MCContext.h:48
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
Definition: AsmPrinter.cpp:163
void EmitFunctionBody()
This method emits the body and trailer for a function.
Definition: AsmPrinter.cpp:784
Mangler * Mang
Name-mangler for global names.
Definition: AsmPrinter.h:93
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
Definition: AsmPrinter.h:201
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
const MCSection * getCurrentSection() const
Return the current section we are emitting to.
Definition: AsmPrinter.cpp:157
void EmitInt16(int Value) const
Emit a short directive and value.
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
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:641
StringRef getTargetTriple() const
Return the target triple string.
Definition: AsmPrinter.cpp:152
void emitGlobalGOTEquivs()
Constant expressions using GOT equivalent globals may not be eligible for PC relative GOT entry conve...
Definition: AsmPrinter.cpp:988
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Definition: AsmPrinter.h:89
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:58
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:107
Streaming machine code generation interface.
Definition: MCStreamer.h:157
virtual void EmitFunctionBodyEnd()
Targets can override this to emit stuff after the last basic block in the function.
Definition: AsmPrinter.h:295
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition: AsmPrinter.h:98
LLVM Basic Block Representation.
Definition: BasicBlock.h:65
const MCAsmInfo * MAI
Target Asm Printer information.
Definition: AsmPrinter.h:74
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
Definition: AsmPrinter.cpp:102
unsigned GetSizeOfEncodedValue(unsigned Encoding) const
Return the size of the encoding in bytes.
This is an important base class in LLVM.
Definition: Constant.h:41
void EmitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
DIE - A structured debug information entry.
Definition: DIE.h:623
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
MCSymbol * GetJTSetSymbol(unsigned UID, unsigned MBBID) const
Return the symbol for the specified jump table .set FIXME: privatize to AsmPrinter.
TargetMachine & TM
Target machine description.
Definition: AsmPrinter.h:70
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:66
Represent the analysis usage information of a pass.
DwarfDebug * getDwarfDebug()
Definition: AsmPrinter.h:147
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
~AsmPrinter() override
Definition: AsmPrinter.cpp:117
void emitFrameAlloc(const MachineInstr &MI)
Definition: AsmPrinter.cpp:772
void computeGlobalGOTEquivs(Module &M)
Unnamed constant global variables solely contaning a pointer to another globals variable act like a g...
Definition: AsmPrinter.cpp:971
void emitDwarfAbbrevs(const std::vector< DIEAbbrev * > &Abbrevs) const
Emit Dwarf abbreviation table.
Abstract base class for all machine specific constantpool value subclasses.
virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, const MCSubtargetInfo *EndInfo) const
Let the target do anything it needs to do after emitting inlineasm.
void EmitAlignment(unsigned NumBits, const GlobalObject *GO=nullptr) const
Emit an alignment directive to the specified power of two boundary.
void emitCFIInstruction(const MachineInstr &MI)
Definition: AsmPrinter.cpp:756
MapVector< const MCSymbol *, GOTEquivUsePair > GlobalGOTEquivs
Definition: AsmPrinter.h:108
void EmitGlobalConstant(const Constant *CV)
Print a general LLVM constant to the .s file.
const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
virtual void EmitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
Definition: AsmPrinter.h:307
virtual void EmitXXStructor(const Constant *CV)
Targets can override this to change how global constants that are part of a C++ static/global constru...
Definition: AsmPrinter.h:320
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
Definition: AsmPrinter.cpp:148
bool EmitSpecialLLVMGlobal(const GlobalVariable *GV)
Check to see if the specified global is a special global used by LLVM.
void EmitTTypeReference(const GlobalValue *GV, unsigned Encoding) const
Emit reference to a ttype global with a specified encoding.
MCSymbol * createTempSymbol(const Twine &Name) const
DwarfDebug * getDwarfDebug() const
Definition: AsmPrinter.h:148
virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB) const
Targets can override this to emit stuff at the start of a basic block.
ConstantArray - Constant Array Declarations.
Definition: Constants.h:356
virtual void EmitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
Definition: AsmPrinter.h:291
MCSymbol * getCurExceptionSym()
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV)
Representation of each machine instruction.
Definition: MachineInstr.h:51
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
Definition: AsmPrinter.cpp:172
GCStrategy describes a garbage collector algorithm's code generation requirements, and provides overridable hooks for those needs which cannot be abstractly described.
Definition: GCStrategy.h:78
void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
MCSymbol * getFunctionBegin() const
Definition: AsmPrinter.h:158
void EmitSLEB128(int64_t Value, const char *Desc=nullptr) const
Emit the specified signed leb128 value.
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
virtual void EmitBasicBlockEnd(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the end of a basic block.
Definition: AsmPrinter.h:304
MCSubtargetInfo - Generic base class for all target subtargets.
MCSymbol * getFunctionEnd() const
Definition: AsmPrinter.h:159
virtual unsigned getISAEncoding()
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
Definition: AsmPrinter.h:435
virtual void EmitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
Definition: AsmPrinter.cpp:588
void EmitCFAByte(unsigned Val) const
Emit a .byte 42 directive for a DW_CFA_xxx value.
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
CFIMoveType needsCFIMoves()
Definition: AsmPrinter.cpp:741
void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const
Emit the 4-byte offset of a string from the start of its section.
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Definition: AsmPrinter.cpp:134
LLVM Value Representation.
Definition: Value.h:69
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
Primary interface to the complete machine description for the target machine.
MCSymbol * CurrentFnSymForSize
The symbol used to represent the start of the current function for the purpose of calculating its siz...
Definition: AsmPrinter.h:103
GCMetadataPrinter - Emits GC metadata as assembly code.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
bool isVerbose() const
Return true if assembly output should contain comments.
Definition: AsmPrinter.h:152
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
MachineModuleInfo - This class contains meta information specific to a module.