LCOV - code coverage report
Current view: top level - include/llvm/MC - MCObjectWriter.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 1 2 50.0 %
Date: 2018-07-13 00:08:38 Functions: 1 3 33.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- llvm/MC/MCObjectWriter.h - Object File Writer Interface --*- 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             : #ifndef LLVM_MC_MCOBJECTWRITER_H
      11             : #define LLVM_MC_MCOBJECTWRITER_H
      12             : 
      13             : #include "llvm/ADT/SmallVector.h"
      14             : #include "llvm/ADT/StringRef.h"
      15             : #include "llvm/ADT/Triple.h"
      16             : #include "llvm/Support/Endian.h"
      17             : #include "llvm/Support/EndianStream.h"
      18             : #include "llvm/Support/raw_ostream.h"
      19             : #include <cassert>
      20             : #include <cstdint>
      21             : 
      22             : namespace llvm {
      23             : 
      24             : class MCAsmLayout;
      25             : class MCAssembler;
      26             : class MCFixup;
      27             : class MCFragment;
      28             : class MCSymbol;
      29             : class MCSymbolRefExpr;
      30             : class MCValue;
      31             : 
      32             : /// Defines the object file and target independent interfaces used by the
      33             : /// assembler backend to write native file format object files.
      34             : ///
      35             : /// The object writer contains a few callbacks used by the assembler to allow
      36             : /// the object writer to modify the assembler data structures at appropriate
      37             : /// points. Once assembly is complete, the object writer is given the
      38             : /// MCAssembler instance, which contains all the symbol and section data which
      39             : /// should be emitted as part of writeObject().
      40       28920 : class MCObjectWriter {
      41             : protected:
      42             :   MCObjectWriter() = default;
      43             : 
      44             : public:
      45             :   MCObjectWriter(const MCObjectWriter &) = delete;
      46             :   MCObjectWriter &operator=(const MCObjectWriter &) = delete;
      47             :   virtual ~MCObjectWriter();
      48             : 
      49             :   /// lifetime management
      50           0 :   virtual void reset() {}
      51             : 
      52             :   /// \name High-Level API
      53             :   /// @{
      54             : 
      55             :   /// Perform any late binding of symbols (for example, to assign symbol
      56             :   /// indices for use when generating relocations).
      57             :   ///
      58             :   /// This routine is called by the assembler after layout and relaxation is
      59             :   /// complete.
      60             :   virtual void executePostLayoutBinding(MCAssembler &Asm,
      61             :                                         const MCAsmLayout &Layout) = 0;
      62             : 
      63             :   /// Record a relocation entry.
      64             :   ///
      65             :   /// This routine is called by the assembler after layout and relaxation, and
      66             :   /// post layout binding. The implementation is responsible for storing
      67             :   /// information about the relocation so that it can be emitted during
      68             :   /// writeObject().
      69             :   virtual void recordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout,
      70             :                                 const MCFragment *Fragment,
      71             :                                 const MCFixup &Fixup, MCValue Target,
      72             :                                 uint64_t &FixedValue) = 0;
      73             : 
      74             :   /// Check whether the difference (A - B) between two symbol references is
      75             :   /// fully resolved.
      76             :   ///
      77             :   /// Clients are not required to answer precisely and may conservatively return
      78             :   /// false, even when a difference is fully resolved.
      79             :   bool isSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
      80             :                                           const MCSymbolRefExpr *A,
      81             :                                           const MCSymbolRefExpr *B,
      82             :                                           bool InSet) const;
      83             : 
      84             :   virtual bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
      85             :                                                       const MCSymbol &A,
      86             :                                                       const MCSymbol &B,
      87             :                                                       bool InSet) const;
      88             : 
      89             :   virtual bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
      90             :                                                       const MCSymbol &SymA,
      91             :                                                       const MCFragment &FB,
      92             :                                                       bool InSet,
      93             :                                                       bool IsPCRel) const;
      94             : 
      95             :   /// Write the object file and returns the number of bytes written.
      96             :   ///
      97             :   /// This routine is called by the assembler after layout and relaxation is
      98             :   /// complete, fixups have been evaluated and applied, and relocations
      99             :   /// generated.
     100             :   virtual uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) = 0;
     101             : 
     102             :   /// @}
     103             : };
     104             : 
     105             : /// Base class for classes that define behaviour that is specific to both the
     106             : /// target and the object format.
     107             : class MCObjectTargetWriter {
     108             : public:
     109             :   virtual ~MCObjectTargetWriter() = default;
     110             :   virtual Triple::ObjectFormatType getFormat() const = 0;
     111             : };
     112             : 
     113             : } // end namespace llvm
     114             : 
     115             : #endif // LLVM_MC_MCOBJECTWRITER_H

Generated by: LCOV version 1.13