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_STUBFACTORY_H_
10 #define MCLD_LD_STUBFACTORY_H_
11 
12 #include <llvm/Support/DataTypes.h>
13 
14 #include <vector>
15 
16 namespace mcld {
17 
18 class BranchIslandFactory;
19 class IRBuilder;
20 class Relocation;
21 class Stub;
22 
23 /** \class StubFactory
24  *  \brief the clone factory of Stub
25  *
26  */
27 class StubFactory {
28  public:
29   ~StubFactory();
30 
31   /// addPrototype - register a stub prototype
32   void addPrototype(Stub* pPrototype);
33 
34   /// create - create a stub if needed, otherwise return NULL
35   Stub* create(Relocation& pReloc,
36                uint64_t pTargetSymValue,
37                IRBuilder& pBuilder,
38                BranchIslandFactory& pBRIslandFactory);
39 
40  private:
41   /// findPrototype - find if there is a registered stub prototype for the given
42   ///                 relocation
43   Stub* findPrototype(const Relocation& pReloc,
44                       const uint64_t pSource,
45                       uint64_t pTargetSymValue);
46 
47  private:
48   typedef std::vector<Stub*> StubPoolType;
49 
50  private:
51   StubPoolType m_StubPool;  // stub pool
52 };
53 
54 }  // namespace mcld
55 
56 #endif  // MCLD_LD_STUBFACTORY_H_
57