• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <vector>
14 
15 namespace mcld {
16 
17 class Stub;
18 class Relocation;
19 class BranchIslandFactory;
20 class IRBuilder;
21 
22 /** \class StubFactory
23  *  \brief the clone factory of Stub
24  *
25  */
26 class StubFactory
27 {
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 of mcld
55 
56 #endif
57