LCOV - code coverage report
Current view: top level - include/llvm/Target - TargetLoweringObjectFile.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 10 27 37.0 %
Date: 2018-10-20 13:21:21 Functions: 6 17 35.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- llvm/Target/TargetLoweringObjectFile.h - Object Info ----*- 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 implements classes used to handle lowerings specific to common
      11             : // object file formats.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILE_H
      16             : #define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILE_H
      17             : 
      18             : #include "llvm/ADT/ArrayRef.h"
      19             : #include "llvm/ADT/StringRef.h"
      20             : #include "llvm/IR/Module.h"
      21             : #include "llvm/MC/MCObjectFileInfo.h"
      22             : #include "llvm/MC/SectionKind.h"
      23             : #include <cstdint>
      24             : 
      25             : namespace llvm {
      26             : 
      27             : class GlobalValue;
      28             : class MachineModuleInfo;
      29             : class Mangler;
      30             : class MCContext;
      31             : class MCExpr;
      32             : class MCSection;
      33             : class MCSymbol;
      34             : class MCSymbolRefExpr;
      35             : class MCStreamer;
      36             : class MCValue;
      37             : class TargetMachine;
      38             : 
      39             : class TargetLoweringObjectFile : public MCObjectFileInfo {
      40             :   MCContext *Ctx = nullptr;
      41             : 
      42             :   /// Name-mangler for global names.
      43             :   Mangler *Mang = nullptr;
      44             : 
      45             : protected:
      46             :   bool SupportIndirectSymViaGOTPCRel = false;
      47             :   bool SupportGOTPCRelWithOffset = true;
      48             :   bool SupportDebugThreadLocalLocation = true;
      49             : 
      50             :   /// PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values
      51             :   /// for EH.
      52             :   unsigned PersonalityEncoding = 0;
      53             :   unsigned LSDAEncoding = 0;
      54             :   unsigned TTypeEncoding = 0;
      55             : 
      56             :   /// This section contains the static constructor pointer list.
      57             :   MCSection *StaticCtorSection = nullptr;
      58             : 
      59             :   /// This section contains the static destructor pointer list.
      60             :   MCSection *StaticDtorSection = nullptr;
      61             : 
      62             : public:
      63       40976 :   TargetLoweringObjectFile() = default;
      64             :   TargetLoweringObjectFile(const TargetLoweringObjectFile &) = delete;
      65             :   TargetLoweringObjectFile &
      66             :   operator=(const TargetLoweringObjectFile &) = delete;
      67             :   virtual ~TargetLoweringObjectFile();
      68             : 
      69           0 :   MCContext &getContext() const { return *Ctx; }
      70           0 :   Mangler &getMangler() const { return *Mang; }
      71             : 
      72             :   /// This method must be called before any actual lowering is done.  This
      73             :   /// specifies the current context for codegen, and gives the lowering
      74             :   /// implementations a chance to set up their default sections.
      75             :   virtual void Initialize(MCContext &ctx, const TargetMachine &TM);
      76             : 
      77             :   virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM,
      78             :                                     const MCSymbol *Sym) const;
      79             : 
      80             :   /// Emit the module-level metadata that the platform cares about.
      81         539 :   virtual void emitModuleMetadata(MCStreamer &Streamer, Module &M) const {}
      82             : 
      83             :   /// Given a constant with the SectionKind, return a section that it should be
      84             :   /// placed in.
      85             :   virtual MCSection *getSectionForConstant(const DataLayout &DL,
      86             :                                            SectionKind Kind,
      87             :                                            const Constant *C,
      88             :                                            unsigned &Align) const;
      89             : 
      90             :   /// Classify the specified global variable into a set of target independent
      91             :   /// categories embodied in SectionKind.
      92             :   static SectionKind getKindForGlobal(const GlobalObject *GO,
      93             :                                       const TargetMachine &TM);
      94             : 
      95             :   /// This method computes the appropriate section to emit the specified global
      96             :   /// variable or function definition. This should not be passed external (or
      97             :   /// available externally) globals.
      98             :   MCSection *SectionForGlobal(const GlobalObject *GO, SectionKind Kind,
      99             :                               const TargetMachine &TM) const;
     100             : 
     101             :   /// This method computes the appropriate section to emit the specified global
     102             :   /// variable or function definition. This should not be passed external (or
     103             :   /// available externally) globals.
     104      406049 :   MCSection *SectionForGlobal(const GlobalObject *GO,
     105             :                               const TargetMachine &TM) const {
     106      406049 :     return SectionForGlobal(GO, getKindForGlobal(GO, TM), TM);
     107             :   }
     108             : 
     109             :   virtual void getNameWithPrefix(SmallVectorImpl<char> &OutName,
     110             :                                  const GlobalValue *GV,
     111             :                                  const TargetMachine &TM) const;
     112             : 
     113             :   virtual MCSection *getSectionForJumpTable(const Function &F,
     114             :                                             const TargetMachine &TM) const;
     115             : 
     116             :   virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
     117             :                                                    const Function &F) const;
     118             : 
     119             :   /// Targets should implement this method to assign a section to globals with
     120             :   /// an explicit section specfied. The implementation of this method can
     121             :   /// assume that GO->hasSection() is true.
     122             :   virtual MCSection *
     123             :   getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
     124             :                            const TargetMachine &TM) const = 0;
     125             : 
     126             :   /// Return an MCExpr to use for a reference to the specified global variable
     127             :   /// from exception handling information.
     128             :   virtual const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
     129             :                                                 unsigned Encoding,
     130             :                                                 const TargetMachine &TM,
     131             :                                                 MachineModuleInfo *MMI,
     132             :                                                 MCStreamer &Streamer) const;
     133             : 
     134             :   /// Return the MCSymbol for a private symbol with global value name as its
     135             :   /// base, with the specified suffix.
     136             :   MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
     137             :                                          StringRef Suffix,
     138             :                                          const TargetMachine &TM) const;
     139             : 
     140             :   // The symbol that gets passed to .cfi_personality.
     141             :   virtual MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
     142             :                                             const TargetMachine &TM,
     143             :                                             MachineModuleInfo *MMI) const;
     144             : 
     145           0 :   unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
     146           0 :   unsigned getLSDAEncoding() const { return LSDAEncoding; }
     147           0 :   unsigned getTTypeEncoding() const { return TTypeEncoding; }
     148             : 
     149             :   const MCExpr *getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
     150             :                                   MCStreamer &Streamer) const;
     151             : 
     152          14 :   virtual MCSection *getStaticCtorSection(unsigned Priority,
     153             :                                           const MCSymbol *KeySym) const {
     154          14 :     return StaticCtorSection;
     155             :   }
     156             : 
     157           4 :   virtual MCSection *getStaticDtorSection(unsigned Priority,
     158             :                                           const MCSymbol *KeySym) const {
     159           4 :     return StaticDtorSection;
     160             :   }
     161             : 
     162             :   /// Create a symbol reference to describe the given TLS variable when
     163             :   /// emitting the address in debug info.
     164             :   virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
     165             : 
     166          20 :   virtual const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
     167             :                                                const GlobalValue *RHS,
     168             :                                                const TargetMachine &TM) const {
     169          20 :     return nullptr;
     170             :   }
     171             : 
     172             :   /// Target supports replacing a data "PC"-relative access to a symbol
     173             :   /// through another symbol, by accessing the later via a GOT entry instead?
     174           0 :   bool supportIndirectSymViaGOTPCRel() const {
     175           0 :     return SupportIndirectSymViaGOTPCRel;
     176             :   }
     177             : 
     178             :   /// Target GOT "PC"-relative relocation supports encoding an additional
     179             :   /// binary expression with an offset?
     180           0 :   bool supportGOTPCRelWithOffset() const {
     181           0 :     return SupportGOTPCRelWithOffset;
     182             :   }
     183             : 
     184             :   /// Target supports TLS offset relocation in debug section?
     185           0 :   bool supportDebugThreadLocalLocation() const {
     186           0 :     return SupportDebugThreadLocalLocation;
     187             :   }
     188             : 
     189             :   /// Get the target specific PC relative GOT entry relocation
     190           0 :   virtual const MCExpr *getIndirectSymViaGOTPCRel(const MCSymbol *Sym,
     191             :                                                   const MCValue &MV,
     192             :                                                   int64_t Offset,
     193             :                                                   MachineModuleInfo *MMI,
     194             :                                                   MCStreamer &Streamer) const {
     195           0 :     return nullptr;
     196             :   }
     197             : 
     198           0 :   virtual void emitLinkerFlagsForGlobal(raw_ostream &OS,
     199           0 :                                         const GlobalValue *GV) const {}
     200             : 
     201           0 :   virtual void emitLinkerFlagsForUsed(raw_ostream &OS,
     202           0 :                                       const GlobalValue *GV) const {}
     203             : 
     204             : protected:
     205             :   virtual MCSection *SelectSectionForGlobal(const GlobalObject *GO,
     206             :                                             SectionKind Kind,
     207             :                                             const TargetMachine &TM) const = 0;
     208             : };
     209             : 
     210             : } // end namespace llvm
     211             : 
     212             : #endif // LLVM_CODEGEN_TARGETLOWERINGOBJECTFILE_H

Generated by: LCOV version 1.13