Home | History | Annotate | Download | only in LD
      1 //===- StubFactory.h ------------------------------------------------------===//
      2 //
      3 //                     The MCLinker Project
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 #ifndef MCLD_LD_STUB_FACTORY_H
     10 #define MCLD_LD_STUB_FACTORY_H
     11 #ifdef ENABLE_UNITTEST
     12 #include <gtest.h>
     13 #endif
     14 
     15 #include <llvm/Support/DataTypes.h>
     16 #include <vector>
     17 
     18 namespace mcld {
     19 
     20 class Stub;
     21 class Relocation;
     22 class BranchIslandFactory;
     23 class IRBuilder;
     24 
     25 /** \class StubFactory
     26  *  \brief the clone factory of Stub
     27  *
     28  */
     29 class StubFactory
     30 {
     31 public:
     32   ~StubFactory();
     33 
     34   /// addPrototype - register a stub prototype
     35   void addPrototype(Stub* pPrototype);
     36 
     37   /// create - create a stub if needed, otherwise return NULL
     38   Stub* create(Relocation& pReloc,
     39                uint64_t pTargetSymValue,
     40                IRBuilder& pBuilder,
     41                BranchIslandFactory& pBRIslandFactory);
     42 
     43 private:
     44   /// findPrototype - find if there is a registered stub prototype for the given
     45   ///                 relocation
     46   Stub* findPrototype(const Relocation& pReloc,
     47                       const uint64_t pSource,
     48                       uint64_t pTargetSymValue);
     49 
     50 private:
     51  typedef std::vector<Stub*> StubPoolType;
     52 
     53 private:
     54   StubPoolType m_StubPool; // stub pool
     55 };
     56 
     57 } // namespace of mcld
     58 
     59 #endif
     60