LCOV - code coverage report
Current view: top level - include/llvm/CodeGen - TargetLoweringObjectFileImpl.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 6 7 85.7 %
Date: 2018-10-20 13:21:21 Functions: 3 8 37.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //==- llvm/CodeGen/TargetLoweringObjectFileImpl.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_TARGETLOWERINGOBJECTFILEIMPL_H
      16             : #define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
      17             : 
      18             : #include "llvm/IR/Module.h"
      19             : #include "llvm/MC/MCExpr.h"
      20             : #include "llvm/Target/TargetLoweringObjectFile.h"
      21             : 
      22             : namespace llvm {
      23             : 
      24             : class GlobalValue;
      25             : class MachineModuleInfo;
      26             : class Mangler;
      27             : class MCContext;
      28             : class MCSection;
      29             : class MCSymbol;
      30             : class TargetMachine;
      31             : 
      32             : class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
      33             :   bool UseInitArray = false;
      34             :   mutable unsigned NextUniqueID = 1;  // ID 0 is reserved for execute-only sections
      35             : 
      36             : protected:
      37             :   MCSymbolRefExpr::VariantKind PLTRelativeVariantKind =
      38             :       MCSymbolRefExpr::VK_None;
      39             :   const TargetMachine *TM;
      40             : 
      41             : public:
      42       33667 :   TargetLoweringObjectFileELF() = default;
      43        1078 :   ~TargetLoweringObjectFileELF() override = default;
      44             : 
      45             :   void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
      46             : 
      47             :   /// Emit Obj-C garbage collection and linker options.
      48             :   void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;
      49             : 
      50             :   void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL,
      51             :                             const MCSymbol *Sym) const override;
      52             : 
      53             :   /// Given a constant with the SectionKind, return a section that it should be
      54             :   /// placed in.
      55             :   MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
      56             :                                    const Constant *C,
      57             :                                    unsigned &Align) const override;
      58             : 
      59             :   MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
      60             :                                       const TargetMachine &TM) const override;
      61             : 
      62             :   MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
      63             :                                     const TargetMachine &TM) const override;
      64             : 
      65             :   MCSection *getSectionForJumpTable(const Function &F,
      66             :                                     const TargetMachine &TM) const override;
      67             : 
      68             :   bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
      69             :                                            const Function &F) const override;
      70             : 
      71             :   /// Return an MCExpr to use for a reference to the specified type info global
      72             :   /// variable from exception handling information.
      73             :   const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
      74             :                                         unsigned Encoding,
      75             :                                         const TargetMachine &TM,
      76             :                                         MachineModuleInfo *MMI,
      77             :                                         MCStreamer &Streamer) const override;
      78             : 
      79             :   // The symbol that gets passed to .cfi_personality.
      80             :   MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
      81             :                                     const TargetMachine &TM,
      82             :                                     MachineModuleInfo *MMI) const override;
      83             : 
      84             :   void InitializeELF(bool UseInitArray_);
      85             :   MCSection *getStaticCtorSection(unsigned Priority,
      86             :                                   const MCSymbol *KeySym) const override;
      87             :   MCSection *getStaticDtorSection(unsigned Priority,
      88             :                                   const MCSymbol *KeySym) const override;
      89             : 
      90             :   const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
      91             :                                        const GlobalValue *RHS,
      92             :                                        const TargetMachine &TM) const override;
      93             : };
      94             : 
      95             : class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
      96             : public:
      97             :   TargetLoweringObjectFileMachO();
      98        1625 :   ~TargetLoweringObjectFileMachO() override = default;
      99             : 
     100             :   void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
     101             : 
     102             :   /// Emit the module flags that specify the garbage collection information.
     103             :   void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;
     104             : 
     105             :   MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
     106             :                                     const TargetMachine &TM) const override;
     107             : 
     108             :   MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
     109             :                                       const TargetMachine &TM) const override;
     110             : 
     111             :   MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
     112             :                                    const Constant *C,
     113             :                                    unsigned &Align) const override;
     114             : 
     115             :   /// The mach-o version of this method defaults to returning a stub reference.
     116             :   const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
     117             :                                         unsigned Encoding,
     118             :                                         const TargetMachine &TM,
     119             :                                         MachineModuleInfo *MMI,
     120             :                                         MCStreamer &Streamer) const override;
     121             : 
     122             :   // The symbol that gets passed to .cfi_personality.
     123             :   MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
     124             :                                     const TargetMachine &TM,
     125             :                                     MachineModuleInfo *MMI) const override;
     126             : 
     127             :   /// Get MachO PC relative GOT entry relocation
     128             :   const MCExpr *getIndirectSymViaGOTPCRel(const MCSymbol *Sym,
     129             :                                           const MCValue &MV, int64_t Offset,
     130             :                                           MachineModuleInfo *MMI,
     131             :                                           MCStreamer &Streamer) const override;
     132             : 
     133             :   void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
     134             :                          const TargetMachine &TM) const override;
     135             : };
     136             : 
     137        1558 : class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
     138             :   mutable unsigned NextUniqueID = 0;
     139             : 
     140             : public:
     141        1487 :   ~TargetLoweringObjectFileCOFF() override = default;
     142             : 
     143             :   void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
     144             :   MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
     145             :                                       const TargetMachine &TM) const override;
     146             : 
     147             :   MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
     148             :                                     const TargetMachine &TM) const override;
     149             : 
     150             :   void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
     151             :                          const TargetMachine &TM) const override;
     152             : 
     153             :   MCSection *getSectionForJumpTable(const Function &F,
     154             :                                     const TargetMachine &TM) const override;
     155             : 
     156             :   /// Emit Obj-C garbage collection and linker options.
     157             :   void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;
     158             : 
     159             :   MCSection *getStaticCtorSection(unsigned Priority,
     160             :                                   const MCSymbol *KeySym) const override;
     161             :   MCSection *getStaticDtorSection(unsigned Priority,
     162             :                                   const MCSymbol *KeySym) const override;
     163             : 
     164             :   void emitLinkerFlagsForGlobal(raw_ostream &OS,
     165             :                                 const GlobalValue *GV) const override;
     166             : 
     167             :   void emitLinkerFlagsForUsed(raw_ostream &OS,
     168             :                               const GlobalValue *GV) const override;
     169             : 
     170             :   const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
     171             :                                        const GlobalValue *RHS,
     172             :                                        const TargetMachine &TM) const override;
     173             : 
     174             :   /// Given a mergeable constant with the specified size and relocation
     175             :   /// information, return a section that it should be placed in.
     176             :   MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
     177             :                                    const Constant *C,
     178             :                                    unsigned &Align) const override;
     179             : };
     180             : 
     181             : class TargetLoweringObjectFileWasm : public TargetLoweringObjectFile {
     182             :   mutable unsigned NextUniqueID = 0;
     183             : 
     184             : public:
     185         352 :   TargetLoweringObjectFileWasm() = default;
     186           0 :   ~TargetLoweringObjectFileWasm() override = default;
     187             : 
     188             :   MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
     189             :                                       const TargetMachine &TM) const override;
     190             : 
     191             :   MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
     192             :                                     const TargetMachine &TM) const override;
     193             : 
     194             :   bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
     195             :                                            const Function &F) const override;
     196             : 
     197             :   void InitializeWasm();
     198             :   MCSection *getStaticCtorSection(unsigned Priority,
     199             :                                   const MCSymbol *KeySym) const override;
     200             :   MCSection *getStaticDtorSection(unsigned Priority,
     201             :                                   const MCSymbol *KeySym) const override;
     202             : 
     203             :   const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
     204             :                                        const GlobalValue *RHS,
     205             :                                        const TargetMachine &TM) const override;
     206             : };
     207             : 
     208             : } // end namespace llvm
     209             : 
     210             : #endif // LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H

Generated by: LCOV version 1.13