LCOV - code coverage report
Current view: top level - include/llvm/Target - TargetLoweringObjectFile.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 10 16 62.5 %
Date: 2018-07-13 00:08:38 Functions: 6 9 66.7 %
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             : 
      49             :   /// This section contains the static constructor pointer list.
      50             :   MCSection *StaticCtorSection = nullptr;
      51             : 
      52             :   /// This section contains the static destructor pointer list.
      53             :   MCSection *StaticDtorSection = nullptr;
      54             : 
      55             : public:
      56       70432 :   TargetLoweringObjectFile() = default;
      57             :   TargetLoweringObjectFile(const TargetLoweringObjectFile &) = delete;
      58             :   TargetLoweringObjectFile &
      59             :   operator=(const TargetLoweringObjectFile &) = delete;
      60             :   virtual ~TargetLoweringObjectFile();
      61             : 
      62             :   MCContext &getContext() const { return *Ctx; }
      63             :   Mangler &getMangler() const { return *Mang; }
      64             : 
      65             :   /// This method must be called before any actual lowering is done.  This
      66             :   /// specifies the current context for codegen, and gives the lowering
      67             :   /// implementations a chance to set up their default sections.
      68             :   virtual void Initialize(MCContext &ctx, const TargetMachine &TM);
      69             : 
      70             :   virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM,
      71             :                                     const MCSymbol *Sym) const;
      72             : 
      73             :   /// Emit the module-level metadata that the platform cares about.
      74         496 :   virtual void emitModuleMetadata(MCStreamer &Streamer, Module &M) const {}
      75             : 
      76             :   /// Given a constant with the SectionKind, return a section that it should be
      77             :   /// placed in.
      78             :   virtual MCSection *getSectionForConstant(const DataLayout &DL,
      79             :                                            SectionKind Kind,
      80             :                                            const Constant *C,
      81             :                                            unsigned &Align) const;
      82             : 
      83             :   /// Classify the specified global variable into a set of target independent
      84             :   /// categories embodied in SectionKind.
      85             :   static SectionKind getKindForGlobal(const GlobalObject *GO,
      86             :                                       const TargetMachine &TM);
      87             : 
      88             :   /// This method computes the appropriate section to emit the specified global
      89             :   /// variable or function definition. This should not be passed external (or
      90             :   /// available externally) globals.
      91             :   MCSection *SectionForGlobal(const GlobalObject *GO, SectionKind Kind,
      92             :                               const TargetMachine &TM) const;
      93             : 
      94             :   /// This method computes the appropriate section to emit the specified global
      95             :   /// variable or function definition. This should not be passed external (or
      96             :   /// available externally) globals.
      97      221394 :   MCSection *SectionForGlobal(const GlobalObject *GO,
      98             :                               const TargetMachine &TM) const {
      99      221394 :     return SectionForGlobal(GO, getKindForGlobal(GO, TM), TM);
     100             :   }
     101             : 
     102             :   virtual void getNameWithPrefix(SmallVectorImpl<char> &OutName,
     103             :                                  const GlobalValue *GV,
     104             :                                  const TargetMachine &TM) const;
     105             : 
     106             :   virtual MCSection *getSectionForJumpTable(const Function &F,
     107             :                                             const TargetMachine &TM) const;
     108             : 
     109             :   virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
     110             :                                                    const Function &F) const;
     111             : 
     112             :   /// Targets should implement this method to assign a section to globals with
     113             :   /// an explicit section specfied. The implementation of this method can
     114             :   /// assume that GO->hasSection() is true.
     115             :   virtual MCSection *
     116             :   getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
     117             :                            const TargetMachine &TM) const = 0;
     118             : 
     119             :   /// Return an MCExpr to use for a reference to the specified global variable
     120             :   /// from exception handling information.
     121             :   virtual const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
     122             :                                                 unsigned Encoding,
     123             :                                                 const TargetMachine &TM,
     124             :                                                 MachineModuleInfo *MMI,
     125             :                                                 MCStreamer &Streamer) const;
     126             : 
     127             :   /// Return the MCSymbol for a private symbol with global value name as its
     128             :   /// base, with the specified suffix.
     129             :   MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
     130             :                                          StringRef Suffix,
     131             :                                          const TargetMachine &TM) const;
     132             : 
     133             :   // The symbol that gets passed to .cfi_personality.
     134             :   virtual MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
     135             :                                             const TargetMachine &TM,
     136             :                                             MachineModuleInfo *MMI) const;
     137             : 
     138             :   const MCExpr *getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
     139             :                                   MCStreamer &Streamer) const;
     140             : 
     141          14 :   virtual MCSection *getStaticCtorSection(unsigned Priority,
     142             :                                           const MCSymbol *KeySym) const {
     143          14 :     return StaticCtorSection;
     144             :   }
     145             : 
     146           4 :   virtual MCSection *getStaticDtorSection(unsigned Priority,
     147             :                                           const MCSymbol *KeySym) const {
     148           4 :     return StaticDtorSection;
     149             :   }
     150             : 
     151             :   /// Create a symbol reference to describe the given TLS variable when
     152             :   /// emitting the address in debug info.
     153             :   virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
     154             : 
     155          20 :   virtual const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
     156             :                                                const GlobalValue *RHS,
     157             :                                                const TargetMachine &TM) const {
     158          20 :     return nullptr;
     159             :   }
     160             : 
     161             :   /// Target supports replacing a data "PC"-relative access to a symbol
     162             :   /// through another symbol, by accessing the later via a GOT entry instead?
     163             :   bool supportIndirectSymViaGOTPCRel() const {
     164             :     return SupportIndirectSymViaGOTPCRel;
     165             :   }
     166             : 
     167             :   /// Target GOT "PC"-relative relocation supports encoding an additional
     168             :   /// binary expression with an offset?
     169             :   bool supportGOTPCRelWithOffset() const {
     170             :     return SupportGOTPCRelWithOffset;
     171             :   }
     172             : 
     173             :   /// Get the target specific PC relative GOT entry relocation
     174           0 :   virtual const MCExpr *getIndirectSymViaGOTPCRel(const MCSymbol *Sym,
     175             :                                                   const MCValue &MV,
     176             :                                                   int64_t Offset,
     177             :                                                   MachineModuleInfo *MMI,
     178             :                                                   MCStreamer &Streamer) const {
     179           0 :     return nullptr;
     180             :   }
     181             : 
     182           0 :   virtual void emitLinkerFlagsForGlobal(raw_ostream &OS,
     183           0 :                                         const GlobalValue *GV) const {}
     184             : 
     185           0 :   virtual void emitLinkerFlagsForUsed(raw_ostream &OS,
     186           0 :                                       const GlobalValue *GV) const {}
     187             : 
     188             : protected:
     189             :   virtual MCSection *SelectSectionForGlobal(const GlobalObject *GO,
     190             :                                             SectionKind Kind,
     191             :                                             const TargetMachine &TM) const = 0;
     192             : };
     193             : 
     194             : } // end namespace llvm
     195             : 
     196             : #endif // LLVM_CODEGEN_TARGETLOWERINGOBJECTFILE_H

Generated by: LCOV version 1.13