LCOV - code coverage report
Current view: top level - include/llvm/CodeGen - AsmPrinter.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 22 24 91.7 %
Date: 2017-09-14 15:23:50 Functions: 11 12 91.7 %
Legend: Lines: hit not hit

          Line data    Source code
       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/SmallVector.h"
      21             : #include "llvm/ADT/StringRef.h"
      22             : #include "llvm/ADT/Twine.h"
      23             : #include "llvm/CodeGen/DwarfStringPoolEntry.h"
      24             : #include "llvm/CodeGen/MachineFunctionPass.h"
      25             : #include "llvm/IR/InlineAsm.h"
      26             : #include "llvm/IR/LLVMContext.h"
      27             : #include "llvm/Support/ErrorHandling.h"
      28             : #include "llvm/Support/SourceMgr.h"
      29             : #include <cstdint>
      30             : #include <memory>
      31             : #include <utility>
      32             : #include <vector>
      33             : 
      34             : namespace llvm {
      35             : 
      36             : class AsmPrinterHandler;
      37             : class BasicBlock;
      38             : class BlockAddress;
      39             : class Constant;
      40             : class ConstantArray;
      41             : class DataLayout;
      42             : class DIE;
      43             : class DIEAbbrev;
      44             : class DwarfDebug;
      45             : class GCMetadataPrinter;
      46             : class GlobalIndirectSymbol;
      47             : class GlobalObject;
      48             : class GlobalValue;
      49             : class GlobalVariable;
      50             : class GCStrategy;
      51             : class MachineBasicBlock;
      52             : class MachineConstantPoolValue;
      53             : class MachineFunction;
      54             : class MachineInstr;
      55             : class MachineJumpTableInfo;
      56             : class MachineLoopInfo;
      57             : class MachineModuleInfo;
      58             : class MachineOptimizationRemarkEmitter;
      59             : class MCAsmInfo;
      60             : class MCCFIInstruction;
      61             : class MCContext;
      62             : class MCExpr;
      63             : class MCInst;
      64             : class MCSection;
      65             : class MCStreamer;
      66             : class MCSubtargetInfo;
      67             : class MCSymbol;
      68             : class MCTargetOptions;
      69             : class MDNode;
      70             : class Module;
      71             : class raw_ostream;
      72             : class TargetLoweringObjectFile;
      73             : class TargetMachine;
      74             : 
      75             : /// This class is intended to be used as a driving class for all asm writers.
      76             : class AsmPrinter : public MachineFunctionPass {
      77             : public:
      78             :   /// Target machine description.
      79             :   ///
      80             :   TargetMachine &TM;
      81             : 
      82             :   /// Target Asm Printer information.
      83             :   ///
      84             :   const MCAsmInfo *MAI;
      85             : 
      86             :   /// This is the context for the output file that we are streaming. This owns
      87             :   /// all of the global MC-related objects for the generated translation unit.
      88             :   MCContext &OutContext;
      89             : 
      90             :   /// This is the MCStreamer object for the file we are generating. This
      91             :   /// contains the transient state for the current translation unit that we are
      92             :   /// generating (such as the current section etc).
      93             :   std::unique_ptr<MCStreamer> OutStreamer;
      94             : 
      95             :   /// The current machine function.
      96             :   const MachineFunction *MF = nullptr;
      97             : 
      98             :   /// This is a pointer to the current MachineModuleInfo.
      99             :   MachineModuleInfo *MMI = nullptr;
     100             : 
     101             :   /// Optimization remark emitter.
     102             :   MachineOptimizationRemarkEmitter *ORE;
     103             : 
     104             :   /// The symbol for the current function. This is recalculated at the beginning
     105             :   /// of each call to runOnMachineFunction().
     106             :   ///
     107             :   MCSymbol *CurrentFnSym = nullptr;
     108             : 
     109             :   /// The symbol used to represent the start of the current function for the
     110             :   /// purpose of calculating its size (e.g. using the .size directive). By
     111             :   /// default, this is equal to CurrentFnSym.
     112             :   MCSymbol *CurrentFnSymForSize = nullptr;
     113             : 
     114             :   /// Map global GOT equivalent MCSymbols to GlobalVariables and keep track of
     115             :   /// its number of uses by other globals.
     116             :   using GOTEquivUsePair = std::pair<const GlobalVariable *, unsigned>;
     117             :   MapVector<const MCSymbol *, GOTEquivUsePair> GlobalGOTEquivs;
     118             : 
     119             :   /// Enable print [latency:throughput] in output
     120             :   bool EnablePrintSchedInfo = false;
     121             : 
     122             : private:
     123             :   MCSymbol *CurrentFnBegin = nullptr;
     124             :   MCSymbol *CurrentFnEnd = nullptr;
     125             :   MCSymbol *CurExceptionSym = nullptr;
     126             : 
     127             :   // The garbage collection metadata printer table.
     128             :   void *GCMetadataPrinters = nullptr; // Really a DenseMap.
     129             : 
     130             :   /// Emit comments in assembly output if this is true.
     131             :   ///
     132             :   bool VerboseAsm;
     133             :   static char ID;
     134             : 
     135             :   /// If VerboseAsm is set, a pointer to the loop info for this function.
     136             :   MachineLoopInfo *LI = nullptr;
     137             : 
     138             :   struct HandlerInfo {
     139             :     AsmPrinterHandler *Handler;
     140             :     const char *TimerName;
     141             :     const char *TimerDescription;
     142             :     const char *TimerGroupName;
     143             :     const char *TimerGroupDescription;
     144             : 
     145             :     HandlerInfo(AsmPrinterHandler *Handler, const char *TimerName,
     146             :                 const char *TimerDescription, const char *TimerGroupName,
     147             :                 const char *TimerGroupDescription)
     148       31369 :         : Handler(Handler), TimerName(TimerName),
     149             :           TimerDescription(TimerDescription), TimerGroupName(TimerGroupName),
     150       31369 :           TimerGroupDescription(TimerGroupDescription) {}
     151             :   };
     152             :   /// A vector of all debug/EH info emitters we should use. This vector
     153             :   /// maintains ownership of the emitters.
     154             :   SmallVector<HandlerInfo, 1> Handlers;
     155             : 
     156             : public:
     157        2261 :   struct SrcMgrDiagInfo {
     158             :     SourceMgr SrcMgr;
     159             :     std::vector<const MDNode *> LocInfos;
     160             :     LLVMContext::InlineAsmDiagHandlerTy DiagHandler;
     161             :     void *DiagContext;
     162             :   };
     163             : 
     164             : private:
     165             :   /// Structure for generating diagnostics for inline assembly. Only initialised
     166             :   /// when necessary.
     167             :   mutable std::unique_ptr<SrcMgrDiagInfo> DiagInfo;
     168             : 
     169             :   /// If the target supports dwarf debug info, this pointer is non-null.
     170             :   DwarfDebug *DD = nullptr;
     171             : 
     172             :   /// If the current module uses dwarf CFI annotations strictly for debugging.
     173             :   bool isCFIMoveForDebugging = false;
     174             : 
     175             : protected:
     176             :   explicit AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer);
     177             : 
     178             : public:
     179             :   ~AsmPrinter() override;
     180             : 
     181             :   DwarfDebug *getDwarfDebug() { return DD; }
     182             :   DwarfDebug *getDwarfDebug() const { return DD; }
     183             : 
     184             :   uint16_t getDwarfVersion() const;
     185             :   void setDwarfVersion(uint16_t Version);
     186             : 
     187             :   bool isPositionIndependent() const;
     188             : 
     189             :   /// Return true if assembly output should contain comments.
     190             :   ///
     191             :   bool isVerbose() const { return VerboseAsm; }
     192             : 
     193             :   /// Return a unique ID for the current function.
     194             :   ///
     195             :   unsigned getFunctionNumber() const;
     196             : 
     197             :   MCSymbol *getFunctionBegin() const { return CurrentFnBegin; }
     198             :   MCSymbol *getFunctionEnd() const { return CurrentFnEnd; }
     199             :   MCSymbol *getCurExceptionSym();
     200             : 
     201             :   /// Return information about object file lowering.
     202             :   const TargetLoweringObjectFile &getObjFileLowering() const;
     203             : 
     204             :   /// Return information about data layout.
     205             :   const DataLayout &getDataLayout() const;
     206             : 
     207             :   /// Return the pointer size from the TargetMachine
     208             :   unsigned getPointerSize() const;
     209             : 
     210             :   /// Return information about subtarget.
     211             :   const MCSubtargetInfo &getSubtargetInfo() const;
     212             : 
     213             :   void EmitToStreamer(MCStreamer &S, const MCInst &Inst);
     214             : 
     215             :   /// Return the current section we are emitting to.
     216             :   const MCSection *getCurrentSection() const;
     217             : 
     218             :   void getNameWithPrefix(SmallVectorImpl<char> &Name,
     219             :                          const GlobalValue *GV) const;
     220             : 
     221             :   MCSymbol *getSymbol(const GlobalValue *GV) const;
     222             : 
     223             :   //===------------------------------------------------------------------===//
     224             :   // XRay instrumentation implementation.
     225             :   //===------------------------------------------------------------------===//
     226             : public:
     227             :   // This describes the kind of sled we're storing in the XRay table.
     228             :   enum class SledKind : uint8_t {
     229             :     FUNCTION_ENTER = 0,
     230             :     FUNCTION_EXIT = 1,
     231             :     TAIL_CALL = 2,
     232             :     LOG_ARGS_ENTER = 3,
     233             :     CUSTOM_EVENT = 4,
     234             :   };
     235             : 
     236             :   // The table will contain these structs that point to the sled, the function
     237             :   // containing the sled, and what kind of sled (and whether they should always
     238             :   // be instrumented). We also use a version identifier that the runtime can use
     239             :   // to decide what to do with the sled, depending on the version of the sled.
     240             :   struct XRayFunctionEntry {
     241             :     const MCSymbol *Sled;
     242             :     const MCSymbol *Function;
     243             :     SledKind Kind;
     244             :     bool AlwaysInstrument;
     245             :     const class Function *Fn;
     246             :     uint8_t Version;
     247             : 
     248             :     void emit(int, MCStreamer *, const MCSymbol *) const;
     249             :   };
     250             : 
     251             :   // All the sleds to be emitted.
     252             :   SmallVector<XRayFunctionEntry, 4> Sleds;
     253             : 
     254             :   // A unique ID used for ELF sections associated with a particular function.
     255             :   unsigned XRayFnUniqueID = 0;
     256             : 
     257             :   // Helper function to record a given XRay sled.
     258             :   void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind,
     259             :                   uint8_t Version = 0);
     260             : 
     261             :   /// Emit a table with all XRay instrumentation points.
     262             :   void emitXRayTable();
     263             : 
     264             :   //===------------------------------------------------------------------===//
     265             :   // MachineFunctionPass Implementation.
     266             :   //===------------------------------------------------------------------===//
     267             : 
     268             :   /// Record analysis usage.
     269             :   ///
     270             :   void getAnalysisUsage(AnalysisUsage &AU) const override;
     271             : 
     272             :   /// Set up the AsmPrinter when we are working on a new module. If your pass
     273             :   /// overrides this, it must make sure to explicitly call this implementation.
     274             :   bool doInitialization(Module &M) override;
     275             : 
     276             :   /// Shut down the asmprinter. If you override this in your pass, you must make
     277             :   /// sure to call it explicitly.
     278             :   bool doFinalization(Module &M) override;
     279             : 
     280             :   /// Emit the specified function out to the OutStreamer.
     281        8005 :   bool runOnMachineFunction(MachineFunction &MF) override {
     282       43244 :     SetupMachineFunction(MF);
     283       43244 :     EmitFunctionBody();
     284        8004 :     return false;
     285             :   }
     286             : 
     287             :   //===------------------------------------------------------------------===//
     288             :   // Coarse grained IR lowering routines.
     289             :   //===------------------------------------------------------------------===//
     290             : 
     291             :   /// This should be called when a new MachineFunction is being processed from
     292             :   /// runOnMachineFunction.
     293             :   void SetupMachineFunction(MachineFunction &MF);
     294             : 
     295             :   /// This method emits the body and trailer for a function.
     296             :   void EmitFunctionBody();
     297             : 
     298             :   void emitCFIInstruction(const MachineInstr &MI);
     299             : 
     300             :   void emitFrameAlloc(const MachineInstr &MI);
     301             : 
     302             :   enum CFIMoveType { CFI_M_None, CFI_M_EH, CFI_M_Debug };
     303             :   CFIMoveType needsCFIMoves() const;
     304             : 
     305             :   /// Returns false if needsCFIMoves() == CFI_M_EH for any function
     306             :   /// in the module.
     307             :   bool needsOnlyDebugCFIMoves() const { return isCFIMoveForDebugging; }
     308             : 
     309             :   bool needsSEHMoves();
     310             : 
     311             :   /// Print to the current output stream assembly representations of the
     312             :   /// constants in the constant pool MCP. This is used to print out constants
     313             :   /// which have been "spilled to memory" by the code generator.
     314             :   ///
     315             :   virtual void EmitConstantPool();
     316             : 
     317             :   /// Print assembly representations of the jump tables used by the current
     318             :   /// function to the current output stream.
     319             :   ///
     320             :   virtual void EmitJumpTableInfo();
     321             : 
     322             :   /// Emit the specified global variable to the .s file.
     323             :   virtual void EmitGlobalVariable(const GlobalVariable *GV);
     324             : 
     325             :   /// Check to see if the specified global is a special global used by LLVM. If
     326             :   /// so, emit it and return true, otherwise do nothing and return false.
     327             :   bool EmitSpecialLLVMGlobal(const GlobalVariable *GV);
     328             : 
     329             :   /// Emit an alignment directive to the specified power of two boundary. For
     330             :   /// example, if you pass in 3 here, you will get an 8 byte alignment. If a
     331             :   /// global value is specified, and if that global has an explicit alignment
     332             :   /// requested, it will override the alignment request if required for
     333             :   /// correctness.
     334             :   ///
     335             :   void EmitAlignment(unsigned NumBits, const GlobalObject *GO = nullptr) const;
     336             : 
     337             :   /// Lower the specified LLVM Constant to an MCExpr.
     338             :   virtual const MCExpr *lowerConstant(const Constant *CV);
     339             : 
     340             :   /// \brief Print a general LLVM constant to the .s file.
     341             :   void EmitGlobalConstant(const DataLayout &DL, const Constant *CV);
     342             : 
     343             :   /// \brief Unnamed constant global variables solely contaning a pointer to
     344             :   /// another globals variable act like a global variable "proxy", or GOT
     345             :   /// equivalents, i.e., it's only used to hold the address of the latter. One
     346             :   /// optimization is to replace accesses to these proxies by using the GOT
     347             :   /// entry for the final global instead. Hence, we select GOT equivalent
     348             :   /// candidates among all the module global variables, avoid emitting them
     349             :   /// unnecessarily and finally replace references to them by pc relative
     350             :   /// accesses to GOT entries.
     351             :   void computeGlobalGOTEquivs(Module &M);
     352             : 
     353             :   /// \brief Constant expressions using GOT equivalent globals may not be
     354             :   /// eligible for PC relative GOT entry conversion, in such cases we need to
     355             :   /// emit the proxies we previously omitted in EmitGlobalVariable.
     356             :   void emitGlobalGOTEquivs();
     357             : 
     358             :   //===------------------------------------------------------------------===//
     359             :   // Overridable Hooks
     360             :   //===------------------------------------------------------------------===//
     361             : 
     362             :   // Targets can, or in the case of EmitInstruction, must implement these to
     363             :   // customize output.
     364             : 
     365             :   /// This virtual method can be overridden by targets that want to emit
     366             :   /// something at the start of their file.
     367        2595 :   virtual void EmitStartOfAsmFile(Module &) {}
     368             : 
     369             :   /// This virtual method can be overridden by targets that want to emit
     370             :   /// something at the end of their file.
     371        1814 :   virtual void EmitEndOfAsmFile(Module &) {}
     372             : 
     373             :   /// Targets can override this to emit stuff before the first basic block in
     374             :   /// the function.
     375      104009 :   virtual void EmitFunctionBodyStart() {}
     376             : 
     377             :   /// Targets can override this to emit stuff after the last basic block in the
     378             :   /// function.
     379       97898 :   virtual void EmitFunctionBodyEnd() {}
     380             : 
     381             :   /// Targets can override this to emit stuff at the start of a basic block.
     382             :   /// By default, this method prints the label for the specified
     383             :   /// MachineBasicBlock, an alignment (if present) and a comment describing it
     384             :   /// if appropriate.
     385             :   virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB) const;
     386             : 
     387             :   /// Targets can override this to emit stuff at the end of a basic block.
     388       79092 :   virtual void EmitBasicBlockEnd(const MachineBasicBlock &MBB) {}
     389             : 
     390             :   /// Targets should implement this to emit instructions.
     391           0 :   virtual void EmitInstruction(const MachineInstr *) {
     392           0 :     llvm_unreachable("EmitInstruction not implemented");
     393             :   }
     394             : 
     395             :   /// Return the symbol for the specified constant pool entry.
     396             :   virtual MCSymbol *GetCPISymbol(unsigned CPID) const;
     397             : 
     398             :   virtual void EmitFunctionEntryLabel();
     399             : 
     400             :   virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
     401             : 
     402             :   /// Targets can override this to change how global constants that are part of
     403             :   /// a C++ static/global constructor list are emitted.
     404         197 :   virtual void EmitXXStructor(const DataLayout &DL, const Constant *CV) {
     405         197 :     EmitGlobalConstant(DL, CV);
     406         197 :   }
     407             : 
     408             :   /// Return true if the basic block has exactly one predecessor and the control
     409             :   /// transfer mechanism between the predecessor and this block is a
     410             :   /// fall-through.
     411             :   virtual bool
     412             :   isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const;
     413             : 
     414             :   /// Targets can override this to customize the output of IMPLICIT_DEF
     415             :   /// instructions in verbose mode.
     416             :   virtual void emitImplicitDef(const MachineInstr *MI) const;
     417             : 
     418             :   //===------------------------------------------------------------------===//
     419             :   // Symbol Lowering Routines.
     420             :   //===------------------------------------------------------------------===//
     421             : 
     422             :   MCSymbol *createTempSymbol(const Twine &Name) const;
     423             : 
     424             :   /// Return the MCSymbol for a private symbol with global value name as its
     425             :   /// base, with the specified suffix.
     426             :   MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
     427             :                                          StringRef Suffix) const;
     428             : 
     429             :   /// Return the MCSymbol for the specified ExternalSymbol.
     430             :   MCSymbol *GetExternalSymbolSymbol(StringRef Sym) const;
     431             : 
     432             :   /// Return the symbol for the specified jump table entry.
     433             :   MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
     434             : 
     435             :   /// Return the symbol for the specified jump table .set
     436             :   /// FIXME: privatize to AsmPrinter.
     437             :   MCSymbol *GetJTSetSymbol(unsigned UID, unsigned MBBID) const;
     438             : 
     439             :   /// Return the MCSymbol used to satisfy BlockAddress uses of the specified
     440             :   /// basic block.
     441             :   MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA) const;
     442             :   MCSymbol *GetBlockAddressSymbol(const BasicBlock *BB) const;
     443             : 
     444             :   //===------------------------------------------------------------------===//
     445             :   // Emission Helper Routines.
     446             :   //===------------------------------------------------------------------===//
     447             : 
     448             :   /// This is just convenient handler for printing offsets.
     449             :   void printOffset(int64_t Offset, raw_ostream &OS) const;
     450             : 
     451             :   /// Emit a byte directive and value.
     452             :   ///
     453             :   void EmitInt8(int Value) const;
     454             : 
     455             :   /// Emit a short directive and value.
     456             :   ///
     457             :   void EmitInt16(int Value) const;
     458             : 
     459             :   /// Emit a long directive and value.
     460             :   ///
     461             :   void EmitInt32(int Value) const;
     462             : 
     463             :   /// Emit something like ".long Hi-Lo" where the size in bytes of the directive
     464             :   /// is specified by Size and Hi/Lo specify the labels.  This implicitly uses
     465             :   /// .set if it is available.
     466             :   void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
     467             :                            unsigned Size) const;
     468             : 
     469             :   /// Emit something like ".long Label+Offset" where the size in bytes of the
     470             :   /// directive is specified by Size and Label specifies the label.  This
     471             :   /// implicitly uses .set if it is available.
     472             :   void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
     473             :                            unsigned Size, bool IsSectionRelative = false) const;
     474             : 
     475             :   /// Emit something like ".long Label" where the size in bytes of the directive
     476             :   /// is specified by Size and Label specifies the label.
     477             :   void EmitLabelReference(const MCSymbol *Label, unsigned Size,
     478             :                           bool IsSectionRelative = false) const {
     479      160846 :     EmitLabelPlusOffset(Label, 0, Size, IsSectionRelative);
     480             :   }
     481             : 
     482             :   //===------------------------------------------------------------------===//
     483             :   // Dwarf Emission Helper Routines
     484             :   //===------------------------------------------------------------------===//
     485             : 
     486             :   /// Emit the specified signed leb128 value.
     487             :   void EmitSLEB128(int64_t Value, const char *Desc = nullptr) const;
     488             : 
     489             :   /// Emit the specified unsigned leb128 value.
     490             :   void EmitULEB128(uint64_t Value, const char *Desc = nullptr,
     491             :                    unsigned PadTo = 0) const;
     492             : 
     493             :   /// Emit a .byte 42 directive that corresponds to an encoding.  If verbose
     494             :   /// assembly output is enabled, we output comments describing the encoding.
     495             :   /// Desc is a string saying what the encoding is specifying (e.g. "LSDA").
     496             :   void EmitEncodingByte(unsigned Val, const char *Desc = nullptr) const;
     497             : 
     498             :   /// Return the size of the encoding in bytes.
     499             :   unsigned GetSizeOfEncodedValue(unsigned Encoding) const;
     500             : 
     501             :   /// Emit reference to a ttype global with a specified encoding.
     502             :   void EmitTTypeReference(const GlobalValue *GV, unsigned Encoding) const;
     503             : 
     504             :   /// Emit a reference to a symbol for use in dwarf. Different object formats
     505             :   /// represent this in different ways. Some use a relocation others encode
     506             :   /// the label offset in its section.
     507             :   void emitDwarfSymbolReference(const MCSymbol *Label,
     508             :                                 bool ForceOffset = false) const;
     509             : 
     510             :   /// Emit the 4-byte offset of a string from the start of its section.
     511             :   ///
     512             :   /// When possible, emit a DwarfStringPool section offset without any
     513             :   /// relocations, and without using the symbol.  Otherwise, defers to \a
     514             :   /// emitDwarfSymbolReference().
     515             :   void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const;
     516             : 
     517             :   /// Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
     518         238 :   virtual unsigned getISAEncoding() { return 0; }
     519             : 
     520             :   /// Emit the directive and value for debug thread local expression
     521             :   ///
     522             :   /// \p Value - The value to emit.
     523             :   /// \p Size - The size of the integer (in bytes) to emit.
     524             :   virtual void EmitDebugThreadLocal(const MCExpr *Value, unsigned Size) const;
     525             : 
     526             :   //===------------------------------------------------------------------===//
     527             :   // Dwarf Lowering Routines
     528             :   //===------------------------------------------------------------------===//
     529             : 
     530             :   /// \brief Emit frame instruction to describe the layout of the frame.
     531             :   void emitCFIInstruction(const MCCFIInstruction &Inst) const;
     532             : 
     533             :   /// \brief Emit Dwarf abbreviation table.
     534         800 :   template <typename T> void emitDwarfAbbrevs(const T &Abbrevs) const {
     535             :     // For each abbreviation.
     536       11078 :     for (const auto &Abbrev : Abbrevs)
     537        7878 :       emitDwarfAbbrev(*Abbrev);
     538             : 
     539             :     // Mark end of abbreviations.
     540         800 :     EmitULEB128(0, "EOM(3)");
     541         800 :   }
     542             : 
     543             :   void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const;
     544             : 
     545             :   /// \brief Recursively emit Dwarf DIE tree.
     546             :   void emitDwarfDIE(const DIE &Die) const;
     547             : 
     548             :   //===------------------------------------------------------------------===//
     549             :   // Inline Asm Support
     550             :   //===------------------------------------------------------------------===//
     551             : 
     552             :   // These are hooks that targets can override to implement inline asm
     553             :   // support.  These should probably be moved out of AsmPrinter someday.
     554             : 
     555             :   /// Print information related to the specified machine instr that is
     556             :   /// independent of the operand, and may be independent of the instr itself.
     557             :   /// This can be useful for portably encoding the comment character or other
     558             :   /// bits of target-specific knowledge into the asmstrings.  The syntax used is
     559             :   /// ${:comment}.  Targets can override this to add support for their own
     560             :   /// strange codes.
     561             :   virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
     562             :                             const char *Code) const;
     563             : 
     564             :   /// Print the specified operand of MI, an INLINEASM instruction, using the
     565             :   /// specified assembler variant.  Targets should override this to format as
     566             :   /// appropriate.  This method can return true if the operand is erroneous.
     567             :   virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
     568             :                                unsigned AsmVariant, const char *ExtraCode,
     569             :                                raw_ostream &OS);
     570             : 
     571             :   /// Print the specified operand of MI, an INLINEASM instruction, using the
     572             :   /// specified assembler variant as an address. Targets should override this to
     573             :   /// format as appropriate.  This method can return true if the operand is
     574             :   /// erroneous.
     575             :   virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
     576             :                                      unsigned AsmVariant, const char *ExtraCode,
     577             :                                      raw_ostream &OS);
     578             : 
     579             :   /// Let the target do anything it needs to do before emitting inlineasm.
     580             :   /// \p StartInfo - the subtarget info before parsing inline asm
     581             :   virtual void emitInlineAsmStart() const;
     582             : 
     583             :   /// Let the target do anything it needs to do after emitting inlineasm.
     584             :   /// This callback can be used restore the original mode in case the
     585             :   /// inlineasm contains directives to switch modes.
     586             :   /// \p StartInfo - the original subtarget info before inline asm
     587             :   /// \p EndInfo   - the final subtarget info after parsing the inline asm,
     588             :   ///                or NULL if the value is unknown.
     589             :   virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
     590             :                                 const MCSubtargetInfo *EndInfo) const;
     591             : 
     592             : private:
     593             :   /// Private state for PrintSpecial()
     594             :   // Assign a unique ID to this machine instruction.
     595             :   mutable const MachineInstr *LastMI = nullptr;
     596             :   mutable unsigned LastFn = 0;
     597             :   mutable unsigned Counter = ~0U;
     598             : 
     599             :   /// This method emits the header for the current function.
     600             :   virtual void EmitFunctionHeader();
     601             : 
     602             :   /// Emit a blob of inline asm to the output streamer.
     603             :   void
     604             :   EmitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
     605             :                 const MCTargetOptions &MCOptions,
     606             :                 const MDNode *LocMDNode = nullptr,
     607             :                 InlineAsm::AsmDialect AsmDialect = InlineAsm::AD_ATT) const;
     608             : 
     609             :   /// This method formats and emits the specified machine instruction that is an
     610             :   /// inline asm.
     611             :   void EmitInlineAsm(const MachineInstr *MI) const;
     612             : 
     613             :   //===------------------------------------------------------------------===//
     614             :   // Internal Implementation Details
     615             :   //===------------------------------------------------------------------===//
     616             : 
     617             :   /// This emits visibility information about symbol, if this is supported by
     618             :   /// the target.
     619             :   void EmitVisibility(MCSymbol *Sym, unsigned Visibility,
     620             :                       bool IsDefinition = true) const;
     621             : 
     622             :   void EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const;
     623             : 
     624             :   void EmitJumpTableEntry(const MachineJumpTableInfo *MJTI,
     625             :                           const MachineBasicBlock *MBB, unsigned uid) const;
     626             :   void EmitLLVMUsedList(const ConstantArray *InitList);
     627             :   /// Emit llvm.ident metadata in an '.ident' directive.
     628             :   void EmitModuleIdents(Module &M);
     629             :   void EmitXXStructorList(const DataLayout &DL, const Constant *List,
     630             :                           bool isCtor);
     631             :   GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy &C);
     632             :   /// Emit GlobalAlias or GlobalIFunc.
     633             :   void emitGlobalIndirectSymbol(Module &M,
     634             :                                 const GlobalIndirectSymbol& GIS);
     635             : };
     636             : 
     637             : } // end namespace llvm
     638             : 
     639             : #endif // LLVM_CODEGEN_ASMPRINTER_H

Generated by: LCOV version 1.13