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

Generated by: LCOV version 1.13